public Watch2Dsettings(Watch2DControl w2DControl) { InitializeComponent(); Watch2DControlModel = w2DControl; PlotColorBox.ItemsSource = typeof(Colors).GetProperties(); PlotColorBox.SelectedItem = typeof(Colors).GetProperty(w2DControl.PlotColorName); }
/// <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(Watch2D model, NodeView nodeView) { var dm = nodeView.ViewModel.DynamoViewModel.Model; var watch2DControl = new Watch2DControl(model); nodeView.inputGrid.Children.Add(watch2DControl); watch2DControl.DataContext = model; model.RequestChangeWatch2D += delegate { model.DispatchOnUIThread(delegate { var xValueNode = model.InPorts[0].Connectors[0].Start.Owner; var xValueIndex = model.InPorts[0].Connectors[0].Start.Index; var xValueId = xValueNode.GetAstIdentifierForOutputIndex(xValueIndex).Name; var startMirror = dm.EngineController.GetMirror(xValueId); var start = 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); } } watch2DControl.Values = start; watch2DControl.AddChart(); }); }; }