mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-05-21 14:46:20 +08:00
Update Tutorial
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
ClearSubscriptions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace helloworld
|
||||
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ViewModel>();
|
||||
auto window = new helloworld::MainWindow(viewModel);
|
||||
window->MoveToScreenCenter();
|
||||
GetApplication()->Run(window);
|
||||
delete window;
|
||||
}
|
||||
@@ -27,4 +27,9 @@ namespace helloworld
|
||||
{
|
||||
InitializeComponents(ViewModel);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
ClearSubscriptions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace helloworld
|
||||
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
|
||||
public:
|
||||
MainWindow(Ptr<vm::IViewModel> ViewModel);
|
||||
~MainWindow();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,62 @@
|
||||
#include <GacUI.h>
|
||||
#include <GacUIReflection.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)
|
||||
{
|
||||
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<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;
|
||||
}
|
||||
Reference in New Issue
Block a user