Ejemplo n.º 1
0
        private void AssociatedChart_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Clicks != 1) return;
            if (e.Button != MouseButtons.Right) return;

            ContextMenuStrip NewMenu = new ContextMenuStrip();
            foreach (var item in base.GetContextMenu(e))
                NewMenu.Items.Add(item);

            NewMenu.Items.Add(this.GetContextMenu());

            #region Selection process
            MaxX = this.ChartAreas[0].CursorX.SelectionEnd;
            MinX = this.ChartAreas[0].CursorX.SelectionStart;

            if (MaxX < MinX)
            {
                MinX = this.ChartAreas[0].CursorX.SelectionEnd;
                MaxX = this.ChartAreas[0].CursorX.SelectionStart;
            }

            MaxY = this.ChartAreas[0].CursorY.SelectionEnd;
            MinY = this.ChartAreas[0].CursorY.SelectionStart;

            if (MaxY < MinY)
            {
                MinY = this.ChartAreas[0].CursorY.SelectionEnd;
                MaxY = this.ChartAreas[0].CursorY.SelectionStart;
            }

            cListWells ListWells = new cListWells(this);
            List<DataPoint> LDP = new List<DataPoint>();
            //cListWell ListWellsToProcess = new cListWell();

            foreach (DataPoint item in this.Series[0].Points)
            {
                if ((item.XValue >= MinX) && (item.XValue <= MaxX) && (item.YValues[0] >= MinY) && (item.YValues[0] <= MaxY))
                {
                    if ((item.Tag != null) && (item.Tag.GetType() == typeof(cWell)))
                    {
                        ListWells.Add((cWell)(item.Tag));
                        LDP.Add(item);
                    }
                }
            }

            if (LDP.Count > 0)
            {
                ToolStripMenuItem SpecificContextMenu = ListWells.GetContextMenu(); //new ToolStripMenuItem("List " + LDP.Count + " wells");
                //ToolStripMenuItem ToolStripMenuItem_ChangeClass = ListWells.GetContextMenu();// new ToolStripMenuItem("Classes");
                //ToolStripMenuItem_CopyClassToClipBoard.Click += new System.EventHandler(this.ToolStripMenuItem_CopyClassToClipBoard);
                //SpecificContextMenu.DropDownItems.Add(ToolStripMenuItem_ChangeClass);

                //cWell TmpWell = (cWell)(LDP[0].Tag);

                //for (int i = 0; i < TmpWell.cGlobalInfo.ListWellClasses.Count; i++)
                //{
                //    ToolStripMenuItem ToolStripMenuItem_NewClass = new ToolStripMenuItem(TmpWell.cGlobalInfo.ListWellClasses[i].Name);
                //    ToolStripMenuItem_NewClass.Click += new System.EventHandler(this.ToolStripMenuItem_NewClass);
                //    ToolStripMenuItem_NewClass.Tag = LDP;
                //    ToolStripMenuItem_ChangeClass.DropDownItems.Add(ToolStripMenuItem_NewClass);
                //}
                NewMenu.Items.Add(SpecificContextMenu);
            }

            if ((MinX < MaxX) && (MaxY > MinY))
            {
                NewMenu.Items.Add(new ToolStripSeparator());

                int NumPtsSelected = 0;
                List<int> ListIdx = new List<int>();

                for (int j = 0; j < this.InputSimpleData[0].Count; j++)
                {
                    if ((this.InputSimpleData[IdxDesc0][j] <= MaxX) && (this.InputSimpleData[IdxDesc0][j] >= MinX) && (this.InputSimpleData[IdxDesc1][j] <= MaxY) && (this.InputSimpleData[IdxDesc1][j] >= MinY))
                    {
                        ListIdx.Add(j);

                        NumPtsSelected++;
                    }
                }

                if (NumPtsSelected > 0)
                {
                    ToolStripMenuItem TSItemSubPopSelection = new ToolStripMenuItem("List " + NumPtsSelected + " Objects");

                    ToolStripMenuItem TSItemSubPopSelectionDataTable = new ToolStripMenuItem("Display Data Table");
                    TSItemSubPopSelectionDataTable.Click += new System.EventHandler(this.TSItemSubPopSelectionDataTable);
                    TSItemSubPopSelectionDataTable.Tag = ListIdx;
                    TSItemSubPopSelection.DropDownItems.Add(TSItemSubPopSelectionDataTable);

                    ToolStripMenuItem TSItemSubPopSelectionDataTableImages = new ToolStripMenuItem("Display Data Table (inc. Images)");
                    TSItemSubPopSelectionDataTableImages.Click += new System.EventHandler(this.TSItemSubPopSelectionDataTableImages);
                    TSItemSubPopSelectionDataTableImages.Tag = ListIdx;
                    TSItemSubPopSelection.DropDownItems.Add(TSItemSubPopSelectionDataTableImages);

                    NewMenu.Items.Add(TSItemSubPopSelection);
                }

                ToolStripMenuItem TSItemZoom = new ToolStripMenuItem("Zoom");
                TSItemZoom.Click += new System.EventHandler(this.TSItemZoom);
                NewMenu.Items.Add(TSItemZoom);

            }

            #endregion

            NewMenu.DropShadowEnabled = true;
            NewMenu.Show(Control.MousePosition);
        }