Placement Information Interface #1140
adragon202
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When trying to iterate through all the nodes in a group to identify placement information specific to that group it would be very helpful if there was an interface that was used for all elements that have X, Y, Height and Width. As it is now Reflection has to be used to get this information generically and that's a sketchy way to do it.
Getting through Reflection
SvgUnit? nodeY = null;
SvgUnit? nodeX = null;
SvgUnit? nodeHeight = null;
SvgUnit? nodeWidth = null;
var xProp = node.GetType().GetProperty(nameof(SvgRectangle.X), typeof(SvgUnit));
var yProp = node.GetType().GetProperty(nameof(SvgRectangle.Y), typeof(SvgUnit));
var heightProp = node.GetType().GetProperty(nameof(SvgRectangle.Height), typeof(SvgUnit));
var widthProp = node.GetType().GetProperty(nameof(SvgRectangle.Width), typeof(SvgUnit));
if (xProp != null) nodeX = xProp.GetValue(node) as SvgUnit?;
if (yProp != null) nodeY = yProp.GetValue(node) as SvgUnit?;
if (heightProp != null) nodeHeight = heightProp.GetValue(node) as SvgUnit?;
if (widthProp != null) nodeWidth = widthProp.GetValue(node) as SvgUnit?;
//Do Stuff with nodeY, nodeX, nodeHeight and nodeWidth
Getting Through Interface
if (node is Svg.ISvgPlacement placement){
//Do Stuff with placement.X, placement.Y, placement.Height and placement.Width
}
Beta Was this translation helpful? Give feedback.
All reactions