コード例 #1
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics graphics = pevent.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(BackColor);

            var checkmarkPath = RoundRectangle.CreateRoundRect(2, 2, 16, 16, 1);
            var checkMarkLine = new Rectangle(3, 3, 14, 14);

            SolidBrush BG  = new SolidBrush(_Enable ? (Checked || enterFlag ? _EnabledCheckedColor : _EnabledUncheckedColor) : _DisabledColor);
            Pen        Pen = new Pen(BG.Color);

            graphics.FillPath(BG, checkmarkPath);
            graphics.DrawPath(Pen, checkmarkPath);

            graphics.DrawLines(new Pen(Color.White, 2), new PointF[]
            {
                new PointF(5, 9), new PointF(9, 13), new PointF(15, 6)
            });
            graphics.FillRectangle(new SolidBrush(Color.White), PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum);

            graphics.DrawString(Text, Font, new SolidBrush(_Enable ? (Checked ? _CheckedColor : ForeColor) : _DisabledStringColor), new RectangleF(22, 0, Width - 22, Height), HopeStringAlign.Center);
        }
コード例 #2
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == 0x000F || m.Msg == 0x133)
            {
                IntPtr hDC = GetWindowDC(m.HWnd);
                if (hDC.ToInt32() == 0)
                {
                    return;
                }

                Graphics graphics = Graphics.FromHdc(hDC);

                graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                graphics.SmoothingMode     = SmoothingMode.HighQuality;
                graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.Clear(Parent.BackColor);

                var backPath = RoundRectangle.CreateRoundRect(1, 1, Width - 2, Height - 2, 2);
                graphics.FillPath(new SolidBrush(Color.White), backPath);
                graphics.DrawPath(new Pen(HopeColors.OneLevelBorder, 2), backPath);

                graphics.FillRectangle(new SolidBrush(Color.White), new RectangleF(1, 1, Width - 2, Height - 2));

                graphics.DrawString(Text, Font, new SolidBrush(HopeColors.PrimaryColor), new Point(6, 6));

                graphics.DrawString("6", new Font("Marlett", 12), new SolidBrush(SystemColors.ControlDark), new Rectangle(Width - 22, (Height - 18) / 2, 18, 18));

                ReleaseDC(m.HWnd, hDC);
            }
        }
コード例 #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Bitmap    B        = new Bitmap(Width, Height);
            Graphics  G        = Graphics.FromImage(B);
            Rectangle TitleBox = new Rectangle(51, 3, Width - 103, 18);
            Rectangle box      = new Rectangle(0, 0, Width - 1, Height - 10);

            G.Clear(Color.Transparent);
            G.SmoothingMode = SmoothingMode.HighQuality;

            // Draw the body of the GroupBox
            G.FillPath(new SolidBrush(_BackGColor), RoundRectangle.RoundRect(new Rectangle(1, 12, Width - 3, box.Height - 1), 8));
            // Draw the border of the GroupBox
            G.DrawPath(new Pen(_BorderColorG), RoundRectangle.RoundRect(new Rectangle(1, 12, Width - 3, Height - 13), 8));

            // Draw the background of the title box
            G.FillPath(new SolidBrush(_HeaderColor), RoundRectangle.RoundRect(TitleBox, 1));
            // Draw the border of the title box
            G.DrawPath(new Pen(_BorderColorH), RoundRectangle.RoundRect(TitleBox, 4));
            // Draw the specified string from 'Text' property inside the title box
            G.DrawString(Text, Font, new SolidBrush(ForeColor), TitleBox, new StringFormat
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            });

            e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }
コード例 #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            LinearGradientBrush LGB = default(LinearGradientBrush);
            GraphicsPath        GP  = default(GraphicsPath);

            e.Graphics.Clear(BackColor);
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            // Create a curvy border
            GP = RoundRectangle.RoundRect(0, 0, Width - 1, Height - 1, 5);
            // Fills the body of the rectangle with a gradient
            LGB = new LinearGradientBrush(ClientRectangle, Color.FromArgb(241, 241, 241), Color.FromArgb(241, 241, 241), 90f);

            e.Graphics.SetClip(GP);
            e.Graphics.FillRectangle(LGB, ClientRectangle);
            e.Graphics.ResetClip();

            // Draw rectangle border
            e.Graphics.DrawPath(new Pen(Color.FromArgb(204, 204, 204)), GP);
            // Draw string
            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(3, 0, Width - 20, Height), new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Near
            });

            // Draw the dropdown arrow
            e.Graphics.DrawLine(new Pen(Color.FromArgb(160, 160, 160), 2), new Point(Width - 18, 10), new Point(Width - 14, 14));
            e.Graphics.DrawLine(new Pen(Color.FromArgb(160, 160, 160), 2), new Point(Width - 14, 14), new Point(Width - 10, 10));
            e.Graphics.DrawLine(new Pen(Color.FromArgb(160, 160, 160)), new Point(Width - 14, 15), new Point(Width - 14, 14));

            GP.Dispose();
            LGB.Dispose();
        }
コード例 #5
0
ファイル: HopeButton.cs プロジェクト: starts2000/ReaLTaiizor
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            if (ButtonType == HopeButtonType.Default)
            {
                var BG = RoundRectangle.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);
                graphics.FillPath(new SolidBrush(enterFlag ? Color.FromArgb(25, _DefaultColor) : _DefaultColor), BG);
                graphics.DrawPath(new Pen(clickFlag ? _DefaultColor : _BorderColor, 1), BG);
                graphics.DrawString(Text, Font, new SolidBrush(enterFlag ? _HoverTextColor : TextColor), new RectangleF(0, 0, Width, Height), HopeStringAlign.Center);
            }
            else
            {
                var BG        = RoundRectangle.CreateRoundRect(0, 0, Width, Height, 3);
                var backColor = _DefaultColor;
                switch (ButtonType)
                {
                case HopeButtonType.Primary:
                    backColor = _PrimaryColor;
                    break;

                case HopeButtonType.Success:
                    backColor = _SuccessColor;
                    break;

                case HopeButtonType.Info:
                    backColor = _InfoColor;
                    break;

                case HopeButtonType.Warning:
                    backColor = _WarningColor;
                    break;

                case HopeButtonType.Danger:
                    backColor = _DangerColor;
                    break;

                default:
                    break;
                }

                var brush = new SolidBrush(enterFlag ? (clickFlag ? backColor : Color.FromArgb(225, backColor)) : backColor);
                graphics.FillPath(brush, BG);
                if (!Enabled)
                {
                    graphics.FillPath(new SolidBrush(Color.FromArgb(125, _BorderColor)), BG);
                }
                graphics.DrawString(Text, Font, new SolidBrush(enterFlag ? _HoverTextColor : TextColor), new RectangleF(0, 0, Width, Height), HopeStringAlign.Center);
            }
        }
コード例 #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            var backBrush = new SolidBrush(_DefaultBackColor);
            var textBrush = new SolidBrush(_DefaultTextColor);

            switch (Type)
            {
            case AlertType.Success:
                backBrush = new SolidBrush(_SuccessBackColor);
                textBrush = new SolidBrush(_SuccessTextColor);
                break;

            case AlertType.Warning:
                backBrush = new SolidBrush(_WarningBackColor);
                textBrush = new SolidBrush(_WarningTextColor);
                break;

            case AlertType.Info:
                backBrush = new SolidBrush(_InfoBackColor);
                textBrush = new SolidBrush(_InfoTextColor);
                break;

            case AlertType.Error:
                backBrush = new SolidBrush(_ErrorBackColor);
                textBrush = new SolidBrush(_ErrorTextColor);
                break;

            default:
                break;
            }

            var back = RoundRectangle.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);

            graphics.FillPath(new SolidBrush(Color.White), back);
            graphics.FillPath(backBrush, back);
            graphics.DrawPath(new Pen(textBrush, 1f), back);
            if (_Close)
            {
                graphics.DrawString(Text, Font, textBrush, new RectangleF(20, 0, Width - 40, Height), HopeStringAlign.Left);
                graphics.DrawString("r", new Font("Marlett", 10), new SolidBrush(_CloseColor), new Rectangle(Width - 34, 1, 34, 34), HopeStringAlign.Center);
            }
            else
            {
                graphics.DrawString(Text, Font, textBrush, new RectangleF(20, 0, Width - 35, Height), HopeStringAlign.Left);
            }
        }
