當前位置: 首頁>>代碼示例>>C#>>正文


C# Media.TranslateTransform類代碼示例

本文整理匯總了C#中System.Windows.Media.TranslateTransform的典型用法代碼示例。如果您正苦於以下問題:C# TranslateTransform類的具體用法?C# TranslateTransform怎麽用?C# TranslateTransform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TranslateTransform類屬於System.Windows.Media命名空間,在下文中一共展示了TranslateTransform類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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;
            }


        }
開發者ID:DiLRandI,項目名稱:ArduinoMonitor,代碼行數:35,代碼來源:MainWindow.xaml.cs

示例2: OnRender

        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            TranslateTransform translation = this.RenderTransform as TranslateTransform;
            if( translation == null)
            {
                translation = new TranslateTransform();
                this.RenderTransform = translation;
            }

            double width = this.Width;
            double height = this.Height;

            if (double.IsNaN(width))
            {
                width = this.ActualWidth;
            }
            if (double.IsNaN(height))
            {
                height = this.ActualHeight;
            }

            translation.X = -width * 0.5;
            translation.Y = -height * 0.5;

            base.OnRender(drawingContext);
        }
開發者ID:duckmaestro,項目名稱:F-AI,代碼行數:26,代碼來源:CenteredGrid.cs

示例3: SetTransform

 public void SetTransform()
 {
     if (pageHolder == null)
         return;
     TranslateTransform t = new TranslateTransform(pageHolder.HeadersSizeActive.Width + 3, 3);
     gr.Transform = t;
 }
開發者ID:Deiwos3,項目名稱:IMS,代碼行數:7,代碼來源:DarkLayer.xaml.cs

示例4: CountDownWpf

 public CountDownWpf()
 {
     InitializeComponent();
     countdownTimer = new Timer {Interval = 1000};
     countdownTimer.Elapsed += countdownTimer_Elapsed;
     RenderTransform = new TranslateTransform() {X = 900, Y=300};
 }
開發者ID:yong-ja,項目名稱:starodyssey,代碼行數:7,代碼來源:CountDownWpf.xaml.cs

示例5: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (AdornedElement.RenderSize.Width < 20)
                return;

            TranslateTransform transform = new TranslateTransform
                    (
                            AdornedElement.RenderSize.Width - 15,
                            (AdornedElement.RenderSize.Height - 5) / 2
                    );
            transform = new TranslateTransform
                    (
                            AdornedElement.RenderSize.Width / 2 - 3.5,
                            AdornedElement.RenderSize.Height / 2 - 10
                    );
            drawingContext.PushTransform(transform);

            Geometry geometry = ascGeometry;
            if (this.Direction == ListSortDirection.Descending)
                geometry = descGeometry;
            drawingContext.DrawGeometry(Brushes.LightGray, null, geometry);

            drawingContext.Pop();
        }
開發者ID:RomanHodulak,項目名稱:WPFClient,代碼行數:26,代碼來源:SortAdorner.cs

示例6: OnMouseMove

        protected override void OnMouseMove(MouseEventArgs e)
        {
            Window wnd = Window.GetWindow(this);
            Point currentLocation = e.MouseDevice.GetPosition(wnd);

            var move = new TranslateTransform(
                currentLocation.X - _previousLocation.X, currentLocation.Y - _previousLocation.Y);

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                var group = new TransformGroup();
                if (_previousTransform != null)
                {
                    group.Children.Add(_previousTransform);
                }
                group.Children.Add(move);

                RenderTransform = group;
            }
            else
            {
                Cursor = Cursors.Hand;
            }

            _previousLocation = currentLocation;
            _previousTransform = RenderTransform;

            MainWindow.Instance.CalculatePositions();
            base.OnMouseMove(e);
        }
開發者ID:taesiri,項目名稱:electric-field,代碼行數:30,代碼來源:NegativeCharge.xaml.cs

示例7: 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);
 }
開發者ID:serioja90,項目名稱:labirynth,代碼行數:26,代碼來源:Wall.cs

示例8: PerformTranstition

        public override void PerformTranstition(UserControl newPage, UserControl oldPage)
        {
            this.newPage = newPage;
            this.oldPage = oldPage;

            Duration duration = new Duration(TimeSpan.FromSeconds(1));

            DoubleAnimation animation = new DoubleAnimation();
            animation.Duration = duration;
            switch (direction)
            {
                case WipeDirection.LeftToRight:
                    animation.To = oldPage.ActualWidth;
                    break;
                case WipeDirection.RightToLeft:
                    animation.To = -oldPage.ActualWidth;
                    break;
            }

            Storyboard sb = new Storyboard();
            sb.Duration = duration;
            sb.Children.Add(animation);
            sb.Completed += sb_Completed;

            TranslateTransform sc = new TranslateTransform();
            oldPage.RenderTransform = sc;

            Storyboard.SetTarget(animation, sc);
            Storyboard.SetTargetProperty(animation, new PropertyPath("X"));

            //oldPage.Resources.Add(sb);

            sb.Begin();
        }
