Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem while Zooming (Read 5294 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Problem while Zooming
Apr 17th, 2009 at 6:30am
Print Post  
Hi,

The scenario is like that:

On mouseEnter I am zooming the node but its containing image is getting flicker on zooming so for that I have created a new ShapeNode inside that zoomed node and put image into that as ImageAlign.Fit...

Now Image flickring problem is isolved but i dont want to add that node in the diagram.I want that new node created as a part or child of parent node on mouseEnter and on mouseLeave that node gets destroyed.

Do you have any suggestion for the same ?



Thanks with Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem while Zooming
Reply #1 - Apr 17th, 2009 at 11:32am
Print Post  
Do you need the image to stay the same size while the node is zoomed?
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Problem while Zooming
Reply #2 - Apr 17th, 2009 at 11:40am
Print Post  
I need,when I zoomed image grow and when I zoomed out image get shrink.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem while Zooming
Reply #3 - Apr 17th, 2009 at 11:52am
Print Post  
How have you implemented zooming on that node, by setting its Bounds? Instead of changing Bounds, you might try setting its RenderTransform to a ScaleTransform; that should scale the image too.

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Problem while Zooming
Reply #4 - Apr 17th, 2009 at 12:05pm
Print Post  
can you plz explain this in detail or can u plz share a sample snippet ?

I have made a node apply image into that through
"imageNode.ImageAlign = ImageAlign.Fit;"
and after that attach this node to the parent node.

The sample snipeet which i have used is :

Code
Select All
var i = e.Source as DiagramNode;

		if (i != null)
		{
		    NodeInfo nodeInfo = i.Tag as NodeInfo;
		    if (nodeInfo != null && nodeInfo.AbstractionType != AbstractionType.absStickyNote)
		    {
			  var ra = new RectAnimation();
			  if (diagram.FindName("mouseEnter") != null)
				diagram.UnregisterName("mouseEnter");
			  diagram.RegisterName("mouseEnter", i);
			  Storyboard.SetTargetName(ra, "mouseEnter");
			  Storyboard.SetTargetProperty(ra, new PropertyPath("Bounds"));

			  double x = (45 + m_xinflate - i.Bounds.Width) / 2;
			  double y = (45 + m_yinflate - i.Bounds.Height) / 2;

			  x = x + ((x / diagram.ZoomFactor) * 100);
			  y = y + ((y / diagram.ZoomFactor) * 100);

			  if (x < 0) x = 0;
			  if (y < 0) y = 0;

			  ra.From = i.Bounds;
			  ra.To = Rect.Inflate(i.Bounds, new Size(x, y));
			  ra.Duration = new Duration(TimeSpan.FromSeconds(0.0));

			  //var sb = new Storyboard() { AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever };
			  var sb = new Storyboard() { AutoReverse = false };

			  ShapeNode node = i as ShapeNode;
			  if (node != null)
			  {
				Point centerPoint = new Point(ra.To.Value.X + ra.To.Value.Width / 2, ra.To.Value.Y + ra.To.Value.Height / 2);
				ShapeNode imageNode = diagram.Factory.CreateShapeNode((centerPoint.X + ra.To.Value.X) / 2, (centerPoint.Y + ra.To.Value.Y) / 2, ra.To.Value.Width / 2, ra.To.Value.Height / 2);

				imageNode.AttachTo(node, AttachToNode.MiddleRight);

				imageNode.Locked = true;
				imageNode.Transparent = true;
				imageNode.Image = node.Image;
				imageNode.ImageAlign = ImageAlign.Fit;

			  }

			  sb.Children.Add(ra);
			  sb.Begin(diagram);

			  double fs = x;
			  if (fs < 10) fs = 10;
			  i.Font.Size = fs;
		    }
		} 




plz let me know what is the solution.
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Problem while Zooming
Reply #5 - Apr 18th, 2009 at 7:09am
Print Post  
Am I missing something  Sad
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem while Zooming
Reply #6 - Apr 18th, 2009 at 7:45am
Print Post  
Instead of using a RectAnimation, try a DoubleAnimation that changes the scale of a ScaleTransform, and set that ScaleTransform as a RenderTransform of the node.

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Problem while Zooming
Reply #7 - Apr 18th, 2009 at 1:00pm
Print Post  
In RectAnimation I am using "ra.To = Rect.Inflate(i.Bounds, new Size(x, y));"

what is its equivalent in DoubleAnimation?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem while Zooming
Reply #8 - Apr 20th, 2009 at 6:24am
Print Post  
Run one double animation for ScaleX and another for ScaleY:

Code
Select All
Transform originalTransform;
DiagramNode node;
private void OnNodeDeactivated(object sender, NodeEventArgs e)
{
	node = e.Node;

	ScaleTransform scale = new ScaleTransform();
	scale.CenterX = node.Bounds.X + node.Bounds.Width / 2;
	scale.CenterY = node.Bounds.Y + node.Bounds.Height / 2;

	originalTransform = node.RenderTransform;
	TransformGroup tg = new TransformGroup();
	tg.Children.Add(originalTransform);
	tg.Children.Add(scale);
	node.RenderTransform = tg;

	var xa = new DoubleAnimation(1, 1.5, new Duration(new TimeSpan(0, 0, 0, 0, 300)));
	var ya = new DoubleAnimation(1, 1.5, new Duration(new TimeSpan(0, 0, 0, 0, 300)));

	if (diagram.FindName("zoom") != null)
		diagram.UnregisterName("zoom");
	diagram.RegisterName("zoom", scale);

	Storyboard.SetTargetName(xa, "zoom");
	Storyboard.SetTargetProperty(xa, new PropertyPath("ScaleX"));
	Storyboard.SetTargetName(ya, "zoom");
	Storyboard.SetTargetProperty(ya, new PropertyPath("ScaleY"));

	var sb = new Storyboard();
	sb.AutoReverse = true;
	sb.Children.Add(xa);
	sb.Children.Add(ya);
	sb.Completed += new EventHandler(sb_Completed);
	sb.Begin(diagram);
}

void sb_Completed(object sender, EventArgs e)
{
	node.RenderTransform = originalTransform;
}
 



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