module refresh_viewmodel; using system::*; using presentation::*;

namespace demo { class RefreshItem { prop Name : string = "" {not observe} prop Title : string = "" {not observe} prop Sub1 : string = "One" {not observe} prop Sub2 : string = "Two" {not observe} prop Sub3 : string = "Three" {not observe} prop Selected : bool = false {not observe} prop LargeImage : GuiImageData^ = null {not observe} prop SmallImage : GuiImageData^ = null {not observe} prop Children : observe RefreshItem^[] = {} {const, not observe} prop DoNotUse : object = null {not observe}

new (name:string, title:string) { Name = name; Title = title; }

new (name:string, title:string, children:RefreshItem^{}) { Name = name; Title = title; for (child in children) { Children.Add(child); } } } }

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0
{ textList.Items[0].Checked = true; }
{ textList.Items[0].Checked = false; }
{ if (textList.Items[0].Checked) { buttonRead.Text = "Read (true)"; } else { buttonRead.Text = "Read (false)"; } }
<_ Text="First"/> <_ Text="Second"/> <_ Text="Third"/> <_ Text="Fourth"/> <_ Text="Fifth"/> <_ Text="Sixth"/>

var items : observe RefreshItem^[] = { new RefreshItem^("First", "1st") new RefreshItem^("Second", "2nd") new RefreshItem^("Third", "3rd") };

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0
{ textList.TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Name; }; }
{ textList.TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Title; }; }
{ self.items[0].Selected = true; textList.NotifyItemDataModified(0, 1); }
{ self.items[0].Selected = false; textList.NotifyItemDataModified(0, 1); }
{ if (self.items[0].Selected) { buttonRead.Text = "Read (true)"; } else { buttonRead.Text = "Read (false)"; } }
self.items
Name
Selected

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0

V

{ switch (comboView.SelectedIndex) { case 0: { listView.View = BigIcon; } case 1: { listView.View = SmallIcon; } case 2: { listView.View = ListViewView::List; } case 3: { listView.View = Tile; } case 4: { listView.View = Information; } case 5: { listView.View = Detail; } } }
{ var s = listView.Items[0].Text; listView.Items[0].Text = s == "First" ? "MainColumn" : "First"; }
{ var s = listView.Items[0].SubItems[0]; listView.Items[0].SubItems[0] = s == "One" ? "SubColumn" : "One"; }
{ var s = listView.DataColumns[0]; var c = listView.DataColumns.Count; if (c == 3) { if (s == 0) { listView.DataColumns[0] = 1; } else { listView.DataColumns.RemoveAt(2); } } else { if (s == 0) { listView.DataColumns.Add(2); } else { listView.DataColumns[0] = 0; } } }
{ var s = listView.Columns[1].Text; var c = listView.Columns.Count; if (c == 4) { if (s == "Category") { listView.Columns[1].Text = "What?"; listView.Columns[2].Text = "Wait?"; } else { listView.Columns.RemoveAt(1); } } else { if (s == "Size") { var column = new ListViewColumn^(); column.Text = "Category"; listView.Columns.Insert(1, column); } else { listView.Columns[1].Text = "Size"; } } }
<_ Text="Id"/> <_ Text="Category"/> <_ Text="Size"/> <_ Text="File"/>
<_>0 <_>1 <_>2
<_ Text="First" LargeImage-uri="res://LargeImages/Task" SmallImage-uri="res://SmallImages/Task"><_>One<_>Two<_>Three <_ Text="Second" LargeImage-uri="res://LargeImages/Reminder" SmallImage-uri="res://SmallImages/Reminder"><_>One<_>Two<_>Three <_ Text="Third" LargeImage-uri="res://LargeImages/Tip" SmallImage-uri="res://SmallImages/Tip"><_>One<_>Two<_>Three <_ Text="Fourth" LargeImage-uri="res://LargeImages/Tip" SmallImage-uri="res://SmallImages/Tip"><_>One<_>Two<_>Three

var items : observe RefreshItem^[] = { new RefreshItem^("First", "1st") new RefreshItem^("Second", "2nd") new RefreshItem^("Third", "3rd") new RefreshItem^("Fourth", "4th") };
{ items[0].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Task", true)); items[0].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Task", true)); items[1].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Reminder", true)); items[1].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Reminder", true)); items[2].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Tip", true)); items[2].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true)); items[3].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Tip", true)); items[3].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true)); }

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0

V

{ switch (comboView.SelectedIndex) { case 0: { listView.View = BigIcon; } case 1: { listView.View = SmallIcon; } case 2: { listView.View = ListViewView::List; } case 3: { listView.View = Tile; } case 4: { listView.View = Information; } case 5: { listView.View = Detail; } } }
{ listView.Columns[0].TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Name; }; }
{ listView.Columns[0].TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Title; }; }
{ var s = self.items[0].Sub1; self.items[0].Sub1 = s == "One" ? "SubColumn" : "One"; listView.NotifyItemDataModified(0, 1); }
{ var s = listView.DataColumns[0]; var c = listView.DataColumns.Count; if (c == 3) { if (s == 0) { listView.DataColumns[0] = 1; } else { listView.DataColumns.RemoveAt(2); } } else { if (s == 0) { listView.DataColumns.Add(2); } else { listView.DataColumns[0] = 0; } } }
{ var s = listView.Columns[1].Text; var c = listView.Columns.Count; if (c == 4) { if (s == "Category") { listView.Columns[1].Text = "What?"; listView.Columns[2].Text = "Wait?"; } else { listView.Columns.RemoveAt(1); } } else { if (s == "Size") { var column = new ListViewColumn^(); column.Text = "Category"; column.TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Sub1; }; listView.Columns.Insert(1, column); } else { listView.Columns[1].Text = "Size"; } } }
self.items
LargeImage
SmallImage
<_ Text="Id" TextProperty="Name"/> <_ Text="Category" TextProperty="Sub1"/> <_ Text="Size" TextProperty="Sub2"/> <_ Text="File" TextProperty="Sub3"/>
<_>0 <_>1 <_>2

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0
{ var node = treeView.Nodes.RootNode.GetChild(0); var data = treeView.Nodes.GetTreeViewData(cast * node); data.text = data.text == "First" ? "One" : "First"; treeView.Nodes.UpdateTreeViewData(cast * node); }
{ var node = treeView.Nodes.RootNode.GetChild(0).GetChild(1); var data = treeView.Nodes.GetTreeViewData(cast * node); data.text = data.text == "Second (1)" ? "Two (1)" : "Second (1)"; treeView.Nodes.UpdateTreeViewData(cast * node); }

