public Watch2D3LinesSettings(Watch2D3LinesControl w2D3LControl)
 {
     InitializeComponent();
     Watch2D3LinesControlModel = w2D3LControl;
     PlotColorBox1.ItemsSource = typeof(Colors).GetProperties();
     PlotColorBox1.SelectedItem = typeof(Colors).GetProperty(w2D3LControl.PlotColorName[0]);
     PlotColorBox2.ItemsSource = typeof(Colors).GetProperties();
     PlotColorBox2.SelectedItem = typeof(Colors).GetProperty(w2D3LControl.PlotColorName[1]);
     PlotColorBox3.ItemsSource = typeof(Colors).GetProperties();
     PlotColorBox3.SelectedItem = typeof(Colors).GetProperty(w2D3LControl.PlotColorName[2]);
 }
 public Watch2D3LinesSettings(Watch2D3LinesControl w2D3LControl)
 {
     InitializeComponent();
     Watch2D3LinesControlModel  = w2D3LControl;
     PlotColorBox1.ItemsSource  = typeof(Colors).GetProperties();
     PlotColorBox1.SelectedItem = typeof(Colors).GetProperty(w2D3LControl.PlotColorName[0]);
     PlotColorBox2.ItemsSource  = typeof(Colors).GetProperties();
     PlotColorBox2.SelectedItem = typeof(Colors).GetProperty(w2D3LControl.PlotColorName[1]);
     PlotColorBox3.ItemsSource  = typeof(Colors).GetProperties();
     PlotColorBox3.SelectedItem = typeof(Colors).GetProperty(w2D3LControl.PlotColorName[2]);
 }
Exemple #3
0
        /// <summary>
        /// At run-time, this method is called during the node
        /// creation. Here you can create custom UI elements and
        /// add them to the node view, but we recommend designing
        /// your UI declaratively using xaml, and binding it to
        /// properties on this node as the DataContext.
        /// </summary>
        /// <param name="model">The NodeModel representing the node's core logic.</param>
        /// <param name="nodeView">The NodeView representing the node in the graph.</param>
        public void CustomizeView(Watch2D3Lines model, NodeView nodeView)
        {
            var dm = nodeView.ViewModel.DynamoViewModel.Model;
            var watch2D3LinesControl = new Watch2D3LinesControl(model);

            nodeView.inputGrid.Children.Add(watch2D3LinesControl);

            watch2D3LinesControl.DataContext = model;

            model.RequestChangeWatch2D += delegate
            {
                model.DispatchOnUIThread(delegate
                {
                    var x1ValueNode  = model.InPorts[0].Connectors[0].Start.Owner;
                    var x1ValueIndex = model.InPorts[0].Connectors[0].Start.Index;
                    var x2ValueNode  = model.InPorts[1].Connectors[0].Start.Owner;
                    var x2ValueIndex = model.InPorts[1].Connectors[0].Start.Index;
                    var x3ValueNode  = model.InPorts[2].Connectors[0].Start.Owner;
                    var x3ValueIndex = model.InPorts[2].Connectors[0].Start.Index;

                    var x1ValueId = x1ValueNode.GetAstIdentifierForOutputIndex(x1ValueIndex).Name;
                    var x2ValueId = x2ValueNode.GetAstIdentifierForOutputIndex(x2ValueIndex).Name;
                    var x3ValueId = x3ValueNode.GetAstIdentifierForOutputIndex(x3ValueIndex).Name;

                    var startMirror = dm.EngineController.GetMirror(x1ValueId);
                    var midMirror   = dm.EngineController.GetMirror(x2ValueId);
                    var endMirror   = dm.EngineController.GetMirror(x3ValueId);

                    var start = new List <double>();
                    var mid   = new List <double>();
                    var end   = new List <double>();

                    if (startMirror == null)
                    {
                        start.Add(1.1);
                    }
                    else
                    {
                        if (startMirror.GetData().IsCollection)
                        {
                            start.AddRange(startMirror.GetData().GetElements().Select(data => (double)data.Data));
                        }
                        else
                        {
                            var x = (double)startMirror.GetData().Data;
                            start.Add(x);
                        }
                    }

                    if (midMirror == null)
                    {
                        mid.Add(1.1);
                    }
                    else
                    {
                        if (midMirror.GetData().IsCollection)
                        {
                            mid.AddRange(midMirror.GetData().GetElements().Select(data => (double)data.Data));
                        }
                        else
                        {
                            var x = (double)midMirror.GetData().Data;
                            mid.Add(x);
                        }
                    }

                    if (endMirror == null)
                    {
                        end.Add(1.1);
                    }
                    else
                    {
                        if (endMirror.GetData().IsCollection)
                        {
                            end.AddRange(endMirror.GetData().GetElements().Select(data => (double)data.Data));
                        }
                        else
                        {
                            var x = (double)endMirror.GetData().Data;
                            end.Add(x);
                        }
                    }

                    var values = new List <List <double> >()
                    {
                        start, mid, end
                    };

                    watch2D3LinesControl.Values = values;
                    watch2D3LinesControl.AddChart();
                });
            };
        }