開發者ID:kuki89,項目名稱:IP_Lab,代碼行數:34,代碼來源:WipeTransition.cs

示例9: LayoutRoot_MouseLeftButtonUp

 private void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     PointCollection points = new PointCollection();
     foreach (Point p in poly.Points)
         points.Add(p);
     Point newPoint = e.GetPosition(poly);
     points.Add(newPoint);
     poly.Points = points;
     // placeholder
     Ellipse ph = new Ellipse
     {
         Fill = new SolidColorBrush(Colors.Black),
         Width = 4D,
         Height = 4D
     };
     TranslateTransform t = new TranslateTransform { X = newPoint.X - 2D, Y = newPoint.Y - 2D };
     ph.RenderTransform = t;
     cnv.Children.Add(ph);
     //
     TextBlock tb = new TextBlock
     {
         Foreground = new SolidColorBrush(Colors.Gray),
         FontSize = 8
     };
     tb.Text = newPoint.ToString();
     tb.RenderTransform = t;
     cnv.Children.Add(tb);
 }
開發者ID:dsummerfield,項目名稱:ctaggart-hg.examples100,代碼行數:28,代碼來源:Euclidean.xaml.cs

示例10: ImageControls

        /// <summary>
        /// ImageControls constructor
        /// </summary>
        /// <param name="uiImage">User's Image</param>
        /// <param name="uiImageCanvas">Canvas the image is displayed on</param>
        /// <param name="uiProcImage">Processed Image</param>
        /// <param name="uiProcImageCanvas">Canvas that the processed image is displayed on</param>
        public ImageControls(Image uiImage, Canvas uiImageCanvas, Image uiProcImage, Canvas uiProcImageCanvas)
        {
            image = uiImage;
            imageCanvas = uiImageCanvas;

            procImage = uiProcImage;
            procImageCanvas = uiProcImageCanvas;

            //Create transform group that includes ScaleTransform (zooming) and TranslateTransform (panning)
            TransformGroup group = new TransformGroup();
            ScaleTransform xform = new ScaleTransform();
            group.Children.Add(xform);
            TranslateTransform tt = new TranslateTransform();
            TranslateTransform ttp = new TranslateTransform();
            group.Children.Add(tt);
            group.Children.Add(ttp);

            //Add transform group to both images. Cant add to canvas because there is no boundry for the canvas, thus the images will expand outside the GUI
            image.RenderTransform = group;
            image.MouseWheel += image_MouseWheel;
            image.MouseLeftButtonDown += image_MouseLeftButtonDown;
            image.MouseLeftButtonUp += image_MouseLeftButtonUp;
            image.MouseMove += image_MouseMove;

            procImage.RenderTransform = group;
            procImage.MouseWheel += procImage_MouseWheel;
            procImage.MouseLeftButtonDown += procImage_MouseLeftButtonDown;
            procImage.MouseLeftButtonUp += procImage_MouseLeftButtonUp;
            procImage.MouseMove += procImage_MouseMove;
        }
開發者ID:jniehus,項目名稱:ProcView,代碼行數:37,代碼來源:ImageControls.cs

示例11: sp_MouseMove

        void sp_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragging_ && !firstDown_) {
                Point currentPosition = e.GetPosition(dragTarget_);

                var transform = dragTarget_.RenderTransform as TranslateTransform;
                if (transform == null) {
                    transform = new TranslateTransform();
                    dragTarget_.RenderTransform = transform;
                }

                transform.X += currentPosition.X - clickPosition.X;
                transform.Y += currentPosition.Y - clickPosition.Y;
                clickPosition = e.GetPosition(dragTarget_);
                //transform.X = currentPosition.X - clickPosition.X;
                //transform.Y = currentPosition.Y - clickPosition.Y;
                if (transform.X + dragTarget_.ActualWidth > canvas.MinWidth) {
                    canvas.MinWidth = canvas.Width = transform.X + dragTarget_.ActualWidth * 2;
                    canvas.InvalidateMeasure();
                    scroller.InvalidateMeasure();
                    scroller.InvalidateScrollInfo();
                }
            } else if (firstDown_)
                firstDown_ = false;
        }
開發者ID:nonconforme,項目名稱:UrContent,代碼行數:25,代碼來源:GraphCanvas.xaml.cs

示例12: gdValues_MouseMove

        void gdValues_MouseMove(object sender, MouseEventArgs e)
        {
            if (inFocus)
            {
                TranslateTransform rt = new TranslateTransform();
                rt.Y = e.GetPosition(this).Y - 400;
                gdValues.RenderTransform = rt;
                start = rt.Y;
                foreach (var c in gdValues.Children)
                {
                    double lblTop = lblSelectedValue.PointToScreen(new Point(0, 0)).Y;

                    if ((c as UIElement).PointToScreen(new Point(0, 0)).Y >= lblTop - 20 && (c as UIElement).PointToScreen(new Point(0, 0)).Y <= lblTop + 20)
                    {
                        (c as Label).Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF005DFF"));
                        selectedText = (c as Label).Content.ToString();
                        (c as Label).BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF005DFF"));
                        element = (c as UIElement);
                    }
                    else
                    {
                        (c as Label).BorderBrush = new SolidColorBrush(Colors.White);
                        (c as Label).Background = new SolidColorBrush(Colors.Transparent);
                    }
                }
            }
        }
