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


C# Media.ScaleTransform類代碼示例

本文整理匯總了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();
 }
開發者ID:Gallardot,項目名稱:GallardotStorage,代碼行數:33,代碼來源:ContinuousMagic.cs

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

示例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;
        }
開發者ID:lengocluyen,項目名稱:pesproject,代碼行數:25,代碼來源:MainPage.xaml.cs

示例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();
 }
開發者ID:Gallardot,項目名稱:GallardotStorage,代碼行數:31,代碼來源:RadiateMagic.cs

示例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);
            }
        }
開發者ID:Slowhobo,項目名稱:path-of-exile-skilltree-planer,代碼行數:25,代碼來源:ZoomBorder.cs

示例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;
        }
開發者ID:rbrother,項目名稱:seikkailulaakso,代碼行數:25,代碼來源:Sprite.cs

示例7: SkalerNed

 private void SkalerNed(object sender, RoutedEventArgs e)
 {
     scaleX -= 0.20;
     scaleY -= 0.20;
     Transform tf = new ScaleTransform(scaleX, scaleY);
     stPnlMain.LayoutTransform = tf;
 }
開發者ID:KasperFlye,項目名稱:CsharpAndDotNet,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例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;
            }
        }
開發者ID:huylu,項目名稱:brownuniversitylads,代碼行數:31,代碼來源:AddImageWindow.xaml.cs

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


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

示例10: FilterCellFactory

 static FilterCellFactory()
 {
     _bmpActiveFilter = LoadImage(".ActiveFilter.png");
     _bmpInactiveFilter = LoadImage(".InactiveFilter.png");
     _sortGlyphTransform = new ScaleTransform();
     _sortGlyphTransform.ScaleY = 0.7;
 }
開發者ID:mdjabirov,項目名稱:C1Decompiled,代碼行數:7,代碼來源:FilterCellFactory.cs

示例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);
        }
開發者ID:ssssyin,項目名稱:silverlightfx,代碼行數:32,代碼來源:Flip.cs

示例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())
			}

		}
開發者ID:JackWangCUMT,項目名稱:FlexCharts,代碼行數:29,代碼來源:SelectThemePopup.xaml.cs

示例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;
        }
開發者ID:nankezhishi,項目名稱:ClearMine,代碼行數:33,代碼來源:AutoTransformPanel.cs

示例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);
        }
開發者ID:realsaraf,項目名稱:eConcierge,代碼行數:60,代碼來源:AnimationHelper.cs

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


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