예제 #1
0
        public MetalPanel()
        {
            this.SetStyle ( ControlStyles.DoubleBuffer |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.Opaque , true);

            this.gradient = new MetalGradient( Color.FromArgb( 96,96,96 ), Color.FromArgb( 0,0,0 ) );
            this.borders = MetalBorders.All;
        }
예제 #2
0
        public MetalPanel()
        {
            this.SetStyle(ControlStyles.DoubleBuffer |
                          ControlStyles.AllPaintingInWmPaint |
                          ControlStyles.UserPaint |
                          ControlStyles.Opaque, true);

            this.gradient = new MetalGradient(Color.FromArgb(96, 96, 96), Color.FromArgb(0, 0, 0));
            this.borders  = MetalBorders.All;
        }
예제 #3
0
        public override void PaintValue(PaintValueEventArgs args)
        {
            MetalGradient gradient = (MetalGradient)args.Value;

            LinearGradientBrush gradientBrush = new LinearGradientBrush(args.Bounds, gradient.Top, gradient.Bottom, 90.0f);

            args.Graphics.FillRectangle(gradientBrush, args.Bounds);

            gradientBrush.Dispose();
        }
예제 #4
0
        public MetalButton()
        {
            this.normalGradient    = new MetalGradient(Color.FromArgb(96, 96, 96), Color.FromArgb(0, 0, 0));
            this.hoverGradient     = new MetalGradient(Color.FromArgb(0, 216, 0), Color.FromArgb(0, 64, 0));
            this.pressedGradient   = new MetalGradient(Color.FromArgb(0, 64, 0), Color.FromArgb(0, 216, 0));
            this.disabledGradient  = new MetalGradient(Color.FromArgb(64, 64, 64), Color.FromArgb(64, 64, 64));
            this.highlightGradient = new MetalGradient(Color.FromArgb(192, 192, 192), Color.FromArgb(96, 96, 96));

            this.TabStop = false;
            this.SetStyle(ControlStyles.Selectable, false);
        }
예제 #5
0
        public static void DrawGradient( Rectangle rectangle, MetalGradient gradient, Graphics graphics )
        {
            if ( rectangle.Width == 0 || rectangle.Height == 0 )
                return;

            LinearGradientBrush brush = new LinearGradientBrush( rectangle, gradient.Top, gradient.Bottom, 90.0f );

            graphics.FillRectangle( brush, rectangle );

            brush.Dispose();
        }
예제 #6
0
		public MetalButton()
		{
			this.normalGradient = new MetalGradient( Color.FromArgb( 96,96,96 ), Color.FromArgb( 0,0,0 ) );
			this.hoverGradient = new MetalGradient( Color.FromArgb( 0,216,0 ), Color.FromArgb( 0,64,0 ) );
			this.pressedGradient = new MetalGradient( Color.FromArgb( 0,64,0 ), Color.FromArgb( 0,216,0 ) );
			this.disabledGradient = new MetalGradient( Color.FromArgb( 64, 64, 64 ), Color.FromArgb( 64, 64, 64 ) );
			this.highlightGradient = new MetalGradient( Color.FromArgb( 192, 192, 192 ), Color.FromArgb( 96, 96, 96 ) );
		
			this.TabStop = false;
			this.SetStyle( ControlStyles.Selectable, false );
		}
예제 #7
0
        public static void DrawGradient(Rectangle rectangle, MetalGradient gradient, Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
            {
                return;
            }

            LinearGradientBrush brush = new LinearGradientBrush(rectangle, gradient.Top, gradient.Bottom, 90.0f);

            graphics.FillRectangle(brush, rectangle);

            brush.Dispose();
        }
예제 #8
0
        private void ReadGradient(XmlReader reader, string gradientName, MetalGradient gradient)
        {
            try
            {
                reader.ReadStartElement(gradientName);

                reader.ReadStartElement("Top");
                gradient.Top = this.ParseColor(reader.ReadString());
                reader.ReadEndElement();

                reader.ReadStartElement("Bottom");
                gradient.Bottom = this.ParseColor(reader.ReadString());
                reader.ReadEndElement();

                reader.ReadEndElement();
            }
            catch {}
        }
