Interaction logic for ParallelCoordinates.xaml
示例#1
0
 public PCsettings(ParallelCoordinatesControl pcControl)
 {
     InitializeComponent();
     ParallelCoordinatesControlModel = pcControl;
     PlotColorBox.ItemsSource = typeof(Colors).GetProperties();
     PlotColorBox.SelectedItem = typeof(Colors).GetProperty(pcControl.PlotColorName);
 }
示例#2
0
 public PCsettings(ParallelCoordinatesControl pcControl)
 {
     InitializeComponent();
     ParallelCoordinatesControlModel = pcControl;
     StartColorBox.ItemsSource       = typeof(Colors).GetProperties();
     StartColorBox.SelectedItem      = typeof(Colors).GetProperty(pcControl.StartColorName);
     StopColorBox.ItemsSource        = typeof(Colors).GetProperties();
     StopColorBox.SelectedItem       = typeof(Colors).GetProperty(pcControl.StopColorName);
 }
        /// <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(ParallelCoordinates model, NodeView nodeView)
        {
            var dm = nodeView.ViewModel.DynamoViewModel.Model;
            var parallelCoordinatesControl = new ParallelCoordinatesControl(model);

            nodeView.inputGrid.Children.Add(parallelCoordinatesControl);

            parallelCoordinatesControl.DataContext = model;

            model.RequestChangeParallelCoordinates += delegate
            {
                model.DispatchOnUIThread(delegate
                {
                    var paramValueNode  = model.InPorts[0].Connectors[0].Start.Owner;
                    var paramValueIndex = model.InPorts[0].Connectors[0].Start.Index;
                    var xValueNode      = model.InPorts[1].Connectors[0].Start.Owner;
                    var xValueIndex     = model.InPorts[1].Connectors[0].Start.Index;

                    var paramValueId = paramValueNode.GetAstIdentifierForOutputIndex(paramValueIndex).Name;
                    var xValueId     = xValueNode.GetAstIdentifierForOutputIndex(xValueIndex).Name;

                    var paramMirror = dm.EngineController.GetMirror(paramValueId);
                    var startMirror = dm.EngineController.GetMirror(xValueId);

                    var param = new List <string>();
                    var start = new List <double>();

                    if (paramMirror.GetData().IsCollection)
                    {
                        param.AddRange(paramMirror.GetData().GetElements().Select(data => (string)data.Data));
                    }
                    else
                    {
                        param.Add((string)paramMirror.GetData().Data);
                    }

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

                    model.ParameterNames.Clear();
                    foreach (var p in param)
                    {
                        model.ParameterNames.Add(p);
                    }

                    model.AddValues(start);
                    parallelCoordinatesControl.AddChart();
                });
            };
        }