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


C# Animation.ThicknessAnimation類代碼示例

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


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

示例1: Show

        /// <summary>
        /// 動態顯示內容
        /// </summary>
        /// <param name="target"></param>
        /// <param name="duration"></param>
        public static void Show(ContentControl target, double duration = .8)
        {

            ThicknessAnimation animtion = new ThicknessAnimation()
            {
                From = new Thickness(target.Margin.Left + 80, target.Margin.Top, target.Margin.Right, target.Margin.Bottom),
                To = new Thickness(160, 0, 0, 0),
                Duration = TimeSpan.FromSeconds(duration),
                FillBehavior = FillBehavior.HoldEnd,
                AccelerationRatio = .5,
                EasingFunction = be
            };

            DoubleAnimation animtion2 = new DoubleAnimation()
            {
                From = 0,
                To = 1,
                Duration = TimeSpan.FromSeconds(duration),
                FillBehavior = FillBehavior.HoldEnd,
                AccelerationRatio = .5,
                EasingFunction = be
            };

            target.BeginAnimation(ContentControl.MarginProperty, animtion);
            target.BeginAnimation(ContentControl.OpacityProperty, animtion2);
        }
開發者ID:ONEWateR,項目名稱:FlowMonitor,代碼行數:31,代碼來源:CAAnimation.cs

示例2: FadeInAnimation

        private static Storyboard FadeInAnimation(int interval, params FrameworkElement[] controls)
        {
            Storyboard fadeInAnimation = new Storyboard();
            int counter = 0;
            foreach (var control in controls)
            {
                control.BeginAnimation(OpacityProperty, null);
                control.BeginAnimation(MarginProperty, null);
                control.Opacity = 0;
                control.Margin = new Thickness(0, control.Margin.Top, 0, 0);
                DoubleAnimation da = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(300));
                ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-10, control.Margin.Top, 10, 0), new Thickness(0, control.Margin.Top, 0, 0), TimeSpan.FromMilliseconds(400));
                Storyboard.SetTarget(da, control);
                Storyboard.SetTarget(ta, control);
                Storyboard.SetTargetProperty(da, new PropertyPath(OpacityProperty));
                Storyboard.SetTargetProperty(ta, new PropertyPath(MarginProperty));
                fadeInAnimation.Children.Add(da);
                fadeInAnimation.Children.Add(ta);
                da.BeginTime = TimeSpan.FromMilliseconds(counter * interval);
                ta.BeginTime = TimeSpan.FromMilliseconds(counter * interval);
                counter++;
            }

            fadeInAnimation.Completed += (s, e) =>
            {
                foreach (var c in controls)
                {
                    c.Opacity = 1;
                }
            };
            return fadeInAnimation;
        }
開發者ID:WELL-E,項目名稱:Hurricane,代碼行數:32,代碼來源:AnimatedStackPanel.cs

示例3: Flush

        public void Flush()
        {
            var thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
            thicknessAnimationUsingKeyFrames.KeyFrames = new ThicknessKeyFrameCollection();

            double delta = (Width - Height) / 2;

            var thicknessAnimation = new ThicknessAnimation()
            {
                From = new Thickness(delta, 0, delta, 0),
                To = new Thickness(delta - 500, -500, delta - 500, -500),
                Duration = new Duration(TimeSpan.FromSeconds(1)),
                AutoReverse = true
            };
            thicknessAnimation.Completed += new EventHandler(animation_Completed);

            _flushEllipse = new Ellipse()
            {
                Fill = new SolidColorBrush(Colors.LightBlue),
                Stroke = new SolidColorBrush(Colors.Orange),
                StrokeThickness = 5,
                Opacity = 0.5
            };

            Children.Add(_flushEllipse);
            _flushEllipse.BeginAnimation(Ellipse.MarginProperty, thicknessAnimation);
        }
開發者ID:hjlfmy,項目名稱:Rubezh,代碼行數:27,代碼來源:ElementXDeviceView.xaml.cs

