public void InitRowSelections(List<RSEntry> rowSelections, SelectableListNodeList rowSelectionSimpleTypes, SelectableListNodeList rowSelectionCollectionTypes) { _rowSelections = rowSelections; _guiStackPanel.Children.Clear(); for (int i = 0; i < _rowSelections.Count; ++i) { var rsItem = _rowSelections[i]; var rsGuiItem = rsItem.GuiItem as RowSelectionItemControl; if (null == rsGuiItem) { var selTypes = new SelectableListNodeList(); if (rsItem.RowSelection is IRowSelectionCollection) { foreach (var item in rowSelectionCollectionTypes) { selTypes.Add(new SelectableListNode(item.Text, item.Tag, rsItem.RowSelection.GetType() == (Type)item.Tag)); } } else // simple type { foreach (var item in rowSelectionSimpleTypes) { selTypes.Add(new SelectableListNode(item.Text, item.Tag, rsItem.RowSelection.GetType() == (Type)item.Tag)); } } rsGuiItem = new RowSelectionItemControl(selTypes, rsItem.DetailsController?.ViewObject); } rsGuiItem.Tag = i; rsGuiItem.IndentationLevel = rsItem.IndentationLevel; rsGuiItem.RowSelectionDetailControl = rsItem.DetailsController?.ViewObject; rsItem.GuiItem = rsGuiItem; _guiStackPanel.Children.Add(rsGuiItem); } }
public void ChangeRowSelection(int idx, SelectableListNodeList rowSelectionTypes) { var rsItem = _rowSelections[idx]; var rsGuiItem = rsItem.GuiItem as RowSelectionItemControl; if (null == rsGuiItem) { var selTypes = new SelectableListNodeList(); foreach (var item in rowSelectionTypes) { selTypes.Add(new SelectableListNode(item.Text, item.Tag, rsItem.RowSelection.GetType() == (Type)item.Tag)); } rsGuiItem = new RowSelectionItemControl(selTypes, rsItem.DetailsController?.ViewObject); } rsGuiItem.Tag = idx; rsGuiItem.IndentationLevel = rsItem.IndentationLevel; rsGuiItem.RowSelectionDetailControl = rsItem.DetailsController?.ViewObject; rsItem.GuiItem = rsGuiItem; _guiStackPanel.Children.RemoveAt(idx); _guiStackPanel.Children.Insert(idx, rsGuiItem); }