예제 #1
0
        public static void ExecActionByName(string name, double width, double height, double x, double y, int zindex, int fontsize)
        {
            UserControl uc = null;

            switch (name)
            {
            case "警情动态":
                uc = PublicParams.padCaseInfo;
                break;

            case "动态视频":
                uc = PublicParams.padVideos;
                PublicParams.videoPadHeight = height;
                PublicParams.videoPadWidth  = width;
                break;

            default:
                break;
            }
            if (uc != null)
            {
                uc.BeginAnimation(UserControl.WidthProperty, null);
                uc.BeginAnimation(UserControl.HeightProperty, null);
                SetPadPositionAndSize(uc, width, height, x, y, fontsize);
                Canvas.SetZIndex(uc, zindex);
            }
        }
예제 #2
0
        private void FadeControls(UserControl fadeOut, UserControl fadeIn, bool nextEnabled, bool backEnabled, bool isFinish = false)
        {
            fadeOut.BeginAnimation(OpacityProperty, GetAnimation(1, 0));
            fadeIn.BeginAnimation(OpacityProperty, GetAnimation(0, 1));
            fadeOut.IsHitTestVisible = false;
            fadeIn.IsHitTestVisible  = true;
            activeControl            = fadeIn;
            lastActiveControl        = fadeOut;
            btn_next.IsEnabled       = nextEnabled;
            btn_back.IsEnabled       = backEnabled;

            if (isFinish)
            {
                btn_next.Content = "Finish";
            }

            if (fadeIn.Name == "components")
            {
                ShowUACIcon(true);
            }
            else
            {
                ShowUACIcon(false);
            }
        }
예제 #3
0
        public static void FadeAnimation(UserControl svi)
        {
            var ObjAnimation = new DoubleAnimation(0, (Duration)TimeSpan.FromSeconds(0.5));

            //   ObjAnimation.Completed +=ObjAnimation_Completed;
            svi.BeginAnimation(UIElement.OpacityProperty, ObjAnimation);
        }
예제 #4
0
        private void efectoPanel(UserControl panel)
        {
            DoubleAnimation da = new DoubleAnimation();

            da.From     = 0.0;
            da.To       = 1;
            da.Duration = new Duration(TimeSpan.FromSeconds(1));
            panel.BeginAnimation(UserControl.OpacityProperty, da);
        }
예제 #5
0
        private void CloseO_Completed(object sender, EventArgs e)
        {
            PlanTypeGrid.Children.Clear();

            UserControl el = (UserControl)currenPanel;

            el.Opacity = 0;
            PlanTypeGrid.Children.Add(el);
            el.BeginAnimation(OpacityProperty, openO);
        }
예제 #6
0
 private void FadeControls(UserControl fadeOut, UserControl fadeIn, bool nextEnabled, bool backEnabled)
 {
     fadeOut.BeginAnimation(OpacityProperty, GetAnimation(1, 0));
     fadeIn.BeginAnimation(OpacityProperty, GetAnimation(0, 1));
     fadeOut.IsHitTestVisible = false;
     fadeIn.IsHitTestVisible  = true;
     activeControl            = fadeIn;
     lastActiveControl        = fadeOut;
     btn_next.IsEnabled       = nextEnabled;
     btn_back.IsEnabled       = backEnabled;
 }
예제 #7
0
        public static void ShakeAnimation(UserControl me)
        {
            ThicknessAnimation bounceAnimation   = new ThicknessAnimation();
            BounceEase         BounceOrientation = new BounceEase();

            BounceOrientation.Bounces      = 2;
            BounceOrientation.Bounciness   = .3;
            bounceAnimation.To             = new Thickness(0, 0, 0, 0);
            bounceAnimation.From           = new Thickness(15, 0, 0, 0);
            bounceAnimation.EasingFunction = BounceOrientation;
            me.BeginAnimation(FrameworkElement.MarginProperty, bounceAnimation);
        }
예제 #8
0
        private void NewPanel(object obj)
        {
            currenPanel = obj;

            if (PlanTypeGrid.Children.Count > 0)
            {
                UserControl el = (UserControl)PlanTypeGrid.Children[0];
                el.BeginAnimation(OpacityProperty, closeO);
            }
            else
            {
                CloseO_Completed(null, null);
            }
        }
예제 #9
0
 /// <summary>
 /// 返回主窗体并播放动画
 /// </summary>
 public void NavigationToMainPage()
 {
     if (VisualPanel != null)
     {
         foreach (UIElement control in VisualPanel.Children)
         {
             DoubleAnimation showda = new DoubleAnimation(1.0d, new Duration(TimeSpan.FromMilliseconds(1200)));
             control.BeginAnimation(OpacityProperty, showda);
         }
         UserControl     ucControl       = (UserControl)this;
         DoubleAnimation da_ShowMainPage = new DoubleAnimation(0d, new Duration(TimeSpan.FromMilliseconds(1000)));
         da_ShowMainPage.Completed += new EventHandler(da_ShowMainPage_Completed);
         ucControl.BeginAnimation(OpacityProperty, da_ShowMainPage);
         this.Dispose();
     }
 }
예제 #10
0
        public static void AnimateWindowSize(this UserControl target, double oldHeight, double newHeight)
        {
            target.Height = oldHeight;
            target.BeginAnimation(UserControl.HeightProperty, null);

            Storyboard sb = new Storyboard();

            var aniHeight = new DoubleAnimationUsingKeyFrames();

            aniHeight.Duration = new Duration(new TimeSpan(0, 0, 0, 2));
            aniHeight.KeyFrames.Add(new EasingDoubleKeyFrame(target.Height, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 1))));
            aniHeight.KeyFrames.Add(new EasingDoubleKeyFrame(newHeight, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 1, 200))));

            Storyboard.SetTarget(aniHeight, target);
            Storyboard.SetTargetProperty(aniHeight, new PropertyPath(UserControl.HeightProperty));

            sb.Children.Add(aniHeight);

            sb.Begin();
        }
예제 #11
0
        public static void addWipeDownAnnimation(UserControl control, double startingDistance)
        {
            ThicknessAnimation backAnimation   = new ThicknessAnimation();
            BackEase           backOrientation = new BackEase();
            double             topMargin       = (-1) * startingDistance;

            backOrientation.Amplitude  = .4;
            backOrientation.EasingMode = EasingMode.EaseIn;
            //double ab = backOrientation.Ease(.7);
            //App.logger.Info("Ease pace : " + ab);
            backAnimation.To             = new Thickness(0, 0, 0, 0);
            backAnimation.From           = new Thickness(0, topMargin, 0, startingDistance);
            backAnimation.EasingFunction = backOrientation;
            //            double ab = backAnimation.;
            //          App.logger.Info("Ease pace : " + ab);
            //backAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));
            //backAnimation.DecelerationRatio = .9;
            backAnimation.SpeedRatio = .3;
            backAnimation.Completed += BackAnimation_Completed;
            control.BeginAnimation(UserControl.MarginProperty, backAnimation);
            App.logger.Info("Deceletation Ration : " + backAnimation.DecelerationRatio);
            App.logger.Info("Acceletation Ration : " + backAnimation.AccelerationRatio);
        }
예제 #12
0
        public static void addBounceAnnimation(UserControl control, Thickness targetThickness)
        {
            ThicknessAnimation bounceAnimation = new ThicknessAnimation();
            //BounceEase BounceOrientation = new BounceEase();
            //BounceOrientation.Bounces = 4;
            //BounceOrientation.Bounciness = 2;

            //bounceAnimation.To = new Thickness(0, 0, 0, 0);
            //bounceAnimation.From = new Thickness(0, targetThickness.Top, 0, targetThickness.Bottom);
            //bounceAnimation.EasingFunction = BounceOrientation;
            //test
            BackEase backOrientation = new BackEase();

            backOrientation.Amplitude = 2;
            backOrientation.Ease(0.3);
            backOrientation.EasingMode = EasingMode.EaseIn;

            bounceAnimation.To             = new Thickness(0, 0, 0, 0);
            bounceAnimation.From           = new Thickness(0, 0, 0, targetThickness.Bottom); //targetThickness.Top, 0, targetThickness.Bottom
            bounceAnimation.EasingFunction = backOrientation;

            control.BeginAnimation(UserControl.MarginProperty, bounceAnimation);
        }
        void Start(Canvas panel)
        {
            // SerializSettingClass(setting);


            panel.Children.Clear();

            Random random = new Random();

            task = Task.Factory.StartNew(new Action(() =>
            {
                for (int j = 0; j < 50; j++)
                {
                    Thread.Sleep(j * 200);
                    //Dispatcher.BeginInvoke(new Action(() =>
                    //{
                    int snowCount = random.Next(2, setting.SnowflakeCount);//Count
                    for (int i = 0; i < snowCount; i++)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            int width = random.Next(5, setting.SnowflakeSize);   //size

                            if (setting.SnowflakeType == 1)
                            {
                                Petal pack  = new Petal();
                                userControl = pack;
                            }
                            else if (setting.SnowflakeType == 2)
                            {
                                BGCFu bGCFu = new BGCFu();
                                userControl = bGCFu;
                            }
                            else if (setting.SnowflakeType == 3)
                            {
                                BGCSnow bGCSnow = new BGCSnow();
                                userControl     = bGCSnow;
                            }
                            else if (setting.SnowflakeType == 4)
                            {
                                BGCStarxaml bGCStarxaml = new BGCStarxaml();
                                userControl             = bGCStarxaml;
                            }
                            else
                            {
                                BGCSnow bGCFu = new BGCSnow();
                                userControl   = bGCFu;
                            }
                            userControl.Width           = width;
                            userControl.Height          = width;
                            userControl.RenderTransform = new RotateTransform();

                            int left = random.Next(0, (int)panel.ActualWidth);
                            Canvas.SetLeft(userControl, left);
                            panel.Children.Add(userControl);
                            int seconds = random.Next(20, 30);
                            userControl.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1)));
                            DoubleAnimationUsingPath doubleAnimation = new DoubleAnimationUsingPath()           //下降动画
                            {
                                Duration       = new Duration(new TimeSpan(0, 0, seconds)),
                                RepeatBehavior = RepeatBehavior.Forever,
                                PathGeometry   = new PathGeometry(new List <PathFigure>()
                                {
                                    new PathFigure(new Point(left, 0), new List <PathSegment>()
                                    {
                                        new LineSegment(new Point(left, panel.ActualHeight), false)
                                    }, false)
                                }),
                                Source = PathAnimationSource.Y
                            };
                            userControl.BeginAnimation(Canvas.TopProperty, doubleAnimation);
                            DoubleAnimation doubleAnimation1 = new DoubleAnimation(360, new Duration(new TimeSpan(0, 0, 12)))                 //旋转动画
                            {
                                RepeatBehavior = RepeatBehavior.Forever,
                            };

                            userControl.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation1);
                        }));
                    }
                }
            }));
        }
예제 #14
0
        private void DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            Thumb thumb    = sender as Thumb;
            int   position = -1;

            if (thumb == thumb_player)
            {
                position = 0;
            }
            else if (thumb == thumb_paved)
            {
                position = 1;
            }
            if (position == -1)
            {
                return;
            }
            double left = Canvas.GetLeft(thumb);

            if (left > gd.ActualWidth / 3 * 2 || (gMain.Children[0] as BaseUserControl).filePath.Equals(String.Empty))
            {
                thumb.RenderTransformOrigin = new Point(0.5, 0.5);
                if (position == 0)
                {
                    thumb.RenderTransform = MatrixTransform_01;
                }
                else if (position == 1)
                {
                    thumb.RenderTransform = MatrixTransform_02;
                }
                double top = Canvas.GetTop(thumb);

                QuadraticBezierSegment quadraticBezierSegment = new QuadraticBezierSegment();
                quadraticBezierSegment.Point1 = new Point((startPoints[position].X - left) / 2, (top - startPoints[position].Y) / 2);
                quadraticBezierSegment.Point2 = new Point(startPoints[position].X - left, startPoints[position].Y - top);
                PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();
                pathSegmentCollection.Add(quadraticBezierSegment);

                PathFigure pathFigure = new PathFigure();
                pathFigure.StartPoint = new Point(0, 0);
                pathFigure.Segments   = pathSegmentCollection;

                PathFigureCollection pathFigureCollection = new PathFigureCollection();
                pathFigureCollection.Add(pathFigure);

                PathGeometry pathGeometry = new PathGeometry();
                pathGeometry.Figures = pathFigureCollection;

                MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
                matrixAnimation.PathGeometry = pathGeometry;
                //动画的路径
                matrixAnimation.Duration   = TimeSpan.FromSeconds(0.5);
                matrixAnimation.Completed += MatrixAnimation_Completed;
                //matrixAnimation.FillBehavior = FillBehavior.Stop;
                //matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
                //matrixAnimation.DoesRotateWithTangent = true;
                //Storyboard.SetTarget(matrixAnimation, thumb);
                if (position == 0)
                {
                    Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_01");//动画的对象
                }
                else if (position == 1)
                {
                    Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_02");//动画的对象
                }
                Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));

                Storyboard pathAnimationStoryboard = new Storyboard();
                pathAnimationStoryboard.Children.Add(matrixAnimation);
                pathAnimationStoryboard.Begin(this);
            }
            else
            {
                BaseMakerLightUserControl baseMakerLightUserControl = gMain.Children[0] as BaseMakerLightUserControl;
                UserControl userControl = null;
                if (position == 0)
                {
                    //加入播放器页面
                    PlayerUserControl playerUserControl = new PlayerUserControl(mw);
                    playerUserControl.SetData(baseMakerLightUserControl.GetData());
                    userControl = playerUserControl;
                }
                else if (position == 1)
                {
                    //加入平铺页面
                    //PavedUserControl pavedUserControl = new PavedUserControl(this,baseMakerLightUserControl.GetData());
                    //userControl = pavedUserControl;
                }
                gMost.Children.Add(userControl);
                DoubleAnimation daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5)));
                userControl.BeginAnimation(OpacityProperty, daV);
                //回原位
                ToolBackToOld(thumb, position);
            }
        }