コード例 #7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics  G = e.Graphics;
            Rectangle ItemBoundsRect = new Rectangle();

            G.Clear(_BaseColor);
            for (int TabIndex = 0; TabIndex <= TabCount - 1; TabIndex++)
            {
                ItemBoundsRect = GetTabRect(TabIndex);
                if (!(TabIndex == SelectedIndex))
                {
                    G.DrawString(TabPages[TabIndex].Text, new Font(Font.Name, Font.Size - 2, FontStyle.Bold), new SolidBrush(_DeactivePageTextColor), new Rectangle(GetTabRect(TabIndex).Location, GetTabRect(TabIndex).Size), new StringFormat
                    {
                        LineAlignment = StringAlignment.Center,
                        Alignment     = StringAlignment.Center
                    });
                }
            }

            // Draw container rectangle
            G.FillPath(new SolidBrush(_PageEdgeColor), RoundRectangle.RoundRect(0, 23, Width - 1, Height - 24, 2));
            G.DrawPath(new Pen(_PageEdgeBorderColor), RoundRectangle.RoundRect(0, 23, Width - 1, Height - 24, 2));

            for (int ItemIndex = 0; ItemIndex <= TabCount - 1; ItemIndex++)
            {
                ItemBoundsRect = GetTabRect(ItemIndex);
                if (ItemIndex == SelectedIndex)
                {
                    // Draw header tabs
                    G.DrawPath(new Pen(_ActivePageBorderColor), RoundRectangle.RoundedTopRect(new Rectangle(new Point(ItemBoundsRect.X - 2, ItemBoundsRect.Y - 2), new Size(ItemBoundsRect.Width + 3, ItemBoundsRect.Height)), 7));
                    G.FillPath(new SolidBrush(_ActivePageBackColor), RoundRectangle.RoundedTopRect(new Rectangle(new Point(ItemBoundsRect.X - 1, ItemBoundsRect.Y - 1), new Size(ItemBoundsRect.Width + 2, ItemBoundsRect.Height)), 7));

                    try
                    {
                        G.DrawString(TabPages[ItemIndex].Text, new Font(Font.Name, Font.Size - 1, FontStyle.Bold), new SolidBrush(_ActivePageTextColor), new Rectangle(GetTabRect(ItemIndex).Location, GetTabRect(ItemIndex).Size), new StringFormat
                        {
                            LineAlignment = StringAlignment.Center,
                            Alignment     = StringAlignment.Center
                        });
                        TabPages[ItemIndex].BackColor = _PageBackColor;
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Bitmap    B = new Bitmap(Width, Height);
            Graphics  G = Graphics.FromImage(B);
            Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
            Color     TransparencyKey = ParentForm.TransparencyKey;

            G.SmoothingMode = SmoothingMode.Default;
            G.Clear(TransparencyKey);

            // Draw the container borders
            G.FillPath(new SolidBrush(Color.FromArgb(52, 52, 52)), RoundRectangle.RoundRect(ClientRectangle, BorderCurve));
            // Draw a rectangle in which the controls should be added on
            G.FillPath(new SolidBrush(Color.FromArgb(32, 41, 50)), RoundRectangle.RoundRect(new Rectangle(2, 20, Width - 5, Height - 42), BorderCurve));

            // Patch the header with a rectangle that has a curve so its border will remain within container bounds
            G.FillPath(new SolidBrush(Color.FromArgb(52, 52, 52)), RoundRectangle.RoundRect(new Rectangle(2, 2, (int)(Width / 2 + 2), 16), BorderCurve));
            G.FillPath(new SolidBrush(Color.FromArgb(52, 52, 52)), RoundRectangle.RoundRect(new Rectangle((int)(Width / 2 - 3), 2, (int)(Width / 2), 16), BorderCurve));
            // Fill the header rectangle below the patch
            G.FillRectangle(new SolidBrush(Color.FromArgb(52, 52, 52)), new Rectangle(2, 15, Width - 5, 10));

            // Increase the thickness of the container borders
            G.DrawPath(new Pen(Color.FromArgb(52, 52, 52)), RoundRectangle.RoundRect(new Rectangle(2, 2, Width - 5, Height - 5), BorderCurve));
            G.DrawPath(new Pen(Color.FromArgb(52, 52, 52)), RoundRectangle.RoundRect(ClientRectangle, BorderCurve));

            // Draw the string from the specified 'Text' property on the header rectangle
            G.DrawString(Text, new Font("Trebuchet MS", 10, FontStyle.Bold), new SolidBrush(Color.FromArgb(221, 221, 221)), new Rectangle(BorderCurve, BorderCurve - 4, Width - 1, 22), new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Near
            });

            // Draws a rectangle at the bottom of the container
            G.FillRectangle(new SolidBrush(Color.FromArgb(52, 52, 52)), 0, Height - 25, Width - 3, 22 - 2);
            G.DrawLine(new Pen(Color.FromArgb(52, 52, 52)), 5, Height - 5, Width - 6, Height - 5);
            G.DrawLine(new Pen(Color.FromArgb(52, 52, 52)), 7, Height - 4, Width - 7, Height - 4);

            G.DrawString(_TextBottom, new Font("Trebuchet MS", 10, FontStyle.Bold), new SolidBrush(Color.FromArgb(221, 221, 221)), 5, Height - 23);

            e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
            G.Dispose();
            B.Dispose();
        }
コード例 #9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics   G     = e.Graphics;
            HatchBrush Hatch = new HatchBrush(HatchStyle.WideDownwardDiagonal, Color.FromArgb(20, Color.Black), Color.Transparent);

            G.Clear(Parent.BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;
            checked
            {
                PipeBorder = RoundRectangle.RoundRect(1, 6, Width - 3, 8, 3);
                try
                {
                    ValueDrawer = (int)Math.Round(unchecked (checked ((double)(_Value - _Minimum) / (double)(_Maximum - _Minimum)) * (double)checked (Width - 11)));
                }
                catch (Exception)
                {
                }
                TrackBarHandleRect = new Rectangle(ValueDrawer, 0, 10, 20);
                G.SetClip(PipeBorder);
                ValueRect = new Rectangle(1, 7, TrackBarHandleRect.X + TrackBarHandleRect.Width - 2, 7);
                VlaueLGB  = new LinearGradientBrush(ValueRect, _ValueColour, _ValueColour, 90f);
                G.FillRectangle(VlaueLGB, ValueRect);

                if (_DrawHatch == true)
                {
                    G.FillRectangle(Hatch, ValueRect);
                }

                G.ResetClip();
                G.SmoothingMode = SmoothingMode.AntiAlias;
                G.DrawPath(new Pen(Color.FromArgb(180, 180, 180)), PipeBorder);
                TrackBarHandle    = RoundRectangle.RoundRect(TrackBarHandleRect, 3);
                TrackBarHandleLGB = new LinearGradientBrush(ClientRectangle, SystemColors.Control, SystemColors.Control, 90f);
                G.FillPath(TrackBarHandleLGB, TrackBarHandle);
                G.DrawPath(new Pen(Color.FromArgb(180, 180, 180)), TrackBarHandle);

                if (_DrawValueString == true)
                {
                    G.DrawString(Convert.ToString(ValueToSet), Font, Brushes.Gray, 0, 25);
                }
            }
        }
コード例 #10
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            var graphics = pe.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            if (Image == null)
            {
                graphics.FillRectangle(new SolidBrush(BackColor), new RectangleF(0, 0, Width, Height));
            }
            base.OnPaint(pe);

            var backPath = RoundRectangle.CreateRoundRect(0, 00, Width, Height, 4);

            graphics.DrawPath(new Pen(Parent.BackColor, 4), backPath);
        }