var rootItem : RefreshItem^ = new RefreshItem^("", "", { new RefreshItem^("First", "1st", { new RefreshItem^("First (1)", "1st (1)") new RefreshItem^("Second (1)", "2nd (1)") new RefreshItem^("Third (1)", "3rd (1)") }) new RefreshItem^("Second", "2nd", { new RefreshItem^("First (2)", "1st (2)") new RefreshItem^("Second (2)", "2nd (2)") new RefreshItem^("Third (2)", "3rd (2)") }) new RefreshItem^("Third", "3rd") new RefreshItem^("Fourth", "4th") });
{ rootItem.Children[0].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Task", true)); rootItem.Children[1].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Reminder", true)); rootItem.Children[2].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true)); rootItem.Children[3].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true));

rootItem.Children[0].Children[0].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Task", true)); rootItem.Children[0].Children[1].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Reminder", true)); rootItem.Children[0].Children[2].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true));

rootItem.Children[1].Children[0].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Task", true)); rootItem.Children[1].Children[1].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Reminder", true)); rootItem.Children[1].Children[2].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true)); }

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0
{ treeView.TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Name; }; }
{ treeView.TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Title; }; }
{ var data = self.rootItem.Children[0]; data.Name = data.Name == "First" ? "One" : "First"; data.Title = data.Title == "1st" ? "One" : "1st"; treeView.NotifyNodeDataModified(data); }
{ var data = self.rootItem.Children[0].Children[1]; data.Name = data.Name == "Second (1)" ? "Two (1)" : "Second (1)"; data.Title = data.Title == "2nd (1)" ? "Two (1)" : "2nd (1)"; treeView.NotifyNodeDataModified(data); }
self.rootItem
DoNotUse
Name
SmallImage
Children

var items : observe RefreshItem^[] = { new RefreshItem^("First", "1st") new RefreshItem^("Second", "2nd") new RefreshItem^("Third", "3rd") new RefreshItem^("Fourth", "4th") };
{ items[0].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Task", true)); items[0].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Task", true)); items[1].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Reminder", true)); items[1].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Reminder", true)); items[2].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Tip", true)); items[2].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true)); items[3].LargeImage = (cast (GuiImageData^) self.ResolveResource("res", "LargeImages/Tip", true)); items[3].SmallImage = (cast (GuiImageData^) self.ResolveResource("res", "SmallImages/Tip", true)); }

<_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0

V

{ switch (comboView.SelectedIndex) { case 0: { dataGrid.View = BigIcon; } case 1: { dataGrid.View = SmallIcon; } case 2: { dataGrid.View = ListViewView::List; } case 3: { dataGrid.View = Tile; } case 4: { dataGrid.View = Information; } case 5: { dataGrid.View = Detail; } case 6: { dataGrid.SetViewToDefault(); } } }
{ dataGrid.Columns[0].TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Name; }; }
{ dataGrid.Columns[0].TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Title; }; }
{ var s = self.items[0].Sub1; self.items[0].Sub1 = s == "One" ? "SubColumn" : "One"; dataGrid.NotifyItemDataModified(0, 1); }
{ var s = dataGrid.DataColumns[0]; var c = dataGrid.DataColumns.Count; if (c == 3) { if (s == 0) { dataGrid.DataColumns[0] = 1; } else { dataGrid.DataColumns.RemoveAt(2); } } else { if (s == 0) { dataGrid.DataColumns.Add(2); } else { dataGrid.DataColumns[0] = 0; } } }
{ var s = dataGrid.Columns[1].Text; var c = dataGrid.Columns.Count; if (c == 4) { if (s == "Category") { dataGrid.Columns[1].Text = "What?"; dataGrid.Columns[2].Text = "Wait?"; } else { dataGrid.Columns.RemoveAt(1); } } else { if (s == "Size") { var column = new DataColumn^(); column.Text = "Category"; column.TextProperty = func(value:object):string { return (cast (RefreshItem^) value).Sub1; }; column.ValueProperty = func(value:object, field:object, update:bool):object { var item = cast (RefreshItem^) value; if (update) { item.Sub1 = cast * field; return null; } else { return item.Sub1; } }; dataGrid.Columns.Insert(1, column); } else { dataGrid.Columns[1].Text = "Size"; } } }
self.items
LargeImage
SmallImage
<_ Text="Id" TextProperty="Name" ValueProperty="Name"/> <_ Text="Category" TextProperty="Sub1" ValueProperty="Sub1"/> <_ Text="Size" TextProperty="Sub2" ValueProperty="Sub2"/> <_ Text="File" TextProperty="Sub3" ValueProperty="Sub3"> HyperlinkVisualizerTemplate;FocusRectangleVisualizerTemplate;CellBorderVisualizerTemplate demo:TextEditor
<_>0 <_>1 <_>2