Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (BorderRound > 0)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            }

            DrawBorderAndFill(e.Graphics);

            bool disabledImage = false;

            Image image = mImage;

            if (Enabled == false)
            {
                if (mDisabledImage != null)
                {
                    image = mDisabledImage;
                }
                else
                {
                    disabledImage = true;
                }
            }
            else if (mIsMouseOver && mMouseOverImage != null)
            {
                image = mMouseOverImage;
            }

            Rectangle contentRect = ClientRectangle;

            if (BorderWidth > 0)
            {
                contentRect = new Rectangle(contentRect.X + BorderWidth, contentRect.Y + BorderWidth,
                                            contentRect.Width - BorderWidth * 2, contentRect.Height - BorderWidth * 2);
            }

            DevAge.Drawing.VisualElements.Container container    = new DevAge.Drawing.VisualElements.Container();
            DevAge.Drawing.VisualElements.TextGDI   textElement  = new DevAge.Drawing.VisualElements.TextGDI(Text);
            DevAge.Drawing.VisualElements.Image     imageElement = new DevAge.Drawing.VisualElements.Image(image);
            imageElement.AnchorArea  = new DevAge.Drawing.AnchorArea(mImageAlignment, mImageStretch);
            imageElement.Enabled     = !disabledImage;
            textElement.AnchorArea   = new DevAge.Drawing.AnchorArea(DevAge.Drawing.Utilities.StringFormatToContentAlignment(mStringFormat), false);
            textElement.StringFormat = mStringFormat;
            textElement.Font         = Font;
            textElement.ForeColor    = ForeColor;
            textElement.Enabled      = Enabled;
            container.Elements.Add(imageElement);
            container.Elements.Add(textElement);



            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                container.Draw(cache, contentRect);
            }
        }
Beispiel #2
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint (e);

			if (BorderRound > 0)
				e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

			DrawBorderAndFill(e.Graphics);

			bool disabledImage = false;

			Image image = mImage;
			if (Enabled == false)
			{
				if (mDisabledImage != null)
					image = mDisabledImage;
				else
					disabledImage = true;
			}
			else if (mIsMouseOver && mMouseOverImage != null)
				image = mMouseOverImage;

			Rectangle contentRect = ClientRectangle;
			if (BorderWidth > 0)
				contentRect = new Rectangle(contentRect.X + BorderWidth, contentRect.Y + BorderWidth,
											contentRect.Width - BorderWidth * 2, contentRect.Height - BorderWidth * 2);

            DevAge.Drawing.VisualElements.Container container = new DevAge.Drawing.VisualElements.Container();
            DevAge.Drawing.VisualElements.TextGDI textElement = new DevAge.Drawing.VisualElements.TextGDI(Text);
            DevAge.Drawing.VisualElements.Image imageElement = new DevAge.Drawing.VisualElements.Image(image);
            imageElement.AnchorArea = new DevAge.Drawing.AnchorArea(mImageAlignment, mImageStretch);
            imageElement.Enabled = !disabledImage;
            textElement.AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.Utilities.StringFormatToContentAlignment(mStringFormat), false);
            textElement.StringFormat = mStringFormat;
            textElement.Font = Font;
            textElement.ForeColor = ForeColor;
            textElement.Enabled = Enabled;
            container.Elements.Add(imageElement);
            container.Elements.Add(textElement);



            using (DevAge.Drawing.GraphicsCache cache = new DevAge.Drawing.GraphicsCache(e.Graphics, e.ClipRectangle))
            {
                container.Draw(cache, contentRect);
            }
		}