コード例 #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            var BG = RoundRectangle.CreateRoundRect(1, 1, Width - 2, Height - 2, 3);

            graphics.FillPath(new SolidBrush(ThemeColor), BG);
            graphics.DrawPath(new Pen(_BorderColor), BG);

            if (ShowText)
            {
                graphics.DrawLine(new Pen(_LineColor, 1), 0, 38, Width, 38);
                graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new RectangleF(15, 0, Width - 50, 38), HopeStringAlign.Left);
            }
        }
コード例 #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics G = e.Graphics;

            G.Clear(Parent.BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;
            TrackThumb      = new Rectangle(8, 10, Width - 16, 2);
            PipeBorder      = RoundRectangle.RoundRect(1, 8, Width - 3, 5, 2);

            try
            {
                ValueDrawer = (int)Math.Round(((double)(_Value - _Minimum) / (double)(_Maximum - _Minimum)) * (double)(Width - 11));
            }
            catch (Exception)
            {
            }

            TrackBarHandleRect = new Rectangle(ValueDrawer, 0, 10, 20);

            G.SetClip(PipeBorder); // Set the clipping region of this Graphics to the specified GraphicsPath
            G.FillPath(new SolidBrush(_EmptyBackColor), PipeBorder);
            FillValue = RoundRectangle.RoundRect(1, 8, TrackBarHandleRect.X + TrackBarHandleRect.Width - 4, 5, 2);

            G.ResetClip(); // Reset the clip region of this Graphics to an infinite region

            G.SmoothingMode = SmoothingMode.HighQuality;
            G.DrawPath(new Pen(_BorderColor), PipeBorder); // Draw pipe border
            G.FillPath(new SolidBrush(_FillBackColor), FillValue);

            G.FillEllipse(new SolidBrush(_ThumbBackColor), TrackThumb.X + (int)Math.Round(unchecked ((double)TrackThumb.Width * ((double)Value / (double)Maximum))) - (int)Math.Round((double)ThumbSize.Width / 2.0), TrackThumb.Y + (int)Math.Round((double)TrackThumb.Height / 2.0) - (int)Math.Round((double)ThumbSize.Height / 2.0), ThumbSize.Width, ThumbSize.Height);
            G.DrawEllipse(new Pen(_ThumbBorderColor), TrackThumb.X + (int)Math.Round(unchecked ((double)TrackThumb.Width * ((double)Value / (double)Maximum))) - (int)Math.Round((double)ThumbSize.Width / 2.0), TrackThumb.Y + (int)Math.Round((double)TrackThumb.Height / 2.0) - (int)Math.Round((double)ThumbSize.Height / 2.0), ThumbSize.Width, ThumbSize.Height);

            if (_DrawValueString == true)
            {
                G.DrawString(Convert.ToString(ValueToSet), Font, Brushes.DimGray, 1, 20);
            }
        }
