Example #1
0
        /// <summary>
        /// acts as a controller for point manipulation on the BW plot
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void zgc_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ZedGraphControl zg   = (ZedGraphControl)sender;
            GraphPane       pane = zg.MasterPane.FindPane(e.Location);

            if (pane == null)
            {
                return;
            }

            if (pane.Tag.ToString() != "BWPlot" && pane.Tag.ToString() != "TSPlot" && pane.Tag.ToString() != "XYPlot")
            {
                return;
            }
            strActiveplot = pane.Tag.ToString();

            //set the pane, curve and point for use by eventhandlers
            _gp = pane;

            CurveItem curve;
            int       pointndx;

            if (!pane.FindNearestPoint(e.Location, out curve, out pointndx))
            {
                return;
            }

            _curve   = curve;
            intPtndx = pointndx;

            PointPair pt = curve.Points[pointndx];

            //boxwhisker plot points do not all have tags - go away if you find one
            if (string.IsNullOrWhiteSpace((string)pt.Tag))
            {
                return;
            }
            string tag = pt.Tag.ToString();

            //build and show context menu items to enable/disable rows in the data sheet
            ContextMenu menuForPlot = new ContextMenu();
            MenuItem    disable     = new MenuItem("Disable Row containing " + tag, new EventHandler(disableRow));
            MenuItem    enable      = new MenuItem("Enable Row containing " + tag, new EventHandler(enableRow));

            menuForPlot.MenuItems.Add(disable);
            menuForPlot.MenuItems.Add(enable);

            //enable/disable the menu items appropriately (if disabled point, enable enable menu item... and conversely)
            CurveList cl1 = zgc.MasterPane.PaneList[2].CurveList;
            CurveList cl2 = zgc.MasterPane.PaneList[1].CurveList;

            if (cl1.Contains(zgc.MasterPane.PaneList[2].CurveList[tag]) || cl2.Contains(zgc.MasterPane.PaneList[2].CurveList[tag]))
            {
                enable.Enabled  = true;
                disable.Enabled = false;
            }
            else
            {
                enable.Enabled  = false;
                disable.Enabled = true;
            }

            //show the enable/disable contextmenu items
            menuForPlot.Show(zgc, new Point(e.X, e.Y));
        }