Ejemplo n.º 1
0
 public void CheckMenuColorTheme()
 {
     if (this.MainMenuStrip != null)
     {
         var rend = MainMenuStrip.Renderer as MyToolStripRenderer;
         if (rend == null)
         {
             return;
         }
         rend.SetColorTheme(MyColorTheme);
         MainMenuStrip.Refresh();
     }
 }
Ejemplo n.º 2
0
 public void CheckMenuColorTheme()
 {
     if (this.MainMenuStrip != null)
     {
         var rend = MainMenuStrip.Renderer as MyToolStripRenderer;
         if (rend == null)
         {
             SetupMenuRenderer();
             rend = MainMenuStrip.Renderer as MyToolStripRenderer;
             if (rend == null)
             {
                 return;
             }
         }
         var colortheme = _topManager.Settings.ColorTheme;
         rend.SetColorTheme(colortheme);
         MainMenuStrip.Refresh();
     }
 }
Ejemplo n.º 3
0
        private bool paintCaption_(Graphics g)
        {
            int  X   = 0;
            int  R   = this.ClientSize.Width;
            bool ret = false;

            // paint caption bar
            // - icon
            // - text
            // - mainmenustrip
            // - min/max/close
            var rc = new Rectangle(X, 0, R, CaptionHeight);

            if (g != null)
            {
                var sb = new SolidBrush(CaptionColor);
                g.FillRectangle(sb, rc);
            }

            if (this.ShowIcon)
            {
                if (g != null)
                {
                    var rcIcon = new Rectangle(X, 0, CaptionHeight, CaptionHeight);
                    g.DrawIcon(this.Icon, rcIcon);
                    X += CaptionHeight;
                }
            }
            if (!string.IsNullOrEmpty(Text))
            {
                var captionFont  = SystemFonts.CaptionFont;
                var captionBrush = SystemBrushes.ActiveCaptionText;

                if (g != null)
                {
                    var m = g.MeasureString(Text, captionFont);
                    int W = CaptionTextWidth;
                    if (W == 0)
                    {
                        W = (int)m.Width + 2;// runf up plus extra pixel space
                    }
                    actualCaptionTextWidth = W;
                    var topOffset   = (CaptionHeight - m.Height) / 2;
                    var captionRect = new RectangleF(X, topOffset < 0 ? 0 : topOffset, W, CaptionHeight);
                    g.DrawString(Text, captionFont, captionBrush, captionRect);
                    X += W;
                }
                else
                {
                    X += actualCaptionTextWidth;// use width from last time we drew it (are we one step behind?)
                }
            }
            //
            // seperator after text
            X += CaptionHeight;
            //
            // control button far right
            if (this.ControlBox)
            {
                R -= CaptionHeight;
                if (g != null)
                {
#if SYSTEM_CLOSE_BUTTON
                    var r = new Rectangle(R, 0, CaptionHeight, CaptionHeight);
                    ControlPaint.DrawCaptionButton(g, r, CaptionButton.Close, ButtonState.Normal | ButtonState.Flat);
#else
                    // just draw a simple cross
                    Pen p = Pens.Black;
                    int o = CaptionHeight / 3;     // offset to cross ends inside the box
                    int w = CaptionHeight - o - o; // width/height of the cross
                    g.DrawLine(p, R + o, o, R + o + w, o + w);
                    g.DrawLine(p, R + o, o + w, R + o + w, o);
#endif
                }
            }
            //
            // seperator before control button
            R -= CaptionHeight;
            //
            // whatever isleft is for mmenu strip
            // from X to R...
            if (this.MainMenuStrip != null)
            {
                // no room for the menu!
                if (R < X)
                {
                    R = X;
                }

                //
                // if mainmenu is not in calculated place then move it
                // - note width check is ">" rather than "!=" becuase we may set toolstrip size and it
                //   may set somethign lower depending what it has
                if (this.MainMenuStrip.Left != X || this.MainMenuStrip.Right > R)
                {
                    // never dock the main menu from outer form...we "own" its position
                    if (this.MainMenuStrip.Dock != DockStyle.None)
                    {
                        this.MainMenuStrip.Dock = DockStyle.None;
                    }

                    this.MainMenuStrip.SetBounds(X, 0, R - X, CaptionHeight);
                    ret = true;
                }
                if (g != null)
                {
                    // menu same back color as us
                    if (MainMenuStrip.BackColor != this.CaptionColor)
                    {
                        MainMenuStrip.BackColor = this.CaptionColor;
                    }

                    MainMenuStrip.Refresh();
                }
            }
            return(ret);
        }