Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Query regarding Zooming on Node (Read 1896 times)
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Query regarding Zooming on Node
May 7th, 2009 at 7:03am
Print Post  
Hi,

I want to perform Zoom-In on node while mouse enter. See the code below. I am facing two problem in this.

1. I want to zoom according to the zoomfactor of the diagram. Let’s say if zoomfactor is 100 than node should not be zoomed, if zoom factor is 40 than node should be zoomed 2.5 times of its original dimension.

2. I have applied double animation for the same and put AutoReverse=true.
I want some delay in autoreverse. For ex. - if time for zooming is 3ms than I want get autoreverse should happen after a time delay say 5 sec.

Code
Select All
 TransformGroup tg = new TransformGroup();
		tg.Children.Add(originalTransform);
		tg.Children.Add(scale);
		sourceNode.RenderTransform = tg;

		var xa = new DoubleAnimation(1, 2, new Duration(new TimeSpan(0, 0, 0, 0, 500)));
		var ya = new DoubleAnimation(1, 2, new Duration(new TimeSpan(0, 0, 0, 0, 500)));

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

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

		var sb = new Storyboard();
		sb.AutoReverse=True;
		sb.Children.Add(xa);
		sb.Children.Add(ya);
		sb.Begin(diagram);
		sb.Stop(); 



Can anybody help me on this?

Thanks,
Bala
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Query regarding Zooming on Node
Reply #1 - May 9th, 2009 at 12:31pm
Print Post  
Hi,
Can anybody give reply for the above post?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query regarding Zooming on Node
Reply #2 - May 11th, 2009 at 9:36am
Print Post  
for 1
Code
Select All
private void testZoomAnimation()
{
	var sourceNode = d.Factory.CreateShapeNode(30, 30, 50, 50);
	var originalTransform = sourceNode.RenderTransform;
	var diagram = d;
	diagram.ZoomFactor = 40;
	double zoom = 100 / diagram.ZoomFactor;
	var scale = new ScaleTransform() { CenterX = sourceNode.Bounds.Width / zoom, CenterY = sourceNode.Bounds.Height / zoom};
	TransformGroup tg = new TransformGroup();
	tg.Children.Add(scale);
	tg.Children.Add(originalTransform);
	sourceNode.RenderTransform = tg;
	DoubleAnimation xa = new DoubleAnimation(1, zoom, new Duration(new TimeSpan(0, 0, 0, 0, 500)));
	DoubleAnimation ya = new DoubleAnimation(1, zoom, new Duration(new TimeSpan(0, 0, 0, 0, 500)));
	if (diagram.FindName("mouseEnter") != null)
		diagram.UnregisterName("mouseEnter");
	diagram.RegisterName("mouseEnter", scale);
	Storyboard.SetTargetName(xa, "mouseEnter");
	Storyboard.SetTargetProperty(xa, new PropertyPath("ScaleX"));
	Storyboard.SetTargetName(ya, "mouseEnter");
	Storyboard.SetTargetProperty(ya, new PropertyPath("ScaleY"));
	var sb = new Storyboard { AutoReverse = true, Children = { xa, ya } };
	sourceNode.MouseEnter += (s, e) => { sb.Begin(diagram); };
}
 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query regarding Zooming on Node
Reply #3 - May 11th, 2009 at 10:07am
Print Post  
for 2 use key frames, with AutoReverse = false:

Code
Select All
...
var xa = new DoubleAnimationUsingKeyFrames{
	Duration = TimeSpan.FromSeconds(3),
	KeyFrames = {
		new LinearDoubleKeyFrame(zoom),
		new LinearDoubleKeyFrame(zoom, KeyTime.Uniform),
		new LinearDoubleKeyFrame(1, KeyTime.Uniform),
	}
};

var ya = new DoubleAnimationUsingKeyFrames{
	Duration = xa.Duration,
	KeyFrames = xa.KeyFrames
};
...
 

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