Hi Walter,
I need your help!
I have a NodeTemplate with a TextBox in it. If I have a Diagram where I have two of this nodes, one is visible and the other is hidden and use DragSelectingTool I get 2 selected Nodes.
If I use a node with a Label in its Template and do the same things I get only one selected node, which is exact what I want.
I have many node templates all nearly the same, but with other controls in - but only the template with the TextBox behaves like this. I even changed it to a DevExpress TextEdit control and the TextEdit shows the same behavior as the TextBox.
If those other three Nodes have Node.visible false, then they will not be selected by the DragSelectingTool.
If they are visible but just behind the node that we see in the screenshot, i.e. occluded by what we see, then they should be selected by the DragSelectingTool.
Oh, you sure remember I have some sort of great Layer-Structure and I could be that two nodes are located on different Layers but at the same position. I not use the layers of diagram. I managed this by setting visible.
Cause I found no reason why the Textbox should cause this I though it must be my code - but I can’t see the nodes that are selected (I tried to move the node - so that I must see the underlying node - but there is none) - and why is it working with the button template?
I still haven’t found where the problem is.
But I found that there are many properties on Part which have to do with the visibility:
Visibility - Gets or sets the user interface (UI) visibility of this element.
IsVisible - Gets a value indicating whether this element is visible in the user interface (UI).
Visible - Gets or sets whether the user may see or pick this part.
IsVisibleElement - This static predicate is true if the given elt’s Visibility is Visible and each of its visual parents are also visible elements, up to the containing Part.
I have bound my internal value for the visibility to the Visibility-Property of the Node.
I this right, or should I better bind to Visible?
What is the difference between all this Visible-Properties?
Also I found out that there is a difference between selecting with the DragSelectingTool and pressing Ctrl-a to select all,
The DragSelectingTool selects only visible (and invisible TextEdit) but the ctrl-a selects all node (visible or not).
Most people depend on the Part.Visible property, which is a boolean and which is more aligned with how people want to control “visibility”, since it’s actually an attached dependency property on the root element of the template.
I think you are agreeing that mouse-interactive tool operations should try to avoid dealing with not-Visible Nodes and Links. The question is whether the CommandHandler.SelectAll command should ignore not-Visible Parts.
I can see why you think the current behavior of the SelectAll command is inconsistent with the tools. However I believe that the thinking is that just because some Nodes and Links happen not to be visible does not mean that the user wouldn’t want to operate on them. Certainly that would be the case if the user afterwards wanted to delete or copy them all.
If you want to override the behavior, here is the standard implementation of that command:
public virtual void SelectAll() {
Diagram diagram = this.Diagram;
if (diagram == null) return;
try {
diagram.Cursor = Cursors.Wait;
foreach (Part p in diagram.Nodes) {
p.IsSelected = true;
}
foreach (Part p in diagram.Links) {
p.IsSelected = true;
}
} finally {
diagram.Cursor = null;
}
}