Esempio n. 1
0
        /// <summary>
        /// Draw item
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(70);
            Bounds   = itemBounds;
            Graphics = 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)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds);

            // Item have focus || mouse hover
            if (Bounds.Contains(owner.MousePosition))
            {
                // Partially transparent tint layer
                g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds);
            }

            // Draw primary text
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush((Bounds.Contains(owner.MousePosition) ? owner.Tint : _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor())), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary);

            // Draw secondary text
            StringFormat sfSecondary = new StringFormat();

            sfSecondary.LineAlignment = StringAlignment.Center;
            Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 10, Bounds.Y + Bounds.Height / 2 - 9, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary);
        }
        /// <summary>
        /// Draw
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(50);
            Bounds   = itemBounds;
            Graphics = 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)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds);

            // Item have focus || mouse hover
            if (Bounds.Contains(owner.MousePosition))
            {
                // Partially transparent tint layer
                g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds);
            }

            // Avatar
            g.FillRectangle(new SolidBrush(owner.Tint), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32)));
            StringFormat sfAvatar = new StringFormat();

            sfAvatar.LineAlignment = StringAlignment.Center;
            sfAvatar.Alignment     = StringAlignment.Center;
            g.DrawString(PrimaryText[0].ToString(), new Font("Segoe UI Light", 12), new SolidBrush(Color.White), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32)), sfAvatar);

            // Draw primary text
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 48, Bounds.Y + 1, Bounds.Width + 50, Bounds.Height), sfPrimary);
        }
Esempio n. 3
0
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(30);
            Bounds   = itemBounds;
            Graphics = 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)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush((_sourceTheme.DARK_BASED) ? MColor.AddRGB(5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()) : MColor.AddRGB(-5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor())), Bounds);

            // Draw primary text
            Color        color     = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI Semibold", 8), new SolidBrush(color), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 5), sfPrimary);

            // Draw divider lines
            Color lineColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y), new Point(Bounds.X + Bounds.Width, Bounds.Y));
            g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y + Bounds.Height - 1), new Point(Bounds.X + Bounds.Width, Bounds.Y + Bounds.Height - 1));
        }
Esempio n. 4
0
        /// <summary>
        /// Draw
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic variables
            Height   = DIP.Set(70);
            Bounds   = itemBounds;
            Graphics = 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 don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)owner.FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Background
            g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds);

            // Item have focus || mouse hover
            if (Bounds.Contains(owner.MousePosition))
            {
                // Partially transparent tint layer
                g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds);
            }

            // Draw primary text
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 21, Bounds.Y + 6, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary);

            // Draw secondary text
            StringFormat sfSecondary = new StringFormat();

            sfSecondary.LineAlignment = StringAlignment.Center;
            Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 21, Bounds.Y + Bounds.Height / 2 - 6, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary);

            Color bad    = new Hex("#F56C6C").ToColor();
            Color medium = new Hex("#E6A23C").ToColor();
            Color good   = new Hex("#67C23A").ToColor();

            string strength  = "";
            Color  infoColor = Color.Beige;

            if (_passwordHash.Length >= 10)
            {
                infoColor = good;
                strength  = "Strong";
            }
            else if (_passwordHash.Length >= 6)
            {
                infoColor = medium;
                strength  = "Good";
            }
            else
            {
                infoColor = bad;
                strength  = "Weak";
            }

            // Draw password hash
            StringFormat sfPassword = new StringFormat();

            sfPassword.LineAlignment = StringAlignment.Center;
            sfPassword.Alignment     = StringAlignment.Far;

            Font  passwordFont  = new Font("Segoe UI", 9);
            SizeF size          = g.MeasureString(strength, passwordFont);
            Color passwordColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor());

            g.DrawString(strength, passwordFont, new SolidBrush(infoColor), new Rectangle(Bounds.X, Bounds.Y, Convert.ToInt32(Bounds.Width - 20), Bounds.Height), sfPassword);
            // new Rectangle(Bounds.X + Bounds.Width - Convert.ToInt32(size.Width) - 21, Bounds.Y + Bounds.Height / 2 - Convert.ToInt32(size.Height/2), Bounds.Width, Bounds.Height / 2 - Convert.ToInt32(size.Height / 2))
        }