示例#1
0
                /// <summary>
                /// Creates a new test window instance with the child element type specified by the
                /// type list selection.
                /// </summary>
                private void InstantiateSelectedType(object sender, EventArgs args)
                {
                    if (typeList.Selection != null)
                    {
                        DemoElements selection   = typeList.Selection.AssocMember;
                        var          testElement = new TestWindowNode(selection);

                        demoRoot.Add(testElement);
                        instanceList.Add($"[#{instanceList.EntryList.Count}] {selection}", testElement);

                        // If selection is empty set selection to new element
                        if (instanceList.Selection == null)
                        {
                            instanceList.SetSelection(testElement);
                        }
                    }
                }
示例#2
0
                /// <summary>
                /// Removes the instance currently selected in the instance list when invoked.
                /// </summary>
                private void RemoveSelectedInstance(object sender, EventArgs args)
                {
                    if (instanceList.Selection != null)
                    {
                        ListBoxEntry <TestWindowNode> selection = instanceList.Selection;
                        TestWindowNode testNode           = selection.AssocMember;
                        var            instanceCollection = instanceList.HudCollection;

                        int index = instanceCollection.FindIndex(x => x.AssocMember == testNode);
                        instanceList.RemoveAt(index);
                        testNode.Unregister();

                        // Attempt to select the previous member
                        if (index > 0)
                        {
                            index--;
                        }

                        if (instanceCollection.Count > 0)
                        {
                            instanceList.SetSelectionAt(index);
                        }
                    }
                }