示例4: txt_PreviewMouseUp

        private void txt_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            DoubleAnimation title_width_animation = new DoubleAnimation();
            ThicknessAnimation title_margin_animation = new ThicknessAnimation();
            DoubleAnimation content_width_animation = new DoubleAnimation();
            DoubleAnimation content_height_animation = new DoubleAnimation();
            ThicknessAnimation content_margin_animation = new ThicknessAnimation();
            DoubleAnimation txt_width_animation = new DoubleAnimation();
            ThicknessAnimation txt_margin_animation = new ThicknessAnimation();
            if (txt.Width < 720 || txt.ActualWidth < 720)
            {
                title_width_animation.To = SystemParameters.PrimaryScreenWidth;

                title_margin_animation.To = new Thickness(0, 10, 0, 0);

                content_height_animation.To = SystemParameters.PrimaryScreenHeight - 105;

                content_width_animation.To = SystemParameters.PrimaryScreenWidth;

                content_margin_animation.To = new Thickness(0, 10, 0, 0);

                txt_width_animation.To = SystemParameters.PrimaryScreenWidth;

                txt_margin_animation.From = new Thickness(0, 0, 0, 0);
                txt_margin_animation.To = new Thickness(0, SystemParameters.PrimaryScreenHeight-txt.ActualHeight - 110, 0, 0);

            }
            else
            {
                title_width_animation.To = 392;

                title_margin_animation.To = new Thickness(0, 200, 0, 0);

                content_height_animation.To = 533;

                content_width_animation.To = 392;

                content_margin_animation.To = new Thickness(0, 10, 0, 0);

                txt_margin_animation.From = new Thickness(0, 0, 0, 0);
                txt_margin_animation.To = new Thickness(0, SystemParameters.PrimaryScreenHeight-txt.ActualHeight -110, 0, 0);

                //txt_width_animation.To = SystemParameters.PrimaryScreenWidth;
            }
            title_width_animation.Duration = TimeSpan.FromSeconds(0.5);
            title_margin_animation.Duration = TimeSpan.FromSeconds(0.5);
            content_height_animation.Duration = TimeSpan.FromSeconds(0.5);
            content_width_animation.Duration = TimeSpan.FromSeconds(0.5);
            content_margin_animation.Duration = TimeSpan.FromSeconds(0.5);
            txt_width_animation.Duration = TimeSpan.FromSeconds(0.5);
            txt_margin_animation.Duration = TimeSpan.FromSeconds(500);

            txt.BeginAnimation(StackPanel.WidthProperty, title_width_animation);
            txt.BeginAnimation(StackPanel.MarginProperty, title_margin_animation);
            //content.BeginAnimation(StackPanel.HeightProperty, content_height_animation);
            //content.BeginAnimation(StackPanel.WidthProperty, title_width_animation);
            //content.BeginAnimation(StackPanel.MarginProperty, content_margin_animation);
            txt.BeginAnimation(TextBlock.WidthProperty, txt_width_animation);
            txt.BeginAnimation(TextBlock.MarginProperty, txt_margin_animation);
        }
開發者ID:cloudtimesoft,項目名稱:fcb_public,代碼行數:60,代碼來源:sub_show.xaml.cs

示例5: Button_Click_1

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Ellipse ellipse1 = new Ellipse();
            ellipse1.Width = 50;
            ellipse1.Height = 20;
            ellipse1.ToolTip = "Touch Me / Потискай меня";
            ellipse1.StrokeThickness = 2;
            ellipse1.Stroke = Brushes.Black;
            ellipse1.Fill = Brushes.Red;
            Mygrid.Children.Add(ellipse1);

            Ellipse ellipse2 = new Ellipse();
            ellipse2.Width = 50;
            ellipse2.Height = 20;
            ellipse2.ToolTip = "Touch Me / Потискай меня";
            ellipse2.StrokeThickness = 2;
            ellipse2.Stroke = Brushes.Red;
            ellipse2.Fill = Brushes.Green;
            Mygrid.Children.Add(ellipse2);

            Random rand1 = new Random((int)DateTime.Now.Ticks);
            Random rand2 = new Random((int)DateTime.Now.Ticks);
            ThicknessAnimation TA1 = new ThicknessAnimation(); //Анимация перемещения
            TA1.From = ellipse1.Margin = new Thickness(10, 100, 0, 0); //Координаты начального положения
            TA1.To = ellipse1.Margin = new Thickness(1400, 100, 0, 0); //Координаты конечного положения
            TA1.Duration = TimeSpan.FromSeconds(rand1.Next(10, 20)); //Время анимации
            ellipse1.BeginAnimation(MarginProperty, TA1); //Запуск анимации

            ThicknessAnimation TA2 = new ThicknessAnimation(); //Анимация перемещения
            TA2.From = ellipse2.Margin = new Thickness(10, 200, 0, 0); //Координаты начального положения
            TA2.To = ellipse2.Margin = new Thickness(1400, 200, 0, 0); //Координаты конечного положения
            TA2.Duration = TimeSpan.FromSeconds(rand2.Next(10, 20)); //Время анимации
            ellipse2.BeginAnimation(MarginProperty, TA2); //Запуск анимации
        }
開發者ID:3A9C,項目名稱:ITstep,代碼行數:34,代碼來源:MainWindow.xaml.cs

示例6: AvatarBounce

        private void AvatarBounce()
        {

            var bounce = new BounceEase { Bounces = 3, Bounciness = 10 };
            var a = new ThicknessAnimation(new Thickness(10, -800, 0, 810), new Thickness(10, 10, 0, 0),
                                           new Duration(new TimeSpan(0, 0, 1))) {EasingFunction = bounce};
            Avi.BeginAnimation(MarginProperty, a);
        }
開發者ID:Conji,項目名稱:Cloudsdale-Win7,代碼行數:8,代碼來源:UserFlyout.xaml.cs

示例7: AnimationUp

 private void AnimationUp(Grid grid)
 {
     ThicknessAnimation ta = new ThicknessAnimation();
     ta.From = grid.Margin;
     ta.To = new Thickness(grid.Margin.Left, RowHeight + SpaceBetweenGrids, 0, 0);
     ta.Duration = new Duration(TimeSpan.FromSeconds(0.5));
     grid.BeginAnimation(Grid.MarginProperty, ta);
 }
