public static void ApplyRotate(TransformGroup t, Duration duration) { var rotateT = new RotateTransform (); t.Children.Add(rotateT); var storyboard = CreateDPAnimation(rotateT, "Angle", duration, 0, 360, false, false, new BounceEase { Bounces = 2, Bounciness = 5 }); storyboard.Begin(); }
public static void ApplyJiggle(TransformGroup t, Duration duration) { var rotateT = new RotateTransform (); t.Children.Add(rotateT); var storyboard = CreateDPAnimation(rotateT, "Angle", duration, 0, 20, false, false, new ElasticEase { Oscillations = 5 }); storyboard.Begin(); }
public static void ApplySnap(TransformGroup t, Duration duration) { var scaleT = new ScaleTransform { ScaleY = 1, ScaleX = 1 }; t.Children.Add(scaleT); var storyboard = CreateDPAnimation(scaleT, "ScaleY", duration, 0, 1, false, false, new ElasticEase { Springiness = 0.4 }); storyboard.Begin(); }
public void DrawImage(Point center, Size s, BitmapImage image) { Image img = new Image(); img.Source = (ImageSource)image; int imageHeight = image.PixelHeight == 0 ? 320 : image.PixelWidth; int imageWidth = image.PixelWidth == 0 ? 180 : image.PixelWidth; ScaleTransform resizeTransform = new ScaleTransform(); resizeTransform.ScaleX = (s.Width / imageHeight) * Canvas.Width; resizeTransform.ScaleY = (s.Height / imageWidth) * Canvas.Height; TranslateTransform posTransform = new TranslateTransform(); posTransform.X = center.X * Canvas.Width; posTransform.Y = center.Y * Canvas.Height; TransformGroup transform = new TransformGroup(); transform.Children.Add(resizeTransform); transform.Children.Add(posTransform); img.RenderTransform = transform; Canvas.Children.Add(img); }
private void InitManipulationTransforms() { _transformGroup = new TransformGroup(); _compositeTransform = new CompositeTransform(); _previousTransform = new MatrixTransform() { Matrix = Matrix.Identity }; _transformGroup.Children.Add(_previousTransform); _transformGroup.Children.Add(_compositeTransform); ManipulateMe.RenderTransform = _transformGroup; }
private void InitManipulationTransforms() { transforms = new TransformGroup(); previousTransform = new MatrixTransform() { Matrix = Matrix.Identity }; deltaTransform = new CompositeTransform(); transforms.Children.Add(previousTransform); transforms.Children.Add(deltaTransform); // Set the render transform on the rect manipulateMe.RenderTransform = transforms; }
private void HandleLowerTextBoxGotFocus(object sender, RoutedEventArgs e) { Transform stackPanelRestore = DebugHelper.CastAndAssert<Transform>(((TextBox)sender).TransformToVisual(rootStackPanel)); TranslateTransform shiftDown = new TranslateTransform(); shiftDown.Y = 90; TransformGroup group = new TransformGroup(); group.Children.Add(DebugHelper.CastAndAssert<Transform>(stackPanelRestore.Inverse)); group.Children.Add(shiftDown); rootStackPanel.RenderTransform = group; }
private void AddMarkings() { for (int i = 0; i < 360; i += 3) { Rectangle rectangle = new Rectangle(); rectangle.Width = (i % 30 == 0) ? 3 : 1; rectangle.Height = 15; rectangle.Fill = new SolidColorBrush(Colors.Black); rectangle.RenderTransformOrigin = new Point(0.5, 0.5); TransformGroup transforms = new TransformGroup(); transforms.Children.Add(new TranslateTransform() { Y = -140 }); transforms.Children.Add(new RotateTransform() { Angle = i }); rectangle.RenderTransform = transforms; baseGrid.Children.Add(rectangle); } }
public TestLineupPage() { this.InitializeComponent(); TransformGroup tg = new TransformGroup(); ScaleTransform st = new ScaleTransform(); tg.Children.Add(st); RotateTransform rt = new RotateTransform(); tg.Children.Add(rt); TranslateTransform tl = new TranslateTransform(); tg.Children.Add(tl); _viewbox.RenderTransform = tg; }
public static void ApplyRandomAnimationEffect(FrameworkElement fe, Duration duration) { fe.RenderTransformOrigin = new Point(0.5, 0.5); var tf = (fe.RenderTransform as TransformGroup); if(tf == null) fe.RenderTransform = tf = new TransformGroup(); int e = Utils.RandomBetweenTwoNumbers(0, 3); switch(e) { case 0: ApplyJiggle(tf, duration); break; case 1: ApplySnap(tf, duration); break; case 2: ApplyThrob(tf, duration); break; case 3: ApplyRotate(tf, duration); break; } }
private void MoveTo(double x , double y) { //定义transform Transform transform = base.RenderTransform; TransformGroup transformGroup = transform as TransformGroup; MatrixTransform matrixTransform = transform as MatrixTransform; TranslateTransform translateTransform = transform as TranslateTransform; //移动 if (translateTransform == null) { if (transformGroup == null) { if (matrixTransform == null) { TransformGroup gp = new TransformGroup(); translateTransform = new TranslateTransform(); if (transform != null) { gp.Children.Add(transform); } gp.Children.Add(translateTransform); base.RenderTransform = gp; } else { Matrix matrix = matrixTransform.Matrix; matrix.OffsetX += x; matrix.OffsetY += y; base.RenderTransform = new MatrixTransform() { Matrix = matrix }; return; } } else { if (transformGroup.Children.Count > 0) { translateTransform = transformGroup.Children[transformGroup.Children.Count - 1] as TranslateTransform; } if (translateTransform == null) { translateTransform = new TranslateTransform(); transformGroup.Children.Add(translateTransform); } } } //添加移动的数值 translateTransform.X += x; translateTransform.Y += y; }
private void InitManipulationTransforms() { //Initialize the transforms transformGroup = new TransformGroup(); compositeTransform = new CompositeTransform(); previousTransform = new MatrixTransform() { Matrix = Matrix.Identity }; transformGroup.Children.Add(previousTransform); transformGroup.Children.Add(compositeTransform); ManipulateMe.RenderTransform = transformGroup; }
private Storyboard CreateEnterAnimation(Panel layoutRoot) { var enterAnimation = new Storyboard(); Storyboard.SetTarget(enterAnimation, layoutRoot); var ad = new AnimationDescription(AnimationEffect.EnterPage, AnimationEffectTarget.Primary); for (int i = 0; i < layoutRoot.Children.Count; i++) { // Add a render transform to the existing one just for animations var element = layoutRoot.Children[i]; var tg = new TransformGroup(); tg.Children.Add(new TranslateTransform()); tg.Children.Add(element.RenderTransform); element.RenderTransform = tg; // Calculate the stagger for each animation. Note that this has a max var delayMs = Math.Min(ad.StaggerDelay.TotalMilliseconds * i * ad.StaggerDelayFactor, ad.DelayLimit.Milliseconds); var delay = TimeSpan.FromMilliseconds(delayMs); foreach (var description in ad.Animations) { var animation = new DoubleAnimationUsingKeyFrames(); // Start the animation at the right offset var startSpline = new SplineDoubleKeyFrame(); startSpline.KeyTime = TimeSpan.FromMilliseconds(0); Storyboard.SetTarget(animation, element); // Hold at that offset until the stagger delay is hit var middleSpline = new SplineDoubleKeyFrame(); middleSpline.KeyTime = delay; // Animation from delayed time to last time var endSpline = new SplineDoubleKeyFrame(); endSpline.KeySpline = new KeySpline() { ControlPoint1 = description.Control1, ControlPoint2 = description.Control2 }; endSpline.KeyTime = description.Duration + delay; // Do the translation if (description.Type == PropertyAnimationType.Translation) { startSpline.Value = ANIMATION_TRANSLATION_START; middleSpline.Value = ANIMATION_TRANSLATION_START; endSpline.Value = ANIMATION_TRANSLATION_END; Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(TransformGroup.Children)[0].X"); } // Opacity else if (description.Type == PropertyAnimationType.Opacity) { startSpline.Value = ANIMATION_OPACITY_START; middleSpline.Value = ANIMATION_OPACITY_START; endSpline.Value = ANIMATION_OPACITY_END; Storyboard.SetTargetProperty(animation, "Opacity"); } else { throw new Exception("Encountered an unexpected animation type."); } // Put the final animation together animation.KeyFrames.Add(startSpline); animation.KeyFrames.Add(middleSpline); animation.KeyFrames.Add(endSpline); enterAnimation.Children.Add(animation); } } return enterAnimation; }
private TransformGroup TransformGroup(double Angle, double X, double Y) { TransformGroup transformGroup = new TransformGroup(); TranslateTransform firstTranslate = new TranslateTransform(); firstTranslate.X = X; firstTranslate.Y = Y; transformGroup.Children.Add(firstTranslate); RotateTransform rotateTransform = new RotateTransform(); rotateTransform.Angle = Angle; transformGroup.Children.Add(rotateTransform); TranslateTransform secondTranslate = new TranslateTransform(); secondTranslate.X = diameter / 2; secondTranslate.Y = diameter / 2; transformGroup.Children.Add(secondTranslate); return transformGroup; }
private void PositionPoints() { if (_pointsPanel != null && _pointsPanel.Children.Count > 0) { var startAngle = 0; var count = (this.Maximum - this.Minimum) / (this.Distance > 0 ? this.Distance : 1); var angleDistance = 360 / count; for (int i = 0; i < count; i++) { var point = _pointsPanel.Children[i] as Line; var translate = new TranslateTransform(); var radius = (this.RenderSize.Height / 2) - OUTER_DISTANCE; var angle = startAngle; var radian = (angle * Math.PI) / 180; translate.X = (int)radius * Math.Sin(radian); translate.Y = (int)((radius * Math.Cos(radian)) * -1); var group = new TransformGroup(); group.Children.Add(new RotateTransform() { Angle = angle }); group.Children.Add(translate); point.RenderTransform = group; if (_labelsPanel != null && _labelsPanel.Children.Count > 0) { var label = _labelsPanel.Children[i] as TextBlock; var labelTranslate = new TranslateTransform(); var labelRadius = (this.RenderSize.Height / 2) - -20d; var labelAngle = startAngle; var labelRadian = (labelAngle * Math.PI) / 180; labelTranslate.X = (int)labelRadius * Math.Sin(labelRadian); labelTranslate.Y = (int)((labelRadius * Math.Cos(labelRadian)) * -1); label.RenderTransform = labelTranslate; } startAngle += angleDistance; } } this.PositionValue(); }
private void ArrangeExpandElement(int idx, UIElement element, double panelCenterX, double panelCenterY, double elementCenterX, double elementCenterY, double destX, double destY) { element.Arrange(new Rect(panelCenterX, panelCenterY, element.DesiredSize.Width, element.DesiredSize.Height)); var transGroup = element.RenderTransform as TransformGroup; Transform translateTransform, rotateTransform; if (transGroup == null) { element.RenderTransform = transGroup = new TransformGroup(); translateTransform = new TranslateTransform(); rotateTransform = new RotateTransform() { CenterX = elementCenterX, CenterY = elementCenterY }; transGroup.Children.Add(translateTransform); transGroup.Children.Add(rotateTransform); } else { translateTransform = transGroup.Children[0] as TranslateTransform; rotateTransform = transGroup.Children[1] as RotateTransform; } element.RenderTransformOrigin = new Point(0.5, 0.5); //if (i != 0) continue; var aniDuration = AnimationDuration + TimeSpan.FromSeconds(AnimationDurationStep * idx); var storySpin = new Storyboard(); var translateXAnimation = new DoubleAnimation() { From = 0, To = destX - panelCenterX, Duration = aniDuration }; var translateYAnimation = new DoubleAnimation() { From = 0, To = destY - panelCenterY, Duration = aniDuration }; var transparentAnimation = new DoubleAnimation() { From = 0, To = 1, Duration = aniDuration }; var rotateXAnimation = new DoubleAnimation() { From = 0, To = destX - panelCenterX, Duration = aniDuration }; var rotateYAnimation = new DoubleAnimation() { From = 0, To = destY - panelCenterY, Duration = aniDuration }; var rotateAngleAnimation = new DoubleAnimation() { From = 0, To = 720, Duration = aniDuration }; storySpin.Children.Add(translateXAnimation); storySpin.Children.Add(translateYAnimation); storySpin.Children.Add(transparentAnimation); storySpin.Children.Add(rotateXAnimation); storySpin.Children.Add(rotateYAnimation); storySpin.Children.Add(rotateAngleAnimation); Storyboard.SetTargetProperty(translateXAnimation, "(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"); Storyboard.SetTargetProperty(translateYAnimation, "(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"); Storyboard.SetTargetProperty(transparentAnimation, "UIElement.Opacity"); Storyboard.SetTargetProperty(rotateXAnimation, "(UIElement.RenderTransform).(TransformGroup.Children)[1].(RotateTransform.CenterX)"); Storyboard.SetTargetProperty(rotateYAnimation, "(UIElement.RenderTransform).(TransformGroup.Children)[1].(RotateTransform.CenterY)"); Storyboard.SetTargetProperty(rotateAngleAnimation, "(UIElement.RenderTransform).(TransformGroup.Children)[1].(RotateTransform.Angle)"); Storyboard.SetTarget(translateXAnimation, element); Storyboard.SetTarget(translateYAnimation, element); Storyboard.SetTarget(transparentAnimation, element); Storyboard.SetTarget(rotateXAnimation, element); Storyboard.SetTarget(rotateYAnimation, element); Storyboard.SetTarget(rotateAngleAnimation, element); storySpin.Begin(); }
protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); ListBoxItem item2 = element as ListBoxItem; if (item2 != null && !items.Contains(item2)) { item2.Visibility = Visibility.Collapsed; if (Orientation == Orientation.Horizontal) item2.HorizontalAlignment = HorizontalAlignment.Center; else item2.VerticalAlignment = VerticalAlignment.Center; items.Add(item2); TransformGroup myTransformGroup = new TransformGroup(); ScaleTransform scaleTransform = new ScaleTransform(); TranslateTransform translateTransform = new TranslateTransform(); PlaneProjection planeProjection = new PlaneProjection() { CenterOfRotationX = .5, CenterOfRotationY = .5, CenterOfRotationZ = .5 }; myTransformGroup.Children.Add(scaleTransform); myTransformGroup.Children.Add(translateTransform); // Associate the transforms to the object item2.RenderTransformOrigin = itemRenderTransformOrigin; item2.RenderTransform = myTransformGroup; item2.Projection = planeProjection; if (items.Count < pageCount + 1) { SetLocation(item2, items.Count - 1); } } }
private void HandleMixLimitTextBoxGotFocus(object sender, RoutedEventArgs e) { Transform stackPanelRestore = DebugHelper.CastAndAssert<Transform>(((TextBox)sender).TransformToVisual(rootGrid)); double shift = 0; if (stackPanelRestore is MatrixTransform) { shift = (stackPanelRestore as MatrixTransform).Matrix.OffsetY; } else if (stackPanelRestore is TranslateTransform) { shift = (stackPanelRestore as TranslateTransform).Y; } else { DebugHelper.Alert(new CallerInfo(), "Unexpected transform type {0}", stackPanelRestore.GetType()); } TranslateTransform shiftDown = new TranslateTransform(); shiftDown.Y = 90 - shift; TransformGroup group = new TransformGroup(); group.Children.Add(shiftDown); rootGrid.RenderTransform = group; RootScrollViewer.VerticalScrollMode = ScrollMode.Disabled; }
// Sets the render transform of the indicator private void SetIndicatorTransforms() { if (RenderTransform is MatrixTransform) { TransformGroup tg = new TransformGroup(); TranslateTransform tt = new TranslateTransform(); RotateTransform rt = new RotateTransform(); tg.Children.Add(rt); tg.Children.Add(tt); this.RenderTransformOrigin = new Point(0.5, 0.5); this.RenderTransform = tg; } }
static public void ApplyMagnificationFactor(Canvas windowContainer, float scale, float rotation) { TransformGroup globalTransform = new TransformGroup(); ScaleTransform windowScale = new ScaleTransform(); RotateTransform orientation = new RotateTransform(); windowScale.ScaleX = scale; windowScale.ScaleY = scale; windowScale.CenterX = windowContainer.Width / 2.0; windowScale.CenterY = windowContainer.Height / 2.0; globalTransform.Children.Add(windowScale); if (rotation != 0.0f) { orientation.Angle = rotation; orientation.CenterX = windowContainer.Width / 2.0; orientation.CenterY = windowContainer.Height / 2.0; globalTransform.Children.Add(orientation); } windowContainer.RenderTransform = globalTransform; screenScale = (double)scale; }
void CreateTransforms() { if (!_createdTransforms) { TranslateTransform SizeAnchorTransform = new TranslateTransform(); SizeAnchorTransform.X = -_size.Width * _anchorPoint.X; SizeAnchorTransform.Y = -_size.Height * _anchorPoint.Y; TranslateTransform OriginTransform = new TranslateTransform(); OriginTransform.X = -_origin.X; OriginTransform.Y = -_origin.Y; TransformGroup ContentTransform = new TransformGroup(); ContentTransform.Children.Add(new RotateTransform()); ContentTransform.Children.Add(new ScaleTransform()); ContentTransform.Children.Add(new TranslateTransform()); TranslateTransform PositionTransform = new TranslateTransform(); PositionTransform.X = _position.X; PositionTransform.Y = _position.Y; TransformGroup LayerTransforms = new TransformGroup(); LayerTransforms.Children.Add(SizeAnchorTransform); LayerTransforms.Children.Add(OriginTransform); LayerTransforms.Children.Add(ContentTransform); LayerTransforms.Children.Add(PositionTransform); RenderTransform = LayerTransforms; VisualWidth = _size.Width; VisualHeight = _size.Height; _createdTransforms = true; if (_createdTransforms) CAXamlDebugCounters.IncCounter("CALayerXamlTransforms"); } }
/// <summary> /// Creates a TransformGroup based on the given Translation, Scale and Rotation /// </summary> /// <param name="transX">Translation in the X-axis</param> /// <param name="transY">Translation in the Y-axis</param> /// <param name="scaleX">Scale factor in the X-axis</param> /// <param name="scaleY">Scale factor in the Y-axis</param> /// <param name="rotAngle">Rotation</param> /// <returns>TransformGroup</returns> internal static TransformGroup CreateTransform(double transX, double transY, double scaleX, double scaleY, double rotAngle = 0.0D) { var translation = new TranslateTransform { X = transX, Y = transY }; var scale = new ScaleTransform { ScaleX = scaleX, ScaleY = scaleY }; //var rotation = new RotateTransform //{ // Angle = rotAngle //}; var transform = new TransformGroup(); // THE ORDER OF TRANSFORM IS IMPORTANT // First, scale, then rotate and finally translate transform.Children.Add(scale); //transform.Children.Add(rotation); transform.Children.Add(translation); return transform; }
private void InitMarkers() { var converter = new ObjectSizeConverter(); var offset = converter.Convert(125); for (int i = 0; i < 60; ++i) { Rectangle marker = new Rectangle(); if ((i % 5) == 0) { marker.Width = converter.Convert(1.5); marker.Height = converter.Convert(8); marker.Fill = new SolidColorBrush(Color.FromArgb(0xe0, 0xff, 0xff, 0xff)); marker.Stroke = new SolidColorBrush(Color.FromArgb(0x80, 0x33, 0x33, 0x33)); marker.StrokeThickness = 0.5; } else { marker.Width = converter.Convert(1); marker.Height = converter.Convert(3); marker.Fill = new SolidColorBrush(Color.FromArgb(0x80, 0xff, 0xff, 0xff)); marker.Stroke = null; marker.StrokeThickness = 0; } TransformGroup transforms = new TransformGroup(); transforms.Children.Add(new TranslateTransform { X =-(marker.Width/2), Y =converter.Convert(92)}); transforms.Children.Add(new RotateTransform { Angle = i * 6 }); transforms.Children.Add(new TranslateTransform {X = offset, Y = offset}); marker.RenderTransform = transforms; _markersCanvas.Children.Add(marker); } }
private static void recursiveResize(UIElement uiElement, TransformGroup transformGroup, double ratio) { foreach (var o in uiElement.GetChildren().Where(c => c is UIElement)) { if (o is Panel) { var panel = (Panel)o; (panel).Margin = new Thickness( panel.Margin.Left / ratio, panel.Margin.Top / ratio, panel.Margin.Right / ratio, panel.Margin.Bottom / ratio); // recursive call. recursiveResize((UIElement)o, transformGroup, ratio); } else if (o is FrameworkElement) { var element = (FrameworkElement)o; element.Margin = new Thickness( element.Margin.Left / ratio, element.Margin.Top / ratio, element.Margin.Right / ratio, element.Margin.Bottom / ratio); element.RenderTransformOrigin = new Point(0.5, 0.5); element.RenderTransform = transformGroup; } } }
/// <summary> /// 프리뷰를 화면비율에 맞게 리사이즈. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FramePreview_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) { Debug.WriteLine("navigated"); PreviewLock = false; var ratio = Window.Current.Bounds.Width / FramePreview.ActualWidth; var page = (FramePreview.Content as Page); if (page != null) { var myTransformGroup = new TransformGroup(); myTransformGroup.Children.Add(new ScaleTransform { ScaleY = 1 / ratio, ScaleX = 1 / ratio }); recursiveResize(page.Content, myTransformGroup, ratio); page.Content.InvalidateMeasure(); //var myScaleTransform = new ScaleTransform //{ // ScaleY = 1 / ratio, // ScaleX = 1 / ratio //}; //var myTransformGroup = new TransformGroup(); //myTransformGroup.Children.Add(myScaleTransform); //var count = page.Content.GetChildren().Count(c => c is UIElement); //Debug.WriteLine(count); //foreach (var o in page.Content.GetChildren().Where(c => c is UIElement)) //{ // if (o is Panel) // { // var panel = (Panel)o; // (panel).Margin = new Thickness( // panel.Margin.Left / ratio, // panel.Margin.Top / ratio, // panel.Margin.Right / ratio, // panel.Margin.Bottom / ratio); // } // else // { // var element = (UIElement)o; // element.RenderTransformOrigin = new Point(0.5, 0.5); // element.RenderTransform = myTransformGroup; // } //} } }
private void AddInitialAnimation() { var tf = new TransformGroup(); RenderTransform = tf; ApplyRandomAnimationEffect(this, new Duration(TimeSpan.FromSeconds(1))); var scale = new ScaleTransform { ScaleX = 0, ScaleY = 0, CenterX = 0.5, CenterY = 0.5 }; tf.Children.Add(scale); var sScale = CreateDPAnimation(scale, "ScaleY", new Duration(TimeSpan.FromSeconds(1)), 0, 1); CreateDPAnimation(scale, "ScaleX", new Duration(TimeSpan.FromSeconds(1)), 0, 1, false, false, new SineEase(), sScale); sScale.Begin(); }
/// <summary> /// The draw text. /// </summary> /// <param name="p"> /// The p. /// </param> /// <param name="text"> /// The text. /// </param> /// <param name="fill"> /// The fill. /// </param> /// <param name="fontFamily"> /// The font family. /// </param> /// <param name="fontSize"> /// The font size. /// </param> /// <param name="fontWeight"> /// The font weight. /// </param> /// <param name="rotate"> /// The rotate. /// </param> /// <param name="halign"> /// The horizontal alignment. /// </param> /// <param name="valign"> /// The vertical alignment. /// </param> /// <param name="maxSize"> /// The maximum size of the text. /// </param> public void DrawText( ScreenPoint p, string text, OxyColor fill, string fontFamily, double fontSize, double fontWeight, double rotate, OxyPlot.HorizontalAlignment halign, OxyPlot.VerticalAlignment valign, OxySize? maxSize) { var tb = new TextBlock { Text = text, Foreground = fill.ToBrush() }; // tb.SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated); if (fontFamily != null) { tb.FontFamily = new FontFamily(fontFamily); } if (fontSize > 0) { tb.FontSize = fontSize; } tb.FontWeight = GetFontWeight(fontWeight); tb.Measure(new Size(1000, 1000)); double dx = 0; if (halign == OxyPlot.HorizontalAlignment.Center) { dx = -tb.ActualWidth / 2; } if (halign == OxyPlot.HorizontalAlignment.Right) { dx = -tb.ActualWidth; } double dy = 0; if (valign == OxyPlot.VerticalAlignment.Middle) { dy = -tb.ActualHeight / 2; } if (valign == OxyPlot.VerticalAlignment.Bottom) { dy = -tb.ActualHeight; } var transform = new TransformGroup(); transform.Children.Add(new TranslateTransform { X = (int)dx, Y = (int)dy }); if (!rotate.Equals(0.0)) { transform.Children.Add(new RotateTransform { Angle = rotate }); } transform.Children.Add(new TranslateTransform { X = (int)p.X, Y = (int)p.Y }); tb.RenderTransform = transform; if (this.clip.HasValue) { // add a clipping container that is not rotated var c = new Canvas(); c.Children.Add(tb); this.Add(c); } else { this.Add(tb); } }
public ElementAdapter(FrameworkElement el) { element_ = el; /** * copy default property */ if(!double.IsNaN(Element.Width)){ Width = Element.Width; } if (!double.IsNaN(Element.Height)) { Height = Element.Height; } X = Canvas.GetLeft(Element); Y = Canvas.GetTop(Element); Alpha = Element.Opacity; /** * Transform */ ScaleTransform myScaleTransform = new ScaleTransform(); myScaleTransform.ScaleX = 1.0; myScaleTransform.ScaleY = 1.0; RotateTransform myRotateTransform = new RotateTransform(); myRotateTransform.Angle = 0; TranslateTransform myTranslate = new TranslateTransform(); myTranslate.X = 0; myTranslate.X = 0; SkewTransform mySkew = new SkewTransform(); mySkew.AngleX = 0; mySkew.AngleY = 0; transformGroup_ = new TransformGroup(); transformGroup_.Children.Add(myScaleTransform); transformGroup_.Children.Add(myRotateTransform); transformGroup_.Children.Add(myTranslate); transformGroup_.Children.Add(mySkew); element_.RenderTransform = transformGroup_; }
// These trigger controls are updated when the user makes a // change to the scope settings private void UpdateTriggerUI() { UpdateTrigger(); btnTriggerMode.Content = tHelper.TriggerModeText().ToUpper(); if (tHelper.Mode == TriggerMode.Scan) { setRectGray(true, rectTriggerOK, btnHorzOffsetLeft.Foreground); setRectGray(true, rectTriggerSlope, btnTriggerSlope.Foreground); setRectGray(true, rectHorzToZero, btnHorzToZero.Foreground); setRectGray(true, rectHorzOffsetLeft, btnHorzOffsetLeft.Foreground); setRectGray(true, rectHorzOffsetRight, btnHorzOffsetRight.Foreground); } else { setRectGray(false, rectHorzOffsetLeft, btnHorzOffsetLeft.Foreground); setRectGray(false, rectHorzOffsetRight, btnHorzOffsetRight.Foreground); setRectGray(false, rectHorzToZero, btnHorzToZero.Foreground); setRectGray(false, rectTriggerOK, btnHorzOffsetLeft.Foreground); setRectGray(false, rectTriggerSlope, btnTriggerSlope.Foreground); UpdateHorzPos(); } btnTriggerSource.Content = tHelper.TriggerSourceText().ToUpper(); switch (tHelper.Source) { case TriggerSource.Ch1: SolidColorBrush brushTrigger1 = new SolidColorBrush(); brushTrigger1.Color = uihelper.clrTrace1; tbTriggerSource.Foreground = brushTrigger1; tbTriggerSlope.Foreground = brushTrigger1; tbTriggerLevel.Foreground = brushTrigger1; tbTriggerLevelEU.Foreground = brushTrigger1; tbTriggerTick.Foreground = brushTrigger1; break; case TriggerSource.Ch2: SolidColorBrush brushTrigger2 = new SolidColorBrush(); brushTrigger2.Color = uihelper.clrTrace2; tbTriggerSource.Foreground = brushTrigger2; tbTriggerSlope.Foreground = brushTrigger2; tbTriggerLevel.Foreground = brushTrigger2; tbTriggerLevelEU.Foreground = brushTrigger2; tbTriggerTick.Foreground = brushTrigger2; break; case TriggerSource.Ext: tbTriggerSource.Foreground = txtHeader.Foreground; tbTriggerSlope.Foreground = txtHeader.Foreground; tbTriggerLevel.Foreground = txtHeader.Foreground; tbTriggerLevelEU.Foreground = txtHeader.Foreground; tbTriggerTick.Foreground = txtHeader.Foreground; break; default: break; } if( rectTriggerSlope.ActualWidth < 80) { btnTriggerSlope.Content = tHelper.TriggerSlopeText().Substring(0, 3).ToUpper() + "..."; } else { btnTriggerSlope.Content = tHelper.TriggerSlopeText().ToUpper(); } if ( tHelper.Slope == TriggerSlope.Rising ) { ScaleTransform scaleTemp = new ScaleTransform(); scaleTemp.ScaleX = 1; TransformGroup tgTemp = new TransformGroup(); tgTemp.Children.Add(scaleTemp); tbTriggerSlope.RenderTransform = tgTemp; tbTriggerSlope.TextAlignment = TextAlignment.Left; } else { ScaleTransform scaleTemp = new ScaleTransform(); scaleTemp.ScaleX = -1; TransformGroup tgTemp = new TransformGroup(); tgTemp.Children.Add(scaleTemp); tbTriggerSlope.RenderTransform = tgTemp; tbTriggerSlope.TextAlignment = TextAlignment.Right; } UpdateTextBlockVoltage(tbTriggerLevel, tbTriggerLevelEU, tHelper.fTriggerLevel_V); UpdateTriggerTick(); }
public void InitializeTransforms() { cumulativeTransform = new TransformGroup(); deltaTransform = new CompositeTransform(); previousTransform = new MatrixTransform() { Matrix = Matrix.Identity }; cumulativeTransform.Children.Add(previousTransform); cumulativeTransform.Children.Add(deltaTransform); element.RenderTransform = cumulativeTransform; }