private void ResetNorth( )
 {
     Storyboard sb = new Storyboard();
     sb.Duration = TimeSpan.FromMilliseconds(500.0);
     DoubleAnimationUsingKeyFrames frames= new DoubleAnimationUsingKeyFrames();
     SplineDoubleKeyFrame frame2 = new SplineDoubleKeyFrame();
     frame2.KeyTime = sb.Duration.TimeSpan;
     frame2.Value = 0.0;
     KeySpline spline = new KeySpline();
     spline.ControlPoint1 = new Point(0.0 , 0.1);
     spline.ControlPoint2 = new Point(0.1 , 1.0);
     frame2.KeySpline = spline;
     SplineDoubleKeyFrame frame = frame2;
     frames.KeyFrames.Add(frame);
     if (this.Map.Angle > 180)
     {
         frame.Value = 360.0;
     }//正转到北
     if (this.Map.Angle <= 180)
     {
         frame.Value = 0.0;
     }//转回去
     frames.SetValue(Storyboard.TargetPropertyProperty , new PropertyPath("Angle"));
     sb.Children.Add(frames);
     Storyboard.SetTarget(frames , this.Map);
     sb.Begin();
 }
Example #2
0
 private void ResetRotation_Click(object sender, RoutedEventArgs e)
 {
     Storyboard s = new Storyboard {
         Duration = TimeSpan.FromMilliseconds(500.0)
     };
     DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames();
     SplineDoubleKeyFrame frame2 = new SplineDoubleKeyFrame {
         KeyTime = s.Duration.TimeSpan,
         Value = 0.0
     };
     KeySpline spline = new KeySpline {
         ControlPoint1 = new Point(0.0, 0.1),
         ControlPoint2 = new Point(0.1, 1.0)
     };
     frame2.KeySpline = spline;
     SplineDoubleKeyFrame keyFrame = frame2;
     frames.KeyFrames.Add(keyFrame);
     keyFrame.Value = 0.0;
     frames.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Rotation", new object[0]));
     s.Children.Add(frames);
     Storyboard.SetTarget(frames, this.Map);
     s.Completed += delegate (object sender2, EventArgs e2) {
         s.Stop();
         this.Map.Rotation = 0.0;
     };
     s.Begin();
 }
Example #3
0
        public void SelectItem(int index)
        {
            if (index == -1)
            {
                selectedIndex = -1;
                return;
            }

            Viewport2DVisual3D vis = _models[index];

            int totalPeicesDeep = (int)Math.Floor(Children.Count / (PeicesPerSide * 3.0));
            int depthOfModel = (int)Math.Floor((double)((_models.IndexOf(vis)) / (PeicesPerSide * 3)));
            double currentDepth = totalPeicesDeep * ScrollPosition;
            double scrollDistancePerPiece = 1.0 / totalPeicesDeep;
            double scrollTo = double.IsInfinity(scrollDistancePerPiece) ? (depthOfModel * 0) : (depthOfModel * scrollDistancePerPiece);

            var scrollAnim = new DoubleAnimationUsingKeyFrames();
            scrollAnim.KeyFrames.Add(new SplineDoubleKeyFrame(scrollTo, new TimeSpan(0, 0, 1)));
            scrollAnim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(TunnelPanel3D.ScrollPositionProperty));
            scrollAnim.SetValue(Storyboard.TargetProperty, this);

            // If the Selected Item is not currently built on the screen then only animate the "ScrollPosition" into position
            if (index > ViewingRangeStopIndex || index < ViewRangeStartIndex)
            {
                this.BeginAnimation(TunnelPanel3D.ScrollPositionProperty, scrollAnim);
                selectedIndex = selectedIndex == index ? -1 : index;
                return;
            }

            //Clear Previous Selected Item
            if (selectedIndex >= 0 || selectedIndex == index)
            {
                ClearItem((selectedIndex == index), selectedIndex);
                if (selectedIndex == index)
                { return; }
            }

            //Bring Selected Item into view
            ResourceDictionary rd = new ResourceDictionary();
            rd.Source = new Uri("pack://application:,,,/V3DControls;component/Themes/Generic.xaml");
            Storyboard sb = ((Storyboard)rd["MovePeiceStoryboard"]).Clone();
            var transformGroup = vis.Transform as Transform3DGroup;

            if (selectedIndex != index && transformGroup != null)
            {
                transformGroup.Children[0].BeginAnimation(TranslateTransform3D.OffsetXProperty, null);
                transformGroup.Children[0].BeginAnimation(TranslateTransform3D.OffsetYProperty, null);
                transformGroup.Children[0].BeginAnimation(TranslateTransform3D.OffsetZProperty, null);
                transformGroup.Children[1].BeginAnimation(RotateTransform3D.RotationProperty, null);
                transformGroup.Children[1].BeginAnimation(RotateTransform3D.CenterXProperty, null);
                transformGroup.Children[1].BeginAnimation(RotateTransform3D.CenterYProperty, null);

                sb.Children[0].SetValue(Storyboard.TargetProperty, vis);
                sb.Children[1].SetValue(Storyboard.TargetProperty, vis);
                sb.Children[2].SetValue(Storyboard.TargetProperty, vis);
                (((sb.Children[2] as DoubleAnimationUsingKeyFrames).KeyFrames[0]) as SplineDoubleKeyFrame).Value = (transformGroup.Children[0] as TranslateTransform3D).OffsetZ + PeicesPerSide - 1;
                sb.Children[3].SetValue(Storyboard.TargetProperty, vis);
                sb.Children[4].SetValue(Storyboard.TargetProperty, vis);
                sb.Children[5].SetValue(Storyboard.TargetProperty, vis);

                sb.Children.Add(scrollAnim);
                isMoveingPeiceIntoView = true;
                needsUpdate = true;

                sb.Completed -= new EventHandler(sbSelectItem_Completed);
                sb.Completed += new EventHandler(sbSelectItem_Completed);
                sb.Begin(this, true);
            }
            selectedIndex = selectedIndex == index ? -1 : index;
            MoveItems_SetItemsOwnerSelectedItem();
        }
