Пример #1
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
                {
                    To       = 10,
                    Duration = new Duration(TimeSpan.FromMilliseconds(200))
                };

                piece.BeginAnimation(PiePiece.PushOutProperty, a);
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the event which occurs just before a pie piece tooltip opens
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PiePieceToolTipOpening(object sender, ToolTipEventArgs e)
        {
            PiePiece piece = (PiePiece)sender;

            CollectionView collectionView = (CollectionView)CollectionViewSource.GetDefaultView(DataContext);

            if (collectionView == null)
            {
                return;
            }

            // select the item which this pie piece represents
            int index = (int)piece.Tag;

            if (piece.ToolTip != null)
            {
                ToolTip tip = (ToolTip)piece.ToolTip;
                tip.DataContext = collectionView.GetItemAt(index);
            }
        }
Пример #3
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(DataContext);

            if (collectionView == null)
            {
                return;
            }

            PiePiece piece = sender as PiePiece;

            if (piece == null)
            {
                return;
            }

            // select the item which this pie piece represents
            int index = (int)piece.Tag;

            collectionView.MoveCurrentToPosition(index);
        }