Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic The grid lines and ruler lines can not be aligned. (Read 3137 times)
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
The grid lines and ruler lines can not be aligned.
May 23rd, 2017 at 5:38am
Print Post  
The grid lines and ruler lines can not be aligned. I set GridSizeX = "10" GridSizeY = "10" GridOffsetX = "0" GridOffsetY = "0", the alignment is shown in the design interface, but after I run the program, I shifted 0.5 right. Then, I set GridOffsetX = "- 0.5" GridOffsetY = "- 0.5" and the grid line is shifted by 0.5 to the left. How to make the grid line alignment ruler scale?
  

design.png ( 69 KB | 101 Downloads )
design.png
Run.png ( 12 KB | 117 Downloads )
Run.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: The grid lines and ruler lines can not be aligned.
Reply #1 - May 23rd, 2017 at 6:22am
Print Post  
Zero offsets work for me. If it looks correct in designer but not in runtime, check if application's startup code isn't setting different values, or loading an older diagram file (where grid properties are stored as well).
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: The grid lines and ruler lines can not be aligned.
Reply #2 - May 23rd, 2017 at 7:40am
Print Post  
Slavcho wrote on May 23rd, 2017 at 6:22am:
Zero offsets work for me. If it looks correct in designer but not in runtime, check if application's startup code isn't setting different values, or loading an older diagram file (where grid properties are stored as well).

I checked the code,There are no other places to set different values.And I've compiled my code from scratch. Still the same problem.Isn't the unit where I set the diagram is mm?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: The grid lines and ruler lines can not be aligned.
Reply #3 - May 23rd, 2017 at 9:02am
Print Post  
The Xaml shows diagram's MeasureUnit is Millimeter, but the ruler's Unit isn't shown there. Please attach a test project that reproduces the problem.
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: The grid lines and ruler lines can not be aligned.
Reply #4 - May 23rd, 2017 at 9:24am
Print Post  
Slavcho wrote on May 23rd, 2017 at 9:02am:
The Xaml shows diagram's MeasureUnit is Millimeter, but the ruler's Unit isn't shown there. Please attach a test project that reproduces the problem.


The initial setting offset is 0, the grid line alignment, run once, the design interface grid line will not be aligned. Need to set offset for other values, and then set to 0, the design interface will be aligned. But when running, will not be aligned.
  

MindfusionDemo.zip ( 43 KB | 112 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: The grid lines and ruler lines can not be aligned.
Reply #5 - May 23rd, 2017 at 1:33pm
Print Post  
It's caused by the control not redrawing the grid but just scaling a cached Visual, and some offset is added when you switch to millimeter which starts to scale too. For time being you can fix it by calling InvalidateBackground to redraw the grid, both when the window is loaded and after zooming -

Code
Select All
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Diagram1.InvalidateBackground();
}

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
    Diagram1.ZoomFactor = Math.Min(1000, Diagram1.ZoomFactor + 50);
    Diagram1.InvalidateBackground();
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: The grid lines and ruler lines can not be aligned.
Reply #6 - May 24th, 2017 at 1:13am
Print Post  
Slavcho wrote on May 23rd, 2017 at 1:33pm:
It's caused by the control not redrawing the grid but just scaling a cached Visual, and some offset is added when you switch to millimeter which starts to scale too. For time being you can fix it by calling InvalidateBackground to redraw the grid, both when the window is loaded and after zooming -

Code
Select All
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Diagram1.InvalidateBackground();
}

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
    Diagram1.ZoomFactor = Math.Min(1000, Diagram1.ZoomFactor + 50);
    Diagram1.InvalidateBackground();
} 



Regards,
Slavcho



ok!I got it.Thanks!!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint