AddressBook FolderUI

This commit is contained in:
vczh
2016-07-29 00:45:32 -07:00
parent 6bd04d0952
commit b9811b60e0
12 changed files with 112 additions and 18 deletions

View File

@@ -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()

View File

@@ -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)

Binary file not shown.

View File

@@ -11,18 +11,37 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
return SetupWindowsDirect2DRenderer();
}
Ptr<GuiImageData> folderImage;
Ptr<GuiImageData> contactImage;
class Category : public Object, public ICategory
{
protected:
ICategory* parent;
WString name;
list::ObservableList<Ptr<ICategory>> folders;
public:
Category(ICategory* _parent)
:parent(_parent)
{
}
ICategory* GetParent()override
{
return parent;
}
WString GetName()override
{
return name;
}
Ptr<GuiImageData> GetImage()override
{
return folderImage;
}
Ptr<IValueObservableList> 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<GuiImageData> GetImage()override
{
return nullptr;
}
Ptr<IValueObservableList> GetFolders()override
{
return folders.GetWrapper();
@@ -74,6 +108,7 @@ class ViewModel : public Object, public IViewModel
{
protected:
Ptr<RootCategory> rootCategory;
Ptr<ICategory> selectedCategory;
public:
ViewModel()
@@ -85,6 +120,28 @@ public:
{
return rootCategory;
}
Ptr<ICategory> GetSelectedCategory()override
{
return selectedCategory;
}
void SetSelectedCategory(Ptr<ICategory> 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 206 B

View File

@@ -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;
}
}
</Workflow-ViewModel>
@@ -48,6 +62,7 @@
<Image content="File" name="Folder">Folder.png</Image>
<Image content="File" name="Contact">Contact.png</Image>
<Image content="File" name="Edit">Edit.png</Image>
<Image content="File" name="BigIcon">ListView_Big.png</Image>
<Image content="File" name="SmallIcon">ListView_Small.png</Image>
@@ -64,11 +79,17 @@
<Window Text="AddressBook" ClientSize="x:480 y:320">
<att.BoundsComposition-set PreferredMinSize="x:480 y:320"/>
<att.ViewModel-set>
<att.SelectedCategory-bind>treeViewFolders.SelectedItem as (demo::ICategory^)</att.SelectedCategory-bind>
</att.ViewModel-set>
<ToolstripCommand ref.Name="commandNewFolder" Image-uri="res://Images/NewFolder">
<ev.Executed>commandNewFolder_Executed</ev.Executed>
<att.Enabled-bind>ViewModel.SelectedCategory is not null</att.Enabled-bind>
<ev.Executed-eval>{}</ev.Executed-eval>
</ToolstripCommand>
<ToolstripCommand ref.Name="commandDeleteFolder" Image-uri="res://Images/Delete">
<ev.Executed>commandDeleteFolder_Executed</ev.Executed>
<att.Enabled-bind>ViewModel.SelectedCategory is null ? false : ViewModel.SelectedCategory.Parent is not null</att.Enabled-bind>
<ev.Executed-eval>{ ViewModel.RemoveCategory(); }</ev.Executed-eval>
</ToolstripCommand>
<ToolstripCommand ref.Name="commandNewContact" Image-uri="res://Images/NewContact">
<ev.Executed>commandNewContact_Executed</ev.Executed>
@@ -101,7 +122,7 @@
<CellOption>composeType:Percentage percentage:1.0</CellOption>
</att.Rows>
<att.Columns>
<CellOption>composeType:Absolute absolute:160</CellOption>
<CellOption>composeType:Absolute absolute:180</CellOption>
<CellOption>composeType:Percentage percentage:1.0</CellOption>
</att.Columns>
@@ -130,7 +151,11 @@
</Cell>
<Cell Site="row:1 column:0">
<BindableTreeView ref.Name="treeViewFolders" ItemSource-eval="ViewModel.GetRootCategory()" HorizontalAlwaysVisible="false" VerticalAlwaysVisible="false">
<BindableTreeView ref.Name="treeViewFolders" HorizontalAlwaysVisible="false" VerticalAlwaysVisible="false">
<att.ItemSource-eval>ViewModel.GetRootCategory()</att.ItemSource-eval>
<att.TextProperty>Name</att.TextProperty>
<att.ImageProperty>Image</att.ImageProperty>
<att.ChildrenProperty>Folders</att.ChildrenProperty>
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
</BindableTreeView>
</Cell>

View File

@@ -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)

View File

@@ -22,7 +22,9 @@ namespace demo
class ICategory : public virtual vl::reflection::IDescriptable, public vl::reflection::Description<ICategory>
{
public:
virtual demo::ICategory* GetParent() = 0;
virtual vl::WString GetName() = 0;
virtual vl::Ptr<vl::presentation::GuiImageData> GetImage() = 0;
virtual vl::Ptr<vl::reflection::description::IValueObservableList> GetFolders() = 0;
virtual vl::Ptr<vl::reflection::description::IValueObservableList> GetContacts() = 0;
};
@@ -31,6 +33,11 @@ namespace demo
{
public:
virtual vl::Ptr<demo::ICategory> GetRootCategory() = 0;
virtual vl::Ptr<demo::ICategory> GetSelectedCategory() = 0;
virtual void SetSelectedCategory(vl::Ptr<demo::ICategory> value) = 0;
vl::Event<void()> SelectedCategoryChanged;
virtual void AddCategory(vl::WString name) = 0;
virtual void RemoveCategory() = 0;
};
template<typename TImpl>

View File

@@ -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)
{
}

View File

@@ -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();