예제 #9
0
        private void WriteGradient(XmlWriter writer, string gradientName, MetalGradient gradient)
        {
            writer.WriteStartElement(gradientName);

            writer.WriteStartElement("Top");

            writer.WriteString(String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", gradient.Top.A, gradient.Top.R, gradient.Top.G, gradient.Top.B));

            writer.WriteEndElement();

            writer.WriteStartElement("Bottom");

            writer.WriteString(String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", gradient.Bottom.A, gradient.Bottom.R, gradient.Bottom.G, gradient.Bottom.B));

            writer.WriteEndElement();

            writer.WriteEndElement();
        }
예제 #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            MetalGradient targetGradient;

            if (MetalStyleManager.UseStyles == true && this.UseStyles == true)
            {
                if (sunk == true)
                {
                    targetGradient = MetalStyleManager.Active.PanelSunk;
                }
                else
                {
                    targetGradient = MetalStyleManager.Active.PanelRaised;
                }
            }
            else
            {
                if (sunk == true)
                {
                    targetGradient        = new MetalGradient();
                    targetGradient.Top    = this.gradient.Bottom;
                    targetGradient.Bottom = this.gradient.Top;
                }
                else
                {
                    targetGradient        = new MetalGradient();
                    targetGradient.Top    = this.gradient.Top;
                    targetGradient.Bottom = this.gradient.Bottom;
                }
            }

            Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);

            MetalHelper.DrawGradient(rect, targetGradient, e.Graphics);

            MetalHelper.DrawBorder(rect, this.Borders, e.Graphics);
        }
예제 #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            MetalGradient targetGradient;

            if ( MetalStyleManager.UseStyles == true && this.UseStyles == true )
            {
                if ( sunk == true )
                    targetGradient = MetalStyleManager.Active.PanelSunk;
                else
                    targetGradient = MetalStyleManager.Active.PanelRaised;
            }
            else
            {
                if ( sunk == true )
                {
                    targetGradient = new MetalGradient();
                    targetGradient.Top = this.gradient.Bottom;
                    targetGradient.Bottom = this.gradient.Top;
                }
                else
                {
                    targetGradient = new MetalGradient();
                    targetGradient.Top = this.gradient.Top;
                    targetGradient.Bottom = this.gradient.Bottom;
                }
            }

            Rectangle rect = new Rectangle( 0, 0, this.Width, this.Height );

            MetalHelper.DrawGradient( rect, targetGradient, e.Graphics );

            MetalHelper.DrawBorder( rect, this.Borders, e.Graphics );
        }
