Update Release

This commit is contained in:
vczh
2015-10-31 22:22:50 -07:00
parent 5ced7086ca
commit 84ce8c004a
6 changed files with 63 additions and 7 deletions
@@ -9,6 +9,15 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
return SetupWindowsDirect2DRenderer(); 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() void GuiMain()
{ {
{ {
@@ -17,7 +26,7 @@ void GuiMain()
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceLoaderManager()->SetResource(L"Resource", resource); GetInstanceLoaderManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window(new ViewModel);
window.MoveToScreenCenter(); window.MoveToScreenCenter();
GetApplication()->Run(&window); GetApplication()->Run(&window);
} }
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Instance ref.CodeBehind="false" ref.Class="demo::MainWindow"> <Instance ref.CodeBehind="false" ref.Class="demo::MainWindow">
<ref.Parameter Name="ViewModel" Class="demo::IViewModel"/>
<Window Text="RichTextEmbedding" ClientSize="x:480 y:320"> <Window Text="RichTextEmbedding" ClientSize="x:480 y:320">
<att.BoundsComposition-set PreferredMinSize="x:480 y:640"/> <att.BoundsComposition-set PreferredMinSize="x:480 y:640"/>
<att.ContainerComposition-set MinSizeLimitation="LimitToElementAndChildren"/> <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"/> <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"> <DocumentItem Name="Button">
<Button Text="Button"/> <Button Text="Button"/>
</DocumentItem> </DocumentItem>
@@ -17,6 +17,21 @@
<Doc content="File" name="Document">Document.xml</Doc> <Doc content="File" name="Document">Document.xml</Doc>
</Folder> </Folder>
<Folder name="MainWindow"> <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> <Instance content="File" name="MainWindowResource">MainWindow.xml</Instance>
</Folder> </Folder>
</Resource> </Resource>
@@ -16,9 +16,9 @@ namespace demo
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER // #endregion CLASS_MEMBER_GUIEVENT_HANDLER
MainWindow::MainWindow() MainWindow::MainWindow(Ptr<demo::IViewModel> ViewModel)
{ {
InitializeComponents(); InitializeComponents(ViewModel);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@@ -35,11 +35,19 @@ namespace vl
namespace description namespace description
{ {
#define _ , #define _ ,
IMPL_CPP_TYPE_INFO(demo::IViewModel)
IMPL_CPP_TYPE_INFO(demo::MainWindow) 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) BEGIN_CLASS_MEMBER(demo::MainWindow)
CLASS_MEMBER_BASE(vl::presentation::controls::GuiWindow) 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) END_CLASS_MEMBER(demo::MainWindow)
#undef _ #undef _
@@ -49,6 +57,7 @@ namespace vl
public: public:
void Load(ITypeManager* manager) void Load(ITypeManager* manager)
{ {
ADD_TYPE_INFO(demo::IViewModel)
ADD_TYPE_INFO(demo::MainWindow) ADD_TYPE_INFO(demo::MainWindow)
} }
@@ -15,30 +15,48 @@ DO NOT MODIFY
namespace demo namespace demo
{ {
class IViewModel;
class MainWindow; 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> template<typename TImpl>
class MainWindow_ : public vl::presentation::controls::GuiWindow, public vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>, public vl::reflection::Description<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>; friend struct vl::reflection::description::CustomTypeDescriptorSelector<TImpl>;
private: private:
Ptr<demo::IViewModel> ViewModel_;
protected: protected:
vl::presentation::controls::GuiDocumentViewer* documentViewer;
void InitializeComponents() void InitializeComponents(Ptr<demo::IViewModel> ViewModel)
{ {
ViewModel_ = ViewModel;
if (InitializeFromResource()) if (InitializeFromResource())
{ {
GUI_INSTANCE_REFERENCE(documentViewer);
} }
else else
{ {
ViewModel_ = 0;
} }
} }
public: public:
MainWindow_() MainWindow_()
:vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>(L"demo::MainWindow") :vl::presentation::GuiInstancePartialClass<vl::presentation::controls::GuiWindow>(L"demo::MainWindow")
,vl::presentation::controls::GuiWindow(vl::presentation::theme::GetCurrentTheme()->CreateWindowStyle()) ,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 namespace description
{ {
DECL_TYPE_INFO(demo::IViewModel)
DECL_TYPE_INFO(demo::MainWindow) DECL_TYPE_INFO(demo::MainWindow)
} }
@@ -64,7 +83,7 @@ namespace demo
// #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.)
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER // #endregion CLASS_MEMBER_GUIEVENT_HANDLER
public: public:
MainWindow(); MainWindow(Ptr<demo::IViewModel> ViewModel);
~MainWindow(); ~MainWindow();
}; };
} }
Binary file not shown.