diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index b5a3fb64..644c250a 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -5489,12 +5489,12 @@ GuiBindableTreeView description::Value GuiBindableTreeView::GetItemSource() { - throw 0; + return itemSource->GetItemSource(); } void GuiBindableTreeView::SetItemSource(description::Value _itemSource) { - throw 0; + itemSource->SetItemSource(_itemSource); } const WString& GuiBindableTreeView::GetTextProperty() diff --git a/Import/GacUIReflection.cpp b/Import/GacUIReflection.cpp index 6546b29f..4d399b9f 100644 --- a/Import/GacUIReflection.cpp +++ b/Import/GacUIReflection.cpp @@ -2635,6 +2635,7 @@ Type Declaration CLASS_MEMBER_PROPERTY_EVENT_FAST(Shortcut, DescriptionChanged) CLASS_MEMBER_PROPERTY_EVENT_FAST(ShortcutBuilder, DescriptionChanged) CLASS_MEMBER_PROPERTY_EVENT_FAST(Enabled, DescriptionChanged) + CLASS_MEMBER_PROPERTY_EVENT_FAST(Selected, DescriptionChanged) END_CLASS_MEMBER(GuiToolstripCommand) BEGIN_CLASS_MEMBER(GuiToolstripMenu) diff --git a/Tools/GacGen.exe b/Tools/GacGen.exe index aab7e4fc..3d7d6a08 100644 Binary files a/Tools/GacGen.exe and b/Tools/GacGen.exe differ diff --git a/Tutorial/GacUI_Controls/AddressBook/Main.cpp b/Tutorial/GacUI_Controls/AddressBook/Main.cpp index 7e4b05b9..adc29575 100644 --- a/Tutorial/GacUI_Controls/AddressBook/Main.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/Main.cpp @@ -11,18 +11,37 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi return SetupWindowsDirect2DRenderer(); } +Ptr folderImage; +Ptr contactImage; + class Category : public Object, public ICategory { protected: + ICategory* parent; WString name; list::ObservableList> folders; public: + Category(ICategory* _parent) + :parent(_parent) + { + } + + ICategory* GetParent()override + { + return parent; + } + WString GetName()override { return name; } + Ptr GetImage()override + { + return folderImage; + } + Ptr GetFolders()override { return folders.GetWrapper(); @@ -37,6 +56,11 @@ public: class StaticCategory : public Category { public: + StaticCategory() + :Category(nullptr) + { + } + WString GetName()override { return L"My Address Book"; @@ -54,11 +78,21 @@ public: folders.Add(new StaticCategory); } + ICategory* GetParent()override + { + return nullptr; + } + WString GetName()override { return L""; } + Ptr GetImage()override + { + return nullptr; + } + Ptr GetFolders()override { return folders.GetWrapper(); @@ -74,6 +108,7 @@ class ViewModel : public Object, public IViewModel { protected: Ptr rootCategory; + Ptr selectedCategory; public: ViewModel() @@ -85,6 +120,28 @@ public: { return rootCategory; } + + Ptr GetSelectedCategory()override + { + return selectedCategory; + } + + void SetSelectedCategory(Ptr value)override + { + if (selectedCategory != value) + { + selectedCategory = value; + SelectedCategoryChanged(); + } + } + + void AddCategory(WString name) + { + } + + void RemoveCategory() + { + } }; void GuiMain() @@ -94,8 +151,14 @@ void GuiMain() FileStream fileStream(L"../UIRes/AddressBook.bin", FileStream::ReadOnly); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); GetResourceManager()->SetResource(L"Resource", resource); + + folderImage = resource->GetImageByPath(L"Images/Folder"); + contactImage = resource->GetImageByPath(L"Images/Contact"); } MainWindow window(new ViewModel); window.MoveToScreenCenter(); GetApplication()->Run(&window); + + folderImage = nullptr; + contactImage = nullptr; } \ No newline at end of file diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Edit.png b/Tutorial/GacUI_Controls/AddressBook/UI/Edit.png new file mode 100644 index 00000000..426607d0 Binary files /dev/null and b/Tutorial/GacUI_Controls/AddressBook/UI/Edit.png differ diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Folder.png b/Tutorial/GacUI_Controls/AddressBook/UI/Folder.png index 89788173..4cbc8efc 100644 Binary files a/Tutorial/GacUI_Controls/AddressBook/UI/Folder.png and b/Tutorial/GacUI_Controls/AddressBook/UI/Folder.png differ diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml index ed4e4e41..801c9efb 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml @@ -23,8 +23,14 @@ { interface ICategory { + func GetParent() : ICategory*; + prop Parent : ICategory* {GetParent} + func GetName() : string; prop Name : string {GetName} + + func GetImage() : presentation::GuiImageData^; + prop Image : presentation::GuiImageData^ {GetImage} func GetFolders() : ObservableList^; prop Folders : ObservableList^ {GetFolders} @@ -36,6 +42,14 @@ interface IViewModel { func GetRootCategory() : ICategory^; + + func GetSelectedCategory() : ICategory^; + func SetSelectedCategory(value : ICategory^) : void; + event SelectedCategoryChanged(); + prop SelectedCategory : ICategory^ {GetSelectedCategory, SetSelectedCategory : SelectedCategoryChanged} + + func AddCategory(name : string) : void; + func RemoveCategory() : void; } } @@ -48,6 +62,7 @@ Folder.png Contact.png + Edit.png ListView_Big.png ListView_Small.png @@ -64,11 +79,17 @@ + + treeViewFolders.SelectedItem as (demo::ICategory^) + + - commandNewFolder_Executed + ViewModel.SelectedCategory is not null + {} - commandDeleteFolder_Executed + ViewModel.SelectedCategory is null ? false : ViewModel.SelectedCategory.Parent is not null + { ViewModel.RemoveCategory(); } commandNewContact_Executed @@ -101,7 +122,7 @@ composeType:Percentage percentage:1.0 - composeType:Absolute absolute:160 + composeType:Absolute absolute:180 composeType:Percentage percentage:1.0 @@ -130,7 +151,11 @@ - + + ViewModel.GetRootCategory() + Name + Image + Folders diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp index 5a541b51..ad63d08d 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp @@ -23,10 +23,14 @@ namespace vl BEGIN_CLASS_MEMBER(demo::ICategory) CLASS_MEMBER_BASE(vl::reflection::IDescriptable) + CLASS_MEMBER_METHOD(GetParent, NO_PARAMETER); CLASS_MEMBER_METHOD(GetName, NO_PARAMETER); + CLASS_MEMBER_METHOD(GetImage, NO_PARAMETER); CLASS_MEMBER_METHOD(GetFolders, NO_PARAMETER); CLASS_MEMBER_METHOD(GetContacts, NO_PARAMETER); + CLASS_MEMBER_PROPERTY_READONLY(Parent, GetParent) CLASS_MEMBER_PROPERTY_READONLY(Name, GetName) + CLASS_MEMBER_PROPERTY_READONLY(Image, GetImage) CLASS_MEMBER_PROPERTY_READONLY(Folders, GetFolders) CLASS_MEMBER_PROPERTY_READONLY(Contacts, GetContacts) END_CLASS_MEMBER(demo::ICategory) @@ -34,6 +38,12 @@ namespace vl BEGIN_CLASS_MEMBER(demo::IViewModel) CLASS_MEMBER_BASE(vl::reflection::IDescriptable) CLASS_MEMBER_METHOD(GetRootCategory, NO_PARAMETER); + CLASS_MEMBER_METHOD(GetSelectedCategory, NO_PARAMETER); + CLASS_MEMBER_METHOD(SetSelectedCategory, { L"value" }); + CLASS_MEMBER_EVENT(SelectedCategoryChanged) + CLASS_MEMBER_METHOD(AddCategory, { L"name" }); + CLASS_MEMBER_METHOD(RemoveCategory, NO_PARAMETER); + CLASS_MEMBER_PROPERTY_EVENT(SelectedCategory, GetSelectedCategory, SetSelectedCategory, SelectedCategoryChanged) END_CLASS_MEMBER(demo::IViewModel) BEGIN_CLASS_MEMBER(demo::MainWindow) @@ -42,12 +52,10 @@ namespace vl CLASS_MEMBER_GUIEVENT_HANDLER(commandBigIcon_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandDeleteContact_Executed, vl::presentation::compositions::GuiEventArgs) - CLASS_MEMBER_GUIEVENT_HANDLER(commandDeleteFolder_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandDetail_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandInformation_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandList_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandNewContact_Executed, vl::presentation::compositions::GuiEventArgs) - CLASS_MEMBER_GUIEVENT_HANDLER(commandNewFolder_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandSmallIcon_Executed, vl::presentation::compositions::GuiEventArgs) CLASS_MEMBER_GUIEVENT_HANDLER(commandTile_Executed, vl::presentation::compositions::GuiEventArgs) diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h index 59af076f..e9056e2d 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.h @@ -22,7 +22,9 @@ namespace demo class ICategory : public virtual vl::reflection::IDescriptable, public vl::reflection::Description { public: + virtual demo::ICategory* GetParent() = 0; virtual vl::WString GetName() = 0; + virtual vl::Ptr GetImage() = 0; virtual vl::Ptr GetFolders() = 0; virtual vl::Ptr GetContacts() = 0; }; @@ -31,6 +33,11 @@ namespace demo { public: virtual vl::Ptr GetRootCategory() = 0; + virtual vl::Ptr GetSelectedCategory() = 0; + virtual void SetSelectedCategory(vl::Ptr value) = 0; + vl::Event SelectedCategoryChanged; + virtual void AddCategory(vl::WString name) = 0; + virtual void RemoveCategory() = 0; }; template diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.cpp b/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.cpp index 3dfe34c2..67fd0f5e 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.cpp @@ -20,10 +20,6 @@ namespace demo { } - void MainWindow::commandDeleteFolder_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments) - { - } - void MainWindow::commandDetail_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments) { } @@ -40,10 +36,6 @@ namespace demo { } - void MainWindow::commandNewFolder_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments) - { - } - void MainWindow::commandSmallIcon_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments) { } diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.h b/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.h index 158e9ebc..86742185 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.h +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/MainWindow.h @@ -22,12 +22,10 @@ namespace demo // #region CLASS_MEMBER_GUIEVENT_HANDLER (DO NOT PUT OTHER CONTENT IN THIS #region.) void commandBigIcon_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandDeleteContact_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); - void commandDeleteFolder_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandDetail_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandInformation_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandList_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandNewContact_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); - void commandNewFolder_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandSmallIcon_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void commandTile_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments); void OnCreate(); diff --git a/Tutorial/GacUI_Controls/UIRes/AddressBook.bin b/Tutorial/GacUI_Controls/UIRes/AddressBook.bin index 54887333..1f015709 100644 Binary files a/Tutorial/GacUI_Controls/UIRes/AddressBook.bin and b/Tutorial/GacUI_Controls/UIRes/AddressBook.bin differ