AddressBook EditContact

This commit is contained in:
vczh
2016-08-04 03:06:23 -07:00
parent 6e1540c0d7
commit 780d261f4c
5 changed files with 44 additions and 1 deletions

View File

@@ -15,11 +15,13 @@ Ptr<GuiImageData> folderImage;
Ptr<GuiImageData> contactBigImage;
Ptr<GuiImageData> contactSmallImage;
class Contact;
class ViewModel;
class Category : public Object, public ICategory
{
friend class ViewModel;
friend class Contact;
protected:
ICategory* parent;
WString name;
@@ -125,6 +127,12 @@ public:
birthday = _birthday;
phone = _phone;
address = _address;
vint index = category->contacts.IndexOf(this);
if (index != -1)
{
category->contacts.NotifyUpdate(index, 1);
}
}
};

View File

@@ -168,6 +168,19 @@
]]>
</ev.Executed-eval>
</ToolstripCommand>
<ToolstripCommand ref.Name="commandEditContact" Image-uri="res://Images/Edit">
<att.Enabled-bind>ViewModel.SelectedContact is not null</att.Enabled-bind>
<ev.Executed-eval>
<![CDATA[
{
var window = new demo::NewContactWindow*(ViewModel.SelectedContact);
window.ForEdit = true;
window.MoveToScreenCenter();
window.ShowModalAndDelete(self, func():void{});
}
]]>
</ev.Executed-eval>
</ToolstripCommand>
<ToolstripCommand ref.Name="commandDeleteContact" Image-uri="res://Images/Delete">
<att.Enabled-bind>ViewModel.SelectedContact is not null</att.Enabled-bind>
<ev.Executed-eval>
@@ -262,6 +275,7 @@
<ToolstripToolBar>
<att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
<ToolstripButton Command-ref="commandNewContact"/>
<ToolstripButton Command-ref="commandEditContact"/>
<ToolstripButton Command-ref="commandDeleteContact"/>
<ToolstripSplitter/>
<ToolstripButton Command-ref="commandBigIcon"/>
@@ -350,9 +364,10 @@
<Instance name="NewContactWindowResource">
<Instance ref.CodeBehind="false" ref.Class="demo::NewContactWindow">
<ref.Property Name="ForEdit" Type="bool" Value="false"/>
<ref.Property Name="Ready" Type="bool" Value="true"/>
<ref.Parameter Name="Contact" Class="demo::IContact"/>
<Window ref.Name="self" Text="New Contact" ClientSize="x:480 y:360" MaximizedBox="false" MinimizedBox="false" SizeBox="false">
<Window ref.Name="self" Text-bind="self.ForEdit ? 'Edit Contact' : 'New Contact'" ClientSize="x:480 y:360" MaximizedBox="false" MinimizedBox="false" SizeBox="false">
<Table CellPadding="5" AlignmentToParent="left:0 top:0 right:0 bottom:0">
<att.Rows>

View File

@@ -150,6 +150,8 @@ namespace vl
CLASS_MEMBER_CONSTRUCTOR(demo::NewContactWindow*(Ptr<demo::IContact>), { L"Contact" })
CLASS_MEMBER_PROPERTY_READONLY_FAST(Contact)
CLASS_MEMBER_EVENT(ForEditChanged)
CLASS_MEMBER_PROPERTY_EVENT_FAST(ForEdit, ForEditChanged)
CLASS_MEMBER_EVENT(ReadyChanged)
CLASS_MEMBER_PROPERTY_EVENT_FAST(Ready, ReadyChanged)
END_CLASS_MEMBER(demo::NewContactWindow)

View File

@@ -73,6 +73,7 @@ namespace demo
vl::presentation::controls::GuiToolstripCommand* commandDeleteContact;
vl::presentation::controls::GuiToolstripCommand* commandDeleteFolder;
vl::presentation::controls::GuiToolstripCommand* commandDetail;
vl::presentation::controls::GuiToolstripCommand* commandEditContact;
vl::presentation::controls::GuiToolstripCommand* commandInformation;
vl::presentation::controls::GuiToolstripCommand* commandList;
vl::presentation::controls::GuiToolstripCommand* commandNewContact;
@@ -92,6 +93,7 @@ namespace demo
GUI_INSTANCE_REFERENCE(commandDeleteContact);
GUI_INSTANCE_REFERENCE(commandDeleteFolder);
GUI_INSTANCE_REFERENCE(commandDetail);
GUI_INSTANCE_REFERENCE(commandEditContact);
GUI_INSTANCE_REFERENCE(commandInformation);
GUI_INSTANCE_REFERENCE(commandList);
GUI_INSTANCE_REFERENCE(commandNewContact);
@@ -115,6 +117,7 @@ namespace demo
,commandDeleteContact(0)
,commandDeleteFolder(0)
,commandDetail(0)
,commandEditContact(0)
,commandInformation(0)
,commandList(0)
,commandNewContact(0)
@@ -139,6 +142,7 @@ namespace demo
friend struct vl::reflection::description::CustomTypeDescriptorSelector<TImpl>;
private:
Ptr<demo::IContact> Contact_;
bool ForEdit_;
bool Ready_;
protected:
vl::presentation::controls::GuiDatePicker* datePickerBirthday;
@@ -173,6 +177,7 @@ namespace demo
,textBoxName(0)
,textBoxPhone(0)
{
this->ForEdit_ = vl::reflection::description::UnboxValue<bool>(vl::reflection::description::Value::From(L"false", reflection::description::GetTypeDescriptor<bool>()));
this->Ready_ = vl::reflection::description::UnboxValue<bool>(vl::reflection::description::Value::From(L"true", reflection::description::GetTypeDescriptor<bool>()));
}
@@ -181,6 +186,19 @@ namespace demo
return Contact_;
}
vl::Event<void()> ForEditChanged;
bool GetForEdit()
{
return ForEdit_;
}
void SetForEdit(bool value)
{
ForEdit_ = value;
ForEditChanged();
}
vl::Event<void()> ReadyChanged;
bool GetReady()