private void InitColors()
        {
            //Set Colors & Fonts
            base.Font         = MetroFonts.Button(metroButtonSize, metroButtonWeight);
            tBorder           = MetroPaint.BorderColor.Button.Normal(Theme);
            tBottomColorBegin = MetroPaint.BackColor.Button.Normal(Theme);
            tBottomColorEnd   = MetroPaint.BackColor.Button.Normal2(Theme);
            Textcol           = MetroPaint.ForeColor.Button.Normal(Theme);
            controlFont       = MetroFonts.Button(metroButtonSize, metroButtonWeight);

            this.Font = MetroFonts.Button(metroButtonSize, metroButtonWeight);

            Invalidate();
            Update();
        }
Exemple #2
0
        private void DrawTextPrompt(Graphics g)
        {
            Color backColor = BackColor;

            if (!useCustomBackColor)
            {
                backColor = MetroPaint.BackColor.Form(Theme);
            }

            var textRect = new Rectangle(2, 2, Width - 20, Height - 4);

            TextRenderer.DrawText(g, promptText, MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect,
                                  SystemColors.GrayText, backColor,
                                  TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
        }
 // Token: 0x060002D4 RID: 724 RVA: 0x00009C68 File Offset: 0x00007E68
 private void CreateBaseTextBox()
 {
     if (this.baseTextBox != null)
     {
         return;
     }
     this.baseTextBox             = new MetroTextBox.PromptedTextBox();
     this.baseTextBox.BorderStyle = BorderStyle.None;
     this.baseTextBox.Font        = MetroFonts.TextBox(this.metroTextBoxSize, this.metroTextBoxWeight);
     this.baseTextBox.Location    = new Point(3, 3);
     this.baseTextBox.Size        = new Size(base.Width - 6, base.Height - 6);
     base.Size = new Size(this.baseTextBox.Width + 6, this.baseTextBox.Height + 6);
     this.baseTextBox.TabStop = true;
     base.Controls.Add(this.baseTextBox);
 }
Exemple #4
0
        public override Size GetPreferredSize(Size proposedSize)
        {
            Size preferredSize;

            base.GetPreferredSize(proposedSize);

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

            return(preferredSize);
        }
Exemple #5
0
        private Size MeasureText(string text)
        {
            Size preferredSize;

            using (Graphics g = CreateGraphics())
            {
                var proposedSize = new Size(int.MaxValue, int.MaxValue);
                preferredSize = TextRenderer.MeasureText(g, text,
                                                         MetroFonts.TabControl(metroLabelSize, metroLabelWeight),
                                                         proposedSize,
                                                         MetroPaint.GetTextFormatFlags(TextAlign) |
                                                         TextFormatFlags.NoPadding);
            }
            return(preferredSize);
        }
        private void CreateListBox()
        {
            if (listboxOpen)
            {
                return;
            }

            listBox      = new WindowsListBox();
            listBox.Font = MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight);
            listBox.Size = new System.Drawing.Size(208, 154);
            listBox.BringToFront();
            listBox.TopMost      = true;
            listBox.DoubleClick += ListBox_DoubleClick;
            listBox.Click       += ListBox_Click;
        }
        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.CheckBox(metroCheckBoxSize, metroCheckBoxWeight), proposedSize, MetroPaint.GetTextFormatFlags(TextAlign));
                preferredSize.Width += 16;
            }

            return(preferredSize);
        }
Exemple #8
0
        private void DrawTab(int index, Graphics graphics)
        {
            Color foreColor;
            Color backColor = BackColor;

            if (!useCustomBackColor)
            {
                backColor = MetroPaint.BackColor.Form(Theme);
            }

            TabPage   tabPage = TabPages[index];
            Rectangle tabRect = GetTabRect(index);

            if (!Enabled)
            {
                foreColor = MetroPaint.ForeColor.Label.Disabled(Theme);
            }
            else
            {
                if (useCustomForeColor)
                {
                    foreColor = DefaultForeColor;
                }
                else
                {
                    foreColor = !useStyleColors
                                    ? MetroPaint.ForeColor.TabControl.Normal(Theme)
                                    : MetroPaint.GetStyleColor(Style);
                }
            }

            if (index == 0)
            {
                tabRect.X = DisplayRectangle.X;
            }

            Rectangle bgRect = tabRect;

            tabRect.Width += 20;

            using (Brush bgBrush = new SolidBrush(backColor))
            {
                graphics.FillRectangle(bgBrush, bgRect);
            }

            TextRenderer.DrawText(graphics, tabPage.Text, MetroFonts.TabControl(metroLabelSize, metroLabelWeight),
                                  tabRect, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign));
        }
Exemple #9
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Color color;

            if (e.Index < 0)
            {
                base.OnDrawItem(e);
                return;
            }
            Color backColor = this.BackColor;

            if (!this.useCustomBackColor)
            {
                backColor = MetroPaint.BackColor.Form(this.Theme);
            }
            if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || e.State == DrawItemState.None)
            {
                using (SolidBrush solidBrush = new SolidBrush(backColor))
                {
                    Graphics  graphics = e.Graphics;
                    int       left     = e.Bounds.Left;
                    int       top      = e.Bounds.Top;
                    int       width    = e.Bounds.Width;
                    Rectangle bounds   = e.Bounds;
                    graphics.FillRectangle(solidBrush, new Rectangle(left, top, width, bounds.Height));
                }
                color = MetroPaint.ForeColor.Link.Normal(this.Theme);
            }
            else
            {
                using (SolidBrush solidBrush1 = new SolidBrush(MetroPaint.GetStyleColor(this.Style)))
                {
                    Graphics  graphic   = e.Graphics;
                    int       num       = e.Bounds.Left;
                    int       top1      = e.Bounds.Top;
                    int       width1    = e.Bounds.Width;
                    Rectangle rectangle = e.Bounds;
                    graphic.FillRectangle(solidBrush1, new Rectangle(num, top1, width1, rectangle.Height));
                }
                color = MetroPaint.ForeColor.Tile.Normal(this.Theme);
            }
            int       num1       = e.Bounds.Top;
            int       width2     = e.Bounds.Width;
            Rectangle bounds1    = e.Bounds;
            Rectangle rectangle1 = new Rectangle(0, num1, width2, bounds1.Height);

            TextRenderer.DrawText(e.Graphics, base.GetItemText(base.Items[e.Index]), MetroFonts.ComboBox(this.metroComboBoxSize, this.metroComboBoxWeight), rectangle1, color, TextFormatFlags.VerticalCenter);
        }
Exemple #10
0
        private void CreateBaseTextBox()
        {
            if (baseTextBox != null)
            {
                return;
            }

            baseTextBox = new PromptedTextBox();

            baseTextBox.BorderStyle = BorderStyle.None;
            baseTextBox.Font        = MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight);
            baseTextBox.Location    = new Point(3, 3);
            baseTextBox.Size        = new Size(Width - 6, Height - 6);

            Size = new Size(baseTextBox.Width + 6, baseTextBox.Height + 6);

            baseTextBox.TabStop = true;
            //baseTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;

            Controls.Add(baseTextBox);

            if (_button != null)
            {
                return;
            }

            _button              = new MetroTextButton();
            _button.Theme        = Theme;
            _button.Style        = Style;
            _button.Location     = new Point(3, 1);
            _button.Size         = new Size(Height - 4, Height - 4);
            _button.TextChanged += _button_TextChanged;
            _button.MouseEnter  += _button_MouseEnter;
            _button.MouseLeave  += _button_MouseLeave;
            _button.Click       += _button_Click;

            if (!this.Controls.Contains(this._button))
            {
                this.Controls.Add(_button);
            }

            if (lnkClear != null)
            {
                return;
            }

            InitializeComponent();
        }
        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;
                }
            }
        }
Exemple #12
0
 public override System.Drawing.Size GetPreferredSize(System.Drawing.Size proposedSize)
 {
     System.Drawing.Size width;
     base.GetPreferredSize(proposedSize);
     using (Graphics graphic = base.CreateGraphics())
     {
         proposedSize = new System.Drawing.Size(2147483647, 2147483647);
         width        = TextRenderer.MeasureText(graphic, this.Text, MetroFonts.CheckBox(this.metroCheckBoxSize, this.metroCheckBoxWeight), proposedSize, MetroPaint.GetTextFormatFlags(this.TextAlign));
         width.Width  = width.Width + 16;
         if (base.CheckAlign == ContentAlignment.TopCenter || base.CheckAlign == ContentAlignment.BottomCenter)
         {
             width.Height = width.Height + 16;
         }
     }
     return(width);
 }
        public override Size GetPreferredSize(Size proposedSize)
        {
            Size preferredSize;

            base.GetPreferredSize(proposedSize);

            using (var g = CreateGraphics())
            {
                string measureText = Text.Length > 0 ? Text : "MeasureText";
                proposedSize          = new Size(int.MaxValue, int.MaxValue);
                preferredSize         = TextRenderer.MeasureText(g, measureText, MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), proposedSize, TextFormatFlags.Left | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.VerticalCenter);
                preferredSize.Height += 4;
            }

            return(preferredSize);
        }
Exemple #14
0
        public virtual void AddButton(string name, string text, DialogResult dr)
        {
            var button = new Button();

            button.BackColor               = ThemeColor;
            button.FlatStyle               = FlatStyle.Flat;
            button.Font                    = MetroFonts.Button(MetroButtonSize.Medium, MetroButtonWeight.Regular);
            button.Name                    = name;
            button.Size                    = new Size(75, 28);
            button.TabIndex                = 0;
            button.Text                    = text;
            button.DialogResult            = dr;
            button.UseVisualStyleBackColor = false;
            this.buttonsPanel.Controls.Add(button);
            this.buttons.Add(button);
        }
Exemple #15
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, ProgressPercentText,
                                                         MetroFonts.ProgressBar(FontSize, FontWeight), proposedSize,
                                                         MetroPaint.GetTextFormatFlags(TextAlign));
            }

            return(preferredSize);
        }
Exemple #16
0
        private void UpdateBaseTextBox()
        {
            if (baseTextBox == null)
            {
                return;
            }

            var size = TextRenderer.MeasureText("0", MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight));

            baseTextBox.Font = MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight);

            baseTextBox.Size     = new Size(Width - 18, Height - 6);
            baseTextBox.Location = new Point(3, (Height - baseTextBox.Height) / 2);

            upButton.Location = new Point(Width - 12, baseTextBox.Location.Y);
            dwButton.Location = new Point(Width - 12, baseTextBox.Location.Y + size.Height - 8);
        }
Exemple #17
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;
            }
        }
Exemple #18
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                Color foreColor;
                Color backColor = BackColor;

                if (!useCustomBackColor)
                {
                    backColor = MetroPaint.BackColor.Form(Theme);
                }

                if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) ||
                    e.State == DrawItemState.None)
                {
                    using (var b = new SolidBrush(backColor))
                    {
                        e.Graphics.FillRectangle(b,
                                                 new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width,
                                                               e.Bounds.Height));
                    }

                    foreColor = MetroPaint.ForeColor.Link.Normal(Theme);
                }
                else
                {
                    using (var b = new SolidBrush(MetroPaint.GetStyleColor(Style)))
                    {
                        e.Graphics.FillRectangle(b,
                                                 new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width,
                                                               e.Bounds.Height));
                    }

                    foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                }

                var textRect = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
                TextRenderer.DrawText(e.Graphics, GetItemText(Items[e.Index]),
                                      MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor,
                                      TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
            }
            else
            {
                base.OnDrawItem(e);
            }
        }
Exemple #19
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                Color foreColor = MetroPaint.ForeColor.Link.Normal(Theme);
                Color backColor = BackColor;

                if (!useCustomBackColor)
                {
                    backColor = MetroPaint.BackColor.Form(Theme);
                }

                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    using (SolidBrush b = new SolidBrush(MetroPaint.GetStyleColor(Style)))
                    {
                        e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
                    }

                    foreColor = MetroPaint.ForeColor.Tile.Normal(Theme);
                    OnItemMouseHover(this.Items[e.Index], e);
                }
                else
                {
                    using (SolidBrush b = new SolidBrush(backColor))
                    {
                        e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height));
                    }
                }

                if (this.DropDownStyle != ComboBoxStyle.DropDown)
                {
                    Rectangle textRect = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);
                    TextRenderer.DrawText(e.Graphics, GetItemText(Items[e.Index]), MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
                }
                else
                {
                    Rectangle textRect = new Rectangle(0, e.Bounds.Top, this.textBox.Width, e.Bounds.Height);
                    TextRenderer.DrawText(e.Graphics, GetItemText(Items[e.Index]), MetroFonts.ComboBox(metroComboBoxSize, metroComboBoxWeight), textRect, foreColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
                }
            }
            else
            {
                base.OnDrawItem(e);
            }
        }
Exemple #20
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();
 }
Exemple #21
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color backColor, foreColor;

            if (useCustomBackground)
            {
                backColor = BackColor;
            }
            else
            {
                backColor = MetroPaint.BackColor.Form(Theme);
            }

            if (useCustomForeColor)
            {
                foreColor = ForeColor;
            }
            else
            {
                if (isHovered && !isPressed && Enabled)
                {
                    foreColor = MetroPaint.ForeColor.Link.Hover(Theme);
                }
                else if (isHovered && isPressed && Enabled)
                {
                    foreColor = MetroPaint.ForeColor.Link.Press(Theme);
                }
                else if (!Enabled)
                {
                    foreColor = MetroPaint.ForeColor.Link.Disabled(Theme);
                }
                else
                {
                    foreColor = !useStyleColors?MetroPaint.ForeColor.Link.Normal(Theme) : MetroPaint.GetStyleColor(Style);
                }
            }

            e.Graphics.Clear(backColor);
            TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), ClientRectangle, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign));

            if (false && isFocused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);
            }
        }
        private void CreateBaseTextBox()
        {
            if (baseTextBox != null)
            {
                return;
            }

            baseTextBox = new TextBox();

            baseTextBox.BorderStyle = BorderStyle.None;
            baseTextBox.Font        = MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight);
            baseTextBox.Location    = new Point(3, 3);
            baseTextBox.Size        = new Size(Width - 6, Height - 6);

            Size = new Size(baseTextBox.Width + 6, baseTextBox.Height + 6);
            //baseTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
            Controls.Add(baseTextBox);
        }
Exemple #23
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();
        }
Exemple #24
0
        // Token: 0x060000B3 RID: 179 RVA: 0x000040D8 File Offset: 0x000022D8
        private void MetroToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            MetroThemeStyle theme     = (base.Theme == MetroThemeStyle.Light) ? MetroThemeStyle.Dark : MetroThemeStyle.Light;
            Color           color     = MetroPaint.BackColor.Form(theme);
            Color           color2    = MetroPaint.BorderColor.Button.Normal(theme);
            Color           foreColor = MetroPaint.ForeColor.Label.Normal(theme);

            using (SolidBrush solidBrush = new SolidBrush(color))
            {
                e.Graphics.FillRectangle(solidBrush, e.Bounds);
            }
            using (Pen pen = new Pen(color2))
            {
                e.Graphics.DrawRectangle(pen, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
            }
            Font font = MetroFonts.Default(13f);

            TextRenderer.DrawText(e.Graphics, e.ToolTipText, font, e.Bounds, foreColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
        }
Exemple #25
0
        private void UpdateBaseTextBox()
        {
            if (baseTextBox == null)
            {
                return;
            }

            baseTextBox.Font = MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight);

            if (displayIcon)
            {
                Point textBoxLocation = new Point(iconSize.Width + 4, 3);
                if (textBoxIconRight)
                {
                    textBoxLocation = new Point(3, 3);
                }


                if ((metroTextBoxSize == MetroTextBoxSize.Px20 || metroTextBoxSize == MetroTextBoxSize.Px18) && !Multiline)
                {
                    baseTextBox.Size     = new Size(Width - 7 - iconSize.Width, 29);
                    baseTextBox.Location = new Point(iconSize.Width + 4, (Height - 29) / 2);
                }
                else
                {
                    baseTextBox.Location = textBoxLocation;
                    baseTextBox.Size     = new Size(Width - 7 - iconSize.Width, Height - 6);
                }
            }
            else
            {
                if ((metroTextBoxSize == MetroTextBoxSize.Px20 || metroTextBoxSize == MetroTextBoxSize.Px18) && !Multiline)
                {
                    baseTextBox.Size     = new Size(Width - 7 - iconSize.Width, 29);
                    baseTextBox.Location = new Point(iconSize.Width + 4, (Height - 29) / 2);
                }
                else
                {
                    baseTextBox.Location = new Point(3, 3);
                    baseTextBox.Size     = new Size(Width - 6, Height - 6);
                }
            }
        }
        private void DrawProgressText(Graphics graphics)
        {
            if (HideProgressText)
            {
                return;
            }

            Color foreColor;

            if (!Enabled)
            {
                foreColor = MetroPaint.ForeColor.ProgressBar.Disabled(Theme);
            }
            else
            {
                foreColor = MetroPaint.ForeColor.ProgressBar.Normal(Theme);
            }

            TextRenderer.DrawText(graphics, ProgressPercentText, MetroFonts.ProgressBar(metroLabelSize, metroLabelWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign));
        }
Exemple #27
0
        private void CreateListBox()
        {
            if (baseListBox != null)
            {
                return;
            }

            baseListBox = new ListBox();

            baseListBox.BorderStyle = BorderStyle.None;
            baseListBox.Font        = MetroFonts.TextBox(metroTextBoxSize, metroTextBoxWeight);
            baseListBox.Location    = new Point(3, 3);
            baseListBox.Size        = new Size(Width - 6, Height - 6);

            Size = new Size(baseListBox.Width + 6, baseListBox.Height + 6);

            baseListBox.TabStop = true;

            Controls.Add(baseListBox);
        }
        protected virtual void OnPaintForeground(PaintEventArgs e)
        {
            if (useCustomForeColor)
            {
                foreColor = ForeColor;
            }
            else
            {
                if (isHovered && !isPressed && Enabled)
                {
                    //foreColor = MetroPaint.ForeColor.Link.Hover(Theme);
                    foreColor = MetroPaint.ForeColor.Link.Normal(Theme);
                }
                else if (isHovered && isPressed && Enabled)
                {
                    foreColor = MetroPaint.ForeColor.Link.Press(Theme);
                }
                else if (!Enabled)
                {
                    foreColor = MetroPaint.ForeColor.Link.Disabled(Theme);
                }
                else
                {
                    foreColor = !useStyleColors?MetroPaint.ForeColor.Link.Hover(Theme) : MetroPaint.GetStyleColor(Style);
                }
            }

            TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign, !this.AutoSize));

            OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics));

            if (displayFocusRectangle && isFocused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);
            }

            if (_image != null)
            {
                DrawIcon(e.Graphics);
            }
        }
Exemple #29
0
        private void MetroToolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            MetroThemeStyle displayTheme = MetroThemeStyle.Light;

            Color backColor   = MetroPaint.BackColor.Form(displayTheme);
            Color borderColor = MetroPaint.BorderColor.Button.Normal(displayTheme);
            Color foreColor   = MetroPaint.ForeColor.Label.Normal(displayTheme);

            using (SolidBrush b = new SolidBrush(backColor))
            {
                e.Graphics.FillRectangle(b, e.Bounds);
            }
            using (Pen p = new Pen(borderColor))
            {
                e.Graphics.DrawRectangle(p, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));
            }

            Font f = MetroFonts.Default(13f);

            TextRenderer.DrawText(e.Graphics, e.ToolTipText, f, e.Bounds, foreColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
        }
        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);
        }