SetSensors() 공개 메소드

public SetSensors ( List sensors, Color>.IDictionary colors ) : void
sensors List
colors Color>.IDictionary
리턴 void
예제 #1
0
        private void PlotSelectionChanged(object sender, EventArgs e)
        {
            var selected = new List <ISensor>();
            IDictionary <ISensor, Color> colors = new Dictionary <ISensor, Color>();
            var colorIndex = 0;

            foreach (var node in treeView.AllNodes)
            {
                var sensorNode = node.Tag as SensorNode;
                if (sensorNode != null)
                {
                    if (sensorNode.Plot)
                    {
                        colors.Add(sensorNode.Sensor,
                                   plotColorPalette[colorIndex % plotColorPalette.Length]);
                        selected.Add(sensorNode.Sensor);
                    }
                    colorIndex++;
                }
            }

            // if a sensor is assigned a color that's already being used by another
            // sensor, try to assign it a new color. This is done only after the
            // previous loop sets an unchanging default color for all sensors, so that
            // colors jump around as little as possible as sensors get added/removed
            // from the plot
            var usedColors = new List <Color>();

            foreach (var curSelectedSensor in selected)
            {
                var curColor = colors[curSelectedSensor];
                if (usedColors.Contains(curColor))
                {
                    foreach (var potentialNewColor in plotColorPalette)
                    {
                        if (!colors.Values.Contains(potentialNewColor))
                        {
                            colors[curSelectedSensor] = potentialNewColor;
                            usedColors.Add(potentialNewColor);
                            break;
                        }
                    }
                }
                else
                {
                    usedColors.Add(curColor);
                }
            }

            sensorPlotColors = colors;
            plotPanel.SetSensors(selected, colors);
        }
예제 #2
0
        private void PlotSelectionChanged(object sender, EventArgs e)
        {
            List <ISensor> selected             = new List <ISensor>();
            IDictionary <ISensor, Color> colors = new Dictionary <ISensor, Color>();
            int colorIndex = 0;

            foreach (TreeNodeAdv node in treeView.AllNodes)
            {
                SensorNode sensorNode = node.Tag as SensorNode;
                if (sensorNode != null)
                {
                    if (sensorNode.Plot)
                    {
                        colors.Add(sensorNode.Sensor, plotColorPalette[colorIndex % plotColorPalette.Length]);
                        selected.Add(sensorNode.Sensor);
                    }
                    colorIndex++;
                }
            }
            sensorPlotColors = colors;
            plotPanel.SetSensors(selected, colors);
        }