Update Tutorial

This commit is contained in:
vczh
2015-09-26 14:09:42 -07:00
parent 2049c4116b
commit 16073716fe
10 changed files with 77 additions and 4 deletions
BIN
View File
Binary file not shown.
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
pushd GacUI_HelloWorlds
pushd CppXml\UI
call Codegen.bat
popd
pushd MVVM\UI
call Codegen.bat
popd
popd
@@ -20,6 +20,11 @@ namespace helloworld
{ {
InitializeComponents(); InitializeComponents();
} }
MainWindow::~MainWindow()
{
ClearSubscriptions();
}
} }
@@ -65,6 +65,7 @@ namespace helloworld
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER // #endregion CLASS_MEMBER_GUIEVENT_HANDLER
public: public:
MainWindow(); MainWindow();
~MainWindow();
}; };
} }
+5 -3
View File
@@ -82,7 +82,9 @@ void GuiMain()
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceLoaderManager()->SetResource(L"Resource", resource); GetInstanceLoaderManager()->SetResource(L"Resource", resource);
} }
helloworld::MainWindow window(new ViewModel); auto viewModel = MakePtr<ViewModel>();
window.MoveToScreenCenter(); auto window = new helloworld::MainWindow(viewModel);
GetApplication()->Run(&window); window->MoveToScreenCenter();
GetApplication()->Run(window);
delete window;
} }
@@ -27,4 +27,9 @@ namespace helloworld
{ {
InitializeComponents(ViewModel); InitializeComponents(ViewModel);
} }
MainWindow::~MainWindow()
{
ClearSubscriptions();
}
} }
@@ -24,6 +24,7 @@ namespace helloworld
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER // #endregion CLASS_MEMBER_GUIEVENT_HANDLER
public: public:
MainWindow(Ptr<vm::IViewModel> ViewModel); MainWindow(Ptr<vm::IViewModel> ViewModel);
~MainWindow();
}; };
} }
Binary file not shown.
@@ -1,11 +1,62 @@
#include <GacUI.h> #include <GacUIReflection.h>
#include <Windows.h> #include <Windows.h>
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) int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{ {
return SetupWindowsDirect2DRenderer(); 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() void GuiMain()
{ {
Ptr<WfRuntimeGlobalContext> globalContext;
{
List<Ptr<ParsingError>> errors;
List<WString> codes;
codes.Add(WorkflowScript);
auto table = WfLoadTable();
auto assembly = Compile(table, codes, errors);
globalContext = MakePtr<WfRuntimeGlobalContext>(assembly);
LoadFunction<void()>(globalContext, L"<initialize>")();
}
auto CreateMainWindow = LoadFunction<GuiWindow*()>(globalContext, L"CreateMainWindow");
auto window = CreateMainWindow();
window->MoveToScreenCenter();
GetApplication()->Run(window);
delete window;
} }