diff --git a/Bloxstrap/Resources/CustomBootstrapperSchema.json b/Bloxstrap/Resources/CustomBootstrapperSchema.json index f29ff75..cb323e2 100644 --- a/Bloxstrap/Resources/CustomBootstrapperSchema.json +++ b/Bloxstrap/Resources/CustomBootstrapperSchema.json @@ -173,6 +173,45 @@ "Color": "Color", "Offset": "double" } + }, + "Shape": { + "SuperClass": "FrameworkElement", + "IsCreatable": false, + "Attributes": { + "Fill": "Brush", + "Stroke": "Brush", + "Stretch": "Stretch", + "StrokeDashCap": "PenLineCap", + "StrokeDashOffset": "double", + "StrokeEndLineCap": "PenLineCap", + "StrokeLineJoin": "PenLineJoin", + "StrokeMiterLimit": "double", + "StrokeStartLineCap": "PenLineCap", + "StrokeThickness": "double" + } + }, + "Ellipse": { + "SuperClass": "Shape", + "IsCreatable": true, + "Attributes": {} + }, + "Line": { + "SuperClass": "Shape", + "IsCreatable": true, + "Attributes": { + "X1": "double", + "X2": "double", + "Y1": "double", + "Y2": "double" + } + }, + "Rectangle": { + "SuperClass": "Shape", + "IsCreatable": true, + "Attributes": { + "RadiusX": "double", + "RadiusY": "double" + } } }, "Types": { @@ -341,6 +380,21 @@ "Reflect", "Repeat" ] + }, + "PenLineCap": { + "Values": [ + "Flat", + "Square", + "Round", + "Triangle" + ] + }, + "PenLineJoin": { + "Values": [ + "Miter", + "Bevel", + "Round" + ] } } } \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/Bootstrapper/CustomDialog.Creator.cs b/Bloxstrap/UI/Elements/Bootstrapper/CustomDialog.Creator.cs index f472c3c..cc1dfdc 100644 --- a/Bloxstrap/UI/Elements/Bootstrapper/CustomDialog.Creator.cs +++ b/Bloxstrap/UI/Elements/Bootstrapper/CustomDialog.Creator.cs @@ -1,9 +1,9 @@ -using System.ComponentModel; -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Shapes; using System.Xml.Linq; using Wpf.Ui.Markup; @@ -46,7 +46,11 @@ namespace Bloxstrap.UI.Elements.Bootstrapper ["ScaleTransform"] = HandleXml_ScaleTransform, ["SkewTransform"] = HandleXml_SkewTransform, ["RotateTransform"] = HandleXml_RotateTransform, - ["TranslateTransform"] = HandleXml_TranslateTransform + ["TranslateTransform"] = HandleXml_TranslateTransform, + + ["Ellipse"] = HandleXmlElement_Ellipse, + ["Line"] = HandleXmlElement_Line, + ["Rectangle"] = HandleXmlElement_Rectangle }; @@ -432,6 +436,61 @@ namespace Bloxstrap.UI.Elements.Bootstrapper } #endregion + #region Shapes + private static void HandleXmlElement_Shape(CustomDialog dialog, Shape shape, XElement xmlElement) + { + HandleXmlElement_FrameworkElement(dialog, shape, xmlElement); + + ApplyBrush_UIElement(dialog, shape, "Fill", Shape.FillProperty, xmlElement); + ApplyBrush_UIElement(dialog, shape, "Stroke", Shape.StrokeProperty, xmlElement); + + shape.Stretch = ParseXmlAttribute(xmlElement, "Stretch", Stretch.Fill); + + shape.StrokeDashCap = ParseXmlAttribute(xmlElement, "StrokeDashCap", PenLineCap.Flat); + shape.StrokeDashOffset = ParseXmlAttribute(xmlElement, "StrokeDashOffset", 0); + shape.StrokeEndLineCap = ParseXmlAttribute(xmlElement, "StrokeEndLineCap", PenLineCap.Flat); + shape.StrokeLineJoin = ParseXmlAttribute(xmlElement, "StrokeLineJoin", PenLineJoin.Miter); + shape.StrokeMiterLimit = ParseXmlAttribute(xmlElement, "StrokeMiterLimit", 10); + shape.StrokeStartLineCap = ParseXmlAttribute(xmlElement, "StrokeStartLineCap", PenLineCap.Flat); + shape.StrokeThickness = ParseXmlAttribute(xmlElement, "StrokeThickness", 1); + + ApplyTransformations_UIElement(dialog, shape, xmlElement); + } + + private static Ellipse HandleXmlElement_Ellipse(CustomDialog dialog, XElement xmlElement) + { + var ellipse = new Ellipse(); + HandleXmlElement_Shape(dialog, ellipse, xmlElement); + + return ellipse; + } + + private static Line HandleXmlElement_Line(CustomDialog dialog, XElement xmlElement) + { + var line = new Line(); + HandleXmlElement_Shape(dialog, line, xmlElement); + + line.X1 = ParseXmlAttribute(xmlElement, "X1", 0); + line.X2 = ParseXmlAttribute(xmlElement, "X2", 0); + line.Y1 = ParseXmlAttribute(xmlElement, "Y1", 0); + line.Y2 = ParseXmlAttribute(xmlElement, "Y2", 0); + + return line; + } + + private static Rectangle HandleXmlElement_Rectangle(CustomDialog dialog, XElement xmlElement) + { + var rectangle = new Rectangle(); + HandleXmlElement_Shape(dialog, rectangle, xmlElement); + + rectangle.RadiusX = ParseXmlAttribute(xmlElement, "RadiusX", 0); + rectangle.RadiusY = ParseXmlAttribute(xmlElement, "RadiusY", 0); + + return rectangle; + } + + #endregion + #region Elements private static void HandleXmlElement_FrameworkElement(CustomDialog dialog, FrameworkElement uiElement, XElement xmlElement) { @@ -767,7 +826,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper #region Public APIs public void ApplyCustomTheme(string name, string contents) { - ThemeDir = Path.Combine(Paths.CustomThemes, name); + ThemeDir = System.IO.Path.Combine(Paths.CustomThemes, name); XElement xml; @@ -786,7 +845,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper public void ApplyCustomTheme(string name) { - string path = Path.Combine(Paths.CustomThemes, name, "Theme.xml"); + string path = System.IO.Path.Combine(Paths.CustomThemes, name, "Theme.xml"); ApplyCustomTheme(name, File.ReadAllText(path)); }