本文整理汇总了C#中System.Windows.Media.ScaleTransform类的典型用法代码示例。如果您正苦于以下问题:C# ScaleTransform类的具体用法?C# ScaleTransform怎么用?C# ScaleTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScaleTransform类属于System.Windows.Media命名空间,在下文中一共展示了ScaleTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSubMagic
void CreateSubMagic(RoleBase caster, Space space, MagicArgs args, int index)
{
AnimationBase animation = new AnimationBase() { Code = args.ResCode, Z = targets[index].Z + 1, Effect = shiftHue };
double offsetStartY = (caster.State == States.Riding ? (caster.Profession == Professions.Taoist ? 130 : 110) : 60) * caster.Scale;
double offsetEndY = (targets[index].State == States.Riding ? 100 : 50) * caster.Scale;
Point from = index == 0 ? new Point(args.Position.X, args.Position.Y - offsetStartY) : temp;
Point to = new Point(targets[index].Position.X, targets[index].Position.Y - offsetEndY);
temp = to;
RotateTransform rotateTransform = new RotateTransform() {
CenterX = animation.Center.X,
CenterY = animation.Center.Y,
Angle = GlobalMethod.GetAngle(to.Y - from.Y, to.X - from.X)
};
ScaleTransform scaleTransform = new ScaleTransform() {
CenterX = animation.Center.X,
CenterY = animation.Center.Y,
ScaleX = (GlobalMethod.GetDistance(index == 0 ? args.Position : targets[index - 1].Position, targets[index].Position) / 440), //440为其实体宽度,这里用了硬编码
ScaleY = caster.Scale
};
TransformGroup transformGroup = new TransformGroup();
transformGroup.Children.Add(scaleTransform);
transformGroup.Children.Add(rotateTransform);
animation.RenderTransform = transformGroup;
animation.Position = from;
space.AddUIElement(animation);
EventHandler handler = null;
animation.End += handler = delegate {
animation.End -= handler;
space.RemoveAnimation(animation);
if (index == targets.Count) { targets.Clear(); }
};
animation.HeartStart();
}
示例2: Wall
public Wall(Canvas container, Point position, double width, double height) {
this.container = container;
this.position = position;
this.width = width;
this.height = height;
this.image = new ImageBrush();
Debug.WriteLine("IMG width: " + imageSource.PixelWidth + ", height: " + imageSource.PixelHeight);
this.image.ImageSource = imageSource;
this.image.Stretch = Stretch.None;
transform = new TranslateTransform();
transform.X = -this.position.X;
transform.Y = -this.position.Y;
st = new ScaleTransform();
st.ScaleX = 1.55;
st.ScaleY = 2;
this.image.RelativeTransform = st;
this.image.Transform = transform;
this.imageContainer = new Canvas();
this.imageContainer.Width = width;
this.imageContainer.Height = height;
this.imageContainer.Background = this.image;
this.container.Children.Add(this.imageContainer);
Canvas.SetLeft(this.imageContainer, this.position.X);
Canvas.SetTop(this.imageContainer, this.position.Y);
Canvas.SetZIndex(this.imageContainer, 2);
}
示例3: Page_SizeChanged
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
// Compare the current window to the ideal dimensions.
double heightRatio = this.ActualHeight / idealPageSize.Height;
double widthRatio = this.ActualWidth / idealPageSize.Width;
// Create the transform.
ScaleTransform scale = new ScaleTransform();
// Determine the smallest dimension.
// This preserves the aspect ratio.
if (heightRatio < widthRatio)
{
scale.ScaleX = heightRatio;
scale.ScaleY = heightRatio;
}
else
{
scale.ScaleX = widthRatio;
scale.ScaleY = widthRatio;
}
// Apply the transform.
this.RenderTransform = scale;
}
示例4: CreateSubMagic
void CreateSubMagic(RoleBase caster,RoleBase startTarget, RoleBase endTarget, Space space, MagicArgs args)
{
AnimationBase animation = new AnimationBase() { Code = args.ResCode, Z = startTarget.Z + 1 };
double offsetStartY = (startTarget.State == States.Riding ? (startTarget.Profession == Professions.Taoist ? 130 : 110) : 60) * args.Scale;
double offsetEndY = (endTarget.State == States.Riding ? 100 : 50) * args.Scale;
Point from = new Point(startTarget.Position.X, startTarget.Position.Y - offsetStartY);
Point to = new Point(endTarget.Position.X, endTarget.Position.Y - offsetEndY);
RotateTransform rotateTransform = new RotateTransform() {
CenterX = animation.Center.X,
CenterY = animation.Center.Y,
Angle = GlobalMethod.GetAngle(to.Y - from.Y, to.X - from.X)
};
ScaleTransform scaleTransform = new ScaleTransform() {
CenterX = animation.Center.X,
CenterY = animation.Center.Y,
ScaleX = (GlobalMethod.GetDistance(startTarget.Position, endTarget.Position) / Convert.ToInt32(args.Tag)),
ScaleY = args.Scale
};
TransformGroup transformGroup = new TransformGroup();
transformGroup.Children.Add(scaleTransform);
transformGroup.Children.Add(rotateTransform);
animation.RenderTransform = transformGroup;
animation.Position = from;
space.AddUIElement(animation);
EventHandler handler = null;
animation.End += handler = delegate {
animation.End -= handler;
space.RemoveAnimation(animation);
};
animation.HeartStart();
}
示例5: Initialize
public void Initialize(UIElement element)
{
this.child = element;
if (child != null)
{
TransformGroup group = new TransformGroup();
ScaleTransform st = new ScaleTransform();
group.Children.Add(st);
TranslateTransform tt = new TranslateTransform();
group.Children.Add(tt);
child.RenderTransform = group;
child.RenderTransformOrigin = new Point(0.0, 0.0);
child.MouseWheel += child_MouseWheel;
child.MouseLeftButtonDown += child_MouseLeftButtonDown;
child.MouseLeftButtonUp += child_MouseLeftButtonUp;
child.MouseMove += child_MouseMove;
child.PreviewMouseRightButtonDown += new MouseButtonEventHandler(child_PreviewMouseRightButtonDown);
}
}
示例6: Sprite
public Sprite(FrameworkElement content)
{
Content = content;
Width = (float)content.Width;
Height = (float)content.Height;
TranslateTransform = new TranslateTransform();
TranslateTransform.X = 0;
TranslateTransform.Y = 0;
RotateTransform = new RotateTransform();
RotateTransform.CenterX = Origin.X;
RotateTransform.CenterY = Origin.Y;
RotateTransform.Angle = 0;
ScaleTransform = new ScaleTransform();
ScaleTransform.ScaleX = 1;
ScaleTransform.ScaleY = 1;
_transformGroup = new TransformGroup();
_transformGroup.Children.Add(RotateTransform);
_transformGroup.Children.Add(TranslateTransform);
_transformGroup.Children.Add(ScaleTransform);
RenderTransform = _transformGroup;
}
示例7: SkalerNed
private void SkalerNed(object sender, RoutedEventArgs e)
{
scaleX -= 0.20;
scaleY -= 0.20;
Transform tf = new ScaleTransform(scaleX, scaleY);
stPnlMain.LayoutTransform = tf;
}
示例8: setWindowSize
//Changes the window size to make the content authoring tool fit in any size of screen
public void setWindowSize()
{
Double width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
Double height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
Double ratio = height / width;
ScaleTransform tran = new ScaleTransform();
if (width < 1024 || height < 850)
{
if (width / 1024 > height / 800)
{
this.Height = height - 60;
this.Width = this.Height / 800 * 1024;
tran.ScaleY = this.Height / 800;
tran.ScaleX = this.Width / 1024;
}
else
{
this.Width = width - 60;
this.Height = this.Width / 1024 * 800;
tran.ScaleX = this.Width / 1024;
tran.ScaleY = this.Height / 800;
}
mainCanvas.RenderTransform = tran;
}
}
示例9: MainWindow
public MainWindow()
{
view = new ViewParams();
InitializeComponent();
scale = new ScaleTransform(1, 1, 0, 0);
pan = new TranslateTransform(0, plot.Height);
signals = new SignalCollection(this);
signals.scaleSignalStrokes(scale);
signals.updateLabels();
resetTransform();
ports = SerialPort.GetPortNames();
Console.WriteLine("ports:");
foreach(string port in ports){
comportList.Items.Add(port.ToString());
Console.WriteLine(port);
}
arduinoPort = new SerialPort();
arduinoPort.Parity = Parity.None;
arduinoPort.StopBits = StopBits.One;
arduinoPort.DataBits = 8;
arduinoPort.BaudRate = 9600;
arduinoPort.ReadTimeout = 200;
if (comportList.Items.Count > 0)
{
arduinoPort.PortName = comportList.Items[0].ToString();
}
else
{
Console.WriteLine("No ports available");
connectButton.IsEnabled = false;
}
}
示例10: FilterCellFactory
static FilterCellFactory()
{
_bmpActiveFilter = LoadImage(".ActiveFilter.png");
_bmpInactiveFilter = LoadImage(".InactiveFilter.png");
_sortGlyphTransform = new ScaleTransform();
_sortGlyphTransform.ScaleY = 0.7;
}
示例11: CreateTransitionAnimation
/// <internalonly />
protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction)
{
if (_scaleTransform == null) {
_scaleTransform = new ScaleTransform();
container.RenderTransform = _scaleTransform;
container.RenderTransformOrigin = new Point(0.5, 0.5);
}
TweenInterpolation interpolation = GetEffectiveInterpolation();
TimeSpan shortDuration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 3);
FlipScaleAnimation scaleAnimation =
new FlipScaleAnimation(Duration, _scaleTransform,
(direction == EffectDirection.Forward ? 180 : -180));
scaleAnimation.Interpolation = interpolation;
DoubleAnimation frontAnimation =
new DoubleAnimation(container.Children[1], UIElement.OpacityProperty, shortDuration,
(direction == EffectDirection.Forward ? 0 : 1));
frontAnimation.Interpolation = interpolation;
frontAnimation.StartDelay = shortDuration;
DoubleAnimation backAnimation =
new DoubleAnimation(container.Children[0], UIElement.OpacityProperty, shortDuration,
(direction == EffectDirection.Forward ? 1 : 0));
backAnimation.Interpolation = interpolation;
backAnimation.StartDelay = shortDuration;
return new ProceduralAnimationSet(scaleAnimation, frontAnimation, backAnimation);
}
示例12: loadBubbles
private void loadBubbles()
{
PART_bubbles.Children.Clear();
var animationSkew = 0;
foreach (var theme in themeSource)
{
var scaleTransfrom = new ScaleTransform(0, 0, .5, .5);
var bubbles = new Ellipse
{
Width = 50,
Height = 50,
Tag = theme,
Fill = theme.P500,
Effect = MaterialPalette.Shadows.ShadowDelta2,
RenderTransformOrigin = new Point(.5, .5),
RenderTransform = scaleTransfrom
};
bubbles.MouseUp += bubbleClicked;
PART_bubbles.Children.Add(bubbles);
scaleTransfrom.animate(ScaleTransform.ScaleXProperty, 400, 1, animationSkew, new BackEase
{ EasingMode = EasingMode.EaseOut, Amplitude = .6 });
scaleTransfrom.animate(ScaleTransform.ScaleYProperty, 400, 1, animationSkew, new BackEase
{ EasingMode = EasingMode.EaseOut, Amplitude = .6 });
animationSkew += 10;
//new SineEase {EasingMode = EasingMode.EaseIn});
//scaleTransfrom.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation())
}
}
示例13: GetTransformFromChild
private static ScaleTransform GetTransformFromChild(UIElement child)
{
ScaleTransform scaleTransform = null;
if (child.RenderTransform == null || child.RenderTransform == MatrixTransform.Identity)
{
scaleTransform = new ScaleTransform();
child.RenderTransform = scaleTransform;
}
else
{
if (child.RenderTransform is ScaleTransform)
{
scaleTransform = child.RenderTransform as ScaleTransform;
}
else if (child.RenderTransform is TransformGroup)
{
foreach (Transform transfrom in (child.RenderTransform as TransformGroup).Children)
{
if (transfrom is ScaleTransform)
{
scaleTransform = transfrom as ScaleTransform;
break;
}
}
}
else
{
throw new InvalidOperationException();
}
}
return scaleTransform;
}
示例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: MatchFinished
public void MatchFinished(bool isAccepted)
{
if (!isAccepted)
{
ColorAnimation opacityOut = new ColorAnimation(Colors.Transparent, new Duration(TimeSpan.FromSeconds(0.5)));
card1.BeginAnimation(Rectangle.FillProperty, opacityOut, HandoffBehavior.SnapshotAndReplace);
card2.BeginAnimation(Rectangle.FillProperty, opacityOut, HandoffBehavior.SnapshotAndReplace);
card3.BeginAnimation(Rectangle.FillProperty, opacityOut, HandoffBehavior.SnapshotAndReplace);
}
else
{
ScaleTransform scale = new ScaleTransform(1.0, 1.0, card1.Width / 2, card1.Height / 2);
DoubleAnimation scaleOutAnim = new DoubleAnimation(1.0, 10.0, new Duration(TimeSpan.FromSeconds(0.5)));
card1.RenderTransform = scale;
card2.RenderTransform = scale;
card3.RenderTransform = scale;
scale.BeginAnimation(ScaleTransform.ScaleXProperty, scaleOutAnim, HandoffBehavior.SnapshotAndReplace);
scale.BeginAnimation(ScaleTransform.ScaleYProperty, scaleOutAnim, HandoffBehavior.SnapshotAndReplace);
scaleOutAnim.Completed += new EventHandler(scaleOutAnim_Completed);
DoubleAnimation opacityOutAnim = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(0.5)));
card1.BeginAnimation(Rectangle.OpacityProperty, opacityOutAnim, HandoffBehavior.SnapshotAndReplace);
card2.BeginAnimation(Rectangle.OpacityProperty, opacityOutAnim, HandoffBehavior.SnapshotAndReplace);
card3.BeginAnimation(Rectangle.OpacityProperty, opacityOutAnim, HandoffBehavior.SnapshotAndReplace);
}
}