Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) diagramView1.Behavior? (Read 9324 times)
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
diagramView1.Behavior?
Nov 24th, 2008 at 7:34pm
Print Post  
I know if I set
diagramView1.Behavior = DoNothing
diagram can not be edited.
But in my implimentation I want two things
1. Nodes and links are not editable
2. But i want to impliment zoomToRect functionality
which basically draws the trasparent Rectangle and zoom to rectagle and retangle is removed after zoom

how this is possible as donothing dont allow to do anything on the view but i just want to draw rect for zoomin
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #1 - Nov 25th, 2008 at 7:09am
Print Post  
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: diagramView1.Behavior?
Reply #2 - Nov 25th, 2008 at 3:12pm
Print Post  
I have implimented this already, but my problem is i dont want to allow users to move link and nodes,

I know this zoomtorect will always create the new node trasferent for zoomto rect perpose.

just dont want to move the existing nodes and links
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #3 - Nov 25th, 2008 at 3:33pm
Print Post  
You could set Locked = true for each DiagramItem, or otherwise implement a custom behavior that never returns Action.Modify.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: diagramView1.Behavior?
Reply #4 - Nov 25th, 2008 at 9:14pm
Print Post  
the things are working perfect except the one problem.

I used the code to draw link from the follwing link which you provide me to solve the link text strik to link line which is working perfect
http://mindfusion.eu/_samples/DrawLinkSample.txt

because of this code when i use zoomToRect for any LinkText it doen't show that text, on the zoom format i could see only the links

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #5 - Nov 26th, 2008 at 6:16am
Print Post  
With this code you get the labels drawn only when the Draw Link handler for the last link in the Z order is called. This might not happen when the link is not visible on the screen, e.g. when you zoom in a lot. Try to call Diagram.Invalidate() after zooming in, this should invalidate the whole diagram and raise the event.
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: diagramView1.Behavior?
Reply #6 - Nov 26th, 2008 at 2:28pm
Print Post  
??? its not happening

I used the code:
Code
Select All
  private void diagram1_NodeCreated(object sender, NodeEventArgs e)
	  {
		ShapeNode node = e.Node as ShapeNode;
		if (!zoomToRectTool && node != null)
		{
		    diagram1.Invalidate();
		    diagramView1.ZoomToRect (node.Bounds);
		   //tried here diagram1.Invalidate();

		    diagram1.Nodes.Remove(node);
		    zoomToRectTool = true;
		    diagramView1.ShowScrollbars = true;

		}
		else
		{
		    diagram1.Nodes.Remove(node);
		}
	  }
 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #7 - Nov 26th, 2008 at 3:26pm
Print Post  
So the Draw method of that link is never called when the link is not inside the view. We have optimized the rendering code too well Wink Instead of drawing all labels from the DrawLink handler for a single link, try to handle the DiagramView.Paint event and draw the labels there.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: diagramView1.Behavior?
Reply #8 - Nov 26th, 2008 at 4:09pm
Print Post  

I use this piece of code the program runs but now i cant see the link lables at all.
even zoomtorezt dont show any lables,

i debug the code it seems string are drawn.
I guess i am missing something

Code
Select All
 private void diagramView1_Paint(object sender, PaintEventArgs e)
	  {
		System.Drawing.Brush textBrush = new System.Drawing.SolidBrush(Color.Black);
		System.Drawing.Brush backBrush = diagram1.BackBrush.CreateGdiBrush(diagram1.Bounds);

		foreach (DiagramLink l in diagram1.Links)
		{
		    int s = l.SegmentCount / 2;
		    PointF p1 = l.ControlPoints[s];
		    PointF p2 = l.ControlPoints[s + 1];
		    float iX;
		    if (p2.X < p1.X)
			  iX = p2.X + 10F;
		    else if (p2.X > p1.X)
			  iX = p2.X - 10F;
		    else
			  iX = (p1.X + p2.X) / 2;
		    PointF c = new PointF(iX, (p1.Y + p2.Y) / 2);//(p1.X + p2.X) / 2

		    SizeF textSize = diagram1.MeasureString(l.Text, l.Font, int.MaxValue, StringFormat.GenericDefault);
		    float w = textSize.Width;
		    float h = textSize.Height;
		    RectangleF textRect = new RectangleF(c.X - w / 2, c.Y - h / 2, w, h);

		    StringFormat stringFormat = new StringFormat();
		    stringFormat.Alignment = StringAlignment.Center;
		    stringFormat.LineAlignment = StringAlignment.Center;


		    e.Graphics.FillRectangle(backBrush, textRect);
		    e.Graphics.DrawString(l.Text, l.Font, textBrush, textRect, stringFormat);

		}

		backBrush.Dispose();
		textBrush.Dispose();

	  } 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #9 - Nov 26th, 2008 at 6:55pm
Print Post  
Try it with the following lines added to the top of the Paint handler -

Code
Select All
float scale = diagramView.ZoomFactor / 100F;
e.Graphics.PageUnit = diagram1.MeasureUnit;
e.Graphics.ScaleTransform(scale, scale);
e.Graphics.TranslateTransform(-diagramView.ScrollX, -diagramView.ScrollY);
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: diagramView1.Behavior?
Reply #10 - Dec 1st, 2008 at 2:49pm
Print Post  
now i am facing some problem

When i draw the rectagle for zoom,
over the link lable , the only link lable (not link) gets disappear
after zoom to rect is done, it shows the link lable properly (zoomed)

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #11 - Dec 2nd, 2008 at 7:11am
Print Post  
We've added a better event for doing this,:
https://mindfusion.eu/_temp/fcnet_drawfore.zip

It's called DrawForeground and is in the Diagram class. It should work also while drawing with the mouse. Handle it like this:

[code]
private void diagram_DrawForeground(object sender, DiagramEventArgs e)
{
     System.Drawing.Brush textBrush = new System.Drawing.SolidBrush(Color.Red);
     System.Drawing.Brush backBrush = diagram.BackBrush.CreateGdiBrush(diagram.Bounds);

     foreach (DiagramLink l in diagram.Links)
     {
           int s = l.SegmentCount / 2;
           PointF p1 = l.ControlPoints[s];
           PointF p2 = l.ControlPoints[s + 1];
           PointF c = new PointF((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);

           SizeF textSize = diagram.MeasureString(l.Text, l.Font, int.MaxValue, StringFormat.GenericDefault);
           float w = textSize.Width;
           float h = textSize.Height;
           RectangleF textRect = new RectangleF(c.X - w / 2, c.Y - h / 2, w, h);

           e.Graphics.FillRectangle(backBrush, textRect);
           e.Graphics.DrawString(l.Text, l.Font, textBrush, textRect, StringFormat.GenericDefault);
     }

     backBrush.Dispose();
     textBrush.Dispose();
}
[/code]

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
nick00
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Nov 7th, 2008
Re: diagramView1.Behavior?
Reply #12 - Dec 2nd, 2008 at 10:23pm
Print Post  
is this for VS2005 version?
Do I need to override the dll of local VS2005?

thanks,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #13 - Dec 3rd, 2008 at 6:30am
Print Post  
Unzip the dlls into a folder and add the folder to the top of your project's reference paths list. Additionally, disable the "Use specific version" property for the mindfusion.* references, if it's enabled.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: diagramView1.Behavior?
Reply #14 - Dec 16th, 2008 at 6:42am
Print Post  
The only reasons I can think of FillRectangle would work and DrawString would not is that either l.Text is an empty string or textBrush is white / transparent. You could add a breakpoint on that line and check if all values passed as arguments to DrawString are ok.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint