Ejemplo n.º 1
0
 // Token: 0x06000196 RID: 406 RVA: 0x00005D54 File Offset: 0x00003F54
 private void CreateBaseTextBox()
 {
     if (this.baseTextBox.Visible && !this.firstInitialization)
     {
         return;
     }
     if (!this.firstInitialization)
     {
         return;
     }
     this.firstInitialization = false;
     if (!base.DesignMode)
     {
         Form form = base.FindForm();
         if (form != null)
         {
             form.ResizeBegin += this.parentForm_ResizeBegin;
             form.ResizeEnd   += this.parentForm_ResizeEnd;
         }
     }
     this.baseTextBox.Visible      = true;
     this.baseTextBox.BorderStyle  = BorderStyle.None;
     this.baseTextBox.Font         = MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight);
     this.baseTextBox.Location     = new Point(1, 0);
     this.baseTextBox.Text         = this.Text;
     this.baseTextBox.ReadOnly     = true;
     this.baseTextBox.Size         = this.GetPreferredSize(Size.Empty);
     this.baseTextBox.Multiline    = true;
     this.baseTextBox.DoubleClick += this.BaseTextBoxOnDoubleClick;
     this.baseTextBox.Click       += this.BaseTextBoxOnClick;
     base.Controls.Add(this.baseTextBox);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MetroMenuStrip()
     : base()
 {
     Renderer  = new metroToolStripRenderer(Theme, Style);
     Font      = MetroFonts.Label(MetroLabelSize.Medium, MetroLabelWeight.Bold);
     ForeColor = MetroPaint.ForeColor.MenuToolStrip.Normal(Theme);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// OnItemAdded-Event we adjust the font and forecolor of this item
        /// </summary>
        /// <param name="e"></param>
        protected override void OnItemAdded(System.Windows.Forms.ToolStripItemEventArgs e)
        {
            base.OnItemAdded(e);

            e.Item.Font      = MetroFonts.Label(MetroLabelSize.Medium, MetroLabelWeight.Light);
            e.Item.ForeColor = MetroPaint.ForeColor.MenuToolStrip.Normal(Theme);
        }
Ejemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color backColor, borderColor, foreColor;

            if (isHovered && !isPressed && Enabled)
            {
                backColor   = MetroPaint.BackColor.Button.Hover(Theme);
                borderColor = MetroPaint.BorderColor.Button.Hover(Theme);
                foreColor   = MetroPaint.ForeColor.Button.Hover(Theme);
            }
            else if (isHovered && isPressed && Enabled)
            {
                backColor   = MetroPaint.BackColor.Button.Press(Theme);
                borderColor = MetroPaint.BorderColor.Button.Press(Theme);
                foreColor   = MetroPaint.ForeColor.Button.Press(Theme);
            }
            else if (!Enabled)
            {
                backColor   = MetroPaint.BackColor.Button.Disabled(Theme);
                borderColor = MetroPaint.BorderColor.Button.Disabled(Theme);
                foreColor   = MetroPaint.ForeColor.Button.Disabled(Theme);
            }
            else
            {
                backColor   = MetroPaint.BackColor.Button.Normal(Theme);
                borderColor = MetroPaint.BorderColor.Button.Normal(Theme);
                foreColor   = MetroPaint.ForeColor.Button.Normal(Theme);
            }

            e.Graphics.Clear(backColor);

            using (Pen p = new Pen(borderColor))
            {
                Rectangle borderRect = new Rectangle(0, 0, Width - 1, Height - 1);
                e.Graphics.DrawRectangle(p, borderRect);
            }

            if (Highlight && !isHovered && !isPressed && Enabled)
            {
                using (Pen p = MetroPaint.GetStylePen(Style))
                {
                    Rectangle borderRect = new Rectangle(0, 0, Width - 1, Height - 1);
                    e.Graphics.DrawRectangle(p, borderRect);
                    borderRect = new Rectangle(1, 1, Width - 3, Height - 3);
                    e.Graphics.DrawRectangle(p, borderRect);
                }
            }

            //TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Button, ClientRectangle, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign));
            //字体修改为用户指定字体
            TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign));

            if (false && isFocused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create the new form
        /// </summary>
        public UpdateCheckForm()
        {
            InitializeComponent();

            // set the font for the HtmlLabel to match the form
            Font font = MetroFonts.Label(MetroLabelSize.Small, MetroLabelWeight.Regular);

            this.versionInfoLabel.Font = new Font(font.FontFamily, 10);
        }
Ejemplo n.º 6
0
        private void InitColors()
        {
            //set font
            this.Font = MetroFonts.Label(metroLabelSize, metroLabelWeight);

            //set BackGroudColor
            base.BackColor = MetroPaint.BackColor.Form(Theme);

            Refresh();
            Update();
        }
Ejemplo n.º 7
0
 public override System.Drawing.Size GetPreferredSize(System.Drawing.Size proposedSize)
 {
     System.Drawing.Size size;
     base.GetPreferredSize(proposedSize);
     using (Graphics graphic = base.CreateGraphics())
     {
         proposedSize = new System.Drawing.Size(2147483647, 2147483647);
         size         = TextRenderer.MeasureText(graphic, this.Text, MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight), proposedSize, MetroPaint.GetTextFormatFlags(this.TextAlign));
     }
     return(size);
 }
Ejemplo n.º 8
0
        // Token: 0x06000192 RID: 402 RVA: 0x00005CA0 File Offset: 0x00003EA0
        public override Size GetPreferredSize(Size proposedSize)
        {
            base.GetPreferredSize(proposedSize);
            Size result;

            using (Graphics graphics = base.CreateGraphics())
            {
                proposedSize = new Size(int.MaxValue, int.MaxValue);
                result       = TextRenderer.MeasureText(graphics, this.Text, MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight), proposedSize, MetroPaint.GetTextFormatFlags(this.TextAlign));
            }
            return(result);
        }
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            e.TextFont = MetroFonts.Label(MetroLabelSize.Medium, MetroLabelWeight.Regular);
            if (e.Item.Selected && e.Item.Pressed == false)
            {
                e.TextColor = MetroPaint.ForeColor.MenuToolStrip.Hover(_theme);
            }
            else
            {
                e.TextColor = MetroPaint.ForeColor.MenuToolStrip.Normal(_theme);
            }

            base.OnRenderItemText(e);
        }
Ejemplo n.º 10
0
        public override Size GetPreferredSize(Size proposedSize)
        {
            Size preferredSize;

            base.GetPreferredSize(proposedSize);

            using (var g = CreateGraphics())
            {
                proposedSize  = new Size(int.MaxValue, int.MaxValue);
                preferredSize = TextRenderer.MeasureText(g, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), proposedSize, MetroPaint.GetTextFormatFlags(TextAlign));
            }

            return(preferredSize);
        }
Ejemplo n.º 11
0
        protected virtual void OnPaintForeground(PaintEventArgs e)
        {
            Color foreColor;

            if (this.useCustomForeColor)
            {
                foreColor = this.ForeColor;
            }
            else if (!base.Enabled)
            {
                if (base.Parent == null)
                {
                    foreColor = MetroPaint.ForeColor.Label.Disabled(this.Theme);
                }
                else
                {
                    foreColor = (!(base.Parent is MetroTile) ? MetroPaint.ForeColor.Label.Normal(this.Theme) : MetroPaint.ForeColor.Tile.Disabled(this.Theme));
                }
            }
            else if (base.Parent == null)
            {
                foreColor = (!this.useStyleColors ? MetroPaint.ForeColor.Label.Normal(this.Theme) : MetroPaint.GetStyleColor(this.Style));
            }
            else if (!(base.Parent is MetroTile))
            {
                foreColor = (!this.useStyleColors ? MetroPaint.ForeColor.Label.Normal(this.Theme) : MetroPaint.GetStyleColor(this.Style));
            }
            else
            {
                foreColor = MetroPaint.ForeColor.Tile.Normal(this.Theme);
            }
            if (this.LabelMode != MetroLabelMode.Selectable)
            {
                this.DestroyBaseTextbox();
                TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight), base.ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(this.TextAlign, this.wrapToLine));
                this.OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics));
            }
            else
            {
                this.CreateBaseTextBox();
                this.UpdateBaseTextBox();
                if (!this.baseTextBox.Visible)
                {
                    TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight), base.ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(this.TextAlign));
                    return;
                }
            }
        }
Ejemplo n.º 12
0
        private void InitColors()
        {
            //set font
            this.Font = MetroFonts.Label(metroLabelSize, metroLabelWeight);

            //set BackGroudColor
            this.BackColor = MetroPaint.BackColor.GroupBox.Normal(Theme);

            //set ForeColor
            this.ForeColor = !useStyleColors?MetroPaint.ForeColor.GroupBox.Normal(Theme) : MetroPaint.GetStyleColor(Style);

            //reset FlatStyle
            if (this.FlatStyle == FlatStyle.System)
            {
                this.FlatStyle = FlatStyle.Standard;
            }
        }
Ejemplo n.º 13
0
 private void UpdateSeparator()
 {
     linePen       = MetroFramework.Drawing.MetroPaint.GetStylePen(Style);
     linePen.Width = 3;
     if (showLabel)
     {
         int height = MetroFonts.Label(metroLabelSize, metroLabelWeight).Height;
         linePositionStart = new Point(0, height);
         linePositionEnd   = new Point(Width, height);
     }
     else
     {
         linePositionStart = new Point(0, 0);
         linePositionEnd   = new Point(Width, 0);
     }
     Refresh();
 }
Ejemplo n.º 14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics   g        = CreateGraphics();
            Font       UsedFont = MetroFonts.Label(MetroLabelSize.Medium, MetroLabelWeight.Regular);
            float      h        = UsedFont.GetHeight();
            RectangleF textRect = new RectangleF(10, 15 - (h / 2), Width - 60, 15 + (h / 2));
            Brush      b        = new SolidBrush(ThemeColor);

            g.FillRectangle(b, textRect);
            b.Dispose();
            g.DrawString(Text, UsedFont, Brushes.White, textRect);
            g.DrawLine(Pens.Black, 0, 0, Width - 1, 0);                  // Draw black border
            g.DrawLine(Pens.Black, Width - 1, 0, Width - 1, Height - 1);
            g.DrawLine(Pens.Black, Width - 1, Height - 1, 0, Height - 1);
            g.DrawLine(Pens.Black, 0, Height - 1, 0, 0);
            g.Dispose();
        }
Ejemplo n.º 15
0
        private void CreateBaseTextBox()
        {
            if (baseTextBox.Visible && !firstInitialization)
            {
                return;
            }
            if (!firstInitialization)
            {
                return;
            }

            firstInitialization = false;

            if (!DesignMode)
            {
                Form parentForm = FindForm();
                if (parentForm != null)
                {
                    parentForm.ResizeBegin += new EventHandler(parentForm_ResizeBegin);
                    parentForm.ResizeEnd   += new EventHandler(parentForm_ResizeEnd);
                }
            }

            baseTextBox.BackColor   = Color.Transparent;
            baseTextBox.Visible     = true;
            baseTextBox.BorderStyle = BorderStyle.None;
            baseTextBox.Font        = MetroFonts.Label(metroLabelSize, metroLabelWeight);
            baseTextBox.Location    = new Point(1, 0);
            baseTextBox.Text        = Text;
            baseTextBox.ReadOnly    = true;

            baseTextBox.Size      = GetPreferredSize(Size.Empty);
            baseTextBox.Multiline = true;

            baseTextBox.DoubleClick += BaseTextBoxOnDoubleClick;
            baseTextBox.Click       += BaseTextBoxOnClick;

            Controls.Add(baseTextBox);
        }
Ejemplo n.º 16
0
        private void CreateBaseTextBox()
        {
            if (baseTextBox.Visible)
            {
                return;
            }

            baseTextBox.Visible     = true;
            baseTextBox.BorderStyle = BorderStyle.None;
            baseTextBox.Font        = MetroFonts.Label(metroLabelSize, metroLabelWeight);
            baseTextBox.Location    = new Point(1, 0);
            baseTextBox.Text        = Text;
            baseTextBox.ReadOnly    = true;

            baseTextBox.Size      = GetPreferredSize(Size.Empty);
            baseTextBox.Multiline = true;

            baseTextBox.DoubleClick += BaseTextBoxOnDoubleClick;
            baseTextBox.Click       += BaseTextBoxOnClick;

            Controls.Add(baseTextBox);
        }
Ejemplo n.º 17
0
        private void UpdateBaseTextBox()
        {
            if (!baseTextBox.Visible)
            {
                return;
            }

            SuspendLayout();
            baseTextBox.SuspendLayout();

            if (useCustomBackColor)
            {
                baseTextBox.BackColor = BackColor;
            }
            else
            {
                baseTextBox.BackColor = MetroPaint.BackColor.Form(Theme);
            }

            if (!Enabled)
            {
                if (Parent != null)
                {
                    //if (Parent is MetroTile)
                    if (false)
                    {
                        baseTextBox.ForeColor = MetroPaint.ForeColor.Tile.Disabled(Theme);
                    }
                    else
                    {
                        if (useStyleColors)
                        {
                            baseTextBox.ForeColor = MetroPaint.GetStyleColor(Style);
                        }
                        else
                        {
                            baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                        }
                    }
                }
                else
                {
                    if (useStyleColors)
                    {
                        baseTextBox.ForeColor = MetroPaint.GetStyleColor(Style);
                    }
                    else
                    {
                        baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                    }
                }
            }
            else
            {
                if (Parent != null)
                {
                    //if (Parent is MetroTile)
                    if (false)
                    {
                        baseTextBox.ForeColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                    }
                    else
                    {
                        if (useStyleColors)
                        {
                            baseTextBox.ForeColor = MetroPaint.GetStyleColor(Style);
                        }
                        else
                        {
                            baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                }
                else
                {
                    if (useStyleColors)
                    {
                        baseTextBox.ForeColor = MetroPaint.GetStyleColor(Style);
                    }
                    else
                    {
                        baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Normal(Theme);
                    }
                }
            }

            baseTextBox.Font        = MetroFonts.Label(metroLabelSize, metroLabelWeight);
            baseTextBox.Text        = Text;
            baseTextBox.BorderStyle = BorderStyle.None;

            Size = GetPreferredSize(Size.Empty);

            baseTextBox.ResumeLayout();
            ResumeLayout();
        }
Ejemplo n.º 18
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            //Set Colors
            Color nudTextColor = !useStyleColors?MetroPaint.ForeColor.NumericUpDown.Normal(Theme) : MetroPaint.GetStyleColor(Style);

            if (!this.Enabled)
            {
                nudTextColor = MetroPaint.ForeColor.NumericUpDown.Disabled(Theme);
            }

            Color nudTextBackColor = !useAlternateColors?MetroPaint.BackColor.NumericUpDown.Normal(Theme) : MetroPaint.BackColor.NumericUpDown.Alternate(Theme);

            Color nudControlsBorderColor = MetroPaint.BorderColor.NumericUpDown.Normal(Theme);
            Color nudControlsBackColor   = MetroPaint.BackColor.NumericUpDown.Normal(Theme);
            Color nudControlsForeColor   = MetroPaint.BorderColor.NumericUpDown.Normal(Theme);

            bool Debug = false; //for check consistency of the Rectangles

            var       gr      = e.Graphics;
            Rectangle nudRect = this.ClientRectangle;

            nudRect.Height -= 1;
            nudRect.Width  -= 1;


            gr.FillRectangle(new SolidBrush(nudControlsBackColor), nudRect);
            gr.DrawRectangle(new Pen(nudControlsBorderColor), nudRect);

            if (Debug)
            {
                gr.DrawRectangle(new Pen(Color.Red), nudRect);
            }

            foreach (Control c in this.Controls)
            {
                if (!(c is TextBox)) // -->Up Down Buttons
                {
                    //override inner's control paintevent (Button UP & Down)
                    typeof(Control).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, c, new object[] { true });
                    c.Paint += (sender, pev) =>
                    {
                        var g = pev.Graphics;
                        int h = c.Height;
                        int w = c.Width;

                        Rectangle buttonsUpDownRect = c.ClientRectangle;
                        buttonsUpDownRect.Height -= 1;
                        buttonsUpDownRect.Width  -= 1;

                        //control rectnagles
                        Rectangle UpArrowRect   = new Rectangle(1, 1, w - 3, h / 2 - 2);
                        Rectangle DownArrowRect = new Rectangle(1, h / 2, w - 3, h / 2 - 2);

                        //Draw Controls Rectangle
                        g.DrawRectangle(new Pen(nudControlsBackColor), buttonsUpDownRect);
                        if (Debug)
                        {
                            g.DrawRectangle(new Pen(Color.Green), buttonsUpDownRect);
                        }

                        //Cutom Draw Buttons
                        if (customDrawButtons)
                        {
                            //ClearBackGround
                            g.FillRectangle(new SolidBrush(nudControlsBackColor), buttonsUpDownRect);

                            //draw BackGround
                            g.FillRectangle(new SolidBrush(nudControlsBackColor), UpArrowRect);
                            g.FillRectangle(new SolidBrush(nudControlsBackColor), DownArrowRect);
                            g.DrawRectangle(new Pen(nudControlsBorderColor), UpArrowRect);
                            g.DrawRectangle(new Pen(nudControlsBorderColor), DownArrowRect);
                            if (Debug)
                            {
                                g.DrawRectangle(new Pen(Color.Violet), UpArrowRect);
                            }
                            if (Debug)
                            {
                                g.DrawRectangle(new Pen(Color.Blue), DownArrowRect);
                            }

                            //draw Arrows
                            MetroDrawingMethods.PaintUpArrow(g, UpArrowRect, nudControlsForeColor, 0, -1);
                            MetroDrawingMethods.PaintDownArrow(g, DownArrowRect, nudControlsForeColor, 0, 0);
                        }
                    };
                }
                else if ((c is TextBox))
                {
                    //Set Textbox fore Color
                    c.ForeColor = nudTextColor;
                    if (Debug)
                    {
                        c.ForeColor = Color.Red;
                    }

                    //Set Textbox back Color
                    c.BackColor = nudTextBackColor;
                    if (Debug)
                    {
                        c.BackColor = Color.Yellow;
                    }

                    c.Font = MetroFonts.Label(metroLabelSize, metroLabelWeight);
                }
            }
        }
Ejemplo n.º 19
0
        protected virtual void OnPaintForeground(PaintEventArgs e)
        {
            Color foreColor;

            if (useCustomForeColor)
            {
                foreColor = ForeColor;
            }
            else
            {
                if (!Enabled)
                {
                    if (Parent != null)
                    {
                        //if (Parent is MetroTile)
                        if (false)
                        {
                            foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                    else
                    {
                        foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                    }
                }
                else
                {
                    if (Parent != null)
                    {
                        //if (Parent is MetroTile)
                        if (false)
                        {
                            foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                        }
                        else
                        {
                            if (useStyleColors)
                            {
                                foreColor = MetroPaint.GetStyleColor(Style);
                            }
                            else
                            {
                                //foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                                foreColor = Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
                            }
                        }
                    }
                    else
                    {
                        if (useStyleColors)
                        {
                            foreColor = MetroPaint.GetStyleColor(Style);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                }
            }

            if (LabelMode == MetroLabelMode.Selectable)
            {
                CreateBaseTextBox();
                UpdateBaseTextBox();

                if (!baseTextBox.Visible)
                {
                    TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign));
                }
            }
            else
            {
                DestroyBaseTextbox();
                TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign, wrapToLine));
                OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics));
            }
        }
Ejemplo n.º 20
0
        protected virtual void OnPaintForeground(PaintEventArgs e)
        {
            Color foreColor;

            if (useCustomForeColor)
            {
                foreColor = ForeColor;
            }
            else
            {
                if (!Enabled)
                {
                    if (Parent != null)
                    {
                        if (Parent is MetroTile)
                        {
                            foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                    else
                    {
                        foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                    }
                }
                else
                {
                    if (Parent != null)
                    {
                        if (Parent is MetroTile)
                        {
                            foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                        }
                        else
                        {
                            if (useStyleColors)
                            {
                                foreColor = MetroPaint.GetStyleColor(Style);
                            }
                            else
                            {
                                foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                            }
                        }
                    }
                    else
                    {
                        if (useStyleColors)
                        {
                            foreColor = MetroPaint.GetStyleColor(Style);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                }
            }
            if (_isShowBorder)
            {
                int cornerRadius = 3;
                //边框颜色
                Color c = borderColor;
                Pen   p = new Pen(c);
                p.Width = 1;
                //边框工作区
                Rectangle    rect = this.ClientRectangle;
                GraphicsPath Rect = new GraphicsPath();
                // 添加圆弧
                Rect.AddArc(0, 0, cornerRadius * 2, cornerRadius * 2, 180, 90);
                Rect.AddArc(rect.Width - cornerRadius * 2 - 1, 0, cornerRadius * 2, cornerRadius * 2, 270, 90);
                Rect.AddArc(rect.Width - cornerRadius * 2 - 1, rect.Height - cornerRadius * 2 - 1, cornerRadius * 2,
                            cornerRadius * 2, 0, 90);
                Rect.AddArc(0, rect.Height - cornerRadius * 2 - 1, cornerRadius * 2, cornerRadius * 2, 90, 90);
                Rect.CloseFigure();
                e.Graphics.DrawPath(p, Rect);
            }
            if (LabelMode == MetroLabelMode.Selectable)
            {
                CreateBaseTextBox();
                UpdateBaseTextBox();

                if (!baseTextBox.Visible)
                {
                    TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign));
                }
            }
            else
            {
                DestroyBaseTextbox();
                TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign, wrapToLine));
                OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics));
            }
        }
Ejemplo n.º 21
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color backColor, foreColor;

            if (useCustomBackground)
            {
                backColor = BackColor;
            }
            else
            {
                backColor = MetroPaint.BackColor.Form(Theme);
                if (Parent is MetroTile)
                {
                    backColor = MetroPaint.GetStyleColor(Style);
                }
            }

            if (!Enabled)
            {
                if (Parent != null)
                {
                    if (Parent is MetroTile)
                    {
                        foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme);
                    }
                    else
                    {
                        foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                    }
                }
                else
                {
                    foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                }
            }
            else
            {
                if (Parent != null)
                {
                    if (Parent is MetroTile)
                    {
                        foreColor = MetroPaint.ForeColor.Tile.Normal(Theme, Style);
                    }
                    else
                    {
                        if (useStyleColors)
                        {
                            foreColor = MetroPaint.GetStyleColor(Style);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                }
                else
                {
                    if (useStyleColors)
                    {
                        foreColor = MetroPaint.GetStyleColor(Style);
                    }
                    else
                    {
                        foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                    }
                }
            }

            e.Graphics.Clear(backColor);

            if (LabelMode == MetroLabelMode.Selectable)
            {
                CreateBaseTextBox();
                UpdateBaseTextBox();
            }
            else
            {
                DestroyBaseTextbox();
                TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign));
            }
        }
Ejemplo n.º 22
0
 // Token: 0x0600019A RID: 410 RVA: 0x00005EFC File Offset: 0x000040FC
 private void UpdateBaseTextBox()
 {
     if (!this.baseTextBox.Visible)
     {
         return;
     }
     base.SuspendLayout();
     this.baseTextBox.SuspendLayout();
     if (this.useCustomBackground)
     {
         this.baseTextBox.BackColor = this.BackColor;
     }
     else
     {
         this.baseTextBox.BackColor = MetroPaint.BackColor.Form(base.Theme);
     }
     if (!base.Enabled)
     {
         if (base.Parent != null)
         {
             if (base.Parent is MetroTile)
             {
                 this.baseTextBox.ForeColor = MetroPaint.ForeColor.Tile.Disabled(base.Theme);
             }
             else if (this.useStyleColors)
             {
                 this.baseTextBox.ForeColor = MetroPaint.GetStyleColor(base.Style);
             }
             else
             {
                 this.baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Disabled(base.Theme);
             }
         }
         else if (this.useStyleColors)
         {
             this.baseTextBox.ForeColor = MetroPaint.GetStyleColor(base.Style);
         }
         else
         {
             this.baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Disabled(base.Theme);
         }
     }
     else if (base.Parent != null)
     {
         if (base.Parent is MetroTile)
         {
             this.baseTextBox.ForeColor = MetroPaint.ForeColor.Tile.Normal(base.Theme);
         }
         else if (this.useStyleColors)
         {
             this.baseTextBox.ForeColor = MetroPaint.GetStyleColor(base.Style);
         }
         else
         {
             this.baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Normal(base.Theme);
         }
     }
     else if (this.useStyleColors)
     {
         this.baseTextBox.ForeColor = MetroPaint.GetStyleColor(base.Style);
     }
     else
     {
         this.baseTextBox.ForeColor = MetroPaint.ForeColor.Label.Normal(base.Theme);
     }
     this.baseTextBox.Font        = MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight);
     this.baseTextBox.Text        = this.Text;
     this.baseTextBox.BorderStyle = BorderStyle.None;
     base.Size = this.GetPreferredSize(Size.Empty);
     this.baseTextBox.ResumeLayout();
     base.ResumeLayout();
 }
Ejemplo n.º 23
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color backColor, foreColor;

            backColor = MetroPaint.GetStyleColor(Style);

            if (isHovered && !isPressed && Enabled)
            {
                foreColor = MetroPaint.ForeColor.Tile.Hover(Theme);
            }
            else if (isHovered && isPressed && Enabled)
            {
                foreColor = MetroPaint.ForeColor.Tile.Press(Theme);
            }
            else if (!Enabled)
            {
                foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme);
            }
            else
            {
                foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
            }

            e.Graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

            if (!isPressed)
            {
                e.Graphics.Clear(MetroPaint.GetStyleColor(Style));
            }
            else
            {
                e.Graphics.Clear(MetroPaint.BackColor.Form(Theme));

                using (SolidBrush b = MetroPaint.GetStyleBrush(Style))
                {
                    Point[] polyPoints = new Point[] { new Point(0, 0), new Point(Width - 1, 2), new Point(Width - 1, Height - 2), new Point(0, Height) };
                    e.Graphics.FillPolygon(b, polyPoints);
                }
            }
            //画图片
            if (TileImage != null)
            {
                Rectangle result = DisplayRectangle;
                switch (tileImageMode)
                {
                case PictureBoxSizeMode.Normal:
                case PictureBoxSizeMode.AutoSize:
                    result.Size = tileImage.Size;
                    break;

                case PictureBoxSizeMode.StretchImage:
                    //居中,大小为磁贴的 长或宽中最小值 的一半
                    int num;
                    if (Width > Height)
                    {
                        num = Height;
                    }
                    else
                    {
                        num = Width;
                    }
                    result.Width  = num / 2;
                    result.Height = num / 2;
                    result.X      = (ClientRectangle.Width - result.Width) / 2;
                    result.Y      = (ClientRectangle.Height - result.Height) / 2;
                    break;

                case PictureBoxSizeMode.CenterImage:
                    result.X   += (result.Width - tileImage.Width) / 2;
                    result.Y   += (result.Height - tileImage.Height) / 2;
                    result.Size = tileImage.Size;
                    break;

                case PictureBoxSizeMode.Zoom:
                    Size  imageSize = tileImage.Size;
                    float ratio     = Math.Min((float)ClientRectangle.Width / (float)imageSize.Width, (float)ClientRectangle.Height / (float)imageSize.Height);
                    result.Width  = (int)(imageSize.Width * ratio);
                    result.Height = (int)(imageSize.Height * ratio);
                    result.X      = (ClientRectangle.Width - result.Width) / 2;
                    result.Y      = (ClientRectangle.Height - result.Height) / 2;
                    break;

                default:
                    break;
                }
                e.Graphics.DrawImage(tileImage, result);
            }

            if (TileCount > 0)
            {
                Size countSize = TextRenderer.MeasureText(TileCount.ToString(), MetroFonts.TileCount);

                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                TextRenderer.DrawText(e.Graphics, TileCount.ToString(), MetroFonts.TileCount, new Point(Width - countSize.Width, 0), foreColor);
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            }

            Size textSize = TextRenderer.MeasureText(Text, MetroFonts.Tile);

            TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), new Point(0, Height - textSize.Height), foreColor);


            if (false && isFocused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);
            }
        }
