Ejemplo n.º 1
0
        public void OnMenuBuilder(ZedGraphControl sender, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
        {
            if (m_ItemDatabase == null)
            {
                return;
            }
            menuStrip.Items.Add(new ToolStripLabel("Threshold:"));
            ToolStripTextBox setThreshold = new ToolStripTextBox("Threshold");

            setThreshold.Text = m_Threshold?.Location.Y.ToString();

            setThreshold.KeyPress += (o, args) =>
            {
                if (((Keys)args.KeyChar) == Keys.Return)
                {
                    if (double.TryParse(setThreshold.Text, out var value))
                    {
                        SetThreshold(value);
                    }
                    else
                    {
                        SetThreshold(null);
                    }
                }
            };
            menuStrip.Items.Add(setThreshold);

            ToolStripMenuItem sendToModule = new ToolStripMenuItem("Send to module");

            sendToModule.Enabled = !string.IsNullOrEmpty(SelectedItem);


            IModule[] modules = m_Manager.GetModules();

            foreach (IModule module in modules)
            {
                if (module.SupportsSendToCalls)
                {
                    ToolStripMenuItem m = new ToolStripMenuItem(module.DisplayName, null, new EventHandler(OnSendToModule));
                    m.Tag = module;
                    sendToModule.DropDownItems.Add(m);
                }
            }

            menuStrip.Items.Add(sendToModule);

            menuStrip.Items.Add(new ToolStripSeparator());

            if (m_SelectedObject is LogGraphCurveItem selectedLine)
            {
                BuildLineMenu(selectedLine, menuStrip, DashStyle.Solid, DashStyle.Dash, DashStyle.Dot, DashStyle.DashDot, DashStyle.DashDotDot);
            }
            else
            {
                BuildAxisMenu(XAxis, menuStrip, "X-Axis", AxisType.Date, AxisType.DateAsOrdinal);
                BuildAxisMenu(YAxis, menuStrip, "Y-Axis", AxisType.Linear, AxisType.LinearAsOrdinal, AxisType.Log);
                //BuildAxisMenu(X2Axis, menuStrip, "X2-Axis");
                BuildAxisMenu(Y2Axis, menuStrip, "Y2-Axis", AxisType.Linear, AxisType.LinearAsOrdinal, AxisType.Log);
            }

            ToolStripLabel label = new ToolStripLabel("Grid item on X-Axis:");

            label.Font = new Font(label.Font, FontStyle.Underline);
            menuStrip.Items.Add(label);

            ToolStripComboBox maps = new ToolStripComboBox("Maps");

            maps.SelectedIndexChanged += new EventHandler(OnMappedItemChanged);
            maps.AutoSize              = true;
            maps.DropDownStyle         = ComboBoxStyle.DropDownList;
            maps.DropDownWidth         = 300;

            maps.Items.Add("None");
            maps.ToolTipText = $"Only values with less than {MaxEntriesInCurveToPopulateGridItems} entries are available.";
            maps.AutoToolTip = true;

            foreach (var curve in CurveList.Cast <LogGraphCurveItem>())
            {
                if (m_ItemDatabase.GetItemRowCount(curve.ItemID) > MaxEntriesInCurveToPopulateGridItems)
                {
                    continue;
                }

                maps.Items.Add(curve.ItemID);
                if (curve.ItemID == m_MappedItem)
                {
                    maps.SelectedIndex = maps.Items.Count - 1;
                }
            }

            menuStrip.Items.Add(maps);
        }