diff --git a/Tutorial/GacUI_Controls/AddressBook/Main.cpp b/Tutorial/GacUI_Controls/AddressBook/Main.cpp index b9c15ff6..1e5b9a0d 100644 --- a/Tutorial/GacUI_Controls/AddressBook/Main.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/Main.cpp @@ -231,9 +231,11 @@ public: Ptr CreateContact()override { - if (auto parent = dynamic_cast(selectedCategory.Obj())) + if (auto category = dynamic_cast(selectedCategory.Obj())) { - return new Contact(parent); + auto contact = new Contact(category); + contact->Update(L"Mr. New Contact", DateTime::LocalTime(), L"(123)-456-7890", L"110 st, New York, NY 10118"); + return contact; } return nullptr; } diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml index 6964ac1d..06eac069 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml @@ -110,8 +110,8 @@ - - + + treeViewFolders.SelectedItem as (demo::ICategory^) @@ -150,6 +150,15 @@ @@ -305,13 +314,101 @@ + + + + + + + + + + + + + + + composeType:MinSize + composeType:MinSize + composeType:MinSize + composeType:MinSize + composeType:Percentage percentage:1.0 + composeType:MinSize + + + composeType:MinSize + composeType:Percentage percentage:1.0 + composeType:MinSize + composeType:MinSize + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp index 902e1478..e31340e1 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp @@ -10,6 +10,34 @@ DO NOT MODIFY #include "Demo.h" +namespace demo +{ + // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) + + void NewContactWindow::OnCreate() + { + } + + void NewContactWindow::OnDestroy() + { + } + + // #endregion CLASS_MEMBER_GUIEVENT_HANDLER + + NewContactWindow::NewContactWindow(Ptr Contact) + { + InitializeComponents(Contact); + OnCreate(); + } + + NewContactWindow::~NewContactWindow() + { + OnDestroy(); + ClearSubscriptions(); + } +} + + namespace demo { // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) @@ -49,6 +77,7 @@ namespace vl IMPL_CPP_TYPE_INFO(demo::IContact) IMPL_CPP_TYPE_INFO(demo::IViewModel) IMPL_CPP_TYPE_INFO(demo::MainWindow) + IMPL_CPP_TYPE_INFO(demo::NewContactWindow) IMPL_CPP_TYPE_INFO(demo::NewFolderWindow) BEGIN_CLASS_MEMBER(demo::ICategory) @@ -114,6 +143,15 @@ namespace vl CLASS_MEMBER_PROPERTY_READONLY_FAST(ViewModel) END_CLASS_MEMBER(demo::MainWindow) + BEGIN_CLASS_MEMBER(demo::NewContactWindow) + CLASS_MEMBER_BASE(vl::presentation::controls::GuiWindow) + CLASS_MEMBER_CONSTRUCTOR(demo::NewContactWindow*(Ptr), { L"Contact" }) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(Contact) + CLASS_MEMBER_EVENT(ReadyChanged) + CLASS_MEMBER_PROPERTY_EVENT_FAST(Ready, ReadyChanged) + END_CLASS_MEMBER(demo::NewContactWindow) + BEGIN_CLASS_MEMBER(demo::NewFolderWindow) CLASS_MEMBER_BASE(vl::presentation::controls::GuiWindow) CLASS_MEMBER_CONSTRUCTOR(demo::NewFolderWindow*(), NO_PARAMETER) @@ -135,6 +173,7 @@ namespace vl ADD_TYPE_INFO(demo::IContact) ADD_TYPE_INFO(demo::IViewModel) ADD_TYPE_INFO(demo::MainWindow) + ADD_TYPE_INFO(demo::NewContactWindow) ADD_TYPE_INFO(demo::NewFolderWindow) } diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h index 6d548dd1..e0c75f70 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h @@ -19,6 +19,7 @@ namespace demo class ICategory; class IViewModel; class MainWindow; + class NewContactWindow; class NewFolderWindow; class IContact : public virtual vl::reflection::IDescriptable, public vl::reflection::Description @@ -131,6 +132,68 @@ namespace demo } }; + template + class NewContactWindow_ : public vl::presentation::controls::GuiWindow, public vl::presentation::GuiInstancePartialClass, public vl::reflection::Description + { + friend struct vl::reflection::description::CustomTypeDescriptorSelector; + private: + Ptr Contact_; + bool Ready_; + protected: + vl::presentation::controls::GuiDatePicker* datePickerBirthday; + vl::presentation::controls::GuiWindow* self; + vl::presentation::controls::GuiDocumentLabel* textBoxAddress; + vl::presentation::controls::GuiDocumentLabel* textBoxName; + vl::presentation::controls::GuiDocumentLabel* textBoxPhone; + + void InitializeComponents(Ptr Contact) + { + Contact_ = Contact; + if (InitializeFromResource()) + { + GUI_INSTANCE_REFERENCE(datePickerBirthday); + GUI_INSTANCE_REFERENCE(self); + GUI_INSTANCE_REFERENCE(textBoxAddress); + GUI_INSTANCE_REFERENCE(textBoxName); + GUI_INSTANCE_REFERENCE(textBoxPhone); + } + else + { + Contact_ = 0; + } + } + public: + NewContactWindow_() + :vl::presentation::GuiInstancePartialClass(L"demo::NewContactWindow") + ,vl::presentation::controls::GuiWindow(vl::presentation::theme::GetCurrentTheme()->CreateWindowStyle()) + ,datePickerBirthday(0) + ,self(0) + ,textBoxAddress(0) + ,textBoxName(0) + ,textBoxPhone(0) + { + this->Ready_ = vl::reflection::description::UnboxValue(vl::reflection::description::Value::From(L"true", reflection::description::GetTypeDescriptor())); + } + + Ptr GetContact() + { + return Contact_; + } + + vl::Event ReadyChanged; + + bool GetReady() + { + return Ready_; + } + + void SetReady(bool value) + { + Ready_ = value; + ReadyChanged(); + } + }; + template class NewFolderWindow_ : public vl::presentation::controls::GuiWindow, public vl::presentation::GuiInstancePartialClass, public vl::reflection::Description { @@ -202,11 +265,31 @@ namespace vl DECL_TYPE_INFO(demo::IContact) DECL_TYPE_INFO(demo::IViewModel) DECL_TYPE_INFO(demo::MainWindow) + DECL_TYPE_INFO(demo::NewContactWindow) DECL_TYPE_INFO(demo::NewFolderWindow) } } } +namespace demo +{ + class NewContactWindow : public demo::NewContactWindow_ + { + friend class demo::NewContactWindow_; + friend struct vl::reflection::description::CustomTypeDescriptorSelector; + protected: + + // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) + void OnCreate(); + void OnDestroy(); + // #endregion CLASS_MEMBER_GUIEVENT_HANDLER + public: + NewContactWindow(Ptr Contact); + ~NewContactWindow(); + }; +} + + namespace demo { class NewFolderWindow : public demo::NewFolderWindow_ diff --git a/Tutorial/GacUI_Controls/UIRes/AddressBook.bin b/Tutorial/GacUI_Controls/UIRes/AddressBook.bin index 356c4168..346c888c 100644 Binary files a/Tutorial/GacUI_Controls/UIRes/AddressBook.bin and b/Tutorial/GacUI_Controls/UIRes/AddressBook.bin differ