Ejemplo n.º 24
0
        protected virtual void OnPaintForeground(PaintEventArgs e)
        {
            Color foreColor;

            if (useCustomForeColor)
            {
                foreColor = ForeColor;
            }
            else
            {
                if (!Enabled)
                {
                    if (Parent != null)
                    {
                        if (Parent is MetroTile)
                        {
                            foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                        }
                    }
                    else
                    {
                        foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
                    }
                }
                else
                {
                    if (Parent != null)
                    {
                        if (Parent is MetroTile)
                        {
                            foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                        }
                        else
                        {
                            if (useStyleColors)
                            {
                                foreColor = MetroPaint.GetStyleColor(Style);
                            }
                            else
                            {
                                foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                            }
                        }
                    }
                    else
                    {
                        if (useStyleColors)
                        {
                            foreColor = MetroPaint.GetStyleColor(Style);
                        }
                        else
                        {
                            foreColor = MetroPaint.ForeColor.Label.Normal(Theme);
                        }
                    }
                }
            }

            TextFormatFlags format = MetroPaint.GetTextFormatFlags(TextAlign);

            if (this.AutoSize == false)
            {
                format |= TextFormatFlags.WordBreak;
            }

            if (LabelMode == MetroLabelMode.Selectable)
            {
                CreateBaseTextBox();
                UpdateBaseTextBox();

                if (!baseTextBox.Visible)
                {
                    TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, format);
                }
            }
            else
            {
                DestroyBaseTextbox();
                TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Label(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, format);
                OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics));
            }
        }
Ejemplo n.º 25
0
        // Token: 0x06000190 RID: 400 RVA: 0x00005AE0 File Offset: 0x00003CE0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color color;

            if (this.useCustomBackground)
            {
                color = this.BackColor;
            }
            else
            {
                color = MetroPaint.BackColor.Form(base.Theme);
                if (base.Parent is MetroTile)
                {
                    color = MetroPaint.GetStyleColor(base.Style);
                }
            }
            Color foreColor;

            if (this.useCustomForeColor)
            {
                foreColor = this.ForeColor;
            }
            else if (!base.Enabled)
            {
                if (base.Parent != null)
                {
                    if (base.Parent is MetroTile)
                    {
                        foreColor = MetroPaint.ForeColor.Tile.Disabled(base.Theme);
                    }
                    else
                    {
                        foreColor = MetroPaint.ForeColor.Label.Normal(base.Theme);
                    }
                }
                else
                {
                    foreColor = MetroPaint.ForeColor.Label.Disabled(base.Theme);
                }
            }
            else if (base.Parent != null)
            {
                if (base.Parent is MetroTile)
                {
                    foreColor = MetroPaint.ForeColor.Tile.Normal(base.Theme);
                }
                else if (this.useStyleColors)
                {
                    foreColor = MetroPaint.GetStyleColor(base.Style);
                }
                else
                {
                    foreColor = MetroPaint.ForeColor.Label.Normal(base.Theme);
                }
            }
            else if (this.useStyleColors)
            {
                foreColor = MetroPaint.GetStyleColor(base.Style);
            }
            else
            {
                foreColor = MetroPaint.ForeColor.Label.Normal(base.Theme);
            }
            e.Graphics.Clear(color);
            if (this.LabelMode == MetroLabelMode.Selectable)
            {
                this.CreateBaseTextBox();
                this.UpdateBaseTextBox();
                if (!this.baseTextBox.Visible)
                {
                    TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight), base.ClientRectangle, foreColor, color, MetroPaint.GetTextFormatFlags(this.TextAlign));
                    return;
                }
            }
            else
            {
                this.DestroyBaseTextbox();
                TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Label(this.metroLabelSize, this.metroLabelWeight), base.ClientRectangle, foreColor, color, MetroPaint.GetTextFormatFlags(this.TextAlign));
            }
        }