Example #4
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            if (IsClosing)
            {
                e.Cancel = !AllowClose;
            }
            else
            {
                IsClosing = true;
                AllowClose = false;

                e.Cancel = true;

                if (PopupBoard is Storyboard)
                {
                    PopupBoard.Stop(this);
                    PopupBoard = null;
                }
                HideBoard = new Storyboard();
                HideBoard.Completed += new EventHandler((od, ed) =>
                {
                    AllowClose = true;
                    Close();
                });

                var rect = DockIcon.IconRect;

                var delay = Config.HideDelay;
                if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
                {
                    delay = 5000;
                }

                for (var i = 0; i < spContent.Children.Count; i++)
                {
                    var ctrl = spContent.Children[i] as FanIconControl;

                    ctrl.GridContent.Effect = null;

                    var animRotate = new DoubleAnimationUsingKeyFrames();
                    animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                    animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));
                    animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animRotate.DecelerationRatio = 0.8;

                    var animMargin = new ThicknessAnimationUsingKeyFrames();
                    animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                    animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
                    animMargin.KeyFrames.Add(new SplineThicknessKeyFrame(
                        new Thickness(0),
                        KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animMargin.DecelerationRatio = 0.8;

                    var animOpacity = new DoubleAnimationUsingKeyFrames();
                    animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag);
                    animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
                    animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animOpacity.DecelerationRatio = 1;

                    var animIconSize = new Int32AnimationUsingKeyFrames();
                    animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                    animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)"));
                    animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animIconSize.DecelerationRatio = 1;

                    HideBoard.Children.Add(animRotate);
                    HideBoard.Children.Add(animMargin);
                    HideBoard.Children.Add(animOpacity);
                    HideBoard.Children.Add(animIconSize);
                }

                HideBoard.Begin(this);
            }
            base.OnClosing(e);
        }
