当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.BeginAnimation方法代码示例

本文整理汇总了C#中System.Windows.Controls.Canvas.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.BeginAnimation方法的具体用法?C# Canvas.BeginAnimation怎么用?C# Canvas.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.Canvas的用法示例。


在下文中一共展示了Canvas.BeginAnimation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Fade

 public void Fade(Canvas c, SliderTargetPos slide, double duration)
 {
     DoubleAnimation fadeanima = new DoubleAnimation();
     if (slide == SliderTargetPos.front)
     {
         fadeanima.From = c.Opacity;
         fadeanima.To = 1;
         fadeanima.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(duration));
         c.BeginAnimation(Canvas.OpacityProperty, fadeanima);
     }
     else
     {
         fadeanima.From = c.Opacity;
         fadeanima.To = 0;
         fadeanima.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(duration));
         c.BeginAnimation(Canvas.OpacityProperty, fadeanima);
     }
 }
开发者ID:Creative2,项目名称:tab_slider,代码行数:18,代码来源:Effects.cs

示例2: MouseNHolder

        public void MouseNHolder(Canvas b, Thickness tothickness, bool isactive)
        {
            ThicknessAnimation holderslide = new ThicknessAnimation();
            if (isactive)
            {
                holderslide.To = tothickness;
                holderslide.From = b.Margin;
                holderslide.Duration = new Duration(TimeSpan.FromMilliseconds(100));
                b.BeginAnimation(Canvas.MarginProperty, holderslide);
            }
            else
            {
                holderslide.To = tothickness;
                holderslide.From = b.Margin;
                holderslide.Duration = new Duration(TimeSpan.FromMilliseconds(100));
                b.BeginAnimation(Canvas.MarginProperty, holderslide);

            }
        }
开发者ID:Creative2,项目名称:tab_slider,代码行数:19,代码来源:Effects.cs

示例3: FoldInnerCanvasSideward

 private void FoldInnerCanvasSideward(Canvas canvas)
 {
     var canvasChildren = canvas.Children.OfType<StackPanel>().ToList();
     if (canvas.Visibility == Visibility.Collapsed)
     {
         canvas.Visibility = Visibility.Visible;
         DoubleAnimation canvasAnimation = new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.Parse("0:0:0.35") };
         if (canvasChildren.Count() > 0)
         {
             double canvasMinWidth = GetCanvasMinWidth(canvas);
             FoldCanvasSideward(canvas);
         }
         canvas.BeginAnimation(Canvas.OpacityProperty, canvasAnimation);
     }
     else
     {
         DoubleAnimation canvasAnimation = new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
         canvasAnimation.Completed += (s, e) => canvas.Visibility = Visibility.Collapsed;
         canvas.BeginAnimation(Canvas.OpacityProperty, canvasAnimation);
         FoldCanvasSideward(canvas);
     }
 }
开发者ID:tonryu,项目名称:NSPIRESystem,代码行数:22,代码来源:LeadDashboard.xaml.cs