コード例 #13
0
ファイル: HopeNumeric.cs プロジェクト: starts2000/ReaLTaiizor
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            var bg = RoundRectangle.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3);

            graphics.FillPath(new SolidBrush(_BaseColor), bg);
            graphics.DrawPath(new Pen(enterFlag ? _BorderHoverColorA : _BorderColorA, 1f), bg);

            textBox.Text      = Math.Round(_value, Precision).ToString();
            textBox.BackColor = BackColor;
            textBox.ForeColor = ForeColor;
            switch (_style)
            {
            case NumericStyle.LeftRight:
                textBox.Size     = new Size(Width - 2 * Height, Height - 2);
                textBox.Location = new Point(Height, 5);
                graphics.DrawLine(new Pen(_BorderColorB, 0.5f), textBox.Location.X - 0.5f, 1, textBox.Location.X - 0.5f, Height - 1);
                break;

            case NumericStyle.TopDown:
                textBox.Size     = new Size(Width - Height - 2, Height - 2);
                textBox.Location = new Point(2, 5);
                graphics.DrawLine(new Pen(_BorderColorB, 0.5f), textBox.Location.X + textBox.Width + 0.5f, Height / 2, Width - 1, Height / 2);
                break;
            }
            graphics.DrawString("+", new Font("Segoe UI", 14f), new SolidBrush((upRectangleF.Contains(mousePoint) && enterFlag) ? _HoverButtonTextColorA : _ButtonTextColorA), upRectangleF, HopeStringAlign.Center);
            graphics.DrawString("-", new Font("Segoe UI", 14f), new SolidBrush((downRectangleF.Contains(mousePoint) && enterFlag) ? _HoverButtonTextColorB : _ButtonTextColorB), downRectangleF, HopeStringAlign.Center);
            graphics.DrawLine(new Pen(_BorderColorB, 0.5f), textBox.Location.X + textBox.Width + 0.5f, 1, textBox.Location.X + textBox.Width + 0.5f, Height - 1);
            graphics.FillRectangle(new SolidBrush(BackColor), textBox.Location.X, 1, textBox.Width, Height - 2);
            base.Controls.Add(textBox);
        }
コード例 #14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            LinearGradientBrush LGB = default(LinearGradientBrush);
            GraphicsPath        GP  = default(GraphicsPath);

            e.Graphics.Clear(Parent.BackColor);
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            // Create a curvy border
            GP = RoundRectangle.RoundRect(0, 0, Width - 1, Height - 1, 5);
            // Fills the body of the rectangle with a gradient
            LGB = new LinearGradientBrush(ClientRectangle, _ColorD, _ColorE, 90.0F);

            e.Graphics.SetClip(GP);
            e.Graphics.FillRectangle(LGB, ClientRectangle);
            e.Graphics.ResetClip();

            // Draw rectangle border
            e.Graphics.DrawPath(new Pen(_ColorF), GP);
            // Draw string
            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(3, 0, Width - 20, Height), new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Near
            });
            e.Graphics.DrawString("6", new Font("Marlett", 13, FontStyle.Regular), new SolidBrush(_ColorG), new Rectangle(3, 0, Width - 4, Height), new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Far
            });
            e.Graphics.DrawLine(new Pen(_ColorH), Width - 24, 4, Width - 24, Height - 5);
            e.Graphics.DrawLine(new Pen(_ColorI), Width - 25, 4, Width - 25, Height - 5);

            GP.Dispose();
            LGB.Dispose();
        }
コード例 #15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Bitmap       B = new Bitmap(Width, Height);
            Graphics     G = Graphics.FromImage(B);
            GraphicsPath GP_MinimizeRect = new GraphicsPath();
            GraphicsPath GP_CloseRect    = new GraphicsPath();

            GP_MinimizeRect.AddRectangle(MinimizeRect);
            GP_CloseRect.AddRectangle(CloseRect);
            G.Clear(BackColor);

            switch (State)
            {
            case MouseState.None:
NonePoint:
                LinearGradientBrush MinimizeGradient = new LinearGradientBrush(MinimizeRect, Color.FromArgb(73, 73, 73), Color.FromArgb(58, 58, 58), 90);
                G.FillPath(MinimizeGradient, GP_MinimizeRect);
                G.DrawPath(new Pen(Color.FromArgb(40, 40, 40)), GP_MinimizeRect);
                G.DrawString("0", new Font("Marlett", 11, FontStyle.Regular), new SolidBrush(Color.FromArgb(221, 221, 221)), MinimizeRect.Width - 22, MinimizeRect.Height - 16);

                LinearGradientBrush CloseGradient = new LinearGradientBrush(CloseRect, Color.FromArgb(73, 73, 73), Color.FromArgb(58, 58, 58), 90);
                G.FillPath(CloseGradient, GP_CloseRect);
                G.DrawPath(new Pen(Color.FromArgb(40, 40, 40)), GP_CloseRect);
                G.DrawString("r", new Font("Marlett", 11, FontStyle.Regular), new SolidBrush(Color.FromArgb(221, 221, 221)), CloseRect.Width - 4, CloseRect.Height - 16);
                break;

            case MouseState.Over:
                if (i > 0 & i < 28)
                {
                    LinearGradientBrush xMinimizeGradient = new LinearGradientBrush(MinimizeRect, Color.FromArgb(76, 76, 76, 76), Color.FromArgb(48, 48, 48), 90f);
                    G.FillPath(xMinimizeGradient, GP_MinimizeRect);
                    G.DrawPath(new Pen(Color.FromArgb(40, 40, 40)), GP_MinimizeRect);
                    G.DrawString("0", new Font("Marlett", 11, FontStyle.Regular), new SolidBrush(Color.FromArgb(221, 221, 221)), MinimizeRect.Width - 22, MinimizeRect.Height - 16);

                    LinearGradientBrush xCloseGradient = new LinearGradientBrush(CloseRect, Color.FromArgb(73, 73, 73), Color.FromArgb(58, 58, 58), 90);
                    G.FillPath(xCloseGradient, GP_CloseRect);
                    G.DrawPath(new Pen(Color.FromArgb(40, 40, 40)), GP_CloseRect);
                    G.DrawString("r", new Font("Marlett", 11, FontStyle.Regular), new SolidBrush(Color.FromArgb(221, 221, 221)), CloseRect.Width - 4, CloseRect.Height - 16);
                }
                else if (i > 30 & i < 75)
                {
                    LinearGradientBrush xCloseGradient = new LinearGradientBrush(CloseRect, Color.FromArgb(76, 76, 76, 76), Color.FromArgb(48, 48, 48), 90);
                    G.FillPath(xCloseGradient, GP_CloseRect);
                    G.DrawPath(new Pen(Color.FromArgb(40, 40, 40)), GP_CloseRect);
                    G.DrawString("r", new Font("Marlett", 11, FontStyle.Regular), new SolidBrush(Color.FromArgb(221, 221, 221)), CloseRect.Width - 4, CloseRect.Height - 16);

                    LinearGradientBrush xMinimizeGradient = new LinearGradientBrush(MinimizeRect, Color.FromArgb(73, 73, 73), Color.FromArgb(58, 58, 58), 90);
                    G.FillPath(xMinimizeGradient, RoundRectangle.RoundRect(MinimizeRect, 1));
                    G.DrawPath(new Pen(Color.FromArgb(40, 40, 40)), GP_MinimizeRect);
                    G.DrawString("0", new Font("Marlett", 11, FontStyle.Regular), new SolidBrush(Color.FromArgb(221, 221, 221)), MinimizeRect.Width - 22, MinimizeRect.Height - 16);
                }
                else
                {
                    goto NonePoint;     // Return to [MouseState = None]
                }
                break;
            }

            e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
            G.Dispose();
            GP_CloseRect.Dispose();
            GP_MinimizeRect.Dispose();
            B.Dispose();
        }
