protected override ITree GetTree(ITypeDescriptorContext context, object value) { ElementGrouping instance = (ElementGrouping)EditorUtility.ResolveContextInstance(context.Instance, false); // false indicates this should not be called in multiselect mode. ITree tree = new VirtualTree(); tree.Root = new GroupingTypesBranch(instance); return(tree); }
/// <summary> /// Get a checkbox-based tree with uncombined ring types /// </summary> protected sealed override ITree GetTree(ITypeDescriptorContext context, object value) { ITree tree = new VirtualTree(); RingTypeBranch branch = new RingTypeBranch(EditorUtility.ResolveContextInstance(context.Instance, true) as ModelElement); tree.Root = branch; branch.Selection = (RingConstraintType)value; return(tree); }
/// <summary> /// Create a new SynchronizeStateEventArgs. /// </summary> /// <param name="tree">Tree raising this event. Necessary to allow clients that handle synchronization themeselves to raise events back to the tree.</param> /// <param name="itemsToSynchronize">Enumerator of items to be synchronized.</param> /// <param name="matchBranch">Branch whose state should be matched.</param> /// <param name="matchRow">Row whose state should be matched.</param> /// <param name="matchColumn">Column whose state should be matched.</param> public SynchronizeStateEventArgs( ITree tree, ColumnItemEnumerator itemsToSynchronize, IBranch matchBranch, int matchRow, int matchColumn) { Handled = false; myItemsToSynchronize = itemsToSynchronize; myMatchBranch = matchBranch; myMatchRow = matchRow; myMatchColumn = matchColumn; myTree = tree as VirtualTree; }
/// <summary> /// Get the ITree representing the current verbalization settings /// </summary> protected override ITree GetTree(ITypeDescriptorContext context, object value) { ITree tree = new VirtualTree(); IBranch rootBranch = new ProviderBranch((string)value, TargetProviders, SnippetsProviders, VerbalizationDirectory, LanguageFormatString); tree.Root = rootBranch; if (rootBranch.VisibleItemCount == 1) { tree.ToggleExpansion(0, 0); } return(tree); }
/// <summary> /// Creates a new form to filter errors for the given ORM model. /// </summary> /// <param name="model">The orm model for which to filter errors.</param> public ModelErrorDisplayFilterForm(ORMModel model) { this.myModel = model; InitializeComponent(); LoadCategories(); ITree tree = new VirtualTree(); IBranch rootBranch = new InitialCategoriesBranch(myCategories, myErrors); tree.Root = rootBranch; #if VISUALSTUDIO_9_0 // MSBUG: Hack workaround crashing bug in VirtualTreeControl.OnToggleExpansion this.virtualTreeControl.ColumnPermutation = new ColumnPermutation(1, new int[]{0}, false); #endif this.virtualTreeControl.Tree = tree; }
protected override DragDropEffects RowDropEffect(Row row, RowDropLocation dropLocation, IDataObject data) { if (!IsWorkpad) { return(base.RowDropEffect(row, dropLocation, data)); } VirtualTree tree = GetTree(data); if (tree == null) { return(DragDropEffects.None); } return((tree == this) ? DragDropEffects.Move : DragDropEffects.Copy); }
public bool TryGetParent(out VirtualTree <T> parent) { T parentNode; if (this.TreeWalker.TryGetParent(this.Root, out parentNode)) { parent = this.ShallowCopy(parentNode); return(true); } else { parent = default(VirtualTree <T>); return(false); } }
/// <summary> /// Creates a new form to filter errors for the given ORM model. /// </summary> /// <param name="model">The orm model for which to filter errors.</param> public ModelErrorDisplayFilterForm(ORMModel model) { this.myModel = model; InitializeComponent(); LoadCategories(); ITree tree = new VirtualTree(); IBranch rootBranch = new InitialCategoriesBranch(myCategories, myErrors); tree.Root = rootBranch; #if VISUALSTUDIO_9_0 // MSBUG: Hack workaround crashing bug in VirtualTreeControl.OnToggleExpansion this.virtualTreeControl.ColumnPermutation = new ColumnPermutation(1, new int[] { 0 }, false); #endif this.virtualTreeControl.Tree = tree; }
public void GetChildAt(int index, int[] expected) { IEnumerable <VirtualTree <Node <int> > > nums = Enumerable .Range(0, 2) .Select(x => VirtualTree .New( new NodeWalker <int>(), Node .Create(x) .AddChildren( Enumerable .Range(0, 3) .Select(y => Node.Create(y)) .ToArray()))); Assert.Equal(expected, nums.GetChildAt(index).Unwrap().Select(x => x.Value).ToArray()); }
private void DiagramOrderDialog_Load(object sender, EventArgs e) { if (LastFormSize != Size.Empty) { Size = LastFormSize; } ITree tree = new VirtualTree(); tree.Root = new DiagramBranch(this); VirtualTreeControl treeControl = DiagramsList; treeControl.Tree = tree; int selectIndex; if (-1 != (selectIndex = myInitialSelectionIndex)) { treeControl.CurrentIndex = selectIndex; } treeControl.Select(); }
public void GetChildrenByKey_ArgumentComparerIsInvoked() { // Get a valid tree. var tree = TestTreeFactory.GetSimpleTree(); // Create a mock IComparer. Mock <IEqualityComparer <Node <int> > > mockComparer = new Mock <IEqualityComparer <Node <int> > >(); mockComparer .Setup(mock => mock.Equals(It.IsAny <Node <int> >(), It.IsAny <Node <int> >())) .Returns(true); // Create a VirtualTree. VirtualTree <Node <int> > vt = VirtualTree.New(new NodeWalker <int>(), tree); // Create a key to use for comparison. Any key is fine. Node <int> key = new Node <int>(0); // Execute the GetChildren. vt.GetChildren(key, mockComparer.Object).ToArray(); // Verify that the comparer argument was used. mockComparer.Verify(x => x.Equals(key, It.IsAny <Node <int> >()), Times.AtLeastOnce); }
public void GetDescendants_ByKey_PropetyComparerIsInvoked() { // Get a valid tree. var tree = TestTreeFactory.GetSimpleTree(); // Create a mock IComparer. Mock <IEqualityComparer <Node <int> > > mockComparer = new Mock <IEqualityComparer <Node <int> > >(); mockComparer .Setup(mock => mock.Equals(It.IsAny <Node <int> >(), It.IsAny <Node <int> >())) .Returns(true); // Create a VirtualTree. VirtualTree <Node <int> > vt = VirtualTree.New(new NodeWalker <int>(), tree, mockComparer.Object); // Create a key to use for comparison. Any key is fine. Node <int> key = new Node <int>(0); // Execute GetDescendants. vt.GetDescendants(key: key).ToArray(); // Verify that the VirtualTree's comparer was used. mockComparer.Verify(x => x.Equals(It.IsAny <Node <int> >(), It.IsAny <Node <int> >()), Times.Exactly(vt.GetDegree())); }
private void DiagramOrderDialog_Load(object sender, EventArgs e) { if (LastFormSize != Size.Empty) { Size = LastFormSize; } ITree tree = new VirtualTree(); tree.Root = new DiagramBranch(this); VirtualTreeControl treeControl = DiagramsList; treeControl.Tree = tree; treeControl.Select(); }
internal PositionManagerEventArgs(VirtualTree owningTree) { myMultiColumnTree = (null != (owningTree as IMultiColumnTree)) ? owningTree : null; myTable = new Hashtable(); }
public DragDropPanelWidget(VirtualTree tree) : base(tree) { }
/// <summary> /// Required UITypeEditor override. Opens dropdown modally /// and waits for user input. /// </summary> /// <param name="context">The descriptor context. Used to retrieve /// the live instance and other data.</param> /// <param name="provider">The service provider for the given context.</param> /// <param name="value">The current property value</param> /// <returns>The updated property value, or the orignal value to effect a cancel</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService editor = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; if (editor != null) { object newObject = value; // Get the list contents and add a null handler if needed IList elements = GetContentList(context, value); string nullText = NullItemText; // Proceed if there is anything to show if (nullText != null || (elements != null && elements.Count != 0)) { // Create a tree control using (DropDownTreeControl treeControl = new DropDownTreeControl()) { #if VISUALSTUDIO_9_0 // MSBUG: Hack workaround crashing bug in VirtualTreeControl.OnToggleExpansion treeControl.ColumnPermutation = new ColumnPermutation(1, new int[] { 0 }, false); #endif // Close the dropdown after a double click treeControl.AfterDoubleClick += delegate(object sender, DoubleClickEventArgs e) { if (e.Button == MouseButtons.Left) { editor.CloseDropDown(); } }; // Create a tree for the control ITree tree = new VirtualTree(); tree.Root = new SimpleBranch(this, elements, nullText); treeControl.Tree = tree; // Manage the size of the control Size lastSize = LastControlSize; if (!lastSize.IsEmpty) { treeControl.Size = lastSize; } int initialIndex = -1; if (value != null) { if (elements != null) { initialIndex = elements.IndexOf(TranslateToDisplayObject(value, elements)); if (nullText != null) { ++initialIndex; } } } else if (nullText != null) { initialIndex = 0; } if (initialIndex != -1) { treeControl.InitialSelectionIndex = initialIndex; } Control adornedControl = SetTreeControlDisplayOptions(treeControl) ?? treeControl; bool escapePressed = false; EditorUtility.AttachEscapeKeyPressedEventHandler( adornedControl, delegate(object sender, EventArgs e) { escapePressed = true; }); // Make sure keystrokes are not forwarded while the modal dropdown is open IVirtualTreeInPlaceControl virtualTreeInPlaceControl = editor as IVirtualTreeInPlaceControl; VirtualTreeInPlaceControlFlags flags = virtualTreeInPlaceControl != null ? virtualTreeInPlaceControl.Flags : 0; if (0 != (flags & VirtualTreeInPlaceControlFlags.ForwardKeyEvents)) { virtualTreeInPlaceControl.Flags = flags & ~VirtualTreeInPlaceControlFlags.ForwardKeyEvents; } // Show the dropdown. This is modal. editor.DropDownControl(adornedControl); // Restore keystroke forwarding if (0 != (flags & VirtualTreeInPlaceControlFlags.ForwardKeyEvents)) { virtualTreeInPlaceControl.Flags = flags; } // Record the final size, we'll use it next time for this type of control LastControlSize = treeControl.Size; // Make sure the user didn't cancel, and translate the null placeholder // back to null if necessary if (!escapePressed) { int lastIndex = treeControl.AnchorIndex; if (lastIndex != -1) { if (nullText != null) { --lastIndex; if (lastIndex == -1) { newObject = null; } else { newObject = elements[lastIndex]; } } else { newObject = elements[lastIndex]; } // Give the caller the chance to change the type of the chosen object newObject = TranslateFromDisplayObject(lastIndex, newObject); } } } } return(newObject); } return(value); }