示例4: FoldCanvasSideward

        private void FoldCanvasSideward(Canvas canvas)
        {
            double minCanvasWidth = GetCanvasMinWidth(canvas);
            double maxCanvasWidth = GetCanvasMaxWidth(canvas);
            if (canvas.Width == minCanvasWidth)
            {
                var canvasChildren = canvas.Children.OfType<StackPanel>().ToList();
                if (canvasChildren.Count() > 0)
                {
                    int numberOfButtonsMinusOne = canvasChildren.Count() - 1;//number of buttons - 1
                    double initialCenterWidth = minCanvasWidth - canvasChildren.FirstOrDefault().ActualWidth - canvasChildren.FirstOrDefault().Margin.Left - canvasChildren.FirstOrDefault().Margin.Right;//width to be centered
                    double finalCenterWidth = maxCanvasWidth - canvasChildren.FirstOrDefault().ActualWidth - canvasChildren.FirstOrDefault().Margin.Left - canvasChildren.FirstOrDefault().Margin.Right;
                    double initialUnitWidth = Math.Round(initialCenterWidth / numberOfButtonsMinusOne);
                    double finalUnitWidth = Math.Round(finalCenterWidth / numberOfButtonsMinusOne);

                    StackPanel firstStackPanel = canvasChildren.FirstOrDefault();
                    int index = 0;
                    foreach (StackPanel child in canvasChildren.Where(c => c != firstStackPanel).ToList())//all buttons except first one
                    {
                        index++;
                        if (child != canvasChildren.Last())//until before the last button
                        {
                            DoubleAnimation childAnimation = new DoubleAnimation() { From = initialUnitWidth * index, To = finalUnitWidth * index, Duration = TimeSpan.Parse("0:0:0.35") };
                            child.BeginAnimation(Canvas.LeftProperty, childAnimation);
                        }
                        else//last button
                        {
                            DoubleAnimation childAnimation = new DoubleAnimation() { From = 0, To = maxCanvasWidth - minCanvasWidth, Duration = TimeSpan.Parse("0:0:0.35") };
                            child.BeginAnimation(Canvas.LeftProperty, childAnimation);
                        }
                    }
                    DoubleAnimation canvasAnimation = new DoubleAnimation() { From = GetCanvasMinWidth(canvas), To = GetCanvasMaxWidth(canvas), Duration = TimeSpan.Parse("0:0:0.35") };
                    canvas.BeginAnimation(Canvas.WidthProperty, canvasAnimation);
                }
            }
            else
            {
                var canvasChildren = canvas.Children.OfType<StackPanel>().ToList();
                if (canvasChildren.Count() > 0)
                {
                    StackPanel firstStackPanel = canvasChildren.FirstOrDefault();
                    foreach (StackPanel child in canvasChildren)//all buttons except first one
                    {
                        if (child != firstStackPanel)
                        {
                            DoubleAnimation childAnimation = new DoubleAnimation() { From = Canvas.GetLeft(child), To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
                            child.BeginAnimation(Canvas.LeftProperty, childAnimation);
                        }
                    }
                    DoubleAnimation canvasAnimation = new DoubleAnimation() { From = GetCanvasMaxWidth(canvas), To = GetCanvasMinWidth(canvas), Duration = TimeSpan.Parse("0:0:0.35") };
                    canvas.BeginAnimation(Canvas.WidthProperty, canvasAnimation);
                }
            }
        }
开发者ID:tonryu,项目名称:NSPIRESystem,代码行数:54,代码来源:LeadDashboard.xaml.cs

示例5: SurfaceToggleButton_Checked

        private void SurfaceToggleButton_Checked(object sender, RoutedEventArgs e)
        {
            //Ein-/Ausblenden der einzelnen Stockwerke per SurfaceToggleButton
            (sender as SurfaceToggleButton).Foreground = Brushes.Black;
            Canvas animatedObject = new Canvas();
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk0"))
            {
                Stockwerk0.Opacity = 1; animatedObject = Stockwerk0; if (!Is3DMode)
                {

                    btn1.IsChecked = false;
                    btn2.IsChecked = false;
                    btn3.IsChecked = false;
                    btn4.IsChecked = false;
                    btn5.IsChecked = false;
                    btn6.IsChecked = false;
                }
            }
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk1"))
            {
                Stockwerk1.Opacity = 1; animatedObject = Stockwerk1; if (!Is3DMode)
                {
                    btn0.IsChecked = false;

                    btn2.IsChecked = false;
                    btn3.IsChecked = false;
                    btn4.IsChecked = false;
                    btn5.IsChecked = false;
                    btn6.IsChecked = false;
                }
            }
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk2"))
            {
                Stockwerk2.Opacity = 1; animatedObject = Stockwerk2; if (!Is3DMode)
                {
                    btn0.IsChecked = false;
                    btn1.IsChecked = false;

                    btn3.IsChecked = false;
                    btn4.IsChecked = false;
                    btn5.IsChecked = false;
                    btn6.IsChecked = false;
                }
            }
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk3"))
            {
                Stockwerk3.Opacity = 1; animatedObject = Stockwerk3; if (!Is3DMode)
                {
                    btn0.IsChecked = false;
                    btn1.IsChecked = false;
                    btn2.IsChecked = false;

                    btn4.IsChecked = false;
                    btn5.IsChecked = false;
                    btn6.IsChecked = false;
                }
            }
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk4"))
            {
                Stockwerk4.Opacity = 1; animatedObject = Stockwerk4; if (!Is3DMode)
                {
                    btn0.IsChecked = false;
                    btn1.IsChecked = false;
                    btn2.IsChecked = false;
                    btn3.IsChecked = false;

                    btn5.IsChecked = false;
                    btn6.IsChecked = false;
                }
            }
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk5"))
            {
                Stockwerk5.Opacity = 1; animatedObject = Stockwerk5; if (!Is3DMode)
                {
                    btn0.IsChecked = false;
                    btn1.IsChecked = false;
                    btn2.IsChecked = false;
                    btn3.IsChecked = false;
                    btn4.IsChecked = false;

                    btn6.IsChecked = false;
                }
            }
            if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk6"))
            {
                Stockwerk6.Opacity = 1; animatedObject = Stockwerk6; if (!Is3DMode)
                {
                    btn0.IsChecked = false;
                    btn1.IsChecked = false;
                    btn2.IsChecked = false;
                    btn3.IsChecked = false;
                    btn4.IsChecked = false;
                    btn5.IsChecked = false;

                }
            }
            DoubleAnimation opacityAnim = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(.6)), FillBehavior.Stop);
            animatedObject.BeginAnimation(Canvas.OpacityProperty, opacityAnim);
        }
