Skip to content

Commit

Permalink
add border
Browse files Browse the repository at this point in the history
  • Loading branch information
bluepilledgreat committed Jan 23, 2025
1 parent bf64ec8 commit d8919e5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Bloxstrap/Resources/CustomBootstrapperSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@
"Orientation": "Orientation"
}
},
"Border": {
"SuperClass": "FrameworkElement",
"IsCreatable": true,
"Attributes": {
"Background": "Brush",
"BorderBrush": "Brush",
"BorderThickness": "Thickness",
"Padding": "Thickness",
"CornerRadius": "CornerRadius"
}
},
"RowDefinition": {
"IsCreatable": true,
"Attributes": {
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Bootstrapper/CustomDialog.Creator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private class DummyFrameworkElement : FrameworkElement { }
["Image"] = HandleXmlElement_Image,
["Grid"] = HandleXmlElement_Grid,
["StackPanel"] = HandleXmlElement_StackPanel,
["Border"] = HandleXmlElement_Border,

["SolidColorBrush"] = HandleXmlElement_SolidColorBrush,
["ImageBrush"] = HandleXmlElement_ImageBrush,
Expand Down
31 changes: 31 additions & 0 deletions Bloxstrap/UI/Elements/Bootstrapper/CustomDialog.Elements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,37 @@ private static StackPanel HandleXmlElement_StackPanel(CustomDialog dialog, XElem

return stackPanel;
}

private static Border HandleXmlElement_Border(CustomDialog dialog, XElement xmlElement)
{
var border = new Border();

ApplyBrush_UIElement(dialog, border, "Background", Border.BackgroundProperty, xmlElement);
ApplyBrush_UIElement(dialog, border, "BorderBrush", Border.BorderBrushProperty, xmlElement);

object? borderThickness = GetThicknessFromXElement(xmlElement, "BorderThickness");
if (borderThickness != null)
border.BorderThickness = (Thickness)borderThickness;

object? padding = GetThicknessFromXElement(xmlElement, "Padding");
if (padding != null)
border.Padding = (Thickness)padding;

object? cornerRadius = GetCornerRadiusFromXElement(xmlElement, "CornerRadius");
if (cornerRadius != null)
border.CornerRadius = (CornerRadius)cornerRadius;

var children = xmlElement.Elements().Where(x => !x.Name.ToString().StartsWith("Border."));
if (children.Any())
{
if (children.Count() > 1)
throw new Exception("Border can only have one child");

border.Child = HandleXml<UIElement>(dialog, children.First());
}

return border;
}
#endregion
}
}

0 comments on commit d8919e5

Please sign in to comment.