diff --git a/Tools/GacGen.exe b/Tools/GacGen.exe index 833527a1..315c27c5 100644 Binary files a/Tools/GacGen.exe and b/Tools/GacGen.exe differ diff --git a/Tools/ParserGen.exe b/Tools/ParserGen.exe index b5d36680..bd972010 100644 Binary files a/Tools/ParserGen.exe and b/Tools/ParserGen.exe differ diff --git a/Tutorial/Codegen.bat b/Tutorial/Codegen.bat new file mode 100644 index 00000000..c1fd42bc --- /dev/null +++ b/Tutorial/Codegen.bat @@ -0,0 +1,8 @@ +pushd GacUI_HelloWorlds +pushd CppXml\UI +call Codegen.bat +popd +pushd MVVM\UI +call Codegen.bat +popd +popd \ No newline at end of file diff --git a/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.cpp b/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.cpp index 1c29cfab..6e19f328 100644 --- a/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.cpp +++ b/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.cpp @@ -20,6 +20,11 @@ namespace helloworld { InitializeComponents(); } + + MainWindow::~MainWindow() + { + ClearSubscriptions(); + } } diff --git a/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.h b/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.h index 4d9963d7..176e6533 100644 --- a/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.h +++ b/Tutorial/GacUI_HelloWorlds/CppXml/UI/Source/HelloWorldPartialClasses.h @@ -65,6 +65,7 @@ namespace helloworld // #endregion CLASS_MEMBER_GUIEVENT_HANDLER public: MainWindow(); + ~MainWindow(); }; } diff --git a/Tutorial/GacUI_HelloWorlds/MVVM/Main.cpp b/Tutorial/GacUI_HelloWorlds/MVVM/Main.cpp index 61aa4b56..57c703e7 100644 --- a/Tutorial/GacUI_HelloWorlds/MVVM/Main.cpp +++ b/Tutorial/GacUI_HelloWorlds/MVVM/Main.cpp @@ -82,7 +82,9 @@ void GuiMain() auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); GetInstanceLoaderManager()->SetResource(L"Resource", resource); } - helloworld::MainWindow window(new ViewModel); - window.MoveToScreenCenter(); - GetApplication()->Run(&window); + auto viewModel = MakePtr(); + auto window = new helloworld::MainWindow(viewModel); + window->MoveToScreenCenter(); + GetApplication()->Run(window); + delete window; } \ No newline at end of file diff --git a/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.cpp b/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.cpp index 09b3d075..1874905f 100644 --- a/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.cpp +++ b/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.cpp @@ -27,4 +27,9 @@ namespace helloworld { InitializeComponents(ViewModel); } + + MainWindow::~MainWindow() + { + ClearSubscriptions(); + } } diff --git a/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.h b/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.h index 2596720b..7413c7b3 100644 --- a/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.h +++ b/Tutorial/GacUI_HelloWorlds/MVVM/UI/Source/MainWindow.h @@ -24,6 +24,7 @@ namespace helloworld // #endregion CLASS_MEMBER_GUIEVENT_HANDLER public: MainWindow(Ptr ViewModel); + ~MainWindow(); }; } diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin b/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin index d6f2187e..f71fea79 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin and b/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin differ diff --git a/Tutorial/GacUI_HelloWorlds/WorkflowScript/Main.cpp b/Tutorial/GacUI_HelloWorlds/WorkflowScript/Main.cpp index 6b0c6809..52d667a8 100644 --- a/Tutorial/GacUI_HelloWorlds/WorkflowScript/Main.cpp +++ b/Tutorial/GacUI_HelloWorlds/WorkflowScript/Main.cpp @@ -1,11 +1,62 @@ -#include +#include #include +using namespace vl::parsing; +using namespace vl::collections; +using namespace vl::workflow; +using namespace vl::workflow::analyzer; +using namespace vl::workflow::runtime; + int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow) { return SetupWindowsDirect2DRenderer(); } +const wchar_t* WorkflowScript = LR"workflow( + +module helloworld; + +using presentation::*; +using presentation::controls::Gui*; +using presentation::theme::*; + +func CreateMainWindow() : Window* +{ + var theme = ITheme::GetCurrentTheme(); + + var window = new Window*(theme.CreateWindowStyle()); + window.Text = "Hello, world!"; + window.ClientSize = cast Size "x:480 y:320"; + window.BoundsComposition.PreferredMinSize = cast Size "x:480 y:320"; + window.MoveToScreenCenter(); + + var label = new Label*(theme.CreateLabelStyle()); + label.Text = "Welcom to GacUI Library!"; + label.Font = cast FontProperties "fontFamily:{Segoe UI} size:32"; + window.AddChild(label); + + return window; +} + +)workflow"; + void GuiMain() { + Ptr globalContext; + { + List> errors; + List codes; + codes.Add(WorkflowScript); + auto table = WfLoadTable(); + auto assembly = Compile(table, codes, errors); + globalContext = MakePtr(assembly); + LoadFunction(globalContext, L"")(); + } + + auto CreateMainWindow = LoadFunction(globalContext, L"CreateMainWindow"); + + auto window = CreateMainWindow(); + window->MoveToScreenCenter(); + GetApplication()->Run(window); + delete window; } \ No newline at end of file