Exemplo n.º 1
0
        public void MouseLeftButtonUp(object eventArgs)
        {
            _mouseUpTime = DateTime.Now;
            var e      = eventArgs as MouseButtonEventArgs;
            var sender = e.Source;

            ChartControl chart;

            if (sender is ChartControl)
            {
                chart = sender as ChartControl;
            }
            else
            {
                chart = ((SimpleDiagram2D)sender).Parent as ChartControl;
            }

            var hitInfo = chart.CalcHitInfo(e.GetPosition(chart));

            if (hitInfo?.SeriesPoint == null || (_mouseUpTime - _mouseDownTime).TotalMilliseconds > 180)
            {
                return;
            }

            if (_selectedHitInfo != null)
            {
                PieSeries.GetExplodedDistance(_selectedHitInfo.SeriesPoint);
                var selectedStoryBoard = new Storyboard();
                var selectedAnimation  = new DoubleAnimation
                {
                    Duration = new Duration(new TimeSpan(0, 0, 0, 0, 400)),
                    To       = 0
                };
                selectedStoryBoard.Children.Add(selectedAnimation);
                Storyboard.SetTarget(selectedAnimation, _selectedHitInfo.SeriesPoint);
                Storyboard.SetTargetProperty(selectedAnimation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
                selectedStoryBoard.Begin();
            }

            var distance   = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint);
            var storyBoard = new Storyboard();
            var animation  = new DoubleAnimation
            {
                Duration = new Duration(new TimeSpan(0, 0, 0, 0, 400)),
                To       = distance > 0 ? 0 : 0.4
            };

            storyBoard.Children.Add(animation);
            Storyboard.SetTarget(animation, hitInfo.SeriesPoint);
            Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
            storyBoard.Begin();

            _selectedHitInfo = hitInfo;
        }
        void Chart_MouseUp(object sender, MouseButtonEventArgs e)
        {
            ChartHitInfo hitInfo = Chart.CalcHitInfo(e.GetPosition(Chart));

            if (hitInfo == null || hitInfo.SeriesPoint == null || !IsClick(DateTime.Now))
            {
                return;
            }
            double     distance   = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint);
            Storyboard storyBoard = new Storyboard();
            var        animation  = distance > 0 ? CollapseAnimation : ExpandAnimation;

            storyBoard.Children.Add(animation);
            Storyboard.SetTarget(animation, hitInfo.SeriesPoint);
            Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
            storyBoard.Begin();
        }
Exemplo n.º 3
0
        void chart_MouseUp(object sender, MouseButtonEventArgs e)
        {
            ChartHitInfo hitInfo = chart.CalcHitInfo(e.GetPosition(chart));

            if (hitInfo == null || hitInfo.SeriesPoint == null || PieSeries.GetExplodedDistance(hitInfo.SeriesPoint) > 0)
            {
                return;
            }
            foreach (SeriesPoint point in chart.Diagram.Series[0].Points)
            {
                if (PieSeries.GetExplodedDistance(point) > 0 && point != hitInfo.SeriesPoint)
                {
                    AnimateExploding(point, true);
                }
            }
            AnimateExploding(hitInfo.SeriesPoint, false);
            UpdateChargeInfo(hitInfo.SeriesPoint);
        }
        void AnimationEnd(object sender, Point e)
        {
            ChartHitInfo hitInfo = (sender as ChartControl).CalcHitInfo(e);

            rotate = false;
            if (hitInfo == null || hitInfo.SeriesPoint == null || !IsClick(DateTime.Now))
            {
                return;
            }
            double          distance   = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint);
            Storyboard      storyBoard = new Storyboard();
            DoubleAnimation animation  = new DoubleAnimation();

            animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 300));
            animation.To       = distance > 0 ? 0 : 0.3;
            storyBoard.Children.Add(animation);
            Storyboard.SetTarget(animation, hitInfo.SeriesPoint);
            Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
            storyBoard.Begin();
        }
Exemplo n.º 5
0
        void AnimateExploding(SeriesPoint seriesPoint, bool isDealayedStart)
        {
            Storyboard storyBoard = new Storyboard();
            DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();

            if (isDealayedStart)
            {
                animation.KeyFrames.Add(new LinearDoubleKeyFrame(explodeDistance, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 300))));
                animation.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 600))));
            }
            else
            {
                double distanceTo = PieSeries.GetExplodedDistance(seriesPoint) > 0 ? 0 : explodeDistance;
                animation.KeyFrames.Add(new LinearDoubleKeyFrame(distanceTo, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 300))));
            }
            storyBoard.Children.Add(animation);
            Storyboard.SetTarget(animation, seriesPoint);
            Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
            storyBoard.Begin();
        }
        /// <summary>
        /// 环形图左键放开事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chart_MouseUp(object sender, MouseButtonEventArgs e)
        {
            ChartControl chartName = sender as ChartControl;
            ChartHitInfo hitInfo   = chartName.CalcHitInfo(e.GetPosition(chartName));

            if (hitInfo == null || hitInfo.SeriesPoint == null)
            {
                return;
            }
            double          distance   = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint);
            Storyboard      storyBoard = new Storyboard();
            DoubleAnimation animation  = new DoubleAnimation();

            animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 300));
            animation.To       = distance > 0 ? 0 : 0.3;
            storyBoard.Children.Add(animation);
            Storyboard.SetTarget(animation, hitInfo.SeriesPoint);
            Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
            storyBoard.Begin();

            e.Handled = true;
        }
Exemplo n.º 7
0
        void chart_MouseUp(object sender, MouseButtonEventArgs e)
        {
            isLeftMouseButtonReleased = true;
            if (!IsClick(e.Timestamp))
            {
                return;
            }
            ChartHitInfo hitInfo = chart.CalcHitInfo(e.GetPosition(chart));

            if (hitInfo == null || hitInfo.SeriesPoint == null)
            {
                return;
            }
            double            distance   = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint);
            AnimationTimeline animation  = distance > 0 ? (AnimationTimeline)TryFindResource("CollapseAnimation") : (AnimationTimeline)TryFindResource("ExplodeAnimation");
            Storyboard        storyBoard = new Storyboard();

            storyBoard.Children.Add(animation);
            Storyboard.SetTarget(animation, hitInfo.SeriesPoint);
            Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty));
            storyBoard.Begin();
        }