/// <param name="all">Indicates if the bevel is applied to a single side (false) or all sides (true) of the control.</param> /// <param name="style">Specifies the style of beveling to apply to the control.</param> /// <param name="pos">Specifies which side of the control is beveled.</param> /// <param name="rect">Bounds of the control the bevel is applied to.</param> /// <param name="renderer">Render management object.</param> /// <summary> /// Draws a piece of the beveled control based on the bevel's border and style. /// </summary> private void DrawPart(Renderer renderer, Rectangle rect, BevelBorder pos, BevelStyle style, bool all) { // Get the skin's control layer and parse the bevel color values. var layer = Skin.Layers["Control"]; var c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value); var c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value); var c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value); if (Color != UndefinedColor) { c3 = Color; } // Get the control's image asset. var img = Skin.Layers["Control"].Image.Resource; var x1 = 0; var y1 = 0; var w1 = 0; var h1 = 0; var x2 = 0; var y2 = 0; var w2 = 0; var h2 = 0; if (style == BevelStyle.Bumped || style == BevelStyle.Etched) { if (all && (pos == BevelBorder.Top || pos == BevelBorder.Bottom)) { rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height); } else if (all && (pos == BevelBorder.Left)) { rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1); } switch (pos) { case BevelBorder.Left: { x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height; x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1; break; } case BevelBorder.Top: { x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1; x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1; break; } case BevelBorder.Right: { x1 = rect.Left + rect.Width - 2; y1 = rect.Top; w1 = 1; h1 = rect.Height; x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1; break; } case BevelBorder.Bottom: { x1 = rect.Left; y1 = rect.Top + rect.Height - 2; w1 = rect.Width; h1 = 1; x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1; break; } } } else { switch (pos) { case BevelBorder.Left: { x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height; break; } case BevelBorder.Top: { x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1; break; } case BevelBorder.Right: { x1 = rect.Left + rect.Width - 1; y1 = rect.Top; w1 = 1; h1 = rect.Height; break; } case BevelBorder.Bottom: { x1 = rect.Left; y1 = rect.Top + rect.Height - 1; w1 = rect.Width; h1 = 1; break; } } } switch (Style) { case BevelStyle.Bumped: { renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1); renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2); break; } case BevelStyle.Etched: { renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2); renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1); break; } case BevelStyle.Raised: { var c = c1; if (pos == BevelBorder.Left || pos == BevelBorder.Top) { c = c1; } else { c = c2; } renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c); break; } case BevelStyle.Lowered: { var c = c1; if (pos == BevelBorder.Left || pos == BevelBorder.Top) { c = c2; } else { c = c1; } renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c); break; } default: { renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c3); break; } } }