This is a migrated thread and some comments may be shown as answers.

Custom Diagram Size (Not viewport)

5 Answers 165 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Fede
Top achievements
Rank 1
Fede asked on 27 Oct 2016, 11:32 AM

Hello,

Our company developer team is trying your product and we are wondering if its possible to set the Width and Height of the Diagram, we tried all the examples in the documentation from viewport to set a container in the center of the diagram and use it as a diagram, we used services, dragging area restrictions but non of then are working as expected.

Our main goal is the following:

We have a grid with 2 Rows (1 for buttons/ the other one for the diagram), out clients need to be able to set the area of the diagram that in the future will export the elements that are inside it. 

We tried to set the height and witdth of the diagram and also the size of the viewport,however, the result is just a smaller view of the diagram but not a real smaller page.

Would you be able to help us?

As commented before we tried to implement the examples from Github, forum and documentation without success.

We will wait for your answer, thanks.

5 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 01 Nov 2016, 11:17 AM
Hi Fede,

I am not sure that I completely understand your requirement. My guess is that you want to select part of the view port and export it. To achieve this you can get the elements that you want to export, get also their viewport and add them in a new diagram. Then export the new diagram. I prepared a small example demonstrated such approach. Can you take a look at it and let me know if this is what you are looking for?

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Fede
Top achievements
Rank 1
answered on 02 Nov 2016, 07:59 AM

Hi Martin,

Sorry if i was not clear in my first message.

What we are trying to accomplish is the following scenario:

- When you use Adobe Photoshop, Illustrator or any other similar Software, when you create a new project you choose the document/page size (Height and Width) and after that you have a dark background and a white page
with the size you selected, all the elements you add will be limited inside the bounds of the page.

- So far , we have try to limit the size of the diagram, however this only limits the actual size of the diagram (element) not the viewport.

- We found a couple of properties (diagram.Viewport.X, diagram.Viewport.Y) and (diagram.Viewport.Width, diagram.Viewport.Height), unfortunately Viewport is in read-only mode we are unable to set those properties.

- We tried almost all of the diagram examples that you have in Github and also read all the documentation and we couldnt find anything that works for us.

- We tried to limit the drag-bounds (you have an example in the documentation) but it does not work as expected and we would like to have a simpler solution (set document page size).

- When we talk about export the diagram we are not talking about export it as an image, we are going to send that diagram to another program and it has to know the size of the document and the elements inside it
(sorry,i didnt explain it correctly).


I hope you can understand now what we are trying to do.

Thank you so much for your help!.

0
Martin Ivanov
Telerik team
answered on 04 Nov 2016, 12:28 PM
Hello Fede,

Thank you for the additional information. So, If I understand correctly you want to create the diagram surface with a specific size (lets say 800x600) and restrict the panning, zooming and dragging in the initial view port. Am I correct? If so, perhaps you can create a dummy shape with white background, which you can use as a canvas. And then restrict the dragging inside this shape. This way when you zoom in and out, or when you pan, the diagram will behave as expected. About setting the viewport of the diagram, you can use the BringIntoView() method. I updated my project to demonstrate this. I hope it helps.

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Rene
Top achievements
Rank 1
answered on 07 Aug 2017, 09:56 AM

Hi Martin,

great solution. One question: The Canvas object in c# is set with

private Rect CanvasBounds = new Rect(0 , 0, 801, 601)

 

Is it possible to set size of the canvas object to "mm" or "cm"?
Thanks
Best Regards
RENE

0
Petar Mladenov
Telerik team
answered on 10 Aug 2017, 07:03 AM
Hi Rene,

WPF Framework does not support specifying size (Width, Height, Size, etc.) properties in mm or cm. We encourage you to use some kind of converting functions (cm to px and vice versa) in code. Such can be found in forums, wikipedia, stackoverflow.

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Diagram
Asked by
Fede
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Fede
Top achievements
Rank 1
Rene
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or