示例#1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            UpdateColors();

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

            W = Width;
            H = Height;

            GraphicsPath GP = new GraphicsPath();

            bool[] GCS = GetConnectedSides();
            // dynamic RoundedBase = Helpers.RoundRect(0, 0, W, H, ???, !(GCS(2) | GCS(1)), !(GCS(1) | GCS(0)), !(GCS(3) | GCS(0)), !(GCS(3) | GCS(2)));
            GraphicsPath RoundedBase = Helpers.RoundRect(0, 0, W, H, 0.3, !(GCS[2] || GCS[1]), !(GCS[1] || GCS[0]), !(GCS[3] || GCS[0]), !(GCS[3] || GCS[2]));
            Rectangle    Base        = new Rectangle(0, 0, W, H);

            var _with17 = G;

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

            switch (State)
            {
            case MouseState.None:
                if (Rounded)
                {
                    //-- Base
                    GP = RoundedBase;
                    _with17.FillPath(new SolidBrush(_BaseColor), GP);

                    //-- Text
                    _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                else
                {
                    //-- Base
                    _with17.FillRectangle(new SolidBrush(_BaseColor), Base);

                    //-- Text
                    _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                break;

            case MouseState.Over:
                if (Rounded)
                {
                    //-- Base
                    GP = RoundedBase;
                    _with17.FillPath(new SolidBrush(_BaseColor), GP);
                    _with17.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), GP);

                    //-- Text
                    _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                else
                {
                    //-- Base
                    _with17.FillRectangle(new SolidBrush(_BaseColor), Base);
                    _with17.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);

                    //-- Text
                    _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                break;

            case MouseState.Down:
                if (Rounded)
                {
                    //-- Base
                    GP = RoundedBase;
                    _with17.FillPath(new SolidBrush(_BaseColor), GP);
                    _with17.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), GP);

                    //-- Text
                    _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                else
                {
                    //-- Base
                    _with17.FillRectangle(new SolidBrush(_BaseColor), Base);
                    _with17.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);

                    //-- Text
                    _with17.DrawString(Text, Font, new SolidBrush(_TextColor), Base, Helpers.CenterSF);
                }
                break;
            }

            base.OnPaint(e);
            G.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(B, 0, 0);
            B.Dispose();
        }
示例#2
0
        private void UpdateColors()
        {
            FlatColors colors = Helpers.GetColors(this);

            _BaseColor = colors.Flat;
        }
示例#3
0
		private void UpdateColors()
		{
			FlatColors colors = Helpers.GetColors(this);

			_ProgressColor = colors.Flat;
		}
示例#4
0
		protected override void OnPaint(PaintEventArgs e)
		{
			this.UpdateColors();

			Bitmap B = new Bitmap(Width, Height);
			Graphics G = Graphics.FromImage(B);
			W = Width - 1;
			H = Height - 1;

			Rectangle Base = new Rectangle(0, 24, W, H);
			GraphicsPath GP = new GraphicsPath();
			GraphicsPath GP2 = new GraphicsPath();
			GraphicsPath GP3 = new GraphicsPath();

			var _with15 = G;
			_with15.SmoothingMode = SmoothingMode.HighQuality;
			_with15.PixelOffsetMode = PixelOffsetMode.HighQuality;
			_with15.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
			_with15.Clear(BackColor);

			//-- Progress Value
			//int iValue = Convert.ToInt32(((float)_Value) / ((float)(_Maximum * Width)));
			float percent = ((float)_Value) / ((float)_Maximum);
			int iValue = (int)(percent * ((float)Width));

			switch (Value)
			{
				case 0:
					//-- Base
					_with15.FillRectangle(new SolidBrush(_BaseColor), Base);
					//--Progress
					_with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
					break;
				case 100:
					//-- Base
					_with15.FillRectangle(new SolidBrush(_BaseColor), Base);
					//--Progress
					_with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1));
					break;
				default:
					//-- Base
					_with15.FillRectangle(new SolidBrush(_BaseColor), Base);

					//--Progress
					GP.AddRectangle(new Rectangle(0, 24, iValue - 1, H - 1));
					_with15.FillPath(new SolidBrush(_ProgressColor), GP);

					if (_Pattern)
					{
						//-- Hatch Brush
						HatchBrush HB = new HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor);
						_with15.FillRectangle(HB, new Rectangle(0, 24, iValue - 1, H - 1));
					}

					if (_ShowBalloon)
					{
						//-- Balloon
						Rectangle Balloon = new Rectangle(iValue - 18, 0, 34, 16);
						GP2 = Helpers.RoundRec(Balloon, 4);
						_with15.FillPath(new SolidBrush(_BaseColor), GP2);

						//-- Arrow
						GP3 = Helpers.DrawArrow(iValue - 9, 16, true);
						_with15.FillPath(new SolidBrush(_BaseColor), GP3);

						//-- Value > You can add "%" > value & "%"
						string text = (_PercentSign ? Value.ToString() + "%" : Value.ToString());
						int wOffset = (_PercentSign ? iValue - 15 : iValue - 11);
						_with15.DrawString(text, new Font("Segoe UI", 10), new SolidBrush(_ProgressColor), new Rectangle(wOffset, -2, W, H), Helpers.NearSF);
					}

					break;
			}

			base.OnPaint(e);
			G.Dispose();
			e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
			e.Graphics.DrawImageUnscaled(B, 0, 0);
			B.Dispose();
		}
示例#5
0
 private void UpdateColors()
 {
     FlatColors colors = Helpers.GetColors(this);
 }
示例#6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            UpdateColors();

            var b = new Bitmap(Width, Height);
            var g = Graphics.FromImage(b);

            _w = Width - 1;
            _h = Height - 1;

            GraphicsPath gp;
            var          Base = new Rectangle(0, 0, _w, _h);

            var with8 = g;

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

            switch (_state)
            {
            case MouseState.None:
                if (Rounded)
                {
                    //-- Base
                    gp = Helpers.RoundRec(Base, 6);
                    with8.FillPath(new SolidBrush(BaseColor), gp);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }
                else
                {
                    //-- Base
                    with8.FillRectangle(new SolidBrush(BaseColor), Base);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }

                break;

            case MouseState.Over:
                if (Rounded)
                {
                    //-- Base
                    gp = Helpers.RoundRec(Base, 6);
                    with8.FillPath(new SolidBrush(BaseColor), gp);
                    with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.White)), gp);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }
                else
                {
                    //-- Base
                    with8.FillRectangle(new SolidBrush(BaseColor), Base);
                    with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), Base);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }

                break;

            case MouseState.Down:
                if (Rounded)
                {
                    //-- Base
                    gp = Helpers.RoundRec(Base, 6);
                    with8.FillPath(new SolidBrush(BaseColor), gp);
                    with8.FillPath(new SolidBrush(Color.FromArgb(20, Color.Black)), gp);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }
                else
                {
                    //-- Base
                    with8.FillRectangle(new SolidBrush(BaseColor), Base);
                    with8.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), Base);

                    //-- Text
                    with8.DrawString(Text, Font, new SolidBrush(TextColor), Base, Helpers.CenterSf);
                }

                break;
            }

            base.OnPaint(e);
            g.Dispose();
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.DrawImageUnscaled(b, 0, 0);
            b.Dispose();
        }
示例#7
0
        private void UpdateColors()
        {
            var colors = Helpers.GetColors(this);

            BaseColor = colors.Flat;
        }