aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Views/ProcedureRunnerExecutionView.xaml.cs
blob: 6b72fbcd5039aab17c0a90b7be95375ebc2390de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using RealTimeGraphX.DataPoints;
using RealTimeGraphX.WPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.FSE.Common.Graphs;

namespace Tango.FSE.Procedures.Views
{
    /// <summary>
    /// Interaction logic for ProcedureRunnerExecutionView.xaml
    /// </summary>
    public partial class ProcedureRunnerExecutionView : UserControl
    {
        public ProcedureRunnerExecutionView()
        {
            InitializeComponent();
        }

        private void RealTimeGraph_Loaded(object sender, RoutedEventArgs e)
        {
            RealTimeGraph graph = sender as RealTimeGraph;
            Result result = graph.DataContext as Result;

            if (result != null && result.IsGraph)
            {
                var values = (result.Value as IEnumerable<double>).ToList();

                WpfGraphController<Int32DataPoint, DoubleDataPoint> controller = new WpfGraphController<Int32DataPoint, DoubleDataPoint>();
                controller.Range.AutoY = false;
                controller.Range.MinimumY = values.Min();
                controller.Range.MaximumY = values.Max();
                controller.Range.MaximumX = values.Count;

                controller.DataSeriesCollection.Add(new WpfGraphDataSeries() { Stroke = Colors.DodgerBlue });
                graph.Controller = controller;

                controller.PushData(
                    Enumerable.Range(0, values.Count).Select(x => new Int32DataPoint(x)),
                    values.Select(x => new DoubleDataPoint(x)));
            }
        }
    }
}
an class="p">: class { return (T)((sender as FrameworkElement).Tag); } private void FitCanvas() { Canvas canvas = GetCanvas(); canvas.Width = canvas.Children.OfType<FrameworkElement>().Max(x => Canvas.GetLeft(x) + x.ActualWidth); canvas.Height = canvas.Children.OfType<FrameworkElement>().Max(x => Canvas.GetTop(x) + x.ActualHeight); } private Canvas GetCanvas() { return itemsControl.FindChild<Canvas>("canvas"); } private void OnControlMouseDown(object sender, MouseButtonEventArgs e) { Canvas.SetZIndex(sender as FrameworkElement, GetCanvas().Children.OfType<FrameworkElement>().Max(x => Canvas.GetZIndex(x) + 1)); } private void OnControlSizeRight(object sender, DragDeltaEventArgs e) { var mdiControl = GetSenderTag<MdiChild>(sender); if (double.IsNaN(mdiControl.View.Width)) mdiControl.View.Width = mdiControl.View.ActualWidth; if (mdiControl.View.Width + e.HorizontalChange > MIN_SIZE) mdiControl.View.Width += e.HorizontalChange; } private void OnControlSizeBottom(object sender, DragDeltaEventArgs e) { var mdiControl = GetSenderTag<MdiChild>(sender); if (double.IsNaN(mdiControl.View.Height)) mdiControl.View.Height = mdiControl.View.ActualHeight; if (mdiControl.View.Height + e.VerticalChange > MIN_SIZE) mdiControl.View.Height += e.VerticalChange; } private void OnControlResize(object sender, DragDeltaEventArgs e) { var mdiControl = GetSenderTag<MdiChild>(sender); if (double.IsNaN(mdiControl.View.Height)) mdiControl.View.Height = mdiControl.View.ActualHeight; if (double.IsNaN(mdiControl.View.Width)) mdiControl.View.Width = mdiControl.View.ActualWidth; if (mdiControl.View.Height + e.VerticalChange > MIN_SIZE) mdiControl.View.Height += e.VerticalChange; if (mdiControl.View.Width + e.HorizontalChange > MIN_SIZE) mdiControl.View.Width += e.HorizontalChange; } private void OnControlClosed(object sender, RoutedEventArgs e) { (ItemsSource as IList).Remove(GetSenderTag<MdiChild>(sender)); } } }