コード例 #1
0
ファイル: MTextBox.cs プロジェクト: mkeida/polar-manager
        /// <summary>
        /// Update
        /// </summary>
        protected void Update(object sender, EventArgs e)
        {
            // Color of text
            _textTint             = MColor.Mix(Color.FromArgb(_tintAlpha, _tint), _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());
            FakeTextBox.ForeColor = _textTint;

            // Alpha
            if (FakeTextBox.Focused)
            {
                if (_tintAlpha < 255)
                {
                    _tintAlpha += 15;
                }
            }
            else
            {
                if (_tintAlpha > 0)
                {
                    _tintAlpha -= 15;
                }
            }

            // Redraw
            Invalidate();
        }
コード例 #2
0
        /// <summary>
        /// Draw method
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Regular raised button
            Color fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());
            Color text = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();

            // Disabled
            if (!Enabled)
            {
                fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                text = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
            }

            // Fill control
            g.FillRectangle(new SolidBrush(fill), ClientRectangle);

            // Click effect
            DrawClick(e);

            // Draw text
            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;
            g.DrawString(Text, new Font("Segoe UI", 9), new SolidBrush(text), new Rectangle(ClientRectangle.X + 10, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height), sf);
        }
コード例 #3
0
        /// <summary>
        /// Update
        /// </summary>
        protected void Update(object sender, EventArgs e)
        {
            // Animation
            _t += 0.05;
            if (_t > 1)
            {
                _t = 1;
            }

            // Opening and closing
            if (_opened)
            {
                // Opening
                Height = _header.Height + Animation.CosinusMotion(_t, _dropdownLength);
            }
            else
            {
                // Closing
                Height = _dropdownLength + _header.Height + 2 - Animation.CosinusMotion(_t, _dropdownLength);
            }

            // Hover effect
            if (_hover)
            {
                if (_hoverAlpha < 255)
                {
                    _hoverAlpha += 15;
                }
            }
            else
            {
                if (_hoverAlpha > 0)
                {
                    _hoverAlpha -= 15;
                }
            }

            // Alpha
            if (Focused || _listBox.Focused || _header.Focused || _search.Focused || _search.FakeTextBox.Focused)
            {
                if (_tintAlpha < 255)
                {
                    _tintAlpha += 15;
                }
            }
            else
            {
                if (_tintAlpha > 0)
                {
                    _tintAlpha -= 15;
                }
            }

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Border color
            Color fill       = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());
            Color frameColor = MColor.Mix(Color.FromArgb(_tintAlpha, _tint), fill);

            BackColor = frameColor;
        }
コード例 #4
0
ファイル: MCheckBox.cs プロジェクト: mkeida/polar-manager
        /// <summary>
        /// Paint
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Scaling
            DIP.GetGraphics(this);

            // Fill color, text and border
            Color fill       = new Color();
            Color border     = new Color();
            Color foreground = new Color();

            if (Enabled)
            {
                // Enabled
                fill       = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_BACKGROUND.Hover.ToColor()), _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor());
                border     = _sourceTheme.CONTROL_BORDER.Normal.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            }
            else
            {
                // Disabled
                fill       = _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor();
                border     = _sourceTheme.CONTROL_BORDER.Disabled.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
            }

            // Draw unchecked checkbox
            int height = 19;

            g.FillRectangle(new SolidBrush(fill), new Rectangle(0, Height / 2 - height / 2, height, height));
            g.DrawRectangle(new Pen(border), new Rectangle(0, Height / 2 - height / 2, height, height));

            // Draws cover
            GraphicsPath square = Draw.GetSquarePath(new Point(10, Height / 2 - height / 2 + 10), _a);

            g.FillPath(new SolidBrush(Enabled ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor()), square);

            int b = Height / 2 - height / 2;

            _checkmark = new Point[]
            {
                new Point(4, b + 9),
                new Point(5, b + 10),
                new Point(6, b + 11),
                new Point(7, b + 12),
                new Point(8, b + 13),
                new Point(9, b + 12),
                new Point(10, b + 11),
                new Point(11, b + 10),
                new Point(12, b + 9),
                new Point(13, b + 8),
                new Point(14, b + 7),
                new Point(15, b + 6),
            };

            // Draws checkmark
            if (_a == 10 && _state == true)
            {
                DrawCheckmarkIn(e);
            }

            if (_a == 10 && _state == false)
            {
                DrawCheckmarkOut(e);
            }

            // Draw text
            g.DrawString(this.Text, this.Font, new SolidBrush(foreground), new Point(25, b));
        }
