예제 #1
0
        public void Render(ToolStripMenuItem mruListMenu, MruMenuListItems mruMenuListItems, int textWidth, EventHandler mruMenuItem_Click)
        {
            // Clear existing menu items, if any
            ToolStripDropDownMenu rootMenu = (ToolStripDropDownMenu)mruListMenu.Owner;
            int mruListMenuIndex           = rootMenu.Items.IndexOf(mruListMenu);

            for (int index = rootMenu.Items.Count - 1; index > mruListMenuIndex; index--)
            {
                if (rootMenu.Items[index] is MruToolStripMenuItem)
                {
                    rootMenu.Items.RemoveAt(index);
                }
            }
            mruListMenu.Enabled = false;
            mruListMenu.Visible = true;

            // Fill MRU menu
            if (mruMenuListItems.Count > 0)
            {
                for (int index = 0; index < mruMenuListItems.Count; index++)
                {
                    string filename = mruMenuListItems[index];
                    MruToolStripMenuItem mruMenuItem = new MruToolStripMenuItem(filename, textWidth, index + 1, mruMenuItem_Click);
                    rootMenu.Items.Insert(mruListMenuIndex + index + 1, mruMenuItem);
                }
                mruListMenu.Enabled = true;
                mruListMenu.Visible = false;
            }
        }
예제 #2
0
        private void RenderInMenu()
        {
            // Clear existing menu items, if any
            ToolStripDropDownMenu rootMenu = (ToolStripDropDownMenu)mruListMenu.Owner;
            int mruListMenuIndex           = rootMenu.Items.IndexOf(mruListMenu);

            for (int index = rootMenu.Items.Count - 1; index > mruListMenuIndex; index--)
            {
                if (rootMenu.Items[index] is MruToolStripMenuItem)
                {
                    rootMenu.Items.RemoveAt(index);
                }
            }

            // Hide mru list menu
            mruListMenu.Enabled = false;
            mruListMenu.Visible = true;

            // Render mru menu
            if (mruMenuListItems.Count > 0)
            {
                for (int index = 0; index < mruMenuListItems.Count; index++)
                {
                    string filename = mruMenuListItems[index];
                    MruToolStripMenuItem mruMenuItem = new MruToolStripMenuItem(filename, textWidth, index + 1, MruMenuItem_Click);
                    rootMenu.Items.Insert(mruListMenuIndex + index + 1, mruMenuItem);
                }
                // Show mru list menu
                mruListMenu.Enabled = true;
                mruListMenu.Visible = false;
            }
        }
예제 #3
0
        private void RenderInSubMenu()
        {
            // Clear existing sub-menu list items, if any
            mruListMenu.DropDownItems.Clear();
            mruListMenu.Enabled = false;

            // Render mru menu
            if (mruMenuListItems.Count > 0)
            {
                for (int index = 0; index < mruMenuListItems.Count; index++)
                {
                    string filename = mruMenuListItems[index];
                    MruToolStripMenuItem mruMenuItem = new MruToolStripMenuItem(filename, textWidth, index + 1, MruMenuItem_Click);
                    mruListMenu.DropDownItems.Add(mruMenuItem);
                }
                mruListMenu.Enabled = true;
            }
        }
예제 #4
0
        private void MruMenuItem_Click(object sender, System.EventArgs e)
        {
            // Get clicked MruToolStripMenuItem
            MruToolStripMenuItem mruMenuItem = (MruToolStripMenuItem)sender;
            string filename = mruMenuItem.Filename;

            // Check if file is missing and, if so, ask if it needs to
            // be deleted. If nobody's registered with the MruMenuItemFileMissing
            // event, the file won't be deleted, MruMenuItemClick will be
            // called and an exception will be raised if the file is missing.
            MruMenuItemFileMissingEventArgs args = new MruMenuItemFileMissingEventArgs(filename, false);

            if (!File.Exists(filename))
            {
                OnMruMenuItemFileMissing(args);
                if (args.RemoveFromMru)
                {
                    this.mruMenuListItems.Remove(filename);
                    return;
                }
            }

            OnMruMenuItemClick(new MruMenuItemClickEventArgs(filename));
        }