コード例 #16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics G = e.Graphics;

            G.SmoothingMode = SmoothingMode.HighQuality;
            G.Clear(Parent.BackColor);

            int          SwitchXLoc       = 3;
            Rectangle    ControlRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
            GraphicsPath ControlPath      = RoundRectangle.RoundRect(ControlRectangle, 4);

            LinearGradientBrush BackgroundLGB = default(LinearGradientBrush);

            if (_Toggled)
            {
                SwitchXLoc    = 37;
                BackgroundLGB = new LinearGradientBrush(ControlRectangle, _ToggledColorA, _ToggledColorB, 90.0F);
            }
            else
            {
                SwitchXLoc    = 0;
                BackgroundLGB = new LinearGradientBrush(ControlRectangle, _ToggledColorC, _ToggledColorD, 90.0F);
            }

            // Fill inside background gradient
            G.FillPath(BackgroundLGB, ControlPath);

            // Draw string
            switch (ToggleType)
            {
            case _Type.OnOff:
                if (Toggled)
                {
                    G.DrawString("ON", new Font("Segoe UI", 12, FontStyle.Regular), new SolidBrush(_ToggledOnOffColorA), Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("OFF", new Font("Segoe UI", 12, FontStyle.Regular), new SolidBrush(_ToggledOnOffColorB), Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case _Type.YesNo:
                if (Toggled)
                {
                    G.DrawString("YES", new Font("Segoe UI", 12, FontStyle.Regular), new SolidBrush(_ToggledYesNoColorA), Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("NO", new Font("Segoe UI", 12, FontStyle.Regular), new SolidBrush(_ToggledYesNoColorB), Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case _Type.IO:
                if (Toggled)
                {
                    G.DrawString("I", new Font("Segoe UI", 12, FontStyle.Regular), new SolidBrush(_ToggledIOColorA), Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("O", new Font("Segoe UI", 12, FontStyle.Regular), new SolidBrush(_ToggledIOColorB), Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;
            }

            Rectangle           SwitchRectangle = new Rectangle(SwitchXLoc, 0, Width - 38, Height);
            GraphicsPath        SwitchPath      = RoundRectangle.RoundRect(SwitchRectangle, 4);
            LinearGradientBrush SwitchButtonLGB = new LinearGradientBrush(SwitchRectangle, _ToggledBackColorA, _ToggledBackColorB, LinearGradientMode.Vertical);

            // Fill switch background gradient
            G.FillPath(SwitchButtonLGB, SwitchPath);

            // Draw borders
            if (_Toggled == true)
            {
                G.DrawPath(new Pen(_ToggledBorderColorA), SwitchPath);
                G.DrawPath(new Pen(_ToggledBorderColorB), ControlPath);
            }
            else
            {
                G.DrawPath(new Pen(_ToggledBorderColorC), SwitchPath);
                G.DrawPath(new Pen(_ToggledBorderColorD), ControlPath);
            }
        }
コード例 #17
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics G = e.Graphics;

            G.SmoothingMode = SmoothingMode.HighQuality;
            G.Clear(Parent.BackColor);
            _Width  = Width - 1;
            _Height = Height - 1;

            GraphicsPath GP        = default;
            GraphicsPath GP2       = new GraphicsPath();
            Rectangle    BaseRect  = new Rectangle(0, 0, _Width, _Height);
            Rectangle    ThumbRect = new Rectangle(_Width / 2, 0, 38, _Height);

            G.SmoothingMode     = (SmoothingMode)2;
            G.PixelOffsetMode   = (PixelOffsetMode)2;
            G.TextRenderingHint = (TextRenderingHint)5;
            G.Clear(BackColor);

            GP        = RoundRectangle.RoundRect(BaseRect, 4);
            ThumbRect = new Rectangle(4, 4, 36, _Height - 8);
            GP2       = RoundRectangle.RoundRect(ThumbRect, 4);
            G.FillPath(new SolidBrush(Color.FromArgb(66, 76, 85)), GP);
            G.FillPath(new SolidBrush(Color.FromArgb(32, 41, 50)), GP2);

            if (_Toggled)
            {
                GP        = RoundRectangle.RoundRect(BaseRect, 4);
                ThumbRect = new Rectangle((_Width / 2) - 2, 4, 36, _Height - 8);
                GP2       = RoundRectangle.RoundRect(ThumbRect, 4);
                G.FillPath(new SolidBrush(Color.FromArgb(32, 34, 37)), GP);
                G.FillPath(new SolidBrush(Color.FromArgb(32, 41, 50)), GP2);
            }

            // Draw string
            switch (ToggleType)
            {
            case _Type.CheckMark:
                if (Toggled)
                {
                    G.DrawString("ü", new Font("Wingdings", 18, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, Bar.Y + 19, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("r", new Font("Marlett", 14, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, Bar.Y + 18, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case _Type.OnOff:
                if (Toggled)
                {
                    G.DrawString("ON", new Font("Microsoft Sans Serif", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, Bar.Y + 16, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("OFF", new Font("Microsoft Sans Serif", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 57, Bar.Y + 16, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case _Type.YesNo:
                if (Toggled)
                {
                    G.DrawString("YES", new Font("Microsoft Sans Serif", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 19, Bar.Y + 16, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("NO", new Font("Microsoft Sans Serif", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 56, Bar.Y + 16, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;

            case _Type.IO:
                if (Toggled)
                {
                    G.DrawString("I", new Font("Microsoft Sans Serif", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, Bar.Y + 16, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                else
                {
                    G.DrawString("O", new Font("Microsoft Sans Serif", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 57, Bar.Y + 16, new StringFormat()
                    {
                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                    });
                }
                break;
            }
        }
コード例 #18
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            var graphics = e.Graphics;

            graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            graphics.SmoothingMode     = SmoothingMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);

            var bg = RoundRectangle.CreateRoundRect(1f, 1f, Width - 2, Height - 2, 3);

            graphics.FillPath(new SolidBrush(BackColor), bg);
            graphics.DrawPath(new Pen(_BorderColor), bg);

            graphics.DrawString(string.Format(_HeaderFormat, CurrentDate.Year, CurrentDate.Month), new Font("Segoe UI", 12f), new SolidBrush(_HeaderTextColor), TopDateRect, HopeStringAlign.Center);

            graphics.DrawString("7", new Font("webdings", 12f), new SolidBrush(previousYearHovered ? _PYHoverColor : _PYColor), PreviousYearRect, HopeStringAlign.Center);
            graphics.DrawString("3", new Font("webdings", 12f), new SolidBrush(previousMonthHovered ? _PMHoverColor : _PMColor), PreviousMonthRect, HopeStringAlign.Center);
            graphics.DrawString("4", new Font("webdings", 12f), new SolidBrush(nextMonthHovered ? _NMHoverColor : _NMColor), NextMonthRect, HopeStringAlign.Center);
            graphics.DrawString("8", new Font("webdings", 12f), new SolidBrush(nextYearHovered ? _NYHoverColor : _NYColor), NextYearRect, HopeStringAlign.Center);

            string s = _DayNames;

            for (int i = 0; i < 7; i++)
            {
                graphics.DrawString(s[i].ToString(), new Font("Segoe UI", 10f), new SolidBrush(_DaysTextColor), new RectangleF(10 + i * (Width - 20) / 7, WeekRect.Y, WeekRect.Width, WeekRect.Height), HopeStringAlign.Center);
            }

            graphics.DrawLine(new Pen(_HeadLineColor, 0.5f), 10, WeekRect.Y + WeekRect.Height, Width - 10, WeekRect.Y + WeekRect.Height);

            DateTime FirstDay = FirstDayOfMonth(CurrentDate);

            for (int i = 0; i < 42; i++)
            {
                var tempDate = DateRectangles[i / 7][i % 7];
                var brush    = new SolidBrush(_DayTextColorA);

                if (HoverX == i / 7 && HoverY == i % 7)
                {
                    var rect1 = tempDate.Rect;
                    var bg1   = RoundRectangle.CreateRoundRect(rect1.X + 2, rect1.Y + 2, rect1.Width - 4, rect1.Width - 4, 3);
                    graphics.FillPath(new SolidBrush(_HoverColor), bg1);
                    //graphics.FillRectangle(new SolidBrush(HopeColors.ThreeLevelBorder), new RectangleF(rect1.X + 3, rect1.Y + 3, rect1.Width - 6, rect1.Width - 6));
                }

                if (tempDate.Date == DateTime.Today)
                {
                    brush = new SolidBrush(_ValueTextColor);
                }

                if (tempDate.Date == Date)
                {
                    var rect1 = tempDate.Rect;
                    var bg1   = RoundRectangle.CreateRoundRect(rect1.X + 2, rect1.Y + 2, rect1.Width - 4, rect1.Width - 4, 3);
                    graphics.FillPath(new SolidBrush(_SelectedBackColor), bg1);

                    //graphics.FillRectangle(new SolidBrush(HopeColors.PrimaryColor), new RectangleF(rect1.X+3,rect1.Y+3,rect1.Width-6,rect1.Width-6));
                    brush = new SolidBrush(_SelectedTextColor);
                }
                graphics.DrawString(DateRectangles[i / 7][i % 7].Date.Day.ToString(), Font, DateRectangles[i / 7][i % 7].Drawn ? brush : new SolidBrush(_DayTextColorB), DateRectangles[i / 7][i % 7].Rect, HopeStringAlign.Center);
            }
        }
コード例 #19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            G.Clear(Color.Transparent);
            G.SmoothingMode = SmoothingMode.HighQuality;

            GP1 = RoundRectangle.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 4);
            GP2 = RoundRectangle.RoundRect(new Rectangle(1, 1, Width - 3, Height - 3), 4);

            R1 = new Rectangle(0, 2, Width - 1, Height - 1);
            //GB1 = new LinearGradientBrush(R1, Color.FromArgb(255, 255, 255), Color.FromArgb(230, 230, 230), 90f);

            // Draw inside background
            G.FillRectangle(new SolidBrush(_BackColorA), R1);
            G.SetClip(GP1);
            G.FillPath(new SolidBrush(_BackColorB), RoundRectangle.RoundRect(new Rectangle(1, 1, Width - 3, Height / 2 - 2), 4));


            I1 = (int)Math.Round(((double)(_Value - _Minimum) / (double)(_Maximum - _Minimum)) * (double)(Width - 3));
            if (I1 > 1)
            {
                GP3 = RoundRectangle.RoundRect(new Rectangle(1, 1, I1, Height - 3), 4);

                R2  = new Rectangle(1, 1, I1, Height - 3);
                GB2 = new LinearGradientBrush(R2, _ProgressColorA, _ProgressColorB, 90f);

                // Fill the value with its gradient
                G.FillPath(GB2, GP3);

                // Draw diagonal lines
                if (_DrawHatch == true)
                {
                    for (var i = 0; i <= (Width - 1) * _Maximum / _Value; i += 20)
                    {
                        G.DrawLine(new Pen(new SolidBrush(_ProgressHatchColor), 10.0F), new Point(Convert.ToInt32(i), 0), new Point((int)(i - 10), Height));
                    }
                }

                G.SetClip(GP3);
                G.SmoothingMode = SmoothingMode.None;
                G.SmoothingMode = SmoothingMode.AntiAlias;
                G.ResetClip();
            }

            // Draw value as a string
            string DrawString = Convert.ToString(Convert.ToInt32(Value)) + "%";

            /*
             *  int textX = (int)(Width - G.MeasureString(DrawString, Font).Width - 1);
             *  int textY = (int)((Height / 2) - (Convert.ToInt32(G.MeasureString(DrawString, Font).Height / 2) - 2));
             */

            if (_ShowPercentage == true)
            {
                switch (ValueAlignment)
                {
                case Alignment.Left:
                    G.DrawString(DrawString, new Font("Segoe UI", 8), new SolidBrush(ForeColor), new Rectangle(0, 0, Width, Height + 2), new StringFormat
                    {
                        Alignment     = StringAlignment.Near,
                        LineAlignment = StringAlignment.Center
                    });
                    break;

                case Alignment.Right:
                    G.DrawString(DrawString, new Font("Segoe UI", 8), new SolidBrush(ForeColor), new Rectangle(0, 0, Width, Height + 2), new StringFormat
                    {
                        Alignment     = StringAlignment.Far,
                        LineAlignment = StringAlignment.Center
                    });
                    break;

                case Alignment.Center:
                    G.DrawString(DrawString, new Font("Segoe UI", 8), new SolidBrush(ForeColor), new Rectangle(0, 0, Width, Height + 2), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;
                }
            }

            // Draw border
            G.DrawPath(new Pen(_BorderColor), GP2);

            e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
            G.Dispose();
            B.Dispose();
        }