Imports System.Text
Imports System.Data
Imports System.Dynamic
Imports Curion.WPF.Controls
Imports Curion.WPF.Data
Imports System.Windows.Controls.Primitives
Public Module mGlobal
Private dataDataTable As DataTable = Nothing
Private dataCurionList As Curion.WPF.Data.List.DataList = Nothing
Private dataExpando As New List(Of ExpandoObject)
Private dataList As New List(Of ExampleClass)
Private dataDictionary As New List(Of Dictionary(Of String, Object))
Sub New()
Randomize()
Call LoadDt()
End Sub
Public ReadOnly Property DataTable As DataTable
Get
Return dataDataTable
End Get
End Property
Public ReadOnly Property CurionList As Curion.WPF.Data.List.DataList
Get
Return dataCurionList
End Get
End Property
Public ReadOnly Property Expando As List(Of ExpandoObject)
Get
Return dataExpando
End Get
End Property
Public ReadOnly Property List As List(Of ExampleClass)
Get
Return dataList
End Get
End Property
Public ReadOnly Property Dictionary As List(Of Dictionary(Of String, Object))
Get
Return dataDictionary
End Get
End Property
Public Sub ShowResults(form As Form.ItemForm)
Dim sb As New StringBuilder
Dim parent As FrameworkElement = Nothing
Dim grid As Grid = Nothing
If form IsNot Nothing Then parent = form.Parent
While parent IsNot Nothing And Not TypeOf parent Is UserControl
parent = parent.Parent
End While
If parent IsNot Nothing Then grid = TryCast(parent.Parent, Grid)
Dim list As New List(Of String)
For Each column In form.ColumnNames
Dim val = form(column)
If TypeOf val Is [Enum] Then
val = [Enum].GetName(val.GetType, val)
Else
val = "" & val ' Convert to string
End If
list.Add(String.Format("{0} = {1}", column, val))
Next
If list.Count = 0 Then
list.Add("{ None }")
End If
If parent Is Nothing OrElse grid Is Nothing Then
' In case there's some special layout
MsgBox(Join(list.ToArray, ", "), MsgBoxStyle.OkOnly, "Current Values")
Else
' UI Sleight of Hand
Call MessWithTheNatives(form, list)
End If
End Sub
#Region " Single Object "
Public Function SingleObject(style As FormStyle) As UserControl
Return SetupSingle("Single Object", dataList(RowNumber), style)
End Function
Public Function SingleDataRow(style As FormStyle) As UserControl
Return SetupSingle("Single Data Row", dataDataTable.Rows(RowNumber), style)
End Function
Public Function SingleExpando(style As FormStyle) As UserControl
Return SetupSingle("Single Expando Object", dataExpando(RowNumber), style)
End Function
Public Function SingleDictionary(style As FormStyle) As UserControl
Return SetupSingle("Single Dictionary Object", dataDictionary(RowNumber), style)
End Function
Public Function SingleCurionRow(style As FormStyle) As UserControl
Return SetupSingle("Single Curion Row", dataCurionList.Rows(RowNumber), style)
End Function
#End Region
#Region " Button Nav Lists "
Public Function ButtonNavObject(style As FormStyle) As UserControl
Return SetupButtonNav("List of Objects", dataList, style)
End Function
Public Function ButtonNavDataTable(style As FormStyle) As UserControl
Return SetupButtonNav("Show DataTable", dataDataTable, style)
End Function
Public Function ButtonNavExpando(style As FormStyle) As UserControl
Return SetupButtonNav("Expando List", dataExpando, style)
End Function
Public Function ButtonNavDictionary(style As FormStyle) As UserControl
Return SetupButtonNav("Dictionary List", dataDictionary, style)
End Function
Public Function ButtonNavCurionList(style As FormStyle) As UserControl
Return SetupButtonNav("Curion List", dataCurionList, style)
End Function
#End Region
#Region " List Nav Lists "
Public Function ListNavObject(style As FormStyle) As UserControl
Return SetupListNav("List of Objects", dataList, style)
End Function
Public Function ListNavDataTable(style As FormStyle) As UserControl
Return SetupListNav("Show DataTable", dataDataTable, style)
End Function
Public Function ListNavExpando(style As FormStyle) As UserControl
Return SetupListNav("Expando List", dataExpando, style)
End Function
Public Function ListNavDictionary(style As FormStyle) As UserControl
Return SetupListNav("Dictionary List", dataDictionary, style)
End Function
Public Function ListNavCurionList(style As FormStyle) As UserControl
Return SetupListNav("Curion List", dataCurionList, style)
End Function
#End Region
#Region " Madness "
Function Madness(bonus As Object) As UserControl
' List of random objects
Dim list As New List(Of Object)
For i = 0 To 10
list.Add(New Person With {.Name = "Person " & (list.Count + 1), .Age = CInt(Rnd() * 20) + 10})
list.Add(New Posts With {.Title = "Post " & (list.Count + 1), .IsActive = CBool(Fix(Rnd() * 2)), .Added = DateAdd(DateInterval.Day, -Rnd() * 5, Today)})
list.Add(New Windows With {.Name = "Window " & (list.Count + 1), .Description = "A simple window number " & (list.Count + 1)})
list.Add(New Thickness With {.Left = Fix(Rnd() * 40) / 10, .Top = Fix(Rnd() * 40) / 10, .Right = Fix(Rnd() * 40) / 10, .Bottom = Fix(Rnd() * 40) / 10})
Dim value = dataList(RowNumber)
list.Add(dataList(RowNumber))
list.Add(bonus)
Next
Using New Curion.WPF.Controls.ContextDefaults
Curion.WPF.Controls.mGlobal.Defaults("Command.Width") = 150
Dim show = New ucButtonNav
Using New Curion.WPF.Controls.Form.SuspendFormGeneration(show.ctlForm)
' Add a default button to our user control to display any missing properties
CType(show.ctlStack.Children(0), Button).IsDefault = False ' Remove default attribute since we're messing with the form and adding a new default
Dim btn As New ToggleButton
Dim act As New Curion.WPF.Controls.ActionStack
act.CommandHeight = 30
act.CommandWidth = 100
act.CommandSpacing = New Thickness(0)
act.Margin = New Thickness(0, 0, 10, 0)
act.Add("Props", "Missing", Sub() GetMissingProps(show.ctlForm))
DirectCast(act.Children(0), Button).IsDefault = True
show.ctlStack.Children.Insert(0, act) ' Add missing properties button
AddHandler show.ctlForm.DataContextChanged, AddressOf Madness_DataContextChanged ' Let's set the Title!
show.FormItemsSource = list ' Wild and whacky list of, well whatever
End Using
Return show
End Using
End Function
Sub Madness_DataContextChanged(sender As Object, e As Curion.WPF.Controls.Form.DataContextChangedEventArgs)
' When the data context changes, lets put the type name of the new object in the Title
Dim frm = TryCast(sender, Curion.WPF.Controls.Form.ItemForm)
If frm Is Nothing Then Return
If e.ChangedTo Is Nothing Then Return
frm.Title = New TextBlock With {.Text = Curion.WPF.Controls.CamelToName(e.ChangedTo.GetType.Name),
.HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
.Style = frm.TryFindResource("Heading1")}
End Sub
Sub GetMissingProps(form As Curion.WPF.Controls.Form.ItemForm)
' Find properties that did not make it onto the form
' ReadOnly, WriteOnly, and Classes that we don't have some form of mapper for
Dim cols = form.ColumnNames
Dim hs As New HashSet(Of String)
For Each col In cols
hs.Add(col)
Next
Dim obj = form.DataContext
Dim missing As New List(Of String)
For Each prop In obj.GetType.GetProperties
Dim sb As New StringBuilder
Dim cnt = 0
If prop.CanRead Then
sb.Append("Read")
cnt += 1
End If
If prop.CanWrite Then
If sb.Length Then sb.Append("/")
sb.Append("Write")
cnt += 1
End If
If cnt = 2 Then
sb.Clear()
Else
sb.Append(" Only ")
End If
If Not hs.Contains(prop.Name) Then
missing.Add(String.Format("{0}{1} As {2}", sb.ToString, prop.Name, prop.PropertyType.Name))
Else
If form.Column(prop.Name) Is Nothing Then
missing.Add(prop.Name + " As" + prop.PropertyType.Name)
End If
End If
Next
If missing.Count = 0 Then missing.Add("[None!]")
Call MessWithTheNatives(form, missing) ' Do an in-place swap, shhhh
End Sub
#End Region
#Region " Potpurri "
Function Potpurri() As UserControl
' Prep columnMaker for form (doing custom column info)
Dim makeColumns = New Form.MakeSimpleColumns
makeColumns.ColumnMapperExceptions.Add("State", Function(obj, header, path) New Form.ComboBoxColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .ItemsSource = GetStates(), .DisplayPath = "Value", .ValuePath = "Key"})
makeColumns.ColumnMapperExceptions.Add("Option", Function(obj, header, path) New Form.ListBoxColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .Height = 65, .Width = 60, .ItemsSource = GetOptions(), .DisplayPath = "Value", .ValuePath = "Key"})
makeColumns.ColumnMapperExceptions.Add("Option2", Function(obj, header, path) New Form.ListBoxColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .Height = 65, .Width = 60, .StyleName = "RadioButtonList", .ItemsSource = GetOptions(), .DisplayPath = "Value", .ValuePath = "Key"})
makeColumns.ColumnMapperExceptions.Add("Option3", Function(obj, header, path) New Form.ListBoxColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .Height = 23, .Width = 60, .StyleName = "RadioButtonList", .Orientation = Orientation.Horizontal, .ItemsSource = GetOptions(), .DisplayPath = "Value", .ValuePath = "Key"})
makeColumns.ColumnMapperExceptions.Add("Card", Function(obj, header, path) New Form.ListBoxColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .Height = 65, .Width = 100, .StyleName = "RadioButtonList", .ItemsSource = obj.Card})
' Prep FormMaker (Creating a CSV layout)
Dim layoutForm As New Form.MakeCsvForm
layoutForm.HeaderWidth = 0
layoutForm.Lines.Add("#Single Stretch")
layoutForm.Lines.Add("Name")
layoutForm.Lines.Add("Address")
layoutForm.Lines.Add("#Stretch and Fixed")
layoutForm.Lines.Add("City=1*,State=130,Zip=60")
layoutForm.Lines.Add("Phone=1*,IsActive=30,Hired=100,Color=1*")
layoutForm.Lines.Add("#Multi Stretch")
layoutForm.Lines.Add("Left,Mid,Right=2*")
layoutForm.Lines.Add("-")
layoutForm.Lines.Add("Option=60,Option2=80,Option3,Card=100")
Dim uc As New ucSingle
Dim form = uc.ctlForm
Using New Form.SuspendFormGeneration(form)
form.LineSpacing = 10
form.HeaderMaker.Width = 60
form.Title = StringTitle("Potpurri", HorizontalAlignment.Left)
form.FormMaker = layoutForm
form.ColumnMaker = makeColumns
form.DataContext = CustomData()
form.Column("City").Width = 100
form.Column("IsActive").SuppressHeading = True
form.Column("Phone").Width = 100
form.Column("Color").Width = 100
form.MakeForm()
End Using
Return uc
End Function
Function CustomData() As ExpandoObject
Dim expando As New ExpandoObject
Dim data As Object
data = expando
' For CSV Forms the order of the fields makes no difference
data.Address = "1212 Main St"
data.City = "Neverville"
data.Color = "Red"
data.Hired = Today
data.IsActive = True
data.Name = "Larry"
data.Phone = "555-1212"
data.State = "NV"
data.Zip = "98321"
data.Left = "Left"
data.Mid = "Mid"
data.Right = "Right"
data.Option = "R"
data.Option2 = "G"
data.Option3 = "B"
data.Card = CardType.MasterCard
Return expando
End Function
Iterator Function GetStates() As IEnumerable(Of KeyValuePair(Of String, String))
Yield New KeyValuePair(Of String, String)("AL", "Alabama")
Yield New KeyValuePair(Of String, String)("AK", "Alaska")
Yield New KeyValuePair(Of String, String)("AZ", "Arizona")
Yield New KeyValuePair(Of String, String)("AR", "Arkansas")
Yield New KeyValuePair(Of String, String)("CA", "California")
Yield New KeyValuePair(Of String, String)("CO", "Colorado")
Yield New KeyValuePair(Of String, String)("CT", "Connecticut")
Yield New KeyValuePair(Of String, String)("DE", "Delaware")
Yield New KeyValuePair(Of String, String)("FL", "Florida")
Yield New KeyValuePair(Of String, String)("GA", "Georgia")
Yield New KeyValuePair(Of String, String)("HI", "Hawaii")
Yield New KeyValuePair(Of String, String)("ID", "Idaho")
Yield New KeyValuePair(Of String, String)("IL", "Illinois")
Yield New KeyValuePair(Of String, String)("IN", "Indiana")
Yield New KeyValuePair(Of String, String)("IA", "Iowa")
Yield New KeyValuePair(Of String, String)("KS", "Kansas")
Yield New KeyValuePair(Of String, String)("KY", "Kentucky")
Yield New KeyValuePair(Of String, String)("LA", "Louisiana")
Yield New KeyValuePair(Of String, String)("MN", "Maine")
Yield New KeyValuePair(Of String, String)("MD", "Maryland")
Yield New KeyValuePair(Of String, String)("MA", "Massachusetts")
Yield New KeyValuePair(Of String, String)("MI", "Michigan")
Yield New KeyValuePair(Of String, String)("MN", "Minnesota")
Yield New KeyValuePair(Of String, String)("MS", "Mississippi")
Yield New KeyValuePair(Of String, String)("MO", "Missouri")
Yield New KeyValuePair(Of String, String)("MT", "Montana")
Yield New KeyValuePair(Of String, String)("NE", "Nebraska")
Yield New KeyValuePair(Of String, String)("NV", "Nevada")
Yield New KeyValuePair(Of String, String)("NH", "New Hampshire")
Yield New KeyValuePair(Of String, String)("NJ", "New Jersey")
Yield New KeyValuePair(Of String, String)("NM", "New Mexico")
Yield New KeyValuePair(Of String, String)("NY", "New York")
Yield New KeyValuePair(Of String, String)("NC", "North Carolina")
Yield New KeyValuePair(Of String, String)("ND", "North Dakota")
Yield New KeyValuePair(Of String, String)("OH", "Ohio")
Yield New KeyValuePair(Of String, String)("OK", "Oklahoma")
Yield New KeyValuePair(Of String, String)("OR", "Oregon")
Yield New KeyValuePair(Of String, String)("PA", "Pennsylvania")
Yield New KeyValuePair(Of String, String)("RI", "Rhode Island")
Yield New KeyValuePair(Of String, String)("SC", "South Carolina")
Yield New KeyValuePair(Of String, String)("SD", "South Dakota")
Yield New KeyValuePair(Of String, String)("TN", "Tennessee")
Yield New KeyValuePair(Of String, String)("TX", "Texas")
Yield New KeyValuePair(Of String, String)("UT", "Utah")
Yield New KeyValuePair(Of String, String)("VT", "Vermont")
Yield New KeyValuePair(Of String, String)("VA", "Virginia")
Yield New KeyValuePair(Of String, String)("WA", "Washington")
Yield New KeyValuePair(Of String, String)("WV", "West Virginia")
Yield New KeyValuePair(Of String, String)("WI", "Wisconsin")
Yield New KeyValuePair(Of String, String)("WYs", "Wyoming")
End Function
Iterator Function GetOptions() As IEnumerable(Of KeyValuePair(Of String, String))
Yield New KeyValuePair(Of String, String)("R", "Red")
Yield New KeyValuePair(Of String, String)("G", "Green")
Yield New KeyValuePair(Of String, String)("B", "Blue")
End Function
#End Region
Function Dependency() As UserControl
Return New CreateDP
End Function
Public Function Separation(style As FormStyle) As UserControl
Dim show = New ucLonely
Using New Curion.WPF.Controls.Form.SuspendFormGeneration(show.ctlForm)
'===========================================================================================
' Set up button mappers to get custom content on the buttons
Dim butFact As New Curion.WPF.Controls.MappedContentButton
butFact.Mapper.Add("First", New Path With {.Data = Geometry.Parse("M 10,0 L10,10 2,5 z M 0,0 L 0,10 2,10 2,0 z"), .Fill = Brushes.Black})
butFact.Mapper.Add("Prior", New Path With {.Data = Geometry.Parse("M 10,0 L10,10 0,5 z"), .Fill = Brushes.Black})
butFact.Mapper.Add("Next", New Path With {.Data = Geometry.Parse("M 0,0 L 0,10 10,5 z"), .Fill = Brushes.Black})
butFact.Mapper.Add("Last", New Path With {.Data = Geometry.Parse("M 0,0 L 0,10 8,5 z M 10,0 L 10,0 10,10 8,10 8,0 z"), .Fill = Brushes.Black})
butFact.Mapper.Add("Add", New Path With {.Data = Geometry.Parse("M19.833,0L32.5,0 32.5,19.833999 52.334,19.833999 52.334,32.500999 32.5,32.500999 32.5,52.333 19.833,52.333 19.833,32.500999 0,32.500999 0,19.833999 19.833,19.833999z"), .Fill = Brushes.Black, .Width = 10, .Height = 10, .Stretch = Stretch.Uniform})
butFact.Mapper.Add("Delete", New Path With {.Data = Geometry.Parse("M51.527958,0L64,12.4741 44.47221,32.001027 64,51.52871 51.528,64.000001 32.000016,44.472668 12.471823,64.000001 0.0010004044,51.528802 19.528015,32.001088 0,12.473726 12.472,0.0010004044 31.999884,19.528773z"), .Fill = Brushes.Black, .Width = 10, .Height = 10, .Stretch = Stretch.Uniform})
butFact.Mapper.Add("Show", New Path With {.Data = Geometry.Parse("F1M1937.77,2316.51L1924.92,2300.18C1929.1,2294.35 1929.14,2286.25 1924.48,2280.33 1918.84,2273.15 1908.45,2271.92 1901.27,2277.56 1894.1,2283.2 1892.86,2293.59 1898.5,2300.77 1903.23,2306.77 1911.26,2308.6 1917.96,2305.74L1930.77,2322.02 1937.77,2316.51z M1903.81,2296.59C1900.48,2292.35 1901.21,2286.21 1905.45,2282.87 1909.69,2279.53 1915.84,2280.26 1919.17,2284.51 1922.51,2288.75 1921.78,2294.89 1917.54,2298.23 1913.29,2301.57 1907.15,2300.84 1903.81,2296.59z"), .Stretch = Stretch.Uniform, .Fill = Brushes.Black, .Width = 10, .Height = 10})
' Routine to make buttons configured a fixed button list and our custom button content mapper
Dim buttonMaker = Function(obj As Curion.WPF.Controls.Form.ItemForm)
Return New Curion.WPF.Controls.CommandStack With {.CommandSource = obj.CommandSource,
.CommandWidth = 23,
.CommandHeight = 23,
.Buttons = "First,*Prior,*Next,Last,,Add,Delete,,Show",
.CommandSpacing = New Thickness(0),
.ButtonMaker = butFact}
End Function
show.ctlForm.ButtonMaker = buttonMaker ' Use the custom button maker
'===========================================================================================
show.ctlForm.CommandSource = New SeparateCommands(show.ctlForm) ' Set command source to use SeparateCommands class
show.ctlForm.FormMaker = FormMaker(style) ' Create a simple, csv, or xml form
show.ctlForm.ItemsSource = dataList ' Where does the data come from?
show.ctlForm.Title = Curion.WPF.Controls.StringTitle("Using Separate Command Object", System.Windows.HorizontalAlignment.Left)
Return show
End Using
End Function
Function NoPrompts() As UserControl
Dim show As New ucSingle
Using New Curion.WPF.Controls.Form.SuspendFormGeneration(show.ctlForm)
show.ctlForm.HeaderMaker = Nothing ' No headers
show.ctlForm.ButtonMaker = Nothing ' No buttons
show.ctlForm.DataContext = New ExampleClass
show.ctlForm.ShowTooltips = True
End Using
Return show
End Function
#Region " Common Setup Layout Routines "
Private Function FormMaker(style As FormStyle) As Curion.WPF.Controls.Form.IMakeForm
Select Case style
Case FormStyle.simple : Return New Curion.WPF.Controls.Form.MakeSimpleForm
Case FormStyle.csv : Return New Curion.WPF.Controls.Form.MakeCsvForm With {.LayoutText = My.Resources.csvLayout}
Case Else : Return New Curion.WPF.Controls.Form.MakeXmlForm With {.LayoutXML = My.Resources.xmlLayout}
End Select
End Function
Private Function SetupListNav(title As String, source As Object, style As FormStyle) As UserControl
Dim show = New ucListNav
Using New Curion.WPF.Controls.Form.SuspendFormGeneration(show.ctlForm)
show.ctlForm.FormMaker = FormMaker(style) ' Assign new layout to form
If Not TypeOf source Is DataTable AndAlso Not TypeOf source Is Curion.WPF.Data.List.DataList AndAlso TypeOf source(0) Is Dictionary(Of String, Object) Then
show.DisplayMemberPath = "[name]"
Else
show.DisplayMemberPath = "name"
End If
show.FormItemsSource = source
show.Title = title
End Using
Return show
End Function
Private Function SetupButtonNav(title As String, source As Object, style As FormStyle) As UserControl
Dim show = New ucButtonNav
Using New Curion.WPF.Controls.Form.SuspendFormGeneration(show.ctlForm)
show.ctlForm.FormMaker = FormMaker(style) ' Assign new layout to form
show.FormItemsSource = source
show.Title = title
End Using
Return show
End Function
Private Function SetupSingle(title As String, source As Object, style As FormStyle) As UserControl
Dim show = New ucSingle
Using New Curion.WPF.Controls.Form.SuspendFormGeneration(show.ctlForm)
show.ctlForm.FormMaker = FormMaker(style)
show.FormDataContext = source
show.Title = title
End Using
Return show
End Function
#End Region
#Region " Support Routines "
Private Function RowNumber() As Integer
Return Fix(Rnd() * dataDataTable.Rows.Count)
End Function
Private Function CopyToExampleClass(index As Integer) As ExampleClass
Dim ex As New ExampleClass
With dataDataTable.Rows(index)
ex.customerId = .Item("customerId")
ex.name = .Item("Name")
ex.address = .Item("Address")
ex.city = .Item("City")
ex.state = .Item("State")
ex.zipcode = .Item("Zipcode")
ex.phone = .Item("Phone")
ex.isActive = .Item("IsActive")
ex.balance = .Item("Balance")
ex.added = .Item("Added")
End With
Return ex
End Function
Private Function CopyToExpando(index As Integer) As ExpandoObject
Dim dr = dataDataTable.Rows(index)
Dim ex As New ExpandoObject
Dim dict = DirectCast(ex, IDictionary(Of String, Object))
For Each k As DataColumn In dataDataTable.Columns
dict.Add(k.ColumnName, dr(k.ColumnName))
Next
Return ex
End Function
Private Sub CopyToCurionRow(list As Curion.WPF.Data.List.DataList, index As Integer)
Dim dr = dataDataTable.Rows(index)
Dim newRow = list.Rows.NewRow
For i = 0 To dataDataTable.Columns.Count - 1
newRow(i) = dr(i)
Next
End Sub
Private Function CreateCurionList() As Curion.WPF.Data.List.DataList
Dim list As New Curion.WPF.Data.List.DataList
For Each c As DataColumn In dataDataTable.Columns
list.Columns.Add(c.ColumnName, c.Caption, c.DataType)
Next
Return list
End Function
Private Function CreateDictionary(index As Integer) As Dictionary(Of String, Object)
Dim dict As New Dictionary(Of String, Object)(StringComparer.CurrentCultureIgnoreCase)
For i = 0 To dataDataTable.Columns.Count - 1
dict.Add(dataDataTable.Columns(i).ColumnName, dataDataTable.Rows(index)(i))
Next
Return dict
End Function
Private Sub LoadDt()
Dim ds As New DataSet
Dim location = My.Computer.FileSystem.GetParentPath(System.Reflection.Assembly.GetAssembly(GetType(ExampleClass)).Location) + "\Customers.xml"
ds.ReadXml(location)
dataDataTable = ds.Tables(0)
dataCurionList = CreateCurionList()
For i = 0 To dataDataTable.Rows.Count - 1
Call CopyToCurionRow(dataCurionList, i)
dataExpando.Add(CopyToExpando(i))
dataList.Add(CopyToExampleClass(i))
dataDictionary.Add(CreateDictionary(i))
Next
End Sub
Private Sub MessWithTheNatives(form As Form.ItemForm, list As List(Of String))
' Build a listbox with missing properties and button to navigate back
Dim parent As FrameworkElement = form.Parent
While parent IsNot Nothing And Not TypeOf parent Is UserControl
parent = parent.Parent
End While
Dim uc = CType(parent, UserControl)
Dim container = CType(uc.Parent, Grid)
Dim stack As New Grid
stack.Margin = New Thickness(10)
stack.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(1, GridUnitType.Star)})
stack.RowDefinitions.Add(New RowDefinition With {.Height = New GridLength(1, GridUnitType.Auto)})
Dim act As New Curion.WPF.Controls.ActionStack
act.CommandHeight = 30
act.CommandWidth = 100
act.Add("Back", "Back", Sub()
container.Children.Clear()
container.Children.Add(uc)
End Sub)
With DirectCast(act.Children(0), Button)
.IsDefault = True
.IsCancel = True
End With
Grid.SetRow(act, 1)
stack.Children.Add(act)
Dim lst As New ListBox
lst.ItemsSource = list
lst.Margin = New Thickness(0, 0, 0, 10)
stack.Children.Add(lst)
' Replace ucButtonNav madness form with list of missing properties and a Back button
container.Children.Clear()
container.Children.Add(stack)
End Sub
#End Region
End Module