What determines Diagram's ManipulationAdorner Visibility?

0 Answers 42 Views
Diagram
David
Top achievements
Rank 1
Iron
Iron
David asked on 31 Jul 2023, 09:27 PM

We have two situations:  one in which a ManipulationAdorner shows up, and one in which it does not.  I've determined that the sole difference, as far as I can tell, is the Visibility property on ManipulationAdorner itself.  In the one case, the Visibility is "Visible"; in the other, "Collapsed".

I see no other differences in this situation, including with DataContext and the styles/templates.  That is, in both cases, the DataContext has the same property values, and, in both cases, the styles/templates used are the same.

Visibility is being set locally, which means directly on the object either in xaml or in code.  We don't set Visibility directly ourselves, so I'm wondering whether there is logic internal to Diagram or ManipulationAdorner that sets the Visibility?  If so, what are the conditions that result in Visible vs Collapsed, please?  My hope is that I can work backwards from there to figure out how we're triggering the Collapsed state.

Thank you!

-David Marshburn

 

Martin Ivanov
Telerik team
commented on 03 Aug 2023, 06:22 AM

Hi David, can you please provide some more information from your side? Which element's Visibility is set and how? In what situations the adorner is collapsed when you expect to be visible? Can you send some code showing your setup? A sample project showing the issue would be very useful. Also, can you send a video that demonstrates what exactly happens?
David
Top achievements
Rank 1
Iron
Iron
commented on 07 Aug 2023, 07:58 PM

The actual ManipulatorAdorner object has visibility set to Visibile/Collapsed.

If it helps, I attach two images of what Visual Studio's visual tree and property explorer have to say.  Note that Visibility is being set locally.  Also, Snoop confirms that the Visibility is set locally.

I've verified that, in both cases, that the selected Diagram objects are selected; that is, instances of subclasses of NodeViewModelBase have IsSelected set to true.  My understand is that that's what should trigger the ManipulatorAdorner to be visible.

Unfortunately, sharable code is going to be tough -- this exists in a large business project I can't share.  I acknowledge that makes this request difficult.  I guess I'm asking for any advice without sharable code and without me taking a day+ to develop a stand-alone project.

What I'm hoping that can happen, though, is that someone can take a look at the ManipulatorAdorner code (or maybe Diagram code) and tell me what sort of situations result in the ManipulatorAdorner's Visibility being set to Collapsed.  Since it's set locally, there has to be a line of code somewhere doing that.

Further, as an aside, you'll see the name MKBManipulableRadDiagram in the visual tree; that's a subclass of RadDiagram we wrote to add some specific mouse & keyboard handling, but that's all it does (and the handling is the same for both of these situations).

Also, I meant to say that I'm on v. 2021.1.325.40 (which is a couple of years old, admittedly).

Thanks!

Martin Ivanov
Telerik team
commented on 10 Aug 2023, 03:23 PM

Thank you for the extra information.

I am afraid that I can't tell what is happening without the project, but I can give you some insight on when the ManipulationAdorner is displayed. This is the code that sets the visibility:

public void Update(IEnumerable<object> items, bool show)
{
	IConnection connection = items.FirstOrDefault() as IConnection;
	var isSingleSelectedConnection = items.Count() == 1 && connection != null;
	var isConnectionAdornerActive = isSingleSelectedConnection && connection.IsConnectorsManipulationEnabled && connection.IsEnabled;

	var newVisibility = show ? Visibility.Visible : Visibility.Collapsed;

	if (isConnectionAdornerActive)
	{
		newVisibility = System.Windows.Visibility.Collapsed;
	}

	this.Visibility = newVisibility;
}
The Update method is invoked in another method that calls it like that:

var isManipulationAdornerVisible = this.SelectionService.SelectedItems.All(d => d.IsManipulationAdornerVisible);

var
manipulating = adornerBounds != new Rect() && isManipulationAdornerVisible && !adornerBounds.X.IsNanOrInfinity() && !adornerBounds.Y.IsNanOrInfinity() && !adornerBounds.Width.IsNanOrInfinity() && !adornerBounds.Height.IsNanOrInfinity(); this.manipulationAdorner.Update(this.SelectionService.SelectedItems, manipulating);

And this code is called on several occasions, like zoom, resize, rotate, selection and more.

If this isn't enough, you can download the source code of Telerik UI for WPF from your telerik.com account and see more details on the updates. 

And if this doesn't help, I suggest you to try isolating this in a runnable project or open a new private ticket and share your original project if possible.

 

No answers yet. Maybe you can help?

Tags
Diagram
Asked by
David
Top achievements
Rank 1
Iron
Iron
Share this question
or