コード例 #5
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Draw raised button
            if (_buttonType == ButtonType.Raised)
            {
                // Fill color
                Color fill = new Color();

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    if (Enabled)
                    {
                        fill = MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint);
                    }
                    else
                    {
                        fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                    }

                    g.FillRectangle(new SolidBrush(fill), ClientRectangle);
                }
                else
                {
                    // Regular raised button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor());

                    // Disabled
                    if (!Enabled)
                    {
                        fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                    }

                    g.FillRectangle(new SolidBrush(fill), ClientRectangle);
                }

                // Click effect
                DrawClick(e);

                // Focus rectangle
                if (Focused || _tintAlpha > 0)
                {
                    Rectangle rc             = new Rectangle(Location.X, Location.Y, Width, Height);
                    Color     frameColor     = MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : fill), fill);
                    Pen       framePen       = new Pen(frameColor);
                    Rectangle frameRectangle = new Rectangle(0, 0, rc.Width - 1, rc.Height - 1);
                    g.DrawRectangle(framePen, frameRectangle);
                }

                // Text
                DrawText(e);
            }

            if (_buttonType == ButtonType.Outline)
            {
                // Fill color
                Color fill   = new Color();
                Color border = new Color();

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    // Fullcolored outlined button
                    fill   = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor();

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                    g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
                }
                else
                {
                    // Fullcolored outlined button
                    fill   = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor);
                    border = (Enabled) ? _sourceTheme.CONTROL_FILL.Normal.ToColor() : _sourceTheme.CONTROL_FILL.Disabled.ToColor();

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                    g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1));
                }

                // Click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }

            if (_buttonType == ButtonType.Flat)
            {
                // Fill color
                Color fill = new Color();

                // Button is filled with his Tint color
                if (_fullColored)
                {
                    // Fullcolored outlined button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor);

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                }
                else
                {
                    // Fullcolored outlined button
                    fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(160, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor);

                    // Disabled
                    if (!Enabled)
                    {
                        fill = Parent.BackColor;
                    }

                    Rectangle r = ClientRectangle;
                    g.FillRectangle(new SolidBrush(fill), r);
                }

                // Click effect
                DrawClick(e);

                // Text
                DrawText(e);
            }
        }
コード例 #6
0
ファイル: MTextBox.cs プロジェクト: mkeida/polar-manager
        /// <summary>
        /// Draw
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);
            Graphics  g  = e.Graphics;
            Rectangle rc = ClientRectangle;

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Clear control
            g.Clear(Parent.BackColor);

            // Fill color
            Color fill = Enabled ? _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor() : _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor();

            // TextBox background color
            FakeTextBox.BackColor = fill;

            // Control outline colors
            Color      backgroundColor = fill;
            SolidBrush backroundBrush  = new SolidBrush(backgroundColor);

            g.FillRectangle(backroundBrush, rc);

            // Draw control outline
            Color frameColor = MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : _sourceTheme.CONTROL_BORDER.Disabled.ToColor()), Enabled ? _sourceTheme.CONTROL_BORDER.Normal.ToColor() : _sourceTheme.CONTROL_BORDER.Disabled.ToColor());
            Pen   framePen   = new Pen(frameColor);

            // Top border
            if (DrawTopBorder)
            {
                g.DrawLine(framePen, new Point(0, 0), new Point(Width, 0));
            }

            // Bottom border
            g.DrawLine(framePen, new Point(0, Height - 1), new Point(Width, Height - 1));

            // Left border
            if (DrawLeftBorder)
            {
                g.DrawLine(framePen, new Point(0, 0), new Point(0, Height - 1));
            }

            // Right border
            if (DrawRightBorder)
            {
                g.DrawLine(framePen, new Point(Width - 1, 0), new Point(Width - 1, Height - 1));
            }
        }
コード例 #7
0
ファイル: MRadioButton.cs プロジェクト: mkeida/polar-manager
        /// <summary>
        /// Draw
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Scaling
            DIP.GetGraphics(this);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Fill color, text and border
            Color fill       = new Color();
            Color border     = new Color();
            Color hover      = new Color();
            Color foreground = new Color();

            if (Enabled)
            {
                // Enabled
                fill       = _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor();
                border     = _sourceTheme.CONTROL_BORDER.Normal.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
                hover      = _sourceTheme.CONTROL_FILL.Hover.ToColor();
            }
            else
            {
                // Disabled
                fill       = _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor();
                border     = _sourceTheme.CONTROL_BORDER.Disabled.ToColor();
                foreground = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
                hover      = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
            }

            // Draw background
            g.FillPath(new SolidBrush(fill), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set((10))));

            // Antialiasing
            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Draw border
            if (!_state)
            {
                g.DrawPath(new Pen(!Checked ? _sourceTheme.CONTROL_BORDER.Normal.ToColor() : _tint, 1), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(10)));
            }

            // Mouse hover
            g.FillPath(new SolidBrush(Color.FromArgb(_hoverAlpha, hover)), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(3)));

            // Animation - inner circle
            g.FillPath(new SolidBrush(Enabled ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor()), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), Convert.ToInt32(_radius)));

            // Animation - border tint
            g.DrawEllipse(new Pen(MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : _sourceTheme.CONTROL_BORDER.Disabled.ToColor()), border)), new Rectangle(0, 0, DIP.Set(20), DIP.Set(20)));

            // Antialiasing
            g.SmoothingMode = SmoothingMode.Default;

            // Draw text
            g.DrawString(this.Text, this.Font, new SolidBrush(foreground), new Point(25 + DIP.Set(8), 2));
        }
コード例 #8
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);
            Graphics g = e.Graphics;

            DIP.GetGraphics(g);

            // Handles control's source theme
            // Check if control has set own theme
            if (Owner.UsedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = Owner.UsedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Draw item background
            Color fill = (Owner.MenuItem == this) ? _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor() : MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(230, _tint, _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor())), _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor());

            g.FillRectangle(new SolidBrush(fill), new Rectangle(0, 0, Width, Height));

            if (FullColored)
            {
                g.FillRectangle(new SolidBrush(MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint)), _tint)), new Rectangle(0, 0, Owner.MenuItem.Height, Owner.MenuItem.Height));
            }

            // Click effect
            DrawClick(e);

            // Icon mode
            if (_icon != null && !_fullColored)
            {
                if (_sourceTheme.DARK_BASED)
                {
                    _icon.DarkBased = true;
                }
                else
                {
                    _icon.DarkBased = false;
                }
            }

            // Draw Icon
            if (_icon != null)
            {
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                if (Owner.SelectedItem == this)
                {
                    Image img = MColor.SetImageColor(_icon.Icon, _tint);
                    g.DrawImage(MColor.SetImageOpacity(img, 1f), 16, 16, 32, 32);
                }
                else
                {
                    g.DrawImage(MColor.SetImageOpacity(_icon.Icon, 1f), 16, 16, 32, 32);
                }
            }
            else
            {
                // Icon rect
                g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(20, 20, 20, 20));
            }

            // Draw text
            SolidBrush brush = (Owner.SelectedItem == this) ? new SolidBrush(_tint) : (_fullColored) ? new SolidBrush(ForeColor) : new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(Text, Font, brush, new Rectangle(65, (Height / 2) - (Font.Height / 2), Width, Height));
        }
コード例 #9
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e">Paint event arguments</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Colors
            Color fill   = new Color();
            Color border = new Color();
            Color fore   = new Color();

            if (Enabled)
            {
                fill   = _sourceTheme.CONTROL_FILL.Normal.ToColor();
                border = MColor.Mix(Color.FromArgb(_tintAlpha, _tint), _sourceTheme.CONTROL_BORDER.Normal.ToColor());
                fore   = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            }
            else
            {
                fill   = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                border = _sourceTheme.CONTROL_BORDER.Disabled.ToColor();
                fore   = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
            }

            // Fill control
            g.FillRectangle(new SolidBrush(fill), ClientRectangle);

            // Handles prefix
            if (_prefix != "")
            {
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(_prefix, this.Font, new SolidBrush(fore), _prefixRectangle, sf);
            }

            // Handles postfix
            if (_postfix != "")
            {
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(_postfix, this.Font, new SolidBrush(fore), _postfixRectangle, sf);
            }

            // Draw borders
            g.DrawRectangle(new Pen(border), new Rectangle(new Point(0, 0), new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1)));
        }