Ejemplo n.º 1
0
        public ContextMenuStrip CreateContextMenuStrip(bool blnIncludeCloseOpenCharacter)
        {
            int intToolStripWidth  = 180;
            int intToolStripHeight = 22;

            using (Graphics g = CreateGraphics())
            {
                intToolStripWidth  = (int)(intToolStripWidth * g.DpiX / 96.0f);
                intToolStripHeight = (int)(intToolStripHeight * g.DpiY / 96.0f);
            }

            //
            // tsToggleFav
            //
            ToolStripMenuItem tsToggleFav = new ToolStripMenuItem
            {
                Image = Properties.Resources.asterisk_orange,
                Name  = "tsToggleFav",
                Size  = new Size(intToolStripWidth, intToolStripHeight),
                Tag   = "Menu_ToggleFavorite"
            };

            tsToggleFav.Click += tsToggleFav_Click;
            //
            // tsSort
            //
            ToolStripMenuItem tsSort = new ToolStripMenuItem
            {
                Image = Properties.Resources.page_refresh,
                Name  = "tsSort",
                Size  = new Size(intToolStripWidth, intToolStripHeight),
                Tag   = "Menu_Sort"
            };

            tsSort.Click += tsSort_Click;
            //
            // tsDelete
            //
            ToolStripMenuItem tsDelete = new ToolStripMenuItem
            {
                Image = Properties.Resources.delete,
                Name  = "tsDelete",
                Size  = new Size(intToolStripWidth, intToolStripHeight),
                Tag   = "Menu_Delete"
            };

            tsDelete.Click += tsDelete_Click;
            //
            // cmsRoster
            //
            ContextMenuStrip cmsRoster = new ContextMenuStrip
            {
                Name = "cmsRoster",
                Size = new Size(intToolStripWidth, intToolStripHeight * 5)
            };

            cmsRoster.Items.AddRange(new ToolStripItem[]
            {
                tsToggleFav,
                tsSort,
                tsDelete
            });

            tsToggleFav.TranslateToolStripItemsRecursively();
            tsSort.TranslateToolStripItemsRecursively();
            tsDelete.TranslateToolStripItemsRecursively();

            if (blnIncludeCloseOpenCharacter)
            {
                //
                // tsCloseOpenCharacter
                //
                ToolStripMenuItem tsCloseOpenCharacter = new ToolStripMenuItem
                {
                    Image = Properties.Resources.door_out,
                    Name  = "tsCloseOpenCharacter",
                    Size  = new Size(intToolStripWidth, intToolStripHeight),
                    Tag   = "Menu_Close"
                };
                tsCloseOpenCharacter.Click += tsCloseOpenCharacter_Click;
                cmsRoster.Items.Add(tsCloseOpenCharacter);
                tsCloseOpenCharacter.TranslateToolStripItemsRecursively();
            }
            cmsRoster.UpdateLightDarkMode();

            return(cmsRoster);
        }