示例#1
0
        public DialogResult ShowSelectColumnMenu(Point screenLoc)
        {
            if (Click != null)             // fire Clicked event if handlers present
            {
                Click(this, EventArgs.Empty);
            }

            ToolStripMenuItem fmi = null;

            SelectFieldMenu.Items.Clear();

            ColumnMapCollection cml = DataMap.BuildFilteredColumnMapList(Flags, SelectedColumn);

            foreach (ColumnMapMsx cm in cml.ColumnMapList)
            {
                QueryColumn qc = cm.QueryColumn;
                QueryTable  qt = qc?.QueryTable;
                fmi = new ToolStripMenuItem();
                if (cm.Selected)
                {
                    fmi.Checked = true;
                }
                else
                {
                    fmi.Image = Bitmaps.Bitmaps16x16.Images[(int)qc.MetaColumn.DataTypeImageIndex];
                    fmi.ImageTransparentColor = System.Drawing.Color.Cyan;
                }

                fmi.Text = cm.SpotfireColumnName;
                if (qc != null)
                {
                    fmi.ToolTipText =
                        "===== Mobius Table and Column =====\r\n" +
                        "Table: " + qt.ActiveLabel + "\r\n" +
                        "Column: " + qc.ActiveLabel + "\r\n" +
                        "(" + qc.MetaTableDotMetaColumnName + ")";
                }

                fmi.Tag    = cm;
                fmi.Click += new System.EventHandler(this.FieldMenuItem_Click);

                SelectFieldMenu.Items.Add(fmi);
            }

            if (Flags.IncludeNoneItem)
            {             // added none item
                fmi        = new ToolStripMenuItem();
                fmi.Text   = "(None)";
                fmi.Click += new System.EventHandler(this.FieldMenuItemExtra_Click);
                SelectFieldMenu.Items.Add(fmi);
            }

            if (!String.IsNullOrEmpty(Flags.ExtraItem))
            {             // added extra item
                fmi        = new ToolStripMenuItem();
                fmi.Text   = Flags.ExtraItem;
                fmi.Click += new System.EventHandler(this.FieldMenuItemExtra_Click);
                SelectFieldMenu.Items.Add(fmi);
            }

            SelectFieldMenu.Show(screenLoc.X, screenLoc.Y);

            MenuItemSelected = false;
            while (SelectFieldMenu.Visible)             // wait til menu closes
            {
                Application.DoEvents();
                Thread.Sleep(100);
            }

            if (!MenuItemSelected)
            {
                return(DialogResult.Cancel);                               // treat as cancel if nothing selected
            }
            CheckForSummarizedVersionOfMetaColumn();

            if (EditValueChanged != null)             // fire EditValueChanged event if handlers present
            {
                EditValueChanged(this, EventArgs.Empty);
            }

            return(DialogResult.OK);
        }