Ejemplo n.º 1
0
        /// <summary>
        /// 添加控件和动画到容器
        /// </summary>
        /// <param name="item">数据项</param>
        public static DependencyObject[] GetAnimation(Point startPoint, Point endPoint, double diameter, PathGeometry pathGeometry, byte[] rgb, Storyboard m_Sb, double pointTime, string m_PointData)
        {
            //grid_Animation.Children.Clear();
            //m_Sb.Children.Clear();
            // Random rd = new Random();

            // 跑动的点
            System.Windows.Controls.Grid grid = GetRunPoint(rgb, m_PointData);

            //到达城市的圆
            Ellipse ell = PathEllipse.GetToEllipse(diameter, diameter, rgb, endPoint);

            StoryBoard.AddPointToStoryboard(grid, ell, m_Sb, pathGeometry, pointTime);

            return(new DependencyObject[] { grid, ell });
        }
Ejemplo n.º 2
0
        public PathControl()
        {
            Uri resourceLocater = new Uri("/PathWpf;component/Themes/PathControl.xaml", System.UriKind.Relative);
            ResourceDictionary resourceDictionary = (ResourceDictionary)Application.LoadComponent(resourceLocater);

            Style = resourceDictionary["PathControlStyle"] as Style;



            Random rd = new Random();

            PointChanges
            .CombineLatest(DiameterChanges, SpeedChanges, (a, c, d) =>
            {
                var startPoint = (a as PathGeometry).Figures.First().StartPoint;
                var endPoint   = (a as PathGeometry).Figures.Last().StartPoint;

                byte[] rgb = new byte[] { (byte)rd.Next(0, 255), (byte)rd.Next(0, 255), (byte)rd.Next(0, 255) };

                Path particlePath = PathEllipse.GetPath(startPoint, endPoint, _storyboard, rgb, (a as PathGeometry), 2);

                return(PathEllipse.GetAnimation(startPoint, endPoint, c, a, rgb, _storyboard, 2, m_PointData));
            })
            .Subscribe(_ =>
            {
                foreach (var x in _)
                {
                    try
                    {
                        contentGrid.Children.Add((UIElement)x);
                    }
                    catch (Exception e)
                    {
                    }
                }
                _storyboard.Begin(this);
            });
        }