开发者ID:pittruff,项目名称:myStik,代码行数:99,代码来源:Raumplan.xaml.cs

示例6: SurfaceToggleButton_Unchecked

 private void SurfaceToggleButton_Unchecked(object sender, RoutedEventArgs e)
 {
     (sender as SurfaceToggleButton).Foreground = Brushes.WhiteSmoke;
     Canvas animatedObject = new Canvas();
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk0")) { Stockwerk0.Opacity = 0; animatedObject = Stockwerk0; }
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk1")) { Stockwerk1.Opacity = 0; animatedObject = Stockwerk1; }
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk2")) { Stockwerk2.Opacity = 0; animatedObject = Stockwerk2; }
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk3")) { Stockwerk3.Opacity = 0; animatedObject = Stockwerk3; }
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk4")) { Stockwerk4.Opacity = 0; animatedObject = Stockwerk4; }
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk5")) { Stockwerk5.Opacity = 0; animatedObject = Stockwerk5; }
     if ((sender as SurfaceToggleButton).Tag.Equals("Stockwerk6")) { Stockwerk6.Opacity = 0; animatedObject = Stockwerk6; }
     DoubleAnimation opacityAnim = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(.6)), FillBehavior.Stop);
     animatedObject.BeginAnimation(Canvas.OpacityProperty, opacityAnim);
 }
开发者ID:pittruff,项目名称:myStik,代码行数:14,代码来源:Raumplan.xaml.cs

示例7: GeoMap

        /// <summary>
        /// Initializes a new instance of the <see cref="GeoMap"/> class.
        /// </summary>
        public GeoMap()
        {
            Canvas = new Canvas();
            Map = new Canvas();
            Canvas.Children.Add(Map);
            Content = Canvas;

            Canvas.SetBinding(WidthProperty,
                new Binding { Path = new PropertyPath(ActualWidthProperty), Source = this });
            Canvas.SetBinding(HeightProperty,
                new Binding { Path = new PropertyPath(ActualHeightProperty), Source = this });

            Lands = new Dictionary<string, MapData>();

            SetCurrentValue(DefaultLandFillProperty, new SolidColorBrush(Color.FromArgb(200,255,255,255)));
            SetCurrentValue(LandStrokeProperty, new SolidColorBrush(Color.FromArgb(30, 55,55, 55)));
            SetCurrentValue(LandStrokeThicknessProperty, 1.3d);
            SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(500));
            SetCurrentValue(BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 96, 125, 138)));
            SetCurrentValue(GradientStopCollectionProperty, new GradientStopCollection
            {
                new GradientStop(Color.FromArgb(100,2,119,188), 0d),
                new GradientStop(Color.FromRgb(2,119,188), 1d),
            });
            SetCurrentValue(HeatMapProperty, new Dictionary<string, double>());
            SetCurrentValue(GeoMapTooltipProperty, new DefaultGeoMapTooltip {Visibility = Visibility.Hidden});
            Canvas.Children.Add(GeoMapTooltip);

            SizeChanged += (sender, e) =>
            {
                Draw();
            };

            MouseWheel += (sender, e) =>
            {
                if (!EnableZoomingAndPanning) return;

                e.Handled = true;
                var rt = Map.RenderTransform as ScaleTransform;
                var p = rt == null ? 1 : rt.ScaleX;
                p += e.Delta > 0 ? .05 : -.05;
                p = p < 1 ? 1 : p;
                var o = e.GetPosition(this);
                if (e.Delta > 0) Map.RenderTransformOrigin = new Point(o.X/ActualWidth,o.Y/ActualHeight);
                Map.RenderTransform = new ScaleTransform(p, p);
            };

            MouseDown += (sender, e) =>
            {
                if (!EnableZoomingAndPanning) return;

                DragOrigin = e.GetPosition(this);
            };

            MouseUp += (sender, e) =>
            {
                if (!EnableZoomingAndPanning) return;

                var end = e.GetPosition(this);
                var delta = new Point(DragOrigin.X - end.X, DragOrigin.Y - end.Y);

                var l = Canvas.GetLeft(Map) - delta.X;
                var t = Canvas.GetTop(Map) - delta.Y;

                if (DisableAnimations)
                {
                    Canvas.SetLeft(Map, l);
                    Canvas.SetTop(Map, t);
                }
                else
                {
                    Map.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(l, AnimationsSpeed));
                    Map.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(t, AnimationsSpeed));
                }
            };
        }
开发者ID:beto-rodriguez,项目名称:Live-Charts,代码行数:79,代码来源:GeoMap.cs


注:本文中的System.Windows.Controls.Canvas.BeginAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。