本文整理汇总了C#中System.Windows.Media.TransformGroup类的典型用法代码示例。如果您正苦于以下问题:C# TransformGroup类的具体用法?C# TransformGroup怎么用?C# TransformGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransformGroup类属于System.Windows.Media命名空间,在下文中一共展示了TransformGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AntGrid
private void AntGrid(Grid g)
{
g.Width = 5;
g.Height = 5;
g.Visibility = Visibility.Visible;
Storyboard sb = new Storyboard();
DoubleAnimation da = new DoubleAnimation(5.0, gridmain.ActualWidth - 10, new Duration(TimeSpan.FromSeconds(2)));
DoubleAnimation da1 = new DoubleAnimation(5.0, gridmain.RowDefinitions[0].ActualHeight - 10, new Duration(TimeSpan.FromSeconds(2)));
DoubleAnimation da2 = new DoubleAnimation(0, 720, new Duration(TimeSpan.FromSeconds(2)));
TransformGroup tg = new TransformGroup();
RotateTransform rt = new RotateTransform(720);
tg.Children.Add(rt);
g.RenderTransform = tg;
g.RenderTransformOrigin = new Point(0.5, 0.5);
Storyboard.SetTarget(da2, g);
Storyboard.SetTargetProperty(da2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));//RotateTransform.AngleProperty
sb.Children.Add(da2);
Storyboard.SetTarget(da, g);
Storyboard.SetTargetProperty(da, new PropertyPath(Grid.WidthProperty));
sb.Children.Add(da);
Storyboard.SetTarget(da1, g);
Storyboard.SetTargetProperty(da1, new PropertyPath(Grid.HeightProperty));
sb.Children.Add(da1);
if (!Resources.Contains("ShowAn"))
Resources.Add("ShowAn", sb);
sb.AccelerationRatio = 1.0;
sb.Begin();
}
示例2: SpriteSheetDrawBehavior
public SpriteSheetDrawBehavior(string fileName, double frameTime, double angle, bool loop)
{
// Beginstate voor non-readonly variabelen
Reset();
// Sprites ophalen
_sprites = SpriteSheetFactory.Instance.GetSprites(fileName);
// Readonly variabelen
_frameCount = _sprites.Length;
_frameTime = frameTime;
_loop = loop;
// Transformgroups aanmaken (voor rechtzetten en spiegelen van de sprites)
_transformRegular = new TransformGroup();
_transformRegular.Children.Add(new ScaleTransform(1, 1));
_transformRegular.Children.Add(new RotateTransform(angle));
_transformFlipped = new TransformGroup();
_transformFlipped.Children.Add(new ScaleTransform(-1, 1));
_transformFlipped.Children.Add(new RotateTransform(-angle));
// Graphics object aanmaken
_gfx = new Image();
_gfx.Source = _sprites[0];
_gfx.RenderTransformOrigin = new Point(0.5, 0.5);
_gfx.RenderTransform = _transformRegular;
}
示例3: NewUserControlFrom
public static UserControl NewUserControlFrom(FigureTemplate template)
{
UserControl retVal = null;
if (template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0]))
{
retVal = new CoolLetter(template.Fill.Clone(), template.Letter[0]);
}
else
{
retVal = template.GeneratorFunc(template.Fill.Clone());
}
var randomTransition1 = (Tweener.TransitionType)Utils.RandomBetweenTwoNumbers(1, (int)Tweener.TransitionType.EaseOutInBounce);
var ani1 = Tweener.Tween.CreateAnimation(randomTransition1, 0, 1, new TimeSpan(0, 0, 0, 1), 30);
var randomTransition2 = (Tweener.TransitionType)Utils.RandomBetweenTwoNumbers(1, (int)Tweener.TransitionType.EaseOutInBounce);
var ani2 = Tweener.Tween.CreateAnimation(randomTransition2, 360, 0, new TimeSpan(0, 0, 0, 1), 30);
retVal.RenderTransformOrigin = new Point(0.5, 0.5);
var group = new TransformGroup();
group.Children.Add(new ScaleTransform());
group.Children.Add(new RotateTransform());
retVal.RenderTransform = group;
group.Children[0].BeginAnimation(ScaleTransform.ScaleXProperty, ani1);
group.Children[0].BeginAnimation(ScaleTransform.ScaleYProperty, ani1);
group.Children[1].BeginAnimation(RotateTransform.AngleProperty, ani2);
if (Settings.Default.UseEffects)
{
retVal.Effect = template.Effect.Clone();
}
return retVal;
}
示例4: expand
public void expand(Image control, String direction)
{
DoubleAnimationUsingKeyFrames dax = new DoubleAnimationUsingKeyFrames();
DoubleAnimationUsingKeyFrames day = new DoubleAnimationUsingKeyFrames();
TransformGroup tg = new TransformGroup();
switch (direction)
{
case ("Left"):
dax.KeyFrames.Add(new LinearDoubleKeyFrame(-80, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
day.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
control.RenderTransform = leftTrans;
leftTrans.BeginAnimation(TranslateTransform.XProperty, dax);
break;
case ("Top"):
dax.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
day.KeyFrames.Add(new LinearDoubleKeyFrame(-80, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
control.RenderTransform = topTrans;
topTrans.BeginAnimation(TranslateTransform.YProperty, day);
break;
case ("Right"):
dax.KeyFrames.Add(new LinearDoubleKeyFrame(80, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
day.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
control.RenderTransform = rightTrans;
rightTrans.BeginAnimation(TranslateTransform.XProperty, dax);
break;
case ("Bottom"):
dax.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
day.KeyFrames.Add(new LinearDoubleKeyFrame(80, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
control.RenderTransform = bottomTrans;
bottomTrans.BeginAnimation(TranslateTransform.YProperty, day);
break;
}
//tg.Children.Add(ttx);
//tg.Children.Add(tty);
}
示例5: Update
/// <summary>
/// Updates the canvas information (for if canvas size changes)
/// </summary>
public void Update(Size canvasSize, int gridSize)
{
var previousSize = CanvasSize;
Center = new Point(canvasSize.Width / 2, canvasSize.Height / 2);
RotationTransform = new RotateTransform(45, Center.X, Center.Y);
FlipTransform = new ScaleTransform(1, -1, Center.X, Center.Y);
Transforms = new TransformGroup();
Transforms.Children.Add(RotationTransform);
Transforms.Children.Add(FlipTransform);
RotationTransformReverse = new RotateTransform(-45, Center.X, Center.Y);
TransformsReverse = new TransformGroup();
TransformsReverse.Children.Add(FlipTransform);
TransformsReverse.Children.Add(RotationTransform);
CanvasSize = canvasSize;
Grid = new Size((int)(canvasSize.Width / gridSize), (int)(canvasSize.Height / gridSize));
GridSquareSize = new Size(gridSize, gridSize);
LastCanvas = this;
ClipRegion = new RectangleGeometry(new Rect(new Point(20, 20), new Size(canvasSize.Width - 40, canvasSize.Height - 40)));
if (OnCanvasSizeChanged != null && !previousSize.Equals(CanvasSize))
OnCanvasSizeChanged(previousSize, CanvasSize);
}
示例6: Test
private void Test()
{
var test = new TransformGroup
{
Children = new TransformCollection
{
new TranslateTransform { X = 10, Y = 20 },
new RotateTransform { Angle = 45 }
}
};
var v = test.Value;
var st = new TransformGroup { Children = new TransformCollection { new SkewTransform { AngleX = 45 } } };
var tt = new TranslateTransform { X = 1 };
var tg1 = new TransformGroup { Children = new TransformCollection { st, tt } };
var tg2 = new TransformGroup { Children = new TransformCollection { tt, st } };
var tg3 = new TransformGroup { Children = new TransformCollection { st } };
var tg4 = new TransformGroup { Children = new TransformCollection { tt } };
var tg5 = new TransformGroup();
tg5.Children.Add(new TranslateTransform { X = 1, Y = 2 });
tg5.Children.Add(new RotateTransform { Angle = -90 });
var tg6 = new TransformGroup();
tg6.Children.Add(new RotateTransform { Angle = -90 });
tg6.Children.Add(new TranslateTransform { X = 1, Y = 2 });
var p = new RotateTransform { Angle = 90 }.Transform(new Point(1, 2));
var m3 = new Matrix3DProjection();
}
示例7: SetScrollEffect
public static void SetScrollEffect(DependencyObject obj, int value)
{
var elem = obj as FrameworkElement;
var transGroup = new TransformGroup();
transGroup.Children.Add(new ScaleTransform());
transGroup.Children.Add(new SkewTransform());
transGroup.Children.Add(new RotateTransform());
transGroup.Children.Add(new TranslateTransform());
elem.RenderTransform = transGroup;
var sb = new Storyboard();
var da = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(da, obj);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)", new object[0]));
da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 60 });
da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 60 });
da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 900)), Value = 0, EasingFunction = new CircleEase { EasingMode = EasingMode.EaseOut } });
sb.Children.Add(da);
var da2 = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(da2, obj);
Storyboard.SetTargetProperty(da2, new PropertyPath(UIElement.OpacityProperty));
da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 0 });
da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 0 });
da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 400)), Value = 1 });
sb.Children.Add(da2);
elem.Loaded += (a, b) =>
{
sb.Begin();
};
obj.SetValue(ScrollEffectProperty, value);
}
示例8: OrientationChangingFrame
/// <summary>
/// Initializes a new instance of the AnimateOrientationChangesFrame class.
/// </summary>
public OrientationChangingFrame()
{
// Find existing "offset transform" and take it over (if possible) to support SIP raise/lower
var transformGroup = new TransformGroup();
var oldTransformGroup = RenderTransform as TransformGroup;
if ( ( null != oldTransformGroup ) && ( 3 <= oldTransformGroup.Children.Count ) )
{
var offsetTransform = oldTransformGroup.Children[0] as TranslateTransform;
if ( null != offsetTransform )
{
transformGroup.Children.Add( offsetTransform );
}
}
// Add custom transforms
transformGroup.Children.Add( _rotateTransform );
transformGroup.Children.Add( _translateTransform );
// Replace existing transform(s)
RenderTransform = transformGroup;
// Set up animation
_progressAnimation.From = 0;
_progressAnimation.To = 1;
Storyboard.SetTarget( _progressAnimation, this );
Storyboard.SetTargetProperty( _progressAnimation, new PropertyPath( "Progress" ) );
_progressStoryboard.Children.Add( _progressAnimation );
// Initialize variables
EasingFunction = new QuarticEase(); // Initialized here to avoid a single shared instance
// Hook events
SizeChanged += new SizeChangedEventHandler( HandleSizeChanged );
OrientationChanged += new EventHandler<OrientationChangedEventArgs>( HandleOrientationChanged );
}
示例9: OnRender
protected override void OnRender(DrawingContext drawingContext) {
// draw everything except the reflection
base.OnRender(drawingContext);
// set opacity
drawingContext.PushOpacityMask(opacityMask);
reflection.Visual = Child;
var group = new TransformGroup();
if (Child.RenderTransform is TransformGroup) {
foreach (var child in ((TransformGroup)Child.RenderTransform).Children) {
group.Children.Add(child);
}
}
else {
group.Children.Add(Child.RenderTransform);
}
scaleTransform.CenterY = (ActualHeight / 1.5) + ((ActualHeight / 1.5) / 4);
scaleTransform.CenterX = ActualWidth / 2;
group.Children.Add(scaleTransform);
reflection.Transform = group;
// draw the reflection
drawingContext.DrawRectangle(
reflection, null,
new Rect(0, ActualHeight / 1.5, ActualWidth, ActualHeight / 3));
// cleanup
drawingContext.Pop();
}
示例10: Window1
public Window1()
{
InitializeComponent();
TransformGroup group = new TransformGroup();
TranslateTransform tt = new TranslateTransform();
group.Children.Add(tt);
image1.RenderTransform = group;
TransformGroup group2 = new TransformGroup();
TranslateTransform tt2 = new TranslateTransform();
group2.Children.Add(tt2);
image2.RenderTransform = group2;
contactDataController = EmulatorContactDataController.Instance;
Point p1 = new Point(12, 39);
ContactDescriptor c1 = new ContactDescriptor(iPhoneID,(int) p1.X,(int) p1.Y, 180.0f);
contactDataController.addContact(iPhoneID, c1);
Point p2 = new Point(245, 190);
ContactDescriptor c2 = new ContactDescriptor(iPadID, (int)p2.X, (int)p2.Y, 180.0f);
contactDataController.addContact(iPadID, c2);
//serverController = new ServerController(5);
//Thread oThread = new Thread(new ThreadStart(serverController.startServer));
SeverThread fetcher = new SeverThread(this.runServer);
//oThread.Start();
fetcher.BeginInvoke(null, null);
}
示例11: SingleChargeSolver
public SingleChargeSolver()
{
InitializeComponent();
Instance = this;
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 6; j++)
{
var newfPoint = new FieldVector
{
Height = 14,
Width = 8,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness((45*i) + 21, (45*j) + 12, 0, 0)
};
gridField.Children.Add(newfPoint);
}
}
var group = new TransformGroup();
var transfer = new TranslateTransform
{
X = 190,
Y = 118
};
group.Children.Add(transfer);
positiveCharge1.RenderTransform = group;
_charges.Add(positiveCharge1.MyCharge);
CalculatePositions();
}
示例12: marker1dEditor
public marker1dEditor() {
InitializeComponent();
ScaleFactor = 1.0f;
group = new TransformGroup();
trans = new TranslateTransform();
group.Children.Add(trans);
marker.RenderTransform = group;
pointerUp.RenderTransform = group;
pointerDown.RenderTransform = group;
pointerUp.Cursor = Cursors.SizeNS;
pointerDown.Cursor = Cursors.SizeNS;
marker.Cursor = Cursors.SizeAll;
marker.MouseDown += new MouseButtonEventHandler(marker_MouseDown);
marker.MouseMove += new MouseEventHandler(marker_MouseMove);
marker.MouseUp += new MouseButtonEventHandler(MouseUpHandler);
pointerUp.MouseDown += new MouseButtonEventHandler(pointerUp_MouseDown);
pointerUp.MouseMove += new MouseEventHandler(pointerUp_MouseMove);
pointerUp.MouseUp += new MouseButtonEventHandler(MouseUpHandler);
pointerDown.MouseDown += new MouseButtonEventHandler(pointerDown_MouseDown);
pointerDown.MouseMove += new MouseEventHandler(pointerDown_MouseMove);
pointerDown.MouseUp += new MouseButtonEventHandler(MouseUpHandler);
}
示例13: CreateNormalizeTransform
static Transform CreateNormalizeTransform(Rect bounds, Point location, Size size, double angle)
{
var t = new TransformGroup();
var b = bounds;
// Move center of the geometry to origin
t.Children.Add(new TranslateTransform(-b.X - b.Width / 2, -b.Y - b.Height / 2));
// Rotate around origin
t.Children.Add(new RotateTransform(angle));
b = t.TransformBounds(bounds);
// Scale to requested size
t.Children.Add(new ScaleTransform(size.Width / b.Width, size.Height / b.Height));
b = t.TransformBounds(bounds);
// Move to requested position
t.Children.Add(new TranslateTransform(-b.X + location.X, -b.Y + location.Y));
t.Freeze();
b = t.TransformBounds(bounds);
Debug.Assert(Math.Abs(b.X - location.X) < 0.0001);
Debug.Assert(Math.Abs(b.Y - location.Y) < 0.0001);
Debug.Assert(Math.Abs(b.Width - size.Width) < 0.0001);
Debug.Assert(Math.Abs(b.Height - size.Height) < 0.0001);
return t;
}
示例14: ParkHotelExplorer
public static void ParkHotelExplorer(bool restore, double width, Canvas canvas, double top, double left, double scale, double rotate)
{
_canvas = canvas;
var hotelExplorer = HotelExplorer.GetInstance();
hotelExplorer.IsFloating = !restore;
hotelExplorer.HightLight(!restore);
var ypos = restore ? top : Canvas.GetTop(hotelExplorer);
var xpos = restore ? width - left - (hotelExplorer.ActualWidth * scale) : Canvas.GetLeft(hotelExplorer);
var yTo = restore ? 55 : top;
var xTo = restore ? 55 : width - left - (hotelExplorer.ActualWidth / scale);
var zoomFrom = restore ? scale : 1;
var zoomTo = restore ? 1 : scale;
var rotateFrom = restore ? rotate : 0;
var rotateTo = restore ? 0 : rotate;
var yAnimation = new DoubleAnimation
{
From = ypos,
To = yTo,
Duration = new Duration(TimeSpan.FromMilliseconds(500))
};
var xAnimation = new DoubleAnimation
{
From = xpos,
To = xTo,
Duration = new Duration(TimeSpan.FromMilliseconds(1000))
};
hotelExplorer.BeginAnimation(Canvas.TopProperty, yAnimation);
hotelExplorer.BeginAnimation(Canvas.LeftProperty, xAnimation);
var zoom = new DoubleAnimation
{
From = zoomFrom,
To = zoomTo,
BeginTime = TimeSpan.FromMilliseconds(0),
Duration = new Duration(TimeSpan.FromMilliseconds(1000))
};
var rotateAnimation = new DoubleAnimation
{
From = rotateFrom,
To = rotateTo,
BeginTime = TimeSpan.FromMilliseconds(0),
Duration = new Duration(TimeSpan.FromMilliseconds(1000))
};
zoom.Completed += HotelZoomCompleted;
var st = new ScaleTransform();
var rt = new RotateTransform(rotateTo, 0, 0);
var group = new TransformGroup();
group.Children.Add(st);
group.Children.Add(rt);
hotelExplorer.Container.WorkingObject.RenderTransform = group;
st.BeginAnimation(ScaleTransform.ScaleXProperty, zoom);
st.BeginAnimation(ScaleTransform.ScaleYProperty, zoom);
st.BeginAnimation(RotateTransform.AngleProperty, rotateAnimation);
}
示例15: MouseWheel
public static void MouseWheel(Canvas c, TransformGroup tg, MouseWheelEventArgs e)
{
int deltaValue;
deltaValue = e.Delta;
TranslateTransform tt = (TranslateTransform)tg.Children[1];
ScaleTransform st = (ScaleTransform)tg.Children[0];
double xSpot = e.GetPosition(c).X;
double ySpot = e.GetPosition(c).Y;
Double x = e.GetPosition(c).X - tt.X;
Double y = e.GetPosition(c).Y - tt.Y;
Double centerX = st.CenterX * (st.ScaleX - 1);
Double centerY = st.CenterY * (st.ScaleY - 1);
st.CenterX = x;
st.CenterY = y;
if (deltaValue > 0)
{
st.ScaleX *= 1.25;
st.ScaleY *= 1.25;
}
else
{
st.ScaleX *= 0.75;
st.ScaleY *= 0.75;
}
}