Exemple #1
0
        public bool CanAddItem(string item)
        {
            // cause i'm stuff
            if (colorInd == colors.Length)
            {
                return(false);
            }
            // get the data item
            IDataItemClient dataItem = null;

            try {
                dataItem = OperationalInterface.Dataset[item];
            }
            catch (Exception) {
                return(false);
            }

            if (dataItem == null)
            {
                return(false);
            }

            // check if there is a converter
            return(DataItemAdapter.HasDefaultAdapter(dataItem));
        }
Exemple #2
0
        public GraphItemAdapter(string name, Color color, double windowSize, DataItemAdapter dataItemAdapter)
        {
            // store values
            this.dataItemAdapter = dataItemAdapter;
            this.name            = name;

            // get the source units
            this.sourceUnits = UnitConverter.GetUnit(dataItemAdapter.DataItemUnits);

            // create the queues
            plotQueue = new TimeWindowQueue(windowSize);
            recvQueue = new TimeWindowQueue(windowSize);

            // create the plot object
            plot       = new LinePlot(plotQueue.ValueList, plotQueue.TimestampList);
            plot.Color = color;
            plot.Label = name;

            // subscribe to relevant events
            Services.RunControlService.RenderCycle += RunControlService_RenderCycle;
            dataItemAdapter.DataValueReceived      += dataItemAdapter_DataValueReceived;
        }
Exemple #3
0
        public void AddGraphItem(string item)
        {
            if (CanAddItem(item))
            {
                IDataItemClient dataItem    = OperationalInterface.Dataset[item];
                DataItemAdapter dataAdapter = DataItemAdapter.GetDefaultAdapter(dataItem);

                Color            itemColor = colors[colorInd++];
                GraphItemAdapter graphItem = new GraphItemAdapter(item, itemColor, windowSize, dataAdapter);

                // add tool bar button
                // create the image for the button
                Bitmap image = (Bitmap)Properties.Resources.GraphIcon.Clone();
                ImageColorizer.Colorize(image, itemColor);
                ToolStripDropDownButton button = new ToolStripDropDownButton(item, image);
                button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                button.Tag          = graphItem;

                // add the drop down items
                ToolStripMenuItem menuSourceUnitSet = new ToolStripMenuItem("Item Units");
                foreach (Unit unit in UnitConverter.GetUnitsEnumerator())
                {
                    ToolStripMenuItem menuSourceUnit = new ToolStripMenuItem(unit.Abbreviation ?? unit.Name, null, menuSourceUnits_Click);
                    menuSourceUnit.Tag = graphItem;
                    if (object.Equals(unit, graphItem.SourceUnits))
                    {
                        menuSourceUnit.Checked = true;
                    }

                    menuSourceUnitSet.DropDownItems.Add(menuSourceUnit);
                }

                ToolStripMenuItem menuDestUnitSet = new ToolStripMenuItem("Dest Units");
                menuDestUnitSet.Name = "menuDestUnitCollection";
                if (graphItem.SourceUnits != null)
                {
                    graphItem.Conversion = UnitConverter.GetConversion(graphItem.SourceUnits, graphItem.SourceUnits);
                    PopulateDestUnits(menuDestUnitSet, graphItem.SourceUnits, graphItem);
                }
                else
                {
                    menuDestUnitSet.Enabled = false;
                }

                ToolStripMenuItem menuRemoveItem = new ToolStripMenuItem("Remove", Properties.Resources.Delete, menuRemoveItem_Click);
                menuRemoveItem.Tag = graphItem;

                // add the menu items to the button
                button.DropDownItems.Add(menuSourceUnitSet);
                button.DropDownItems.Add(menuDestUnitSet);
                button.DropDownItems.Add(new ToolStripSeparator());
                button.DropDownItems.Add(menuRemoveItem);

                toolStripItems.Items.Add(button);

                // add to the plot
                plotSurface.Add(graphItem.LinePlot);

                graphItems.Add(graphItem);
            }
        }