開發者ID:damy90,項目名稱:Telerik-all,代碼行數:8,代碼來源:Settings.xaml.cs

示例8: BtnBack_Click

 private void BtnBack_Click(object sender, RoutedEventArgs e)
 {
     ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-618, 0, 1003, 0), new Duration(TimeSpan.FromMilliseconds(350)));
     ExponentialEase ee = new ExponentialEase();
     ee.EasingMode = EasingMode.EaseOut;
     ta.EasingFunction = ee;
     ta.Completed += ta_Completed;
     this.OptGrid.BeginAnimation(MarginProperty, ta);
 }
開發者ID:lantian2012,項目名稱:3DS-GuitarHero,代碼行數:9,代碼來源:VHelpPage.xaml.cs

示例9: DockPanel_MouseEnter

    private void DockPanel_MouseEnter(object sender, MouseEventArgs e) {
      var ta = new ThicknessAnimation();
/*
      ta.From = MenuCanvas.Margin;
      ta.To = new Thickness(0,15,-360,0);
      ta.Duration = new Duration(TimeSpan.FromMilliseconds(500));
      MenuCanvas.BeginAnimation(MarginProperty, ta);
*/
    }
開發者ID:Rushman1,項目名稱:PictureViewer,代碼行數:9,代碼來源:Shell.xaml.cs

示例10: Beweeg

 public void Beweeg(Point target)
 {
     var thickness = new Thickness(target.X, target.Y, 0, 0);
     var moveAnimation = new ThicknessAnimation(Margin, thickness, TimeSpan.FromMilliseconds(500))
         {
             FillBehavior = FillBehavior.Stop
         };
     moveAnimation.Completed += (sender, args) => Margin = thickness;
     BeginAnimation(MarginProperty, moveAnimation);
 }
開發者ID:Roconda,項目名稱:Barricade,代碼行數:10,代碼來源:Barricade.xaml.cs

示例11: CreateSlideInAnimation

		static AnimationTimeline CreateSlideInAnimation(FrameworkElement frameworkElement)
		{
			var parent = frameworkElement.Parent as FrameworkElement;
			
			var marginAnimation = new ThicknessAnimation();
			marginAnimation.From = new Thickness(parent.ActualWidth, 0, 0, 0);
			marginAnimation.To = new Thickness(0);
			marginAnimation.Duration = duration;
			return marginAnimation;
		}
開發者ID:nylen,項目名稱:SharpDevelop,代碼行數:10,代碼來源:SlideBehaviour.cs

示例12: StartLeaveAnimation

    private void StartLeaveAnimation() {
      var ta=new ThicknessAnimation();
/*
      ta.From=MenuCanvas.Margin;
      ta.To=new Thickness(0, 15, -410, 0);
      ta.Duration=new Duration(TimeSpan.FromMilliseconds(500));
      MenuCanvas.BeginAnimation(MarginProperty, ta);
*/

    }
開發者ID:Rushman1,項目名稱:PictureViewer,代碼行數:10,代碼來源:Shell.xaml.cs

示例13: HideMessage

 public void HideMessage()
 {
     ThicknessAnimation ta1 = new ThicknessAnimation();
     ta1.To = new Thickness(848, 55, 0, 0);
     ta1.Duration = new Duration(TimeSpan.FromSeconds(2));
     DoubleAnimation da1 = new DoubleAnimation();
     da1.To = 0;
     da1.Duration = new Duration(TimeSpan.FromSeconds(2));
     PopupContainer.BeginAnimation(Grid.MarginProperty, ta1);
     PopupContainer.BeginAnimation(Grid.OpacityProperty, da1);
 }
開發者ID:HamzaElgarrab,項目名稱:LeGarage_Client,代碼行數:11,代碼來源:MainWindow.xaml.cs

示例14: SideBarAnimation

        private static void SideBarAnimation(Panel sideBar, int from, int to, ThicknessAnimation ta)
        {
            DoubleAnimation da = new DoubleAnimation();
            da.From = from;
            da.To = to;
            da.Duration = TimeSpan.FromSeconds(0.4);
            sideBar.BeginAnimation(TextBlock.OpacityProperty, da);

            ta.Duration = TimeSpan.FromSeconds(0.2);
            sideBar.BeginAnimation(TextBlock.MarginProperty, ta);
        }
開發者ID:QingWei-Li,項目名稱:MyLife,代碼行數:11,代碼來源:MainWindow.xaml.cs

示例15: Animation

 static Animation()
 {
     ca = new ColorAnimation();
     ta = new ThicknessAnimation();
     da = new DoubleAnimation();
     sbOnce = new Storyboard();
     sbForever = new Storyboard();
     sbForever.RepeatBehavior = RepeatBehavior.Forever;
     sbForever.Children.Add(new DoubleAnimation());
     sb = sbOnce;
     sb.Children.Add(new DoubleAnimation());
 }
開發者ID:RicoAcuzar,項目名稱:SysAd-Project,代碼行數:12,代碼來源:Animation.cs


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