This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have a problem with the diagram and the behaviour of the grid lines. Attached you can find a sample project.
When you click the checkbox to disable the grid lines nothing happens. As soon I scroll the diagram the grid lines disappear. Regards, Dan |
|
|
Hello Dan The problem is that the DiagramSurface does not know about the custom behavior of your CustomSnap class - it does not know about the IsGridLinesEnabled property, and so does not know when to update. Scrolling causes a redraw which in-turn calls your CustomSnap methods. Fortunately, this is easy to get working. I would recommend that to disable the grid lines, you set the SnapLineDrawing property of the DiagramSurface to null. You could bind the SnapLineDrawing property to IsGridLinesEnabled on the window view model, and use a converter that will either return the IntervalSnapLineDrawing, or null depending on the value. Let me know if you have any questions about this. -Jason Fauchelle |
|
|
Hi Jason, setting the SnapLineDrawing to null does not produce the expected result. The gridlines are still visible. However setting the viewport 1px forward and back solved the problem, if i delay the action with dispatcher.BeginInvoke and a low priority like application idle. I would prefere if diagramsurfae.Invalidate or any similar method on the diagramsurface would do that. Setting the viewport forward and back is like shaking the grid, only to trigger a new rendering of the background. Kind regards Markus |
|
|
Hello Markus I've attached the sample project that demonstrates setting the SnapLineDrawing to null. I have done it the quick way that exposes an ISnapLineDrawing object through a property on the model. You'll probably want to do it by using a converter on the boolean property instead which will produce the same result. I recommend this approach as bindings are generally more convenient than calling a method. To run the sample project, you'll need to set the WPF Diagram dll references. Let me know how it goes. -Jason Fauchelle |
|
|
Hi Jason, it is working for this sample, but unfortunately it's not producing the desired behavior. I want to control snapping and displaying the grid lines separately. I want to be able to snap the nodes on a 12px raster and provide the user an option to display the gridlines or not. This is very common in many applications because sometimes the gridlines are annoying for users. Your solution is all or nothing. The Interface you provide with ISnapSpecifier gives you the possibility of doing that, but you cannot tell the surface that it must update the grid. So the interface is simply missing a property or event like: Action Update {get; set;} that I can call in my implementation to tell the surface that something on my SnapSpecifier has changed and it needs to redraw the grid. I agree that attaching a dependency property or writing a converter is ugly. Thanks Markus |
|
|
Hello Markus When I add a node to the sample I sent you, and then click the CheckBox to hide the grid lines, the node still snaps to the snap-specifiers when I move it. Just to clarify, is that the behavior you want? If you do the same thing with the sample I sent you, does the node move smoothly rather than obeying the snap specifiers when the grid lines are hidden? If so, maybe you have an older version, though I can't think of any recent changes that would have fixed this. Nevertheless, I have updated the DiagramSurface in a way that I think you will like. As you may know, I can not add the event/property you described to the interface as this would be a breaking change, but I have done the next best thing. Once you install the next nightly build, you can make your CustomSnap class implement the INotifyPropertyChanged interface, and then raise a property changed event when the IsGridlinesEnabled property changes. The DiagramSurface will now consider this to be a signal to redraw the grid, thus causing the lines to be dynamically displayed or hidden using your original idea. This will be more convenient than binding the SnapLineDrawing. The next nightly build will be available at around 1200 GMT. Let me know if you need help getting this to work. -Jason Fauchelle |
|
|
Hi Jason, today we integrated the latest nightly build in our product. We updated our CustomSnap class to raise the property changed event and it works perfect. Thanks Markus |
|
|
Quick question about this functionality. Is it possible to only draw the grid lines and not have the snapping behaviour? |
|
|
Hi eliz, in my sample above there is a customsnap class that implements this feature. Kind regards Markus |
|
|
Hello Eliz This is not yet a built-in feature, but as Markus mentioned, the CustomSnap class in his WpfDiagram sample in the first post above will work very well for you. Use instances of this class to set the vertical and horizontal snap specifiers of the DiagramSurface, and set IsSnapEnabled to false. -Jason Fauchelle |
|