mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-05-20 03:11:23 +08:00
...
This commit is contained in:
@@ -33,6 +33,35 @@
|
||||
|
||||
@cpp:Protected
|
||||
var recentFiles : observe ToolstripCommand*[] = {};
|
||||
|
||||
@cpp:Protected
|
||||
func AddRecentFile(path : string) : void
|
||||
{
|
||||
for (i in range [0, recentFiles.Count))
|
||||
{
|
||||
if (recentFiles[i].Text == path)
|
||||
{
|
||||
var existingCommand = recentFiles[i];
|
||||
recentFiles.RemoveAt(i);
|
||||
recentFiles.Insert(0, existingCommand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (recentFiles.Count == 10)
|
||||
{
|
||||
recentFiles.RemoveAt(9);
|
||||
}
|
||||
|
||||
var command = new ToolstripCommand*();
|
||||
command.Text = path;
|
||||
attach(command.Executed, func(sender : GuiGraphicsComposition*, arguments : GuiEventArgs*) : void
|
||||
{
|
||||
LoadFile(path);
|
||||
});
|
||||
|
||||
recentFiles.Insert(0, command);
|
||||
}
|
||||
]]>
|
||||
</ref.Members>
|
||||
<Window ref.Name="self" Text="TextEditor" ClientSize="x:480 y:320" ev.WindowClosing="window_Closing">
|
||||
|
||||
@@ -214,6 +214,19 @@ Closures
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
__vwsnf32_Demo_demo_MainWindow_AddRecentFile_::__vwsnf32_Demo_demo_MainWindow_AddRecentFile_(::vl::WString __vwsnctor_path, ::demo::MainWindow* __vwsnctorthis_0)
|
||||
:path(__vwsnctor_path)
|
||||
, __vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0))
|
||||
{
|
||||
}
|
||||
|
||||
void __vwsnf32_Demo_demo_MainWindow_AddRecentFile_::operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const
|
||||
{
|
||||
__vwsnthis_0->LoadFile(path);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
__vwsnf3_Demo_demo_FindWindowConstructor___vwsn_initialize_instance__::__vwsnf3_Demo_demo_FindWindowConstructor___vwsn_initialize_instance__(::demo::FindWindowConstructor* __vwsnctorthis_0)
|
||||
:__vwsnthis_0(::vl::__vwsn::This(__vwsnctorthis_0))
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace vl_workflow_global
|
||||
struct __vwsnf29_Demo_demo_MainWindowConstructor___vwsn_initialize_instance__;
|
||||
struct __vwsnf2_Demo_demo_AboutWindowConstructor___vwsn_initialize_instance__;
|
||||
struct __vwsnf30_Demo_demo_MainWindowConstructor___vwsn_initialize_instance__;
|
||||
struct __vwsnf32_Demo_demo_MainWindow_AddRecentFile_;
|
||||
struct __vwsnf3_Demo_demo_FindWindowConstructor___vwsn_initialize_instance__;
|
||||
struct __vwsnf4_Demo_demo_FindWindowConstructor___vwsn_initialize_instance__;
|
||||
struct __vwsnf5_Demo_demo_MainWindowConstructor___vwsn_initialize_instance__;
|
||||
@@ -406,6 +407,16 @@ Closures
|
||||
void operator()(const ::vl::reflection::description::Value& __vwsn_value_) const;
|
||||
};
|
||||
|
||||
struct __vwsnf32_Demo_demo_MainWindow_AddRecentFile_
|
||||
{
|
||||
::vl::WString path;
|
||||
::demo::MainWindow* __vwsnthis_0;
|
||||
|
||||
__vwsnf32_Demo_demo_MainWindow_AddRecentFile_(::vl::WString __vwsnctor_path, ::demo::MainWindow* __vwsnctorthis_0);
|
||||
|
||||
void operator()(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments) const;
|
||||
};
|
||||
|
||||
struct __vwsnf3_Demo_demo_FindWindowConstructor___vwsn_initialize_instance__
|
||||
{
|
||||
::demo::FindWindowConstructor* __vwsnthis_0;
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace vl
|
||||
|
||||
BEGIN_CLASS_MEMBER(::demo::MainWindow)
|
||||
CLASS_MEMBER_CONSTRUCTOR(::demo::MainWindow*(), NO_PARAMETER)
|
||||
CLASS_MEMBER_METHOD(AddRecentFile, { L"path" })
|
||||
CLASS_MEMBER_METHOD(CanCloseFile, NO_PARAMETER)
|
||||
CLASS_MEMBER_METHOD(LoadFile, { L"path" })
|
||||
CLASS_MEMBER_METHOD(OpenFile, { L"filterIndex" })
|
||||
|
||||
@@ -81,6 +81,7 @@ namespace demo
|
||||
{
|
||||
SetupTextConfig();
|
||||
}
|
||||
AddRecentFile(path);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -145,6 +146,7 @@ namespace demo
|
||||
{
|
||||
SetupTextConfig();
|
||||
}
|
||||
AddRecentFile(targetFileName);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -174,6 +176,36 @@ namespace demo
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::AddRecentFile(const ::vl::WString& path)
|
||||
{
|
||||
{
|
||||
auto __vwsn_for_begin_i = static_cast<::vl::vint>(0);
|
||||
auto __vwsn_for_end_i = (::vl::__vwsn::This(this->recentFiles.Obj())->GetCount() - static_cast<::vl::vint>(1));
|
||||
auto i = __vwsn_for_begin_i;
|
||||
while ((i <= __vwsn_for_end_i))
|
||||
{
|
||||
{
|
||||
if ((::vl::__vwsn::This(::vl::__vwsn::Unbox<::vl::presentation::controls::GuiToolstripCommand*>(::vl::__vwsn::This(this->recentFiles.Obj())->Get(i)))->GetText() == path))
|
||||
{
|
||||
auto existingCommand = ::vl::__vwsn::Unbox<::vl::presentation::controls::GuiToolstripCommand*>(::vl::__vwsn::This(this->recentFiles.Obj())->Get(i));
|
||||
::vl::__vwsn::This(this->recentFiles.Obj())->RemoveAt(i);
|
||||
::vl::__vwsn::This(this->recentFiles.Obj())->Insert(static_cast<::vl::vint>(0), ::vl::__vwsn::Box(existingCommand));
|
||||
return;
|
||||
}
|
||||
}
|
||||
(i = (i + static_cast<::vl::vint>(1)));
|
||||
}
|
||||
}
|
||||
if ((::vl::__vwsn::This(this->recentFiles.Obj())->GetCount() == static_cast<::vl::vint>(10)))
|
||||
{
|
||||
::vl::__vwsn::This(this->recentFiles.Obj())->RemoveAt(static_cast<::vl::vint>(9));
|
||||
}
|
||||
auto command = new ::vl::presentation::controls::GuiToolstripCommand();
|
||||
::vl::__vwsn::This(command)->SetText(path);
|
||||
::vl::__vwsn::EventAttach(::vl::__vwsn::This(command)->Executed, LAMBDA(::vl_workflow_global::__vwsnf32_Demo_demo_MainWindow_AddRecentFile_(path, this)));
|
||||
::vl::__vwsn::This(this->recentFiles.Obj())->Insert(static_cast<::vl::vint>(0), ::vl::__vwsn::Box(command));
|
||||
}
|
||||
|
||||
USERIMPL(/* ::demo::MainWindow */)
|
||||
void MainWindow::commandFileNewText_Executed(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace demo
|
||||
{
|
||||
class MainWindow : public ::vl::presentation::controls::GuiWindow, public ::demo::MainWindowConstructor, public ::vl::reflection::Description<MainWindow>
|
||||
{
|
||||
friend struct ::vl_workflow_global::__vwsnf32_Demo_demo_MainWindow_AddRecentFile_;
|
||||
friend class ::demo::MainWindowConstructor;
|
||||
friend class ::vl_workflow_global::__vwsnc1_Demo_demo_MainWindowConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription;
|
||||
friend class ::vl_workflow_global::__vwsnc2_Demo_demo_MainWindowConstructor___vwsn_initialize_instance___vl_reflection_description_IValueSubscription;
|
||||
@@ -78,6 +79,7 @@ namespace demo
|
||||
bool isXml;
|
||||
::vl::Ptr<::vl::presentation::controls::GuiWindow> findWindow;
|
||||
::vl::Ptr<::vl::reflection::description::IValueObservableList> recentFiles;
|
||||
void AddRecentFile(const ::vl::WString& path);
|
||||
void commandFileNewText_Executed(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments);
|
||||
void commandFileNewXml_Executed(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments);
|
||||
void commandFileOpen_Executed(::vl::presentation::compositions::GuiGraphicsComposition* sender, ::vl::presentation::compositions::GuiEventArgs* arguments);
|
||||
|
||||
Reference in New Issue
Block a user