/// <summary>
 /// Handles data point state property change.
 /// </summary>
 /// <param name="dataPoint">The data point.</param>
 /// <param name="oldValue">The old value.</param>
 /// <param name="newValue">The new value.</param>
 protected virtual void OnDataPointStateChanged(DataPoint dataPoint, DataPointState oldValue, DataPointState newValue)
 {
     if (dataPoint.State == DataPointState.Hidden)
     {
         DetachEventHandlersFromDataPoint(dataPoint);
         PlotArea.Children.Remove(dataPoint);
     }
 }
示例#2
0
        /// <summary>
        /// Called when the value of the State property changes.
        /// </summary>
        /// <param name="d">Control that changed its State.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnStatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataPoint      source   = (DataPoint)d;
            DataPointState oldValue = (DataPointState)e.OldValue;
            DataPointState newValue = (DataPointState)e.NewValue;

            source.OnStatePropertyChanged(oldValue, newValue);
        }
        /// <summary>
        /// Called when the value of the State property changes.
        /// </summary>
        /// <param name="oldValue">The value to be replaced.</param>
        /// <param name="newValue">The new value.</param>
        protected virtual void OnStatePropertyChanged(DataPointState oldValue, DataPointState newValue)
        {
            if (!IsCoercingState)
            {
                if (newValue < oldValue)
                {
                    // If we've somehow gone backwards in the life cycle (other
                    // than when we go back to normal from updating) coerce to
                    // old value.
                    IsCoercingState = true;
                    this.State      = oldValue;
                    IsCoercingState = false;
                }
                else
                {
                    // Update selection
                    if (newValue > DataPointState.Normal)
                    {
                        this.IsSelectionEnabled = false;
                    }

                    // Start state transition
                    bool transitionStarted = false;
                    switch (newValue)
                    {
                    case DataPointState.Showing:
                    case DataPointState.Hiding:
                        transitionStarted = GoToCurrentRevealState();
                        break;
                    }

                    // Fire Changed event
                    RoutedPropertyChangedEventHandler <DataPointState> handler = this.StateChanged;
                    if (handler != null)
                    {
                        handler(this, new RoutedPropertyChangedEventArgs <DataPointState>(oldValue, newValue));
                    }

                    // Change state if no transition started
                    if (!transitionStarted && _templateApplied)
                    {
                        switch (newValue)
                        {
                        case DataPointState.Showing:
                            State = DataPointState.Normal;
                            break;

                        case DataPointState.Hiding:
                            State = DataPointState.Hidden;
                            break;
                        }
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        ///     Called when the value of the State property changes.
        /// </summary>
        /// <param name="oldValue">The value to be replaced.</param>
        /// <param name="newValue">The new value.</param>
        protected virtual void OnStatePropertyChanged(DataPointState oldValue, DataPointState newValue)
        {
            // If state ever goes to or past PendingRemoval, the DataPoint is no longer active
            if (newValue >= DataPointState.PendingRemoval)
            {
                IsActive = false;
            }

            // Update selection
            if (DataPointState.Normal < newValue)
            {
                IsSelectionEnabled = false;
            }

            // Start state transition
            bool transitionStarted = false;

            switch (newValue)
            {
            case DataPointState.Showing:
            case DataPointState.Hiding:
                transitionStarted = GoToCurrentRevealState();
                break;
            }

            // Fire Changed event
            RoutedPropertyChangedEventHandler <DataPointState> handler = StateChanged;

            if (handler != null)
            {
                handler(this, new RoutedPropertyChangedEventArgs <DataPointState>(oldValue, newValue));
            }

            // Change state if no transition started
            if (!transitionStarted)
            {
                switch (newValue)
                {
                case DataPointState.Showing:
                    if (_appliedTemplate)
                    {
                        State = DataPointState.Normal;
                    }
                    break;

                case DataPointState.Hiding:
                    State = DataPointState.Hidden;
                    break;
                }
            }
        }
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IList <DataPoint> dataPoints, DataPointState newState)
        {
            if (PlotArea == null || dataPoints.Count == 0)
            {
                return;
            }

            string     guid = Guid.NewGuid().ToString();
            Storyboard stateChangeStoryBoard = new Storyboard();

            stateChangeStoryBoard.Completed +=
                (sender, args) =>
            {
                PlotArea.Resources.Remove(guid);
            };

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                // Create an Animation
                ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, new PropertyPath("State"));

                // Create a key frame
                DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
                discreteObjectKeyFrame.Value = newState;

                // Create the specified animation type
                switch (AnimationSequence)
                {
                case AnimationSequence.Simultaneous:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
                    break;

                case AnimationSequence.FirstToLast:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPoints.Count));
                    break;

                case AnimationSequence.LastToFirst:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPoints.Count - count - 1) / dataPoints.Count));
                    break;
                }

                // Add the Animation to the Storyboard
                objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });

            _storyBoardQueue.Enqueue(stateChangeStoryBoard);
        }
示例#6
0
 /// <summary>
 /// Handles data point state property change.
 /// </summary>
 /// <param name="dataPoint">The data point.</param>
 /// <param name="oldValue">The old value.</param>
 /// <param name="newValue">The new value.</param>
 protected virtual void OnDataPointStateChanged(DataPoint dataPoint, DataPointState oldValue, DataPointState newValue)
 {
     if (dataPoint.State == DataPointState.Hidden)
     {
         DetachEventHandlersFromDataPoint(dataPoint);
         PlotArea.Children.Remove(dataPoint);
     }
 }
示例#7
0
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="dataPointCount">The number of data points in the sequence.</param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IEnumerable<DataPoint> dataPoints, int dataPointCount, DataPointState newState)
        {
            if (PlotArea == null || dataPointCount == 0)
            {
                return;
            }

            string guid = Guid.NewGuid().ToString();
            Storyboard stateChangeStoryBoard = new Storyboard();
            stateChangeStoryBoard.Completed +=
                (sender, args) =>
                {
                    PlotArea.Resources.Remove(guid);
                };

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                // Create an Animation
                ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, new PropertyPath("State"));

                // Create a key frame
                DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
                discreteObjectKeyFrame.Value = newState;

                // Create the specified animation type
                switch (AnimationSequence)
                {
                    case AnimationSequence.Simultaneous:
                        discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
                        break;
                    case AnimationSequence.FirstToLast:
                        discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPointCount));
                        break;
                    case AnimationSequence.LastToFirst:
                        discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count - 1) / dataPointCount));
                        break;
                }

                // Add the Animation to the Storyboard
                objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });

            _storyBoardQueue.Enqueue(stateChangeStoryBoard);
        }
示例#8
0
        /// <summary>
        /// Called when the value of the State property changes.
        /// </summary>
        /// <param name="oldValue">The value to be replaced.</param>
        /// <param name="newValue">The new value.</param>
        protected virtual void OnStatePropertyChanged(DataPointState oldValue, DataPointState newValue)
        {
            if (!IsCoercingState)
            {
                if (newValue < oldValue)
                {
                    // If we've somehow gone backwards in the life cycle (other
                    // than when we go back to normal from updating) coerce to
                    // old value.
                    IsCoercingState = true;
                    this.State = oldValue;
                    IsCoercingState = false;
                }
                else
                {
                    // Update selection
                    if (newValue > DataPointState.Normal)
                    {
                        this.IsSelectionEnabled = false;
                    }

                    // Start state transition
                    bool transitionStarted = false;
                    switch (newValue)
                    {
                        case DataPointState.Showing:
                        case DataPointState.Hiding:
                            transitionStarted = GoToCurrentRevealState();
                            break;
                    }

                    // Fire Changed event
                    RoutedPropertyChangedEventHandler<DataPointState> handler = this.StateChanged;
                    if (handler != null)
                    {
                        handler(this, new RoutedPropertyChangedEventArgs<DataPointState>(oldValue, newValue));
                    }

                    // Change state if no transition started
                    if (!transitionStarted && _templateApplied)
                    {
                        switch (newValue)
                        {
                            case DataPointState.Showing:
                                State = DataPointState.Normal;
                                break;
                            case DataPointState.Hiding:
                                State = DataPointState.Hidden;
                                break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="dataPointCount">The number of data points in the sequence.</param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IEnumerable<DataPoint> dataPoints, int dataPointCount, DataPointState newState)
        {
            if (PlotArea == null || dataPointCount == 0)
            {
                return;
            }

            Storyboard stateChangeStoryBoard = new Storyboard();

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                // Create an Animation
                ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
                objectAnimationUsingKeyFrames.EnableDependentAnimation = true;
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, "State");

                // Create a key frame
                DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
                discreteObjectKeyFrame.Value = (object)((int)newState);

                // Create the specified animation type
                switch (AnimationSequence)
                {
                    case AnimationSequence.Simultaneous:
                        discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
                        break;
                    case AnimationSequence.FirstToLast:
                        discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPointCount));
                        break;
                    case AnimationSequence.LastToFirst:
                        discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count - 1) / dataPointCount));
                        break;
                }

                // Add the Animation to the Storyboard
                objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });
            //stateChangeStoryBoard.Duration = new Duration(AnimationSequence.Simultaneous == AnimationSequence ?
            //    TimeSpan.FromTicks(1) :
            //    TimeSpan.FromMilliseconds(1001));

            _storyBoardQueue.Enqueue(
                stateChangeStoryBoard,
                (sender, args) =>
                {
                    stateChangeStoryBoard.Stop();
                });
        }
 /// <summary>
 /// Handles the StateChanged event of a DataPoint.
 /// </summary>
 /// <param name="sender">Event source.</param>
 /// <param name="e">Event arguments.</param>
 private void DataPointStateChanged(object sender, DataPointState oldValue,DataPointState newValue)
 {
     DataPoint dataPoint = (DataPoint)sender;
     if (DataPointState.Hidden == dataPoint.State)
     {
         DataItems.Remove(DataItems.Where(di => di.DataPoint == dataPoint).Single());
         RemovedDataItems();
     }
 }
 /// <summary>
 /// Handles data point state property change.
 /// </summary>
 /// <param name="dataPoint">The data point.</param>
 /// <param name="oldValue">The old value.</param>
 /// <param name="newValue">The new value.</param>
 protected virtual void OnDataPointStateChanged(DataPoint dataPoint, DataPointState oldValue, DataPointState newValue)
 {
    
 }
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="dataPointCount">The number of data points in the sequence.</param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IEnumerable<DataPoint> dataPoints, int dataPointCount, DataPointState newState)
        {
            if (PlotArea == null || dataPointCount == 0)
            {
                return;
            }

            Storyboard stateChangeStoryBoard = new Storyboard();

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                dataPoint.Opacity = 0;
                // Create an Animation
                DoubleAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                //TO-DO : Understand what is this 
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, "Opacity");


                EasingDoubleKeyFrame BeginKeyFrame = new EasingDoubleKeyFrame();
                BeginKeyFrame.Value = 0;
                BeginKeyFrame.EasingFunction = new ElasticEase();

                EasingDoubleKeyFrame EndKeyFrame = new EasingDoubleKeyFrame();
                EndKeyFrame.Value = 100;
                EndKeyFrame.EasingFunction =new ElasticEase();

                // Create the specified animation type
                switch (AnimationSequence)
                {
                    case AnimationSequence.Simultaneous:
                        BeginKeyFrame.KeyTime = TimeSpan.Zero;
                        EndKeyFrame.KeyTime = TimeSpan.FromSeconds(1);
                        break;
                    case AnimationSequence.FirstToLast:
                        BeginKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPointCount));
                        EndKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * (((double)count+1)/ dataPointCount));
                        break;
                    case AnimationSequence.LastToFirst:
                        BeginKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count - 1) / dataPointCount));
                        EndKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count) / dataPointCount));

                        break;
                }
                
                objectAnimationUsingKeyFrames.KeyFrames.Add(BeginKeyFrame);
                objectAnimationUsingKeyFrames.KeyFrames.Add(EndKeyFrame);
                objectAnimationUsingKeyFrames.Duration = new TimeSpan(0, 0, 1);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });
            stateChangeStoryBoard.Duration = new TimeSpan(0, 1, 0);
            _storyBoardQueue.Enqueue(
                stateChangeStoryBoard,
                (sender, args) =>
                {
                    //stateChangeStoryBoard.Stop();
                });
        }
 void OnDataPointStateChanged(object sender, DataPointState oldValue,DataPointState newValue)
 {
     DataPoint dataPoint = (DataPoint)sender;
     if (dataPoint.State == DataPointState.Hidden)
     {
         DetachEventHandlersFromDataPoint(dataPoint);
         PlotArea.Children.Remove(dataPoint);
     }
 }
示例#14
0
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="dataPointCount">The number of data points in the sequence.</param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IEnumerable <DataPoint> dataPoints, int dataPointCount, DataPointState newState)
        {
            if (PlotArea == null || dataPointCount == 0)
            {
                return;
            }

            Storyboard stateChangeStoryBoard = new Storyboard();

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                // Create an Animation
                ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, new PropertyPath("State"));

                // Create a key frame
                DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
                discreteObjectKeyFrame.Value = newState;

                // Create the specified animation type
                switch (AnimationSequence)
                {
                case AnimationSequence.Simultaneous:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
                    break;

                case AnimationSequence.FirstToLast:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPointCount));
                    break;

                case AnimationSequence.LastToFirst:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count - 1) / dataPointCount));
                    break;
                }

                // Add the Animation to the Storyboard
                objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });
            stateChangeStoryBoard.Duration = new Duration(AnimationSequence.Simultaneous == AnimationSequence ?
                                                          TimeSpan.FromTicks(1) :
                                                          TimeSpan.FromMilliseconds(1001));

            _storyBoardQueue.Enqueue(
                stateChangeStoryBoard,
                (sender, args) =>
            {
                stateChangeStoryBoard.Stop();
            });
        }