private IBorder GetNewBorder(Cell source_cell, bool left, bool top, bool right, bool bottom) { IBorder border = source_cell.Border; IBorder newBorder = source_cell.Border; if (border is LineBorder) { LineBorder lineBorder = border as LineBorder; newBorder = new LineBorder(lineBorder.Color, lineBorder.Thickness, left, top, right, bottom); } else if (border is BevelBorder) { BevelBorder bevelBorder = border as BevelBorder; newBorder = new BevelBorder(bevelBorder.Type, bevelBorder.Highlight, bevelBorder.Shadow, bevelBorder.Thickness, left, top, right, bottom); } else if (border is ComplexBorder) { ComplexBorder complexBorder = border as ComplexBorder; } else if (border is CompoundBorder) { } else if (border is DoubleLineBorder) { } else if (border is RoundedLineBorder) { } return(newBorder); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// private void DrawPart(Renderer renderer, Rectangle rect, BevelBorder pos, BevelStyle style, bool all) { SkinLayer layer = Skin.Layers["Control"]; Color c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value); Color c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value); Color c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value); if (Color != UndefinedColor) c3 = Color; Texture2D img = Skin.Layers["Control"].Image.Resource; int x1 = 0; int y1 = 0; int w1 = 0; int h1 = 0; int x2 = 0; int y2 = 0; int w2 = 0; int 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: { Color 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: { Color 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; } } }
} // DrawControl private void DrawPart(Rectangle rect, BevelBorder pos, BevelStyle style, bool all) { SkinLayer layer = SkinInformation.Layers["Control"]; Color c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value); Color c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value); Color c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value); if (Color != UndefinedColor) c3 = Color; Texture texture = SkinInformation.Layers["Control"].Image.Texture; int x1 = 0; int y1 = 0; int w1 = 0; int h1 = 0; int x2 = 0; int y2 = 0; int w2 = 0; int 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(texture.Resource, new Rectangle(x1, y1, w1, h1), c1); Renderer.Draw(texture.Resource, new Rectangle(x2, y2, w2, h2), c2); break; } case BevelStyle.Etched: { Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c2); Renderer.Draw(texture.Resource, new Rectangle(x2, y2, w2, h2), c1); break; } case BevelStyle.Raised: { Color c = c1; if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c1; else c = c2; Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c); break; } case BevelStyle.Lowered: { Color c = c1; if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c2; else c = c1; Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c); break; } default: { Renderer.Draw(texture.Resource, new Rectangle(x1, y1, w1, h1), c3); break; } } } // DrawPart
/// <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; } } }