Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Gridlines not drawn when moving a node (Read 2144 times)
Cornel
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Dec 17th, 2008
Gridlines not drawn when moving a node
Aug 30th, 2010 at 12:29pm
Print Post  
Hi Stoyo,
We have a problem with the repaint of grid lines when moving nodes programmatically (using .Move method), namely that the grid lines are not always drawn when a node is moved.
To illustrate this issue I placed a diagram view on a form and I added the following code:

[code]
public partial class Form1 : Form
{
ShapeNode node;

public Form1()
{
InitializeComponent();

diagramView1.MouseMove += new MouseEventHandler(diagramView1_MouseMove);

diagram1.BackBrush = new MindFusion.Drawing.SolidBrush("#FFFFFFFF");
diagram1.MeasureUnit = GraphicsUnit.Millimeter;
diagram1.GridSizeX = 1;
diagram1.GridSizeY = 1;
diagram1.GridStyle = GridStyle.Lines;
diagram1.ShowGrid = true;

node = new ShapeNode(this.diagram1);
node.Shape = Shapes.Rectangle;
this.diagram1.Nodes.Add(node);

}

private void diagramView1_MouseMove(object sender, MouseEventArgs e)
{
PointF mousePosition = diagramView1.ClientToDoc(e.Location);
node.Move(mousePosition.X - node.Bounds.Width / 2, mousePosition.Y - node.Bounds.Height / 2);
}

}

[/code]
The issue is visible when the mouse is moved slowly over the diagram.
We tried to use the Invalidate method of diagram/diagramView; it works ok, but it leads to bad performance when many items are drawn on the diagram.

How can we solve this issue (we are using version 5.3.5)?

Regards,
Cornel
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Gridlines not drawn when moving a node
Reply #1 - Aug 30th, 2010 at 2:39pm
Print Post  
Hi Cornel,

The control does some nasty tricks with integer arithmetics to draw the grid quickly, otherwise it would take a lot of time to render it especially such a dense one as yours. It seems as a result it misses the first lines of the grid on the top and left in some cases, depending on which side of the screen pixel the invalid area happens to be defined in floating-point coordinates. Our developer tells me it should be possible to work around this by aligning the invalidated area to the nearest screen pixel whose offset from the view origin is divisible by the grid size. He'll try to create a sample that shows that in the next few days.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Gridlines not drawn when moving a node
Reply #2 - Aug 30th, 2010 at 8:13pm
Print Post  
Another approach you could try is to use the StartInteraction method from this version to implement that movement mode:

https://mindfusion.eu/_beta/fcnet54_startintr.zip

Code
Select All
diagramView.StartInteraction(
	new InteractionState(node, 8, Action.Modify), node.GetCenter()); 



This simulates interaction started by the user, and while it is in progress, the control draws everything except the moved node by copying the content of a cache bitmap to the screen. The cache also includes the full grid, so the lines appear as expected.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint