Ejemplo n.º 1
0
 public HSARHViewModel(double pressure, SeriesCollection seriesCollection, VisualElementsCollection cartesianVisuals)
 {
     _pressure         = pressure;
     _seriesCollection = seriesCollection;
     _cartesianVisuals = cartesianVisuals;
     InitChart();
 }
Ejemplo n.º 2
0
        public UiElementsViewModel()
        {
            Values    = DataProvider.Points.AsChartValues();
            Formatter = x =>
            {
                long ticks = (long)x;
                if (x < DateTime.MinValue.Ticks)
                {
                    ticks = DateTime.MinValue.Ticks;
                }
                if (x > DateTime.MaxValue.Ticks)
                {
                    ticks = DateTime.MaxValue.Ticks;
                }
                return(new DateTime(ticks).ToString("dd MMM"));
            };
            Step = TimeSpan.FromDays(1).Ticks * 2;

            //get some random points to add an event in the chart.
            var e1 = Values.Skip(15).Take(1).First();
            var e2 = Values.Skip(35).Take(1).First();

            SelectedVisualElement = new VisualElement
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Bottom,
                UIElement           = new SelectedItemControl(),
                IsScaledWithChart   = true,
                ScaleXRatio         = TimeSpan.FromDays(1).Ticks,
                ScaleYRatio         = 200
            };

            Visuals = new VisualElementsCollection
            {
                new VisualElement
                {
                    X = e1.DateTime.Ticks,
                    Y = e1.Value,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Top,
                    UIElement           = new EventAControl()
                },
                new VisualElement
                {
                    X = e2.DateTime.Ticks,
                    Y = e2.Value,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Top,
                    UIElement           = new EventBControl()
                },
                SelectedVisualElement
            };
        }
Ejemplo n.º 3
0
        public JimmyTheTestsGuy()
        {
            InitializeComponent();

            From = 10;
            To   = 50;

            Visuals = new VisualElementsCollection
            {
                new VisualElement
                {
                    X         = 3,
                    Y         = 3,
                    UIElement = new TextBlock
                    {
                        Text = i++.ToString()
                    }
                },
                new VisualElement
                {
                    X         = 3,
                    Y         = 3,
                    UIElement = new TextBlock
                    {
                        Text = i++.ToString()
                    }
                },
                new VisualElement
                {
                    X         = 3,
                    Y         = 3,
                    UIElement = new TextBlock
                    {
                        Text = i++.ToString()
                    }
                }
            };

            DataContext = this;
        }
Ejemplo n.º 4
0
        public UiElementsViewModel()
        {
            Values    = DataProvider.Points.AsChartValues();
            Formatter = x => new DateTime((long)x).ToString("dd MMM");
            Step      = TimeSpan.FromDays(1).Ticks * 2;

            //lets get some random points to add an even in the chart.
            var e1 = Values.Skip(15).Take(1).First();
            var e2 = Values.Skip(35).Take(1).First();

            SelectedVisualElement = new VisualElement
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom,
                UIElement           = new SelectedItemControl()
            };

            Visuals = new VisualElementsCollection
            {
                new VisualElement
                {
                    X = e1.DateTime.Ticks,
                    Y = e1.Value,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Top,
                    UIElement           = new EventAControl()
                },
                new VisualElement
                {
                    X = e2.DateTime.Ticks,
                    Y = e2.Value,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Top,
                    UIElement           = new EventBControl()
                },
                SelectedVisualElement
            };
        }
Ejemplo n.º 5
0
 public HSChart()
 {
     _seriesCollection = new SeriesCollection();
     _cartesianVisuals = new VisualElementsCollection();
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int    contr = 0;
            double x2    = 0;

            Curve[] curves = (Curve[])value;
            if (curves != null)
            {
                VisualElementsCollection result = new VisualElementsCollection();
                Curve prevLine = null;
                foreach (var curve in curves)
                {
                    Curve line = curve;
                    {
                        if (curve != null)
                        {
                            double placeX = x2 = 0.05 * Math.Log(line.Points.Max(p => p.X));
                            double distY  = line.Points.First(p => p.X > placeX).Y;
                            double placeY = Math.Log(distY * 0.7, 10);
                            if (prevLine != null)
                            {
                                double prevdistY = prevLine.Points.OrderBy(p => p.X - placeX).First().Y;
                                placeY = 0.9 * (Math.Log(distY / prevdistY, 10)) + Math.Log(prevdistY, 10);
                            }
                            result.Add(new VisualElement()
                            {
                                X = placeX, Y = placeY, UIElement = new TextBlock()
                                {
                                    Text       = curve.dU,
                                    FontWeight = FontWeights.Bold, FontSize = 15, VerticalAlignment = VerticalAlignment.Top
                                }
                            });
                        }
                    }
                    prevLine = line;
                    contr    = 1;
                }
                if (contr == 1)
                {
                    result.Add(new VisualElement()
                    {
                        X         = x2,
                        Y         = 2.903,
                        UIElement = new TextBlock()
                        {
                            Text              = "F",
                            FontWeight        = FontWeights.Bold,
                            FontSize          = 15,
                            VerticalAlignment = VerticalAlignment.Top
                        }
                    });
                }
                return(result);
            }
            else
            {
                return new VisualElementsCollection()
                       {
                           new VisualElement()
                       }
            };
        }