Example #1
0
		public SkinControl(SkinControl source)
			: base(source) {
			this.Inherits = source.Inherits;
			this.DefaultSize = source.DefaultSize;
			this.MinimumSize = source.MinimumSize;
			this.OriginMargins = source.OriginMargins;
			this.ClientMargins = source.ClientMargins;
			this.ResizerSize = source.ResizerSize;
			this.Layers = new SkinList<SkinLayer>(source.Layers);
			this.Attributes = new SkinList<SkinAttribute>(source.Attributes);
		}
Example #2
0
		private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, EAlignment alignment, int index) {
			Rectangle rect = new Rectangle();
			int xc = (int)((float)imageSize.Width / partSize.Width);
			int yc = (int)((float)imageSize.Height / partSize.Height);

			int xm = (index) % xc;
			int ym = (index) / xc;

			int adj = 1;
			margins.Left += margins.Left > 0 ? adj : 0;
			margins.Top += margins.Top > 0 ? adj : 0;
			margins.Right += margins.Right > 0 ? adj : 0;
			margins.Bottom += margins.Bottom > 0 ? adj : 0;

			margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
			switch (alignment) {
				case EAlignment.TopLeft: {
						rect = new Rectangle((0 + (xm * partSize.Width)),
											 (0 + (ym * partSize.Height)),
											 margins.Left,
											 margins.Top);
						break;
					}
				case EAlignment.TopCenter: {
						rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
											 (0 + (ym * partSize.Height)),
											 partSize.Width - margins.Left - margins.Right,
											 margins.Top);
						break;
					}
				case EAlignment.TopRight: {
						rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
											 (0 + (ym * partSize.Height)),
											 margins.Right,
											 margins.Top);
						break;
					}
				case EAlignment.MiddleLeft: {
						rect = new Rectangle((0 + (xm * partSize.Width)),
											 (0 + (ym * partSize.Height)) + margins.Top,
											 margins.Left,
											 partSize.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.MiddleCenter: {
						rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
											 (0 + (ym * partSize.Height)) + margins.Top,
											 partSize.Width - margins.Left - margins.Right,
											 partSize.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.MiddleRight: {
						rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
											 (0 + (ym * partSize.Height)) + margins.Top,
											 margins.Right,
											 partSize.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.BottomLeft: {
						rect = new Rectangle((0 + (xm * partSize.Width)),
											 (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
											 margins.Left,
											 margins.Bottom);
						break;
					}
				case EAlignment.BottomCenter: {
						rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
											 (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
											 partSize.Width - margins.Left - margins.Right,
											 margins.Bottom);
						break;
					}
				case EAlignment.BottomRight: {
						rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
											 (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
											 margins.Right,
											 margins.Bottom);
						break;
					}
			}

			return rect;
		}
Example #3
0
		public void DrawGlyph(Glyph glyph, Rectangle rect) {
			Size imageSize = new Size(glyph.Image.Width, glyph.Image.Height);

			if (!glyph.SourceRect.IsEmpty) {
				imageSize = new Size(glyph.SourceRect.Width, glyph.SourceRect.Height);
			}

			if (glyph.SizeMode == ESizeMode.Centered) {
				rect = new Rectangle((rect.X + (rect.Width - imageSize.Width) / 2) + glyph.Offset.X,
									 (rect.Y + (rect.Height - imageSize.Height) / 2) + glyph.Offset.Y,
									 imageSize.Width,
									 imageSize.Height);
			} else if (glyph.SizeMode == ESizeMode.Normal) {
				rect = new Rectangle(rect.X + glyph.Offset.X, rect.Y + glyph.Offset.Y, imageSize.Width, imageSize.Height);
			} else if (glyph.SizeMode == ESizeMode.Auto) {
				rect = new Rectangle(rect.X + glyph.Offset.X, rect.Y + glyph.Offset.Y, imageSize.Width, imageSize.Height);
			}

			if (glyph.SourceRect.IsEmpty) {
				Draw(glyph.Image, rect, glyph.Color);
			} else {
				Draw(glyph.Image, rect, glyph.SourceRect, glyph.Color);
			}
		}
Example #4
0
		public virtual void DrawLayer(SkinLayer layer, Rectangle rect, Color color, int index) {
			Size imageSize = new Size(layer.Image.Resource.Width, layer.Image.Resource.Height);
			Size partSize = new Size(layer.Width, layer.Height);

			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopLeft, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopCenter, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.TopRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.TopRight, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleLeft, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleCenter, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.MiddleRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.MiddleRight, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomLeft), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomLeft, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomCenter), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomCenter, index), color);
			Draw(layer.Image.Resource, GetDestinationArea(rect, layer.SizingMargins, EAlignment.BottomRight), GetSourceArea(imageSize, partSize, layer.SizingMargins, EAlignment.BottomRight, index), color);
		}