Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to center a drawing area (Read 5271 times)
Tos
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Apr 26th, 2006
How to center a drawing area
Apr 26th, 2006 at 12:52pm
Print Post  
I failed to find a property that changes the location of the drawing area within the control. Could you please help me to find it?

Thanks in advance,
Anton Malinovsky
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to center a drawing area
Reply #1 - Apr 26th, 2006 at 1:03pm
Print Post  
Hi,

Try the ScrollX and ScrollY properties.

Stoyan
  
Back to top
 
IP Logged
 
Tos
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Apr 26th, 2006
Re: How to center a drawing area
Reply #2 - Apr 26th, 2006 at 1:08pm
Print Post  
ScrollX / ScrollY are used for the drawing area scrolling, am I right?. But I need another functionallity - if the drawing area is smaller than the conrol it is displayed on the top / left of the control and I need to display it on the center of the control.

Anton Malinovsky
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to center a drawing area
Reply #3 - Apr 26th, 2006 at 2:09pm
Print Post  
You could set ScrollX/Y to negative coordinates to achieve that. However that doesn't seem to work correctly when ExteriorBrush is enabled - the area to the left and top isn't repainted, so for now set ExteriorBrush to null.

To calculate the ScrollX/Y values that center the document in the visible area, use fc.ClientToDoc(fc.ClientRectangle) to find out the visible area size in document coordinates, subtract the DocExtents from it and divide the result by 2.

Stoyan
  
Back to top
 
IP Logged
 
Tos
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Apr 26th, 2006
Re: How to center a drawing area
Reply #4 - Apr 26th, 2006 at 2:42pm
Print Post  
I looks like there is a misunderstanding between us. I've sent a sample of the functionality I need (I tried the ScrollX / ScrollY but it doues not work). Sorry for bothering you but I really confused.

Thank you for your support,
Anton Malinovsky
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to center a drawing area
Reply #5 - Apr 26th, 2006 at 4:08pm
Print Post  
The scroll properties will do the job, e.g. try this code:

fc.DocExtents = new RectangleF(0, 0, 100, 100);
fc.CreateBox(0, 0, 100, 100);

fc.ExteriorBrush = null;
RectangleF visible = fc.ClientToDoc(fc.ClientRectangle);
RectangleF doc = fc.DocExtents;

if (visible.Width > doc.Width)
  fc.ScrollX = doc.Left - (visible.Width - doc.Width) / 2;
if (visible.Height > doc.Height)
  fc.ScrollY = doc.Top - (visible.Height - doc.Height) / 2;


You can put the calculations in an OnResize event handler to keep the diagram centered. To reproduce the exact look from your screenshots your must set ExteriorBrush. However it doesn't work correctly if the ScrollX/Y point is outside DocExtents, we will fix that in next release.

Stoyan
  
Back to top
 
IP Logged
 
Tos
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Apr 26th, 2006
Re: How to center a drawing area
Reply #6 - Apr 26th, 2006 at 4:38pm
Print Post  
I've tried the code. The code does not center the drawing area inself - it centers the content of the area (i.e. the created box).

Anton Malinovsky
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to center a drawing area
Reply #7 - Apr 26th, 2006 at 5:00pm
Print Post  
We used the box only to show you where and how big the document area is and how it is centered. Remove the box and set

fc.ExteriorBrush = new SolidBrush(Color.Gray)

and you will see that the whole document is centered in the document area, however the top and left parts won't be drawn correctly.
  
Back to top
 
IP Logged
 
Tos
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Apr 26th, 2006
Re: How to center a drawing area
Reply #8 - Apr 26th, 2006 at 5:10pm
Print Post  
Now I see, it does the trick, sorry for taking your time. Of course with the exterior brush set to null it has a little use. I hope the next version will be ok.

Thanks for your help,
Anton Malinovsky
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to center a drawing area
Reply #9 - Apr 26th, 2006 at 5:26pm
Print Post  
Here is the next version, now the top and left parts should be painted correctly with the ExteriorBrush:

https://mindfusion.org/_beta/fcnet41.zip

It is very much untested, do not send it to your users yet.

Also you might want to set RestrictObjectsToDoc to InsideOnly in order to prevent moving items into the gray area.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint