Пример #1
0
        /// <summary>
        /// LineThicknessProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnLineThicknessPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine source = d as TrendLine;

            //source.FirePropertyChanged(VcProperties.LineThickness");
            source.UpdateVisual(VcProperties.LineThickness, e.NewValue);
        }
Пример #2
0
        /// <summary>
        /// ValueProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine trendLine = d as TrendLine;


            // Double / Int32 value entered in Managed Code
            if (e.NewValue.GetType().Equals(typeof(Double)) || e.NewValue.GetType().Equals(typeof(Int32)))
            {
                trendLine.InternalNumericValue = Convert.ToDouble(e.NewValue);
            }
            // DateTime value entered in Managed Code
            else if ((e.NewValue.GetType().Equals(typeof(DateTime))))
            {
                trendLine.InternalDateValue = (DateTime)e.NewValue;
            }
            // Double / Int32 / DateTime entered in XAML
            else if ((e.NewValue.GetType().Equals(typeof(String))))
            {
                DateTime dateTimeresult;
                Double   doubleResult;

                if (String.IsNullOrEmpty(e.NewValue.ToString()))
                {
                    trendLine.InternalNumericValue = Double.NaN;
                }
                // Double entered in XAML
                else if (Double.TryParse((string)e.NewValue, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out doubleResult))
                {
                    trendLine.InternalNumericValue = doubleResult;
                }
                // DateTime entered in XAML
                else if (DateTime.TryParse((string)e.NewValue, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTimeresult))
                {
                    trendLine.InternalDateValue = dateTimeresult;
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Invalid Input for AxisMaximum");
                    throw new Exception("Invalid Input for AxisMaximum");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Invalid Input for AxisMaximum");
                throw new Exception("Invalid Input for AxisMaximum");
            }

            trendLine.UpdateVisual(VcProperties.Value, e.NewValue);
        }
Пример #3
0
        public void OrientationDefaultValue()
        {
            Chart chart = new Chart();
            chart.AnimationEnabled = false;
            chart.Width = 500;
            chart.Height = 300;

            Common.CreateAndAddDefaultDataSeries(chart);

            TrendLine trendLine = new TrendLine();
            chart.TrendLines.Add(trendLine);

            EnqueueDelay(_sleepTime);
            CreateAsyncTask(chart,
                () => Assert.AreEqual(Orientation.Horizontal, trendLine.Orientation));

            EnqueueTestComplete();
        }
Пример #4
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.UserControl = ((Apollo.TrafficRateBullet)(target));
                return;

            case 2:
                this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.myTrendlineLabel = ((Visifire.Charts.TrendLine)(target));
                return;

            case 4:
                this.myBulletValue = ((Visifire.Charts.DataPoint)(target));
                return;
            }
            this._contentLoaded = true;
        }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.UserControl = ((Apollo.TrafficRateBullet)(target));
     return;
     case 2:
     this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
     return;
     case 3:
     this.myTrendlineLabel = ((Visifire.Charts.TrendLine)(target));
     return;
     case 4:
     this.myBulletValue = ((Visifire.Charts.DataPoint)(target));
     return;
     }
     this._contentLoaded = true;
 }
Пример #6
0
        public void TestTrendLineWithDateTime()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Random rand = new Random();

            TestPanel.Children.Add(chart);

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(_sleepTime);

            Axis axis = new Axis();
            axis.Interval = 1;
            axis.IntervalType = IntervalTypes.Months;
            chart.AxesX.Add(axis);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Value = new DateTime(2001, 3, 3);
                trendLine.Orientation = Orientation.Vertical;
                chart.TrendLines.Add(trendLine);

                DataSeries dataSeries = new DataSeries();

                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 1, 1), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 2, 2), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 3, 3), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 4, 4), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 5, 5), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 6, 6), YValue = rand.Next(10, 100) });

                chart.Series.Add(dataSeries);
            });

            EnqueueCallback(() =>
            {
                Assert.AreEqual(new DateTime(2001, 3, 3), chart.TrendLines[0].Value);
            });

            EnqueueDelay(_sleepTime);
            EnqueueTestComplete();
        }
Пример #7
0
        public void TestTrendLineInBar()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Random rand = new Random();

            TestPanel.Children.Add(chart);

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(_sleepTime);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Value = new DateTime(2009, 2, 1, 1, 2, 3);
                chart.TrendLines.Add(trendLine);

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Bar;
                dataSeries.XValueType = ChartValueTypes.DateTime;

                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2009, 1, 1, 1, 2, 3), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2009, 2, 1, 4, 5, 6), YValue = rand.Next(10, 100) });
                dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2009, 3, 1, 12, 4, 8), YValue = rand.Next(10, 100) });

                chart.Series.Add(dataSeries);
            });

            EnqueueDelay(_sleepTime);
            EnqueueTestComplete();
        }
Пример #8
0
        public void TestTrendLineWithDateTime()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Random rand = new Random();

            Axis axis = new Axis();
            axis.Interval = 1;
            axis.IntervalType = IntervalTypes.Months;
            chart.AxesX.Add(axis);

       
            TrendLine trendLine = new TrendLine();
            trendLine.Value = new DateTime(2001, 3, 3);
            trendLine.Orientation = Orientation.Vertical;
            chart.TrendLines.Add(trendLine);

            DataSeries dataSeries = new DataSeries();

            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 1, 1), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 2, 2), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 3, 3), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 4, 4), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 5, 5), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2001, 6, 6), YValue = rand.Next(10, 100) });

            chart.Series.Add(dataSeries);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(new DateTime(2001, 3, 3), chart.TrendLines[0].Value);
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
Пример #9
0
        public void TestTrendLineInBar()
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 300;

            _isLoaded = false;
            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            Random rand = new Random();

            TrendLine trendLine = new TrendLine();
            trendLine.Value = new DateTime(2009, 2, 1, 1, 2, 3);
            chart.TrendLines.Add(trendLine);

            DataSeries dataSeries = new DataSeries();
            dataSeries.RenderAs = RenderAs.Bar;
            dataSeries.XValueType = ChartValueTypes.DateTime;

            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2009, 1, 1, 1, 2, 3), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2009, 2, 1, 4, 5, 6), YValue = rand.Next(10, 100) });
            dataSeries.DataPoints.Add(new DataPoint() { XValue = new DateTime(2009, 3, 1, 12, 4, 8), YValue = rand.Next(10, 100) });

            chart.Series.Add(dataSeries);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                window.Dispatcher.InvokeShutdown();
                window.Close();
            }
        }
Пример #10
0
        public void TestTrendLineSerialization()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;

            _isLoaded = false;

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            TrendLine trendLine = new TrendLine();
            trendLine.Value = 10;
            chart.TrendLines.Add(trendLine);

            DataSeries ds = new DataSeries();
            DataPoint dp = new DataPoint();
            dp.YValue = 20;
            ds.DataPoints.Add(dp);
            chart.Series.Add(ds);

            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                MessageBox.Show(XamlWriter.Save(trendLine));
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }
Пример #11
0
        /// <summary>
        /// OrientationProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnOrientationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine source = d as TrendLine;

            source.FirePropertyChanged(VcProperties.Orientation);
        }
Пример #12
0
        /// <summary>
        /// AxisTypeProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnAxisTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine source = d as TrendLine;

            source.FirePropertyChanged(VcProperties.AxisType);
        }
Пример #13
0
        /// <summary>
        /// ShadowEnabledProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnShadowEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine trendLine = d as TrendLine;

            trendLine.UpdateVisual(VcProperties.ShadowEnabled, e.NewValue);
        }
Пример #14
0
        /// <summary>
        /// LineStyleProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnLineStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine source = d as TrendLine;

            source.UpdateVisual(VcProperties.LineStyle, e.NewValue);
        }
Пример #15
0
        public void TestTrendLinesCollectionChanged()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            chart.AnimationEnabled = false;

            Int32 trendLinesAdded = 0;

            _isLoaded = false;

            Common.CreateAndAddDefaultDataSeries(chart);

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            TestPanel.Children.Add(chart);

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(1000);

            chart.TrendLines.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
            =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    trendLinesAdded += e.NewItems.Count;
                    Assert.AreEqual(1, e.NewItems.Count);
                }
            };

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Orientation = Orientation.Horizontal;
                trendLine.InternalNumericValue = 30;
                chart.TrendLines.Add(trendLine);
            });

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Orientation = Orientation.Vertical;
                trendLine.InternalNumericValue = 3;
                chart.TrendLines.Add(trendLine);
            });

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Orientation = Orientation.Vertical;
                trendLine.InternalNumericValue = 4;
                chart.TrendLines.Add(trendLine);
            });

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Orientation = Orientation.Horizontal;
                trendLine.InternalNumericValue = 60;
                chart.TrendLines.Add(trendLine);
            });

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Orientation = Orientation.Horizontal;
                trendLine.InternalNumericValue = 80;
                chart.TrendLines.Add(trendLine);
            });

            EnqueueConditional(() => { return _isLoaded; });
            EnqueueDelay(1000);

            EnqueueCallback(() =>
            {
                TrendLine trendLine = new TrendLine();
                trendLine.Orientation = Orientation.Vertical;
                trendLine.InternalNumericValue = 1;
                chart.TrendLines.Add(trendLine);
            });

            EnqueueDelay(1000);
            EnqueueTestComplete();
        }
Пример #16
0
        /// <summary>
        /// HrefProperty changed call back function
        /// </summary>
        /// <param name="d">DependencyObject</param>
        /// <param name="e">DependencyPropertyChangedEventArgs</param>
        private static void OnHrefChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TrendLine trendLine = d as TrendLine;

            trendLine.FirePropertyChanged(VcProperties.Href);
        }
Пример #17
0
        public void TestTrendLinesCollectionChanged()
        {
            Chart chart = new Chart();
            chart.Width = 400;
            chart.Height = 300;
            

            Int32 trendLinesAdded = 0;

            _isLoaded = false;

            Common.CreateAndAddDefaultDataSeries(chart);

            chart.Loaded += new RoutedEventHandler(chart_Loaded);

            chart.TrendLines.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
            =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    trendLinesAdded += e.NewItems.Count;
                    Assert.AreEqual(1, e.NewItems.Count);
                }
            };

            TrendLine trendLine = new TrendLine();
            trendLine.Orientation = Orientation.Horizontal;
            trendLine.Value = 30;
            chart.TrendLines.Add(trendLine);

            trendLine = new TrendLine();
            trendLine.Orientation = Orientation.Vertical;
            trendLine.Value = 3;
            chart.TrendLines.Add(trendLine);

            trendLine = new TrendLine();
            trendLine.Orientation = Orientation.Vertical;
            trendLine.Value = 4;
            chart.TrendLines.Add(trendLine);

            trendLine = new TrendLine();
            trendLine.Orientation = Orientation.Horizontal;
            trendLine.Value = 60;
            chart.TrendLines.Add(trendLine);

            trendLine = new TrendLine();
            trendLine.Orientation = Orientation.Horizontal;
            trendLine.Value = 80;
            chart.TrendLines.Add(trendLine);

            trendLine = new TrendLine();
            trendLine.Orientation = Orientation.Vertical;
            trendLine.Value = 1;
            chart.TrendLines.Add(trendLine);
        
            Window window = new Window();
            window.Content = chart;
            window.Show();
            if (_isLoaded)
            {
                Assert.AreEqual(6, trendLinesAdded);
            }

            window.Dispatcher.InvokeShutdown();
            window.Close();
        }