開發者ID:voxPopuli92,項目名稱:ViserInformator,代碼行數:27,代碼來源:ctrIzborSmera.xaml.cs

示例13: Bounce

        /// <summary>
        /// Bounces the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="whenDone">The when done.</param>
        public static void Bounce(UIElement element, Direction direction, EventHandler whenDone = null)
        {
            var translateTransform = new TranslateTransform();
            element.RenderTransform = translateTransform;
            switch (direction)
            {
                case Direction.Up:
                    translateTransform.BeginAnimation(
                        TranslateTransform.YProperty,
                        CreateDoubleAnimation(
                        0,
                        -15,
                        0.2,
                        (o, e) => translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateDoubleAnimationWithEasing(-15, 0, 0.8, new BounceEase { Bounces = 3, EasingMode = EasingMode.EaseOut })),
                        whenDone));
                    break;

                case Direction.Down:
                    translateTransform.BeginAnimation(
                        TranslateTransform.YProperty,
                        CreateDoubleAnimation(
                        0,
                        15,
                        0.2,
                        (o, e) => translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateDoubleAnimationWithEasing(15, 0, 0.8, new BounceEase { Bounces = 3, EasingMode = EasingMode.EaseOut })),
                        whenDone));
                    break;
            }
        }
開發者ID:quitrk,項目名稱:MiniDeskTube,代碼行數:35,代碼來源:Animate.cs

示例14: Manager

        //Editor Ed = new Editor(Edit);

        public Manager(TabControl tabs, StackPanel Background, StackPanel Edit)
        {
            // TODO: Complete member initialization
            this.tabs = tabs;
            this.Background = Background;
            this.Edit = Edit;
            trSkw = new SkewTransform(0, 0);
            trRot = new RotateTransform(0);
            trTns = new TranslateTransform(0, 0);
            trScl = new ScaleTransform(1, 1);
            trSkw2 = new SkewTransform(0, 0);
            trRot2 = new RotateTransform(0);
            trTns2 = new TranslateTransform(0, 0);
            trScl2 = new ScaleTransform(1, 1);
            trGrp2 = new TransformGroup();
            trGrp2.Children.Add(trSkw2);
            trGrp2.Children.Add(trRot2);
            trGrp2.Children.Add(trTns2);
            trGrp2.Children.Add(trScl2);
            trGrp = new TransformGroup();
            trGrp.Children.Add(trSkw);
            trGrp.Children.Add(trRot);
            trGrp.Children.Add(trTns);
            trGrp.Children.Add(trScl);
        }
開發者ID:DenysGranevych,項目名稱:Development-of-welcoming-Cards,代碼行數:27,代碼來源:manager.cs

示例15: ArrangeOverride

        /// <summary>
        /// Provides the behavior for the Arrange pass of Silverlight layout. Classes can override this method to define their own Arrange pass behavior.
        /// </summary>
        /// <param name="finalSize">The final area within the parent that this object should use to arrange itself and its children.</param>
        /// <returns>
        /// The actual size that is used after the element is arranged in layout.
        /// </returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (Symbol is ESRI.ArcGIS.Client.Symbols.MarkerSymbol)
            {
                UIElement child = GetChild();
                Transform childTransform = child == null ? null : child.RenderTransform;

                if (childTransform != null)
                {
                    // Arrange the symbol following it's desired size, the final size which is taking care of the transform is not the good one
                    Size size = child.DesiredSize.Height == 0 && child.DesiredSize.Width == 0 ? finalSize : child.DesiredSize;
                    child.Arrange(new Rect(new Point(0, 0), size));

                    // Now we need to translate the symbol in order that the visual part of the symbol be in the snapshot
                    Rect rect = childTransform.TransformBounds(new Rect(new Point(0, 0), child.DesiredSize)); // visual position of the symbol after transformation
                    child.RenderTransformOrigin = new Point(0, 0); // for the swatch, the transform origin must be (0,0) whatever the transform origin used in the map
                    if (rect.X != 0 || rect.Y != 0)
                        RenderTransform = new TranslateTransform { X = -rect.X, Y = -rect.Y }; // Center the symbol

                    return finalSize;
                }

            }
            return base.ArrangeOverride(finalSize);
        }
開發者ID:Esri,項目名稱:arcgis-toolkit-sl-wpf,代碼行數:32,代碼來源:SymbolPresenter.cs


注:本文中的System.Windows.Media.TranslateTransform類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。