Archive for May, 2009

ProxyRenderTransform Library v2

Aucun commentaire

proxyRenderTransform.jpg
I've just released V2 of ProxyrenderTransform. ProxyRenderTransform use extensions methods to allow easy access to renderTransforms nodes. These are difficult to target by C# when they are not named. If you add the reference ProxyRenderTransform.dll, you will easily reach RenderTransform for any FrameWork element by extensions methods :

  • SetX / GetX
  • SetScaleX / GetScaleX
  • SetRotate / GetRotate
  • SetSkewX / SetSkewY

You can get PropertyPath corresponding the way Blend create RenderTransformGroup via static properties

  • _SCALE_X_PATH // (UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)
  • _SCALE_Y_PATH
  • _SKEW_X_PATH
  • _SKEW_Y_PATH
  • _ROTATE_PATH
  • _TRANSLATE_X_PATH
  • _TRANSLATE_Y_PATH

You can also get reference to transform nodes themselves

  • GetScaleNode
  • GetTranslateNode
  • GetRotateNode
  • GetSkewNode

there's an example below :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void Page_Loaded(object sender, RoutedEventArgs e)
{
//any FrameworkElement can now have direct access to his RenderTransform
rec.SetX(605);
Debug.WriteLine( rec.GetX());
//rec.SetX(105);
//rec.SetRotate(60);
//rec.SetScaleX(2);
 
dp.Interval = TimeSpan.FromMilliseconds(10);
dp.Tick += new EventHandler(dp_Tick);
dp.Start();
}
 
void dp_Tick(object sender, EventArgs e)
{
double newX = (double)rec_Copy.GetX() ( 500 - (double)rec_Copy.GetX() ) * .2;
rec_Copy.SetX(newX);
}

In that release, you will have access to 3D projection plan too...

You can get library under MS-PL licence on Code Plex here.
Don't hesitate to send me an email or post a comment if you encounter bugs or difficulties when you use it :)