示例#1
0
        private void MakePieVisible(PiePiece pClickedPiePiece)
        {
            PiePiece lLastClickedPiePiece = PieList.FirstOrDefault(x => x.PushOut > 0.0);

            if (lLastClickedPiePiece != null)
            {
                MakePieInvisible(lLastClickedPiePiece);
            }
            DoubleAnimation lShow = new DoubleAnimation(BackgroundPiece.Radius * 0.04, new Duration(TimeSpan.FromMilliseconds(IsAnimate ? 200 : 0)));

            pClickedPiePiece.BeginAnimation(PiePiece.PushOutProperty, lShow);
        }
示例#2
0
        private void AnimateAngle(PiePiece pPiePiece, DependencyProperty pDependencyProperty, double pAngle, EventHandler pEventHandler = null)
        {
            double          oldAngle  = (double)pPiePiece.GetValue(pDependencyProperty);
            DoubleAnimation animation = new DoubleAnimation(oldAngle, pAngle, new Duration(TimeSpan.FromMilliseconds(IsAnimate ? 500 : 0)), FillBehavior.HoldEnd);

            animation.EasingFunction = EasingFunction;
            if (pEventHandler != null)
            {
                animation.Completed += pEventHandler;
            }
            pPiePiece.BeginAnimation(pDependencyProperty, animation);
        }
示例#3
0
        /// <summary>
        /// Handles the event which occurs when the selected item has changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CollectionViewCurrentChanged(object sender, EventArgs e)
        {
            CollectionView collectionView = (CollectionView)sender;

            if (collectionView != null && collectionView.CurrentPosition >= 0 && collectionView.CurrentPosition <= piePieces.Count)
            {
                PiePiece        piece = piePieces[collectionView.CurrentPosition];
                DoubleAnimation a     = new DoubleAnimation();
                a.To       = 10;
                a.Duration = new Duration(TimeSpan.FromMilliseconds(500));
                piece.BeginAnimation(PiePiece.PushOutProperty, a);
            }
        }
示例#4
0
        /// <summary>
        /// Handles the MouseUp event from the individual Pie Pieces
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PiePieceMouseUp(object sender, MouseButtonEventArgs e)
        {
            CollectionView collectionView = (CollectionView)CollectionViewSource.GetDefaultView(this.DataContext);
            //Индекс для определения текущей позиции
            int collectionIndex = collectionView.CurrentPosition;

            if (collectionView == null)
            {
                return;
            }
            PiePiece piece = sender as PiePiece;

            if (piece == null)
            {
                return;
            }
            // Выбираем нужный кусок пирога
            int index = (int)piece.Tag;

            if (collectionIndex == index)
            {
                if (collectionView != null && collectionView.CurrentPosition >= 0 && collectionView.CurrentPosition <= piePieces.Count)
                {
                    DoubleAnimation a = new DoubleAnimation();
                    if (piece.PushOut == 10)
                    {
                        a.To       = 0;
                        a.Duration = new Duration(TimeSpan.FromMilliseconds(300));
                    }
                    else
                    {
                        a.To       = 10;
                        a.Duration = new Duration(TimeSpan.FromMilliseconds(500));
                    }
                    piece.BeginAnimation(PiePiece.PushOutProperty, a);
                }
            }
            else
            {
                collectionView.MoveCurrentToPosition(index);
            }
        }
示例#5
0
        private void AddNewPiePiece(FingerEventArgs finger)
        {
            DispatcherTimer startTimer = new DispatcherTimer();
            startTimer.Tick += new EventHandler(startTimer_Elapsed);
            startTimer.Interval = TimeSpan.FromMilliseconds(this._holdTime);
            _holdFingerList.Add(finger.FingerID, startTimer);
            _holdFingerPositionList.Add(finger.FingerID, finger.Position);

            PiePiece pie = new PiePiece();
            pie.Radius = 24;
            pie.InnerRadius = 12;
            pie.Fill = Brushes.Beige;
            pie.Opacity = .8d;
            Canvas.SetLeft(pie, finger.Position.X);
            Canvas.SetTop(pie, finger.Position.Y);
            PopupStage.Children.Add(pie);
            pie.BeginAnimation(PiePiece.WedgeAngleProperty, new DoubleAnimation(360, new Duration(TimeSpan.FromMilliseconds(this._holdTime))));
            startTimer.Tag = pie;
            startTimer.Start();
        }
示例#6
0
        private void MakePieInvisible(PiePiece pClickedPiePiece)
        {
            DoubleAnimation lHide = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(IsAnimate ? 200 : 0)));

            pClickedPiePiece.BeginAnimation(PiePiece.PushOutProperty, lHide);
        }