예제 #12
0
        private void WriteGradient( XmlWriter writer, string gradientName, MetalGradient gradient )
        {
            writer.WriteStartElement( gradientName );

            writer.WriteStartElement( "Top" );

            writer.WriteString(	String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", gradient.Top.A, gradient.Top.R, gradient.Top.G, gradient.Top.B));

            writer.WriteEndElement();

            writer.WriteStartElement( "Bottom" );

            writer.WriteString(	String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", gradient.Bottom.A, gradient.Bottom.R, gradient.Bottom.G, gradient.Bottom.B));

            writer.WriteEndElement();

            writer.WriteEndElement();
        }
예제 #13
0
        private void ReadGradient( XmlReader reader, string gradientName, MetalGradient gradient )
        {
            try
            {
                reader.ReadStartElement( gradientName );

                reader.ReadStartElement( "Top" );
                gradient.Top = this.ParseColor( reader.ReadString() );
                reader.ReadEndElement();

                reader.ReadStartElement( "Bottom" );
                gradient.Bottom = this.ParseColor( reader.ReadString() );
                reader.ReadEndElement();

                reader.ReadEndElement();
            }
            catch{}
        }
예제 #14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            MetalGradient activeGradient = normalGradient;

            if (MetalStyleManager.UseStyles == true)
            {
                if (this.Enabled == false)
                {
                    activeGradient = MetalStyleManager.Active.ButtonDisabled;
                }
                else if (this.mouseDown == true)
                {
                    activeGradient = MetalStyleManager.Active.ButtonPressed;
                }
                else if (this.mouseOver == true)
                {
                    activeGradient = MetalStyleManager.Active.ButtonHover;
                }
                else if (this.highlight == true)
                {
                    activeGradient = MetalStyleManager.Active.ButtonHighlight;
                }
                else
                {
                    activeGradient = MetalStyleManager.Active.ButtonNormal;
                }
            }
            else
            {
                if (this.Enabled == false)
                {
                    activeGradient = disabledGradient;
                }
                else if (this.mouseDown == true)
                {
                    activeGradient = pressedGradient;
                }
                else if (this.mouseOver == true)
                {
                    activeGradient = hoverGradient;
                }
                else if (this.highlight == true)
                {
                    activeGradient = highlightGradient;
                }
                else
                {
                    activeGradient = normalGradient;
                }
            }

            MetalHelper.DrawGradient(this.ClientRectangle, activeGradient, e.Graphics);

//			StringFormat stringFormat = new StringFormat();
//			stringFormat.Alignment = StringAlignment.Center;
//			stringFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap;
//			stringFormat.LineAlignment = StringAlignment.Center;
//			stringFormat.Trimming = StringTrimming.EllipsisCharacter;
//
//			RectangleF shadowRectangle = new RectangleF( this.ClientRectangle.X+1, this.ClientRectangle.Y+1, this.ClientRectangle.Width, this.ClientRectangle.Height );
//			RectangleF normalRectangle = new RectangleF( this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height );
//
//			e.Graphics.DrawString( this.Text, this.Font, Brushes.Black, shadowRectangle, stringFormat );
//
//			SolidBrush fontBrush = new SolidBrush( this.ForeColor );
//
//			e.Graphics.DrawString( this.Text, this.Font, fontBrush, normalRectangle, stringFormat );
//
//			fontBrush.Dispose();

            StringAlignment vertical   = StringAlignment.Center;
            StringAlignment horizontal = StringAlignment.Center;

            if (this.Image != null)
            {
                switch (this.ImageAlign)
                {
                case ContentAlignment.BottomCenter:
                {
                    horizontal = StringAlignment.Center;
                    vertical   = StringAlignment.Far;
                    break;
                }

                case ContentAlignment.BottomLeft:
                {
                    horizontal = StringAlignment.Near;
                    vertical   = StringAlignment.Far;
                    break;
                }

                case ContentAlignment.BottomRight:
                {
                    horizontal = StringAlignment.Far;
                    vertical   = StringAlignment.Far;
                    break;
                }

                case ContentAlignment.MiddleCenter:
                {
                    horizontal = StringAlignment.Center;
                    vertical   = StringAlignment.Center;
                    break;
                }

                case ContentAlignment.MiddleLeft:
                {
                    horizontal = StringAlignment.Near;
                    vertical   = StringAlignment.Center;
                    break;
                }

                case ContentAlignment.MiddleRight:
                {
                    horizontal = StringAlignment.Far;
                    vertical   = StringAlignment.Center;
                    break;
                }

                case ContentAlignment.TopCenter:
                {
                    horizontal = StringAlignment.Center;
                    vertical   = StringAlignment.Near;
                    break;
                }

                case ContentAlignment.TopLeft:
                {
                    horizontal = StringAlignment.Near;
                    vertical   = StringAlignment.Near;
                    break;
                }

                case ContentAlignment.TopRight:
                {
                    horizontal = StringAlignment.Far;
                    vertical   = StringAlignment.Near;
                    break;
                }
                }

                int imageLeft = 0;
                int imageTop  = 0;

                switch (horizontal)
                {
                case StringAlignment.Near:
                    imageLeft = 4;
                    break;

                case StringAlignment.Center:
                    imageLeft = this.ClientRectangle.Width / 2 - this.Image.Width / 2;
                    break;

                case StringAlignment.Far:
                    imageLeft = this.Width - this.Image.Width - 4;
                    break;
                }

                switch (vertical)
                {
                case StringAlignment.Near:
                    imageTop = 2;
                    break;

                case StringAlignment.Center:
                    imageTop = this.ClientRectangle.Height / 2 - this.Image.Height / 2;
                    break;

                case StringAlignment.Far:
                    imageTop = this.Height - this.Image.Height - 2;
                    break;
                }

                if (this.Enabled == false)
                {
                    ControlPaint.DrawImageDisabled(e.Graphics, this.Image, imageLeft, imageTop, MetalStyleManager.Active.ButtonDisabled.Bottom);
                }
                else
                {
                    e.Graphics.DrawImage(this.Image, imageLeft, imageTop, this.Image.Width, this.Image.Height);
                }
            }

            Rectangle textRectangle = this.ClientRectangle;

            if (this.Image != null)
            {
                switch (horizontal)
                {
                case StringAlignment.Near:
                    textRectangle = new Rectangle(this.Image.Width + 4, 0, this.ClientRectangle.Width - this.Image.Width - 2, this.ClientRectangle.Height);
                    break;

                case StringAlignment.Center:
                    textRectangle = new Rectangle(0, this.Image.Height + 2, this.ClientRectangle.Width, this.ClientRectangle.Height - this.Image.Height - 2);
                    break;

                case StringAlignment.Far:
                    textRectangle = new Rectangle(0, 0, this.ClientRectangle.Width - this.Image.Width - 2, this.ClientRectangle.Height);
                    break;
                }
            }

            if (this.Enabled == false)
            {
                MetalHelper.DrawText(this.Text, textRectangle, this.TextAlign, e.Graphics, true, ControlPaint.Dark(MetalStyleManager.Active.ForeColor), Color.Empty);
            }
            else
            {
                MetalHelper.DrawText(this.Text, textRectangle, this.TextAlign, e.Graphics, true, Color.Empty, Color.Empty);
            }

            MetalHelper.DrawBorder(this.ClientRectangle, this.borders, e.Graphics);
        }