mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-03-26 17:02:39 +08:00
Update Release
This commit is contained in:
@@ -9,6 +9,15 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||
return SetupWindowsDirect2DRenderer();
|
||||
}
|
||||
|
||||
class ViewModel : public Object, public virtual demo::IViewModel
|
||||
{
|
||||
public:
|
||||
void OpenUrl(WString url)override
|
||||
{
|
||||
ShellExecute(NULL, L"OPEN", url.Buffer(), NULL, NULL, SW_MAXIMIZE);
|
||||
}
|
||||
};
|
||||
|
||||
void GuiMain()
|
||||
{
|
||||
{
|
||||
@@ -17,7 +26,7 @@ void GuiMain()
|
||||
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
|
||||
GetInstanceLoaderManager()->SetResource(L"Resource", resource);
|
||||
}
|
||||
demo::MainWindow window;
|
||||
demo::MainWindow window(new ViewModel);
|
||||
window.MoveToScreenCenter();
|
||||
GetApplication()->Run(&window);
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Instance ref.CodeBehind="false" ref.Class="demo::MainWindow">
|
||||
<ref.Parameter Name="ViewModel" Class="demo::IViewModel"/>
|
||||
<Window Text="RichTextEmbedding" ClientSize="x:480 y:320">
|
||||
<att.BoundsComposition-set PreferredMinSize="x:480 y:640"/>
|
||||
<att.ContainerComposition-set MinSizeLimitation="LimitToElementAndChildren"/>
|
||||
|
||||
<DocumentViewer EditMode="Selectable" Document-uri="res://EmbeddedDocument/Document">
|
||||
<DocumentViewer ref.Name="documentViewer" EditMode="ViewOnly" Document-uri="res://EmbeddedDocument/Document">
|
||||
<att.BoundsComposition-set AlignmentToParent="left:5 top:5 right:5 bottom:5"/>
|
||||
<ev.ActiveHyperlinkExecuted-eval>
|
||||
ViewModel.OpenUrl(documentViewer.ActiveHyperlinkReference);
|
||||
</ev.ActiveHyperlinkExecuted-eval>
|
||||
<DocumentItem Name="Button">
|
||||
<Button Text="Button"/>
|
||||
</DocumentItem>
|
||||
|
||||
@@ -17,6 +17,21 @@
|
||||
<Doc content="File" name="Document">Document.xml</Doc>
|
||||
</Folder>
|
||||
<Folder name="MainWindow">
|
||||
<Script name="ViewModelResource">
|
||||
<Workflow-ViewModel>
|
||||
<![CDATA[
|
||||
module viewmodel;
|
||||
|
||||
namespace demo
|
||||
{
|
||||
interface IViewModel
|
||||
{
|
||||
func OpenUrl(url : string) : void;
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</Workflow-ViewModel>
|
||||
</Script>
|
||||
<Instance content="File" name="MainWindowResource">MainWindow.xml</Instance>
|
||||
</Folder>
|
||||
</Resource>
|
||||
@@ -16,9 +16,9 @@ namespace demo
|
||||
|
||||
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
|
||||
|
||||
MainWindow::MainWindow()
|
||||
MainWindow::MainWindow(Ptr<demo::IViewModel> ViewModel)
|
||||
{
|
||||
InitializeComponents();
|
||||
InitializeComponents(ViewModel);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -35,11 +35,19 @@ namespace vl
|
||||
namespace description
|
||||
{
|
||||
#define _ ,
|
||||
IMPL_CPP_TYPE_INFO(demo::IViewModel)
|
||||
IMPL_CPP_TYPE_INFO(demo::MainWindow)
|
||||
|
||||
BEGIN_CLASS_MEMBER(demo::IViewModel)
|
||||
CLASS_MEMBER_BASE(vl::reflection::IDescriptable)
|
||||
CLASS_MEMBER_METHOD(OpenUrl, { L"url" });
|
||||
END_CLASS_MEMBER(demo::IViewModel)
|
||||
|
||||
BEGIN_CLASS_MEMBER(demo::MainWindow)
|
||||
CLASS_MEMBER_BASE(vl::presentation::controls::GuiWindow)
|
||||
CLASS_MEMBER_CONSTRUCTOR(demo::MainWindow*(), NO_PARAMETER)
|
||||
CLASS_MEMBER_CONSTRUCTOR(demo::MainWindow*(Ptr<demo::IViewModel>), { L"ViewModel" })
|
||||
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewModel)
|
||||
END_CLASS_MEMBER(demo::MainWindow)
|
||||
|
||||
#undef _
|
||||
@@ -49,6 +57,7 @@ namespace vl
|
||||
public:
|
||||
void Load(ITypeManager* manager)
|
||||
{
|
||||
ADD_TYPE_INFO(demo::IViewModel)
|
||||
ADD_TYPE_INFO(demo::MainWindow)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,30 +15,48 @@ DO NOT MODIFY
|
||||
|
||||
namespace demo
|
||||
{
|
||||
class IViewModel;
|
||||
class MainWindow;
|
||||
|
||||
class IViewModel : public virtual vl::reflection::IDescriptable, public vl::reflection::Description<IViewModel>
|
||||
{
|
||||
public:
|
||||
virtual void OpenUrl(vl::WString url) = 0;
|
||||
};
|
||||
|
||||
template<typename TImpl>
|
||||
class MainWindow_ : public vl::presentation::controls::GuiWindow, public vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>, public vl::reflection::Description<TImpl>
|
||||
{
|
||||
friend struct vl::reflection::description::CustomTypeDescriptorSelector<TImpl>;
|
||||
private:
|
||||
Ptr<demo::IViewModel> ViewModel_;
|
||||
protected:
|
||||
vl::presentation::controls::GuiDocumentViewer* documentViewer;
|
||||
|
||||
void InitializeComponents()
|
||||
void InitializeComponents(Ptr<demo::IViewModel> ViewModel)
|
||||
{
|
||||
ViewModel_ = ViewModel;
|
||||
if (InitializeFromResource())
|
||||
{
|
||||
GUI_INSTANCE_REFERENCE(documentViewer);
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewModel_ = 0;
|
||||
}
|
||||
}
|
||||
public:
|
||||
MainWindow_()
|
||||
:vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>(L"demo::MainWindow")
|
||||
,vl::presentation::controls::GuiWindow(vl::presentation::theme::GetCurrentTheme()->CreateWindowStyle())
|
||||
,documentViewer(0)
|
||||
{
|
||||
}
|
||||
|
||||
Ptr<demo::IViewModel> GetViewModel()
|
||||
{
|
||||
return ViewModel_;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -48,6 +66,7 @@ namespace vl
|
||||
{
|
||||
namespace description
|
||||
{
|
||||
DECL_TYPE_INFO(demo::IViewModel)
|
||||
DECL_TYPE_INFO(demo::MainWindow)
|
||||
|
||||
}
|
||||
@@ -64,7 +83,7 @@ namespace demo
|
||||
// #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.)
|
||||
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
|
||||
public:
|
||||
MainWindow();
|
||||
MainWindow(Ptr<demo::IViewModel> ViewModel);
|
||||
~MainWindow();
|
||||
};
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user