Ejemplo n.º 1
0
 public void Test_PropertyNameBinding_EmptyPropertyName()
 {
     Assert.ThrowsException <ArgumentException>(() => {
         PropertyNameDataPointBinding binding = new PropertyNameDataPointBinding();
         binding.PropertyName = null;
     });
 }
Ejemplo n.º 2
0
 public void Test_PropertyNameBinding_MissingProperty()
 {
     Assert.ThrowsException <NullReferenceException>(() => {
         PropertyNameDataPointBinding binding = new PropertyNameDataPointBinding();
         binding.PropertyName = "Wrong";
         binding.GetValue(new BusinessObject());
     });
 }
Ejemplo n.º 3
0
        public void Test_PropertyNameBinding_DynamicObject()
        {
            PropertyNameDataPointBinding binding = new PropertyNameDataPointBinding();

            binding.PropertyName = "Value";

            dynamic obj = new MyDynamicObject();

            obj.Value = 1;

            Assert.AreEqual <double>(1, (double)binding.GetValue(obj), "DynamicObject Value not looked-up correctly");
        }
Ejemplo n.º 4
0
        public void Test_PropertyNameBinding()
        {
            PropertyNameDataPointBinding binding = new PropertyNameDataPointBinding();

            binding.PropertyName = "Value";

            BusinessObject obj = new BusinessObject()
            {
                Value = 1
            };

            Assert.AreEqual <double>(1, (double)binding.GetValue(obj), "Value not looked-up correctly");
        }
Ejemplo n.º 5
0
        public void Test_PropertyNameBinding_PropertyChanged()
        {
            bool propertyChangedFired = false;

            PropertyNameDataPointBinding binding = new PropertyNameDataPointBinding();

            binding.PropertyChanged += (sender, args) =>
            {
                propertyChangedFired = true;
                Assert.AreEqual <string>("PropertyName", args.PropertyName);
            };

            binding.PropertyName = "Value";

            Assert.IsTrue(propertyChangedFired);
        }
 private void UpdateSeries()
 {
     var m = DataContext as HistoricalChartViewModel;
     if (m != null)
     {
         this.Chart.Series.Clear();
         for (int i = 0; i < m.Data.Count; i++)
         {
             var cat = new PropertyNameDataPointBinding() { PropertyName = "Time" };
             var val = new PropertyNameDataPointBinding() { PropertyName = "Value" };
             var ls = new LineSeries();
             ls.CategoryBinding = cat;
             ls.ValueBinding = val;
             ls.ItemsSource = m.Data[i];
             ls.Stroke = new SolidColorBrush(m.Legend[i].Color);
             ls.StrokeThickness = 1;
             this.Chart.Series.Add(ls);
         }
     }
 }
Ejemplo n.º 7
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            chart.Series.Clear();
            foreach (var counter in viewModel.Counters)
            {
                if (counter.Points.Count > 0)
                {
                    Dictionary<DateTime, int> points = new Dictionary<DateTime, int>();
                    var span = counter.Points.Last() - counter.Points.First();
                    var bucket = span.TotalDays;
                    foreach (var point in counter.Points)
                        if (!points.ContainsKey(point.Date))
                            points.Add(point.Date, 1);
                        else
                            points[point.Date]++;
                    var shaped = points.Select(u => new TimePoint{ Date = u.Key, Value = u.Value }).ToList();

                    PropertyNameDataPointBinding categoryBinding = new PropertyNameDataPointBinding();
                    categoryBinding.PropertyName = "Date";

                    PropertyNameDataPointBinding valueBinding = new PropertyNameDataPointBinding();
                    valueBinding.PropertyName = "Value";

                    var series = new LineSeries() { ItemsSource = shaped, DisplayName = counter.Text, CategoryBinding = categoryBinding, ValueBinding = valueBinding, StrokeThickness = 2, Stroke = new SolidColorBrush(Colors.Orange)};
                    chart.Series.Add(series);
                }
            }
        }