mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
add grids
This commit is contained in:
parent
7e5ddb2073
commit
2c41456a15
@ -16,7 +16,11 @@
|
|||||||
"LayoutTransform": "Transform",
|
"LayoutTransform": "Transform",
|
||||||
"Opacity": "double",
|
"Opacity": "double",
|
||||||
"OpacityMask": "Brush",
|
"OpacityMask": "Brush",
|
||||||
"RenderTransformOrigin": "Point"
|
"RenderTransformOrigin": "Point",
|
||||||
|
"Grid.Row": "int",
|
||||||
|
"Grid.RowSpan": "int",
|
||||||
|
"Grid.Column": "int",
|
||||||
|
"Grid.ColumnSpan": "int"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Control": {
|
"Control": {
|
||||||
@ -119,6 +123,30 @@
|
|||||||
"IsAnimated": "bool"
|
"IsAnimated": "bool"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Grid": {
|
||||||
|
"SuperClass": "FrameworkElement",
|
||||||
|
"IsCreatable": true,
|
||||||
|
"Attributes": {
|
||||||
|
"RowDefinitions": "object",
|
||||||
|
"ColumnDefinitions": "object"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RowDefinition": {
|
||||||
|
"IsCreatable": true,
|
||||||
|
"Attributes": {
|
||||||
|
"Height": "GridLength",
|
||||||
|
"MinHeight": "double",
|
||||||
|
"MaxHeight": "double"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ColumnDefinition": {
|
||||||
|
"IsCreatable": true,
|
||||||
|
"Attributes": {
|
||||||
|
"Width": "GridLength",
|
||||||
|
"MinWidth": "double",
|
||||||
|
"MaxWidth": "double"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ScaleTransform": {
|
"ScaleTransform": {
|
||||||
"IsCreatable": true,
|
"IsCreatable": true,
|
||||||
"Attributes": {
|
"Attributes": {
|
||||||
@ -277,6 +305,7 @@
|
|||||||
"ImageSource": {},
|
"ImageSource": {},
|
||||||
"Transform": { "CanHaveElement": true },
|
"Transform": { "CanHaveElement": true },
|
||||||
"FontFamily": {},
|
"FontFamily": {},
|
||||||
|
"GridLength": {},
|
||||||
"Visibility": {
|
"Visibility": {
|
||||||
"Values": [
|
"Values": [
|
||||||
"Visible",
|
"Visible",
|
||||||
|
@ -66,6 +66,9 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
|||||||
|
|
||||||
private static object? GetCornerRadiusFromXElement(XElement xmlElement, string attributeName) => GetTypeFromXElement(CornerRadiusConverter, xmlElement, attributeName);
|
private static object? GetCornerRadiusFromXElement(XElement xmlElement, string attributeName) => GetTypeFromXElement(CornerRadiusConverter, xmlElement, attributeName);
|
||||||
|
|
||||||
|
public static GridLengthConverter GridLengthConverter { get; } = new GridLengthConverter();
|
||||||
|
private static object? GetGridLengthFromXElement(XElement xmlElement, string attributeName) => GetTypeFromXElement(GridLengthConverter, xmlElement, attributeName);
|
||||||
|
|
||||||
|
|
||||||
private static BrushConverter? _brushConverter = null;
|
private static BrushConverter? _brushConverter = null;
|
||||||
private static BrushConverter BrushConverter { get => _brushConverter ??= new BrushConverter(); }
|
private static BrushConverter BrushConverter { get => _brushConverter ??= new BrushConverter(); }
|
||||||
|
@ -30,6 +30,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
|||||||
["TextBlock"] = HandleXmlElement_TextBlock,
|
["TextBlock"] = HandleXmlElement_TextBlock,
|
||||||
["MarkdownTextBlock"] = HandleXmlElement_MarkdownTextBlock,
|
["MarkdownTextBlock"] = HandleXmlElement_MarkdownTextBlock,
|
||||||
["Image"] = HandleXmlElement_Image,
|
["Image"] = HandleXmlElement_Image,
|
||||||
|
["Grid"] = HandleXmlElement_Grid,
|
||||||
|
|
||||||
["SolidColorBrush"] = HandleXmlElement_SolidColorBrush,
|
["SolidColorBrush"] = HandleXmlElement_SolidColorBrush,
|
||||||
["ImageBrush"] = HandleXmlElement_ImageBrush,
|
["ImageBrush"] = HandleXmlElement_ImageBrush,
|
||||||
@ -47,7 +48,10 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
|||||||
|
|
||||||
["Ellipse"] = HandleXmlElement_Ellipse,
|
["Ellipse"] = HandleXmlElement_Ellipse,
|
||||||
["Line"] = HandleXmlElement_Line,
|
["Line"] = HandleXmlElement_Line,
|
||||||
["Rectangle"] = HandleXmlElement_Rectangle
|
["Rectangle"] = HandleXmlElement_Rectangle,
|
||||||
|
|
||||||
|
["RowDefinition"] = HandleXmlElement_RowDefinition,
|
||||||
|
["ColumnDefinition"] = HandleXmlElement_ColumnDefinition
|
||||||
};
|
};
|
||||||
|
|
||||||
private static T HandleXml<T>(CustomDialog dialog, XElement xmlElement) where T : class
|
private static T HandleXml<T>(CustomDialog dialog, XElement xmlElement) where T : class
|
||||||
|
@ -316,6 +316,16 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
|||||||
int zIndex = ParseXmlAttributeClamped(xmlElement, "ZIndex", defaultValue: 0, min: 0, max: 1000);
|
int zIndex = ParseXmlAttributeClamped(xmlElement, "ZIndex", defaultValue: 0, min: 0, max: 1000);
|
||||||
Panel.SetZIndex(uiElement, zIndex);
|
Panel.SetZIndex(uiElement, zIndex);
|
||||||
|
|
||||||
|
int gridRow = ParseXmlAttribute<int>(xmlElement, "Grid.Row", 0);
|
||||||
|
Grid.SetRow(uiElement, gridRow);
|
||||||
|
int gridRowSpan = ParseXmlAttribute<int>(xmlElement, "Grid.RowSpan", 1);
|
||||||
|
Grid.SetRowSpan(uiElement, gridRowSpan);
|
||||||
|
|
||||||
|
int gridColumn = ParseXmlAttribute<int>(xmlElement, "Grid.Column", 0);
|
||||||
|
Grid.SetColumn(uiElement, gridColumn);
|
||||||
|
int gridColumnSpan = ParseXmlAttribute<int>(xmlElement, "Grid.ColumnSpan", 1);
|
||||||
|
Grid.SetColumnSpan(uiElement, gridColumnSpan);
|
||||||
|
|
||||||
ApplyTransformations_UIElement(dialog, uiElement, xmlElement);
|
ApplyTransformations_UIElement(dialog, uiElement, xmlElement);
|
||||||
ApplyEffects_UIElement(dialog, uiElement, xmlElement);
|
ApplyEffects_UIElement(dialog, uiElement, xmlElement);
|
||||||
}
|
}
|
||||||
@ -614,6 +624,88 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
|
|||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RowDefinition HandleXmlElement_RowDefinition(CustomDialog dialog, XElement xmlElement)
|
||||||
|
{
|
||||||
|
var rowDefinition = new RowDefinition();
|
||||||
|
|
||||||
|
var height = GetGridLengthFromXElement(xmlElement, "Height");
|
||||||
|
if (height != null)
|
||||||
|
rowDefinition.Height = (GridLength)height;
|
||||||
|
|
||||||
|
rowDefinition.MinHeight = ParseXmlAttribute<double>(xmlElement, "MinHeight", 0);
|
||||||
|
rowDefinition.MaxHeight = ParseXmlAttribute<double>(xmlElement, "MaxHeight", double.PositiveInfinity);
|
||||||
|
|
||||||
|
return rowDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ColumnDefinition HandleXmlElement_ColumnDefinition(CustomDialog dialog, XElement xmlElement)
|
||||||
|
{
|
||||||
|
var columnDefinition = new ColumnDefinition();
|
||||||
|
|
||||||
|
var width = GetGridLengthFromXElement(xmlElement, "Width");
|
||||||
|
if (width != null)
|
||||||
|
columnDefinition.Width = (GridLength)width;
|
||||||
|
|
||||||
|
columnDefinition.MinWidth = ParseXmlAttribute<double>(xmlElement, "MinWidth", 0);
|
||||||
|
columnDefinition.MaxWidth = ParseXmlAttribute<double>(xmlElement, "MaxWidth", double.PositiveInfinity);
|
||||||
|
|
||||||
|
return columnDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleXmlElement_Grid_RowDefinitions(Grid grid, CustomDialog dialog, XElement xmlElement)
|
||||||
|
{
|
||||||
|
foreach (var element in xmlElement.Elements())
|
||||||
|
{
|
||||||
|
var rowDefinition = HandleXml<RowDefinition>(dialog, element);
|
||||||
|
grid.RowDefinitions.Add(rowDefinition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleXmlElement_Grid_ColumnDefinitions(Grid grid, CustomDialog dialog, XElement xmlElement)
|
||||||
|
{
|
||||||
|
foreach (var element in xmlElement.Elements())
|
||||||
|
{
|
||||||
|
var columnDefinition = HandleXml<ColumnDefinition>(dialog, element);
|
||||||
|
grid.ColumnDefinitions.Add(columnDefinition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Grid HandleXmlElement_Grid(CustomDialog dialog, XElement xmlElement)
|
||||||
|
{
|
||||||
|
var grid = new Grid();
|
||||||
|
HandleXmlElement_FrameworkElement(dialog, grid, xmlElement);
|
||||||
|
|
||||||
|
bool rowsSet = false;
|
||||||
|
bool columnsSet = false;
|
||||||
|
|
||||||
|
foreach (var element in xmlElement.Elements())
|
||||||
|
{
|
||||||
|
if (element.Name == "Grid.RowDefinitions")
|
||||||
|
{
|
||||||
|
if (rowsSet)
|
||||||
|
throw new Exception("Grid can only have one RowDefinitions defined");
|
||||||
|
rowsSet = true;
|
||||||
|
|
||||||
|
HandleXmlElement_Grid_RowDefinitions(grid, dialog, element);
|
||||||
|
}
|
||||||
|
else if (element.Name == "Grid.ColumnDefinitions")
|
||||||
|
{
|
||||||
|
if (columnsSet)
|
||||||
|
throw new Exception("Grid can only have one ColumnDefinitions defined");
|
||||||
|
columnsSet = true;
|
||||||
|
|
||||||
|
HandleXmlElement_Grid_ColumnDefinitions(grid, dialog, element);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var uiElement = HandleXml<FrameworkElement>(dialog, element);
|
||||||
|
grid.Children.Add(uiElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user