Example #1
0
        private ContextMenuTag CreateCommonMenuItems(
            ContextMenuStrip Menu,
            ListView LV,
            CtxMenuFlags MFlags = CtxMenuFlags.All)
        {
            // FindFirst
            var FindFirst = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | System.Windows.Forms.Keys.F),
                Size         = new System.Drawing.Size(202, 22),
                Text         = "Find",
            };

            FindFirst.Click += new EventHandler(menuCommonLVFindFirst_Click);

            // FindNext
            var FindNext = new ToolStripMenuItem()
            {
                ShortcutKeys = Keys.F3,
                Size         = new System.Drawing.Size(202, 22),
                Text         = "Find Next",
            };

            FindNext.Click += new EventHandler(menuCommonLVFindNext_Click);

            var CopyItem = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | Keys.C),
                Size         = new System.Drawing.Size(202, 22),
                Text         = "Copy"
            };

            CopyItem.Click += new EventHandler(menuCommonLVCopyItem_Click);

            var SelectAll = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | Keys.A),
                Size         = new System.Drawing.Size(202, 22),
                Text         = "Select all"
            };

            SelectAll.Click += new EventHandler(menuCommonLVSelectAll_Click);

            var ExportToTextFile = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | Keys.S),
                Size         = new System.Drawing.Size(202, 22),
                Text         = "Export to text file"
            };

            ExportToTextFile.Click += new EventHandler(menuCommonLVExportToTextFile_Click);

            var Delete = new ToolStripMenuItem()
            {
                ShortcutKeys = Keys.Delete,
                Size         = new System.Drawing.Size(202, 22),
                Text         = "Delete"
            };

            Delete.Click += new EventHandler(menuCommonLVDeleteItem_Click);

            if (MFlags.HasFlag(CtxMenuFlags.Find))
            {
                Menu.Items.AddRange(new ToolStripItem[]
                {
                    new ToolStripSeparator(),
                    FindFirst,
                    FindNext,
                });
            }

            if (MFlags.HasFlag(CtxMenuFlags.Delete))
            {
                Menu.Items.AddRange(new ToolStripItem[]
                {
                    new ToolStripSeparator(),
                    Delete
                });
            }

            if (MFlags.HasFlag(CtxMenuFlags.Export))
            {
                Menu.Items.AddRange(new ToolStripItem[]
                {
                    new ToolStripSeparator(),
                    ExportToTextFile
                });
            }

            Menu.Items.AddRange(new ToolStripItem[]
            {
                new ToolStripSeparator(),
                CopyItem,
                SelectAll,
            });

            // Install column sorter
            LV.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(lvCommon_ColumnClick);

            var Context = new ContextMenuTag()
            {
                lv = LV
            };

            Menu.Tag = Context;
            LV.Tag   = Context;

            LV.ContextMenuStrip = Menu;

            return(Context);
        }
Example #2
0
        private ContextMenuTag CreateCommonMenuItems(
            ContextMenuStrip Menu,
            ListView LV,
            CtxMenuFlags MFlags = CtxMenuFlags.All)
        {
            // FindFirst
            var FindFirst = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | System.Windows.Forms.Keys.F),
                Size = new System.Drawing.Size(202, 22),
                Text = "Find",
            };
            FindFirst.Click += new EventHandler(menuCommonLVFindFirst_Click);

            // FindNext
            var FindNext = new ToolStripMenuItem()
            {
                ShortcutKeys = Keys.F3,
                Size = new System.Drawing.Size(202, 22),
                Text = "Find Next",
            };
            FindNext.Click += new EventHandler(menuCommonLVFindNext_Click);

            var CopyItem = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | Keys.C),
                Size = new System.Drawing.Size(202, 22),
                Text = "Copy"
            };
            CopyItem.Click += new EventHandler(menuCommonLVCopyItem_Click);

            var SelectAll = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | Keys.A),
                Size = new System.Drawing.Size(202, 22),
                Text = "Select all"
            };
            SelectAll.Click += new EventHandler(menuCommonLVSelectAll_Click);

            var ExportToTextFile = new ToolStripMenuItem()
            {
                ShortcutKeys = (Keys.Control | Keys.S),
                Size = new System.Drawing.Size(202, 22),
                Text = "Export to text file"
            };
            ExportToTextFile.Click += new EventHandler(menuCommonLVExportToTextFile_Click);

            var Delete = new ToolStripMenuItem()
            {
                ShortcutKeys = Keys.Delete,
                Size = new System.Drawing.Size(202, 22),
                Text = "Delete"
            };
            Delete.Click += new EventHandler(menuCommonLVDeleteItem_Click);

            if (MFlags.HasFlag(CtxMenuFlags.Find))
            {
                Menu.Items.AddRange(new ToolStripItem[]
                {
                    new ToolStripSeparator(),
                    FindFirst,
                    FindNext,
                });
            }

            if (MFlags.HasFlag(CtxMenuFlags.Delete))
            {
                Menu.Items.AddRange(new ToolStripItem[]
                {
                    new ToolStripSeparator(),
                    Delete
                });
            }

            if (MFlags.HasFlag(CtxMenuFlags.Export))
            {
                Menu.Items.AddRange(new ToolStripItem[]
                {
                    new ToolStripSeparator(),
                    ExportToTextFile
                });
            }

            Menu.Items.AddRange(new ToolStripItem[]
            {
                new ToolStripSeparator(),
                CopyItem,
                SelectAll,
            });

            // Install column sorter
            LV.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(lvCommon_ColumnClick);

            var Context = new ContextMenuTag()
            {
                lv = LV
            };
            Menu.Tag = Context;
            LV.Tag = Context;

            LV.ContextMenuStrip = Menu;

            return Context;
        }