Example #5
0
        private void Window_Activated(object sender, EventArgs e)
        {
            if (IsClosing || IsOpened)
            {
                return;
            }
            IsOpened = true;

            DockIcon.IconName = App.StartupPath + "Container-Opened.png";

            PopupBoard = new Storyboard();
            PopupBoard.Completed += new EventHandler(PopupAnimation_Completed);

            var rect = DockIcon.IconRect;

            var delay = Config.PopupDelay;
            if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
            {
                delay = 5000;
            }

            for (var i = 0; i < spContent.Children.Count; i++)
            {
                var ctrl = spContent.Children[i] as FanIconControl;

                var k = (double)(spContent.Children.Count - 1 - i) / MaxItems;

                var animRotate = new DoubleAnimationUsingKeyFrames();
                animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));
                animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(k * Angle, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animRotate.DecelerationRatio = 0.8;

                var animMargin = new ThicknessAnimationUsingKeyFrames();
                animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
                animMargin.KeyFrames.Add(new SplineThicknessKeyFrame(
                    new Thickness(0, 0, -IconSize / 2 * (1 - Math.Sin((1 - k) * Math.PI / 2)) - (IconSize - rect.Width) / 2,
                        rect.Height + IconSize * (spContent.Children.Count - 1 - i)),
                    KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animMargin.DecelerationRatio = 0.8;

                var animOpacity = new DoubleAnimationUsingKeyFrames();
                animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag);
                animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
                animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animOpacity.DecelerationRatio = 1;

                var animIconSize = new Int32AnimationUsingKeyFrames();
                animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)"));
                animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))));
                animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(IconSize, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animIconSize.DecelerationRatio = 1;

                PopupBoard.Children.Add(animRotate);
                PopupBoard.Children.Add(animMargin);
                PopupBoard.Children.Add(animOpacity);
                PopupBoard.Children.Add(animIconSize);
            }

            PopupBoard.Begin(this);
        }
Example #6
0
        private void PopupAnimation_Completed(object sender, EventArgs e)
        {
            if (HideBoard == null)
            {
                var board = new Storyboard();

                foreach (FanIconControl ctrl in spContent.Children)
                {
                    if (spContent.Children.IndexOf(ctrl) < spContent.Children.Count - 1)
                    {
                        ctrl.GridContent.Effect = ShadowEffect;

                        var anim = new DoubleAnimationUsingKeyFrames();
                        anim.SetValue(Storyboard.TargetNameProperty, ctrl.GridContent.Tag);
                        anim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Effect).(Opacity)"));
                        anim.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))));
                        anim.KeyFrames.Add(new SplineDoubleKeyFrame(0.3, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(800))));

                        board.Children.Add(anim);
                    }
                    if (!ctrl.IsRendered)
                    {
                        ctrl.Render();
                    }
                }

                board.Begin(this);

                Activate();
            }
        }
        private void SendToLocation(DragablzItem dragablzItem, double location)
        {                        
            double activeTarget;
            if (Math.Abs(_getLocation(dragablzItem) - location) < 1.0
                ||
                _activeStoryboardTargetLocations.TryGetValue(dragablzItem, out activeTarget)
                && Math.Abs(activeTarget - location) < 1.0)
            {             
                return;
            }            

            _activeStoryboardTargetLocations[dragablzItem] = location;

            var storyboard = new Storyboard {FillBehavior = FillBehavior.Stop};
            storyboard.WhenComplete(sb =>
            {
                _setLocation(dragablzItem, location);
                sb.Remove(dragablzItem);
                _activeStoryboardTargetLocations.Remove(dragablzItem);
            });

            var timeline = new DoubleAnimationUsingKeyFrames();
            timeline.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(_canvasDependencyProperty));
            timeline.KeyFrames.Add(
                new EasingDoubleKeyFrame(location, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)))
                {
                    EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
                });
            storyboard.Children.Add(timeline);            
            storyboard.Begin(dragablzItem, true);            
        }
Example #8
0
 private void ResetRotation_Click(object sender, RoutedEventArgs e)
 {
     Storyboard s = new Storyboard();
     s.Duration = TimeSpan.FromMilliseconds(500);
     DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();
     SplineDoubleKeyFrame spline = new SplineDoubleKeyFrame() { KeyTime = s.Duration.TimeSpan, Value = 0, KeySpline = new KeySpline() { ControlPoint1 = new System.Windows.Point(0, 0.1), ControlPoint2 = new System.Windows.Point(0.1, 1) } };
     anim.KeyFrames.Add(spline);
     spline.Value = 0;
     anim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Rotation"));
     s.Children.Add(anim);
     Storyboard.SetTarget(anim, Map);
     s.Completed += (sender2, e2) =>
     {
         s.Stop();
         Map.Rotation = 0;
     };
     s.Begin();
 }