Skip to content

Instantly share code, notes, and snippets.

@SQL-MisterMagoo
Last active November 22, 2019 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SQL-MisterMagoo/6a056c50862d1b28e1a1d7b4be1c1bf3 to your computer and use it in GitHub Desktop.
Save SQL-MisterMagoo/6a056c50862d1b28e1a1d7b4be1c1bf3 to your computer and use it in GitHub Desktop.
C# Class for CSS Properties with ToString() override suitable for a `style` attribute - https://github.com/SQL-MisterMagoo/SampleStyle
using System.Reflection;
using System.Text;
using System.Text.Json.Serialization;
public class CssProperties
{
[JsonPropertyName("align-content")] public string AlignContent { get; set; }
[JsonPropertyName("align-items")] public string AlignItems { get; set; }
[JsonPropertyName("alignment-baseline")] public string AlignmentBaseline { get; set; }
[JsonPropertyName("align-self")] public string AlignSelf { get; set; }
[JsonPropertyName("animation-delay")] public string AnimationDelay { get; set; }
[JsonPropertyName("animation-direction")] public string AnimationDirection { get; set; }
[JsonPropertyName("animation-duration")] public string AnimationDuration { get; set; }
[JsonPropertyName("animation-fill-mode")] public string AnimationFillMode { get; set; }
[JsonPropertyName("animation-iteration-count")] public string AnimationIterationCount { get; set; }
[JsonPropertyName("animation-name")] public string AnimationName { get; set; }
[JsonPropertyName("animation-play-state")] public string AnimationPlayState { get; set; }
[JsonPropertyName("animation-timing-function")] public string AnimationTimingFunction { get; set; }
[JsonPropertyName("backdrop-filter")] public string BackdropFilter { get; set; }
[JsonPropertyName("backface-visibility")] public string BackfaceVisibility { get; set; }
[JsonPropertyName("background-attachment")] public string BackgroundAttachment { get; set; }
[JsonPropertyName("background-blend-mode")] public string BackgroundBlendMode { get; set; }
[JsonPropertyName("background-clip")] public string BackgroundClip { get; set; }
[JsonPropertyName("background-color")] public string BackgroundColor { get; set; }
[JsonPropertyName("background-image")] public string BackgroundImage { get; set; }
[JsonPropertyName("background-origin")] public string BackgroundOrigin { get; set; }
[JsonPropertyName("background-position")] public string BackgroundPosition { get; set; }
[JsonPropertyName("background-repeat")] public string BackgroundRepeat { get; set; }
[JsonPropertyName("background-size")] public string BackgroundSize { get; set; }
[JsonPropertyName("baseline-shift")] public string BaselineShift { get; set; }
[JsonPropertyName("border-bottom-color")] public string BorderBottomColor { get; set; }
[JsonPropertyName("border-bottom-left-radius")] public string BorderBottomLeftRadius { get; set; }
[JsonPropertyName("border-bottom-right-radius")] public string BorderBottomRightRadius { get; set; }
[JsonPropertyName("border-bottom-style")] public string BorderBottomStyle { get; set; }
[JsonPropertyName("border-bottom-width")] public string BorderBottomWidth { get; set; }
[JsonPropertyName("border-collapse")] public string BorderCollapse { get; set; }
[JsonPropertyName("border-image-outset")] public string BorderImageOutset { get; set; }
[JsonPropertyName("border-image-repeat")] public string BorderImageRepeat { get; set; }
[JsonPropertyName("border-image-slice")] public string BorderImageSlice { get; set; }
[JsonPropertyName("border-image-source")] public string BorderImageSource { get; set; }
[JsonPropertyName("border-image-width")] public string BorderImageWidth { get; set; }
[JsonPropertyName("border-left-color")] public string BorderLeftColor { get; set; }
[JsonPropertyName("border-left-style")] public string BorderLeftStyle { get; set; }
[JsonPropertyName("border-left-width")] public string BorderLeftWidth { get; set; }
[JsonPropertyName("border-right-color")] public string BorderRightColor { get; set; }
[JsonPropertyName("border-right-style")] public string BorderRightStyle { get; set; }
[JsonPropertyName("border-right-width")] public string BorderRightWidth { get; set; }
[JsonPropertyName("border-top-color")] public string BorderTopColor { get; set; }
[JsonPropertyName("border-top-left-radius")] public string BorderTopLeftRadius { get; set; }
[JsonPropertyName("border-top-right-radius")] public string BorderTopRightRadius { get; set; }
[JsonPropertyName("border-top-style")] public string BorderTopStyle { get; set; }
[JsonPropertyName("border-top-width")] public string BorderTopWidth { get; set; }
[JsonPropertyName("bottom")] public string Bottom { get; set; }
[JsonPropertyName("box-shadow")] public string BoxShadow { get; set; }
[JsonPropertyName("box-sizing")] public string BoxSizing { get; set; }
[JsonPropertyName("break-after")] public string BreakAfter { get; set; }
[JsonPropertyName("break-before")] public string BreakBefore { get; set; }
[JsonPropertyName("break-inside")] public string BreakInside { get; set; }
[JsonPropertyName("buffered-rendering")] public string BufferedRendering { get; set; }
[JsonPropertyName("caption-side")] public string CaptionSide { get; set; }
[JsonPropertyName("caret-color")] public string CaretColor { get; set; }
[JsonPropertyName("clear")] public string Clear { get; set; }
[JsonPropertyName("clip")] public string Clip { get; set; }
[JsonPropertyName("clip-path")] public string ClipPath { get; set; }
[JsonPropertyName("clip-rule")] public string ClipRule { get; set; }
[JsonPropertyName("color")] public string Color { get; set; }
[JsonPropertyName("color-interpolation")] public string ColorInterpolation { get; set; }
[JsonPropertyName("color-interpolation-filters")] public string ColorInterpolationFilters { get; set; }
[JsonPropertyName("color-rendering")] public string ColorRendering { get; set; }
[JsonPropertyName("column-count")] public string ColumnCount { get; set; }
[JsonPropertyName("column-gap")] public string ColumnGap { get; set; }
[JsonPropertyName("column-rule-color")] public string ColumnRuleColor { get; set; }
[JsonPropertyName("column-rule-style")] public string ColumnRuleStyle { get; set; }
[JsonPropertyName("column-rule-width")] public string ColumnRuleWidth { get; set; }
[JsonPropertyName("column-span")] public string ColumnSpan { get; set; }
[JsonPropertyName("column-width")] public string ColumnWidth { get; set; }
[JsonPropertyName("content")] public string Content { get; set; }
[JsonPropertyName("cursor")] public string Cursor { get; set; }
[JsonPropertyName("cx")] public string Cx { get; set; }
[JsonPropertyName("cy")] public string Cy { get; set; }
[JsonPropertyName("d")] public string D { get; set; }
[JsonPropertyName("direction")] public string Direction { get; set; }
[JsonPropertyName("display")] public string Display { get; set; }
[JsonPropertyName("dominant-baseline")] public string DominantBaseline { get; set; }
[JsonPropertyName("empty-cells")] public string EmptyCells { get; set; }
[JsonPropertyName("fill")] public string Fill { get; set; }
[JsonPropertyName("fill-opacity")] public string FillOpacity { get; set; }
[JsonPropertyName("fill-rule")] public string FillRule { get; set; }
[JsonPropertyName("filter")] public string Filter { get; set; }
[JsonPropertyName("flex-basis")] public string FlexBasis { get; set; }
[JsonPropertyName("flex-direction")] public string FlexDirection { get; set; }
[JsonPropertyName("flex-grow")] public string FlexGrow { get; set; }
[JsonPropertyName("flex-shrink")] public string FlexShrink { get; set; }
[JsonPropertyName("flex-wrap")] public string FlexWrap { get; set; }
[JsonPropertyName("float")] public string Float { get; set; }
[JsonPropertyName("flood-color")] public string FloodColor { get; set; }
[JsonPropertyName("flood-opacity")] public string FloodOpacity { get; set; }
[JsonPropertyName("font-family")] public string FontFamily { get; set; }
[JsonPropertyName("font-kerning")] public string FontKerning { get; set; }
[JsonPropertyName("font-optical-sizing")] public string FontOpticalSizing { get; set; }
[JsonPropertyName("font-size")] public string FontSize { get; set; }
[JsonPropertyName("font-stretch")] public string FontStretch { get; set; }
[JsonPropertyName("font-style")] public string FontStyle { get; set; }
[JsonPropertyName("font-variant")] public string FontVariant { get; set; }
[JsonPropertyName("font-variant-caps")] public string FontVariantCaps { get; set; }
[JsonPropertyName("font-variant-east-asian")] public string FontVariantEastAsian { get; set; }
[JsonPropertyName("font-variant-ligatures")] public string FontVariantLigatures { get; set; }
[JsonPropertyName("font-variant-numeric")] public string FontVariantNumeric { get; set; }
[JsonPropertyName("font-weight")] public string FontWeight { get; set; }
[JsonPropertyName("grid-auto-columns")] public string GridAutoColumns { get; set; }
[JsonPropertyName("grid-auto-flow")] public string GridAutoFlow { get; set; }
[JsonPropertyName("grid-auto-rows")] public string GridAutoRows { get; set; }
[JsonPropertyName("grid-column-end")] public string GridColumnEnd { get; set; }
[JsonPropertyName("grid-column-start")] public string GridColumnStart { get; set; }
[JsonPropertyName("grid-row-end")] public string GridRowEnd { get; set; }
[JsonPropertyName("grid-row-start")] public string GridRowStart { get; set; }
[JsonPropertyName("grid-template-areas")] public string GridTemplateAreas { get; set; }
[JsonPropertyName("grid-template-columns")] public string GridTemplateColumns { get; set; }
[JsonPropertyName("grid-template-rows")] public string GridTemplateRows { get; set; }
[JsonPropertyName("height")] public string Height { get; set; }
[JsonPropertyName("hyphens")] public string Hyphens { get; set; }
[JsonPropertyName("image-rendering")] public string ImageRendering { get; set; }
[JsonPropertyName("isolation")] public string Isolation { get; set; }
[JsonPropertyName("justify-content")] public string JustifyContent { get; set; }
[JsonPropertyName("justify-items")] public string JustifyItems { get; set; }
[JsonPropertyName("justify-self")] public string JustifySelf { get; set; }
[JsonPropertyName("left")] public string Left { get; set; }
[JsonPropertyName("letter-spacing")] public string LetterSpacing { get; set; }
[JsonPropertyName("lighting-color")] public string LightingColor { get; set; }
[JsonPropertyName("line-break")] public string LineBreak { get; set; }
[JsonPropertyName("line-height")] public string LineHeight { get; set; }
[JsonPropertyName("list-style-image")] public string ListStyleImage { get; set; }
[JsonPropertyName("list-style-position")] public string ListStylePosition { get; set; }
[JsonPropertyName("list-style-type")] public string ListStyleType { get; set; }
[JsonPropertyName("margin-bottom")] public string MarginBottom { get; set; }
[JsonPropertyName("margin-left")] public string MarginLeft { get; set; }
[JsonPropertyName("margin-right")] public string MarginRight { get; set; }
[JsonPropertyName("margin-top")] public string MarginTop { get; set; }
[JsonPropertyName("marker-end")] public string MarkerEnd { get; set; }
[JsonPropertyName("marker-mid")] public string MarkerMid { get; set; }
[JsonPropertyName("marker-start")] public string MarkerStart { get; set; }
[JsonPropertyName("mask")] public string Mask { get; set; }
[JsonPropertyName("mask-type")] public string MaskType { get; set; }
[JsonPropertyName("max-height")] public string MaxHeight { get; set; }
[JsonPropertyName("max-width")] public string MaxWidth { get; set; }
[JsonPropertyName("min-height")] public string MinHeight { get; set; }
[JsonPropertyName("min-width")] public string MinWidth { get; set; }
[JsonPropertyName("mix-blend-mode")] public string MixBlendMode { get; set; }
[JsonPropertyName("object-fit")] public string ObjectFit { get; set; }
[JsonPropertyName("object-position")] public string ObjectPosition { get; set; }
[JsonPropertyName("offset-distance")] public string OffsetDistance { get; set; }
[JsonPropertyName("offset-path")] public string OffsetPath { get; set; }
[JsonPropertyName("offset-rotate")] public string OffsetRotate { get; set; }
[JsonPropertyName("opacity")] public string Opacity { get; set; }
[JsonPropertyName("order")] public string Order { get; set; }
[JsonPropertyName("orphans")] public string Orphans { get; set; }
[JsonPropertyName("outline-color")] public string OutlineColor { get; set; }
[JsonPropertyName("outline-offset")] public string OutlineOffset { get; set; }
[JsonPropertyName("outline-style")] public string OutlineStyle { get; set; }
[JsonPropertyName("outline-width")] public string OutlineWidth { get; set; }
[JsonPropertyName("overflow-anchor")] public string OverflowAnchor { get; set; }
[JsonPropertyName("overflow-wrap")] public string OverflowWrap { get; set; }
[JsonPropertyName("overflow-x")] public string OverflowX { get; set; }
[JsonPropertyName("overflow-y")] public string OverflowY { get; set; }
[JsonPropertyName("padding-bottom")] public string PaddingBottom { get; set; }
[JsonPropertyName("padding-left")] public string PaddingLeft { get; set; }
[JsonPropertyName("padding-right")] public string PaddingRight { get; set; }
[JsonPropertyName("padding-top")] public string PaddingTop { get; set; }
[JsonPropertyName("paint-order")] public string PaintOrder { get; set; }
[JsonPropertyName("perspective")] public string Perspective { get; set; }
[JsonPropertyName("perspective-origin")] public string PerspectiveOrigin { get; set; }
[JsonPropertyName("pointer-events")] public string PointerEvents { get; set; }
[JsonPropertyName("position")] public string Position { get; set; }
[JsonPropertyName("r")] public string R { get; set; }
[JsonPropertyName("resize")] public string Resize { get; set; }
[JsonPropertyName("right")] public string Right { get; set; }
[JsonPropertyName("row-gap")] public string RowGap { get; set; }
[JsonPropertyName("rx")] public string Rx { get; set; }
[JsonPropertyName("ry")] public string Ry { get; set; }
[JsonPropertyName("scroll-behavior")] public string ScrollBehavior { get; set; }
[JsonPropertyName("shape-image-threshold")] public string ShapeImageThreshold { get; set; }
[JsonPropertyName("shape-margin")] public string ShapeMargin { get; set; }
[JsonPropertyName("shape-outside")] public string ShapeOutside { get; set; }
[JsonPropertyName("shape-rendering")] public string ShapeRendering { get; set; }
[JsonPropertyName("speak")] public string Speak { get; set; }
[JsonPropertyName("stop-color")] public string StopColor { get; set; }
[JsonPropertyName("stop-opacity")] public string StopOpacity { get; set; }
[JsonPropertyName("stroke")] public string Stroke { get; set; }
[JsonPropertyName("stroke-dasharray")] public string StrokeDasharray { get; set; }
[JsonPropertyName("stroke-dashoffset")] public string StrokeDashoffset { get; set; }
[JsonPropertyName("stroke-linecap")] public string StrokeLinecap { get; set; }
[JsonPropertyName("stroke-linejoin")] public string StrokeLinejoin { get; set; }
[JsonPropertyName("stroke-miterlimit")] public string StrokeMiterlimit { get; set; }
[JsonPropertyName("stroke-opacity")] public string StrokeOpacity { get; set; }
[JsonPropertyName("stroke-width")] public string StrokeWidth { get; set; }
[JsonPropertyName("table-layout")] public string TableLayout { get; set; }
[JsonPropertyName("tab-size")] public string TabSize { get; set; }
[JsonPropertyName("text-align")] public string TextAlign { get; set; }
[JsonPropertyName("text-align-last")] public string TextAlignLast { get; set; }
[JsonPropertyName("text-anchor")] public string TextAnchor { get; set; }
[JsonPropertyName("text-decoration")] public string TextDecoration { get; set; }
[JsonPropertyName("text-decoration-color")] public string TextDecorationColor { get; set; }
[JsonPropertyName("text-decoration-line")] public string TextDecorationLine { get; set; }
[JsonPropertyName("text-decoration-skip-ink")] public string TextDecorationSkipInk { get; set; }
[JsonPropertyName("text-decoration-style")] public string TextDecorationStyle { get; set; }
[JsonPropertyName("text-indent")] public string TextIndent { get; set; }
[JsonPropertyName("text-overflow")] public string TextOverflow { get; set; }
[JsonPropertyName("text-rendering")] public string TextRendering { get; set; }
[JsonPropertyName("text-shadow")] public string TextShadow { get; set; }
[JsonPropertyName("text-size-adjust")] public string TextSizeAdjust { get; set; }
[JsonPropertyName("text-transform")] public string TextTransform { get; set; }
[JsonPropertyName("text-underline-position")] public string TextUnderlinePosition { get; set; }
[JsonPropertyName("top")] public string Top { get; set; }
[JsonPropertyName("touch-action")] public string TouchAction { get; set; }
[JsonPropertyName("transform")] public string Transform { get; set; }
[JsonPropertyName("transform-origin")] public string TransformOrigin { get; set; }
[JsonPropertyName("transform-style")] public string TransformStyle { get; set; }
[JsonPropertyName("transition-delay")] public string TransitionDelay { get; set; }
[JsonPropertyName("transition-duration")] public string TransitionDuration { get; set; }
[JsonPropertyName("transition-property")] public string TransitionProperty { get; set; }
[JsonPropertyName("transition-timing-function")] public string TransitionTimingFunction { get; set; }
[JsonPropertyName("unicode-bidi")] public string UnicodeBidi { get; set; }
[JsonPropertyName("user-select")] public string UserSelect { get; set; }
[JsonPropertyName("vector-effect")] public string VectorEffect { get; set; }
[JsonPropertyName("vertical-align")] public string VerticalAlign { get; set; }
[JsonPropertyName("visibility")] public string Visibility { get; set; }
[JsonPropertyName("-webkit-appearance")] public string WebkitAppearance { get; set; }
[JsonPropertyName("-webkit-app-region")] public string WebkitAppRegion { get; set; }
[JsonPropertyName("-webkit-border-horizontal-spacing")] public string WebkitBorderHorizontalSpacing { get; set; }
[JsonPropertyName("-webkit-border-image")] public string WebkitBorderImage { get; set; }
[JsonPropertyName("-webkit-border-vertical-spacing")] public string WebkitBorderVerticalSpacing { get; set; }
[JsonPropertyName("-webkit-box-align")] public string WebkitBoxAlign { get; set; }
[JsonPropertyName("-webkit-box-decoration-break")] public string WebkitBoxDecorationBreak { get; set; }
[JsonPropertyName("-webkit-box-direction")] public string WebkitBoxDirection { get; set; }
[JsonPropertyName("-webkit-box-flex")] public string WebkitBoxFlex { get; set; }
[JsonPropertyName("-webkit-box-ordinal-group")] public string WebkitBoxOrdinalGroup { get; set; }
[JsonPropertyName("-webkit-box-orient")] public string WebkitBoxOrient { get; set; }
[JsonPropertyName("-webkit-box-pack")] public string WebkitBoxPack { get; set; }
[JsonPropertyName("-webkit-box-reflect")] public string WebkitBoxReflect { get; set; }
[JsonPropertyName("-webkit-font-smoothing")] public string WebkitFontSmoothing { get; set; }
[JsonPropertyName("-webkit-highlight")] public string WebkitHighlight { get; set; }
[JsonPropertyName("-webkit-hyphenate-character")] public string WebkitHyphenateCharacter { get; set; }
[JsonPropertyName("-webkit-line-break")] public string WebkitLineBreak { get; set; }
[JsonPropertyName("-webkit-line-clamp")] public string WebkitLineClamp { get; set; }
[JsonPropertyName("-webkit-locale")] public string WebkitLocale { get; set; }
[JsonPropertyName("-webkit-margin-after-collapse")] public string WebkitMarginAfterCollapse { get; set; }
[JsonPropertyName("-webkit-margin-before-collapse")] public string WebkitMarginBeforeCollapse { get; set; }
[JsonPropertyName("-webkit-mask-box-image")] public string WebkitMaskBoxImage { get; set; }
[JsonPropertyName("-webkit-mask-box-image-outset")] public string WebkitMaskBoxImageOutset { get; set; }
[JsonPropertyName("-webkit-mask-box-image-repeat")] public string WebkitMaskBoxImageRepeat { get; set; }
[JsonPropertyName("-webkit-mask-box-image-slice")] public string WebkitMaskBoxImageSlice { get; set; }
[JsonPropertyName("-webkit-mask-box-image-source")] public string WebkitMaskBoxImageSource { get; set; }
[JsonPropertyName("-webkit-mask-box-image-width")] public string WebkitMaskBoxImageWidth { get; set; }
[JsonPropertyName("-webkit-mask-clip")] public string WebkitMaskClip { get; set; }
[JsonPropertyName("-webkit-mask-composite")] public string WebkitMaskComposite { get; set; }
[JsonPropertyName("-webkit-mask-image")] public string WebkitMaskImage { get; set; }
[JsonPropertyName("-webkit-mask-origin")] public string WebkitMaskOrigin { get; set; }
[JsonPropertyName("-webkit-mask-position")] public string WebkitMaskPosition { get; set; }
[JsonPropertyName("-webkit-mask-repeat")] public string WebkitMaskRepeat { get; set; }
[JsonPropertyName("-webkit-mask-size")] public string WebkitMaskSize { get; set; }
[JsonPropertyName("-webkit-print-color-adjust")] public string WebkitPrintColorAdjust { get; set; }
[JsonPropertyName("-webkit-rtl-ordering")] public string WebkitRtlOrdering { get; set; }
[JsonPropertyName("-webkit-tap-highlight-color")] public string WebkitTapHighlightColor { get; set; }
[JsonPropertyName("-webkit-text-combine")] public string WebkitTextCombine { get; set; }
[JsonPropertyName("-webkit-text-decorations-in-effect")] public string WebkitTextDecorationsInEffect { get; set; }
[JsonPropertyName("-webkit-text-emphasis-color")] public string WebkitTextEmphasisColor { get; set; }
[JsonPropertyName("-webkit-text-emphasis-position")] public string WebkitTextEmphasisPosition { get; set; }
[JsonPropertyName("-webkit-text-emphasis-style")] public string WebkitTextEmphasisStyle { get; set; }
[JsonPropertyName("-webkit-text-fill-color")] public string WebkitTextFillColor { get; set; }
[JsonPropertyName("-webkit-text-orientation")] public string WebkitTextOrientation { get; set; }
[JsonPropertyName("-webkit-text-security")] public string WebkitTextSecurity { get; set; }
[JsonPropertyName("-webkit-text-stroke-color")] public string WebkitTextStrokeColor { get; set; }
[JsonPropertyName("-webkit-text-stroke-width")] public string WebkitTextStrokeWidth { get; set; }
[JsonPropertyName("-webkit-user-drag")] public string WebkitUserDrag { get; set; }
[JsonPropertyName("-webkit-user-modify")] public string WebkitUserModify { get; set; }
[JsonPropertyName("-webkit-writing-mode")] public string WebkitWritingMode { get; set; }
[JsonPropertyName("white-space")] public string WhiteSpace { get; set; }
[JsonPropertyName("widows")] public string Widows { get; set; }
[JsonPropertyName("width")] public string Width { get; set; }
[JsonPropertyName("will-change")] public string WillChange { get; set; }
[JsonPropertyName("word-break")] public string WordBreak { get; set; }
[JsonPropertyName("word-spacing")] public string WordSpacing { get; set; }
[JsonPropertyName("writing-mode")] public string WritingMode { get; set; }
[JsonPropertyName("x")] public string X { get; set; }
[JsonPropertyName("y")] public string Y { get; set; }
[JsonPropertyName("z-index")] public string ZIndex { get; set; }
[JsonPropertyName("zoom")] public string Zoom { get; set; }
public override string ToString()
{
StringBuilder cssText = new StringBuilder();
var props = GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var prop in props)
{
string name = prop.Name;
var cats = prop.GetCustomAttributes(typeof(JsonPropertyNameAttribute), false);
if (cats is object && cats[0] is JsonPropertyNameAttribute)
{
name = ((JsonPropertyNameAttribute)cats[0]).Name;
}
string value = (string)prop.GetValue(this);
if (name is object && value is object)
{
cssText.Append($"{name}:{value};");
}
}
return cssText.ToString();
}
}
<div class="line" style=@(styles) />
@code {
[Parameter]
public double X1 { get; set; }
[Parameter]
public double Y1 { get; set; }
[Parameter]
public double X2 { get; set; }
[Parameter]
public double Y2 { get; set; }
[Parameter]
public string LineWidth { get; set; } = "4px";
[Parameter]
public int ZIndex { get; set; }
[Parameter]
public string Colour { get; set; }
[Parameter]
public string TransitionSelector { get; set; } = "all";
[Parameter]
public string TransitionDuration { get; set; } = "16ms";
[Parameter]
public string TransitionTiming { get; set; } = "ease-in-out";
[Parameter]
public string Units { get; set; } = "px";
[Parameter]
public string BorderRadius { get; set; } = "5px";
private CssProperties styleProperties = new CssProperties()
{
Position = "absolute",
BoxShadow = "0px 0px 5px blue",
TransformOrigin = "0 100%",
};
private string styles;
private int length => (int)Math.Ceiling(Math.Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)));
private double angle => Math.Atan2(Y2 - Y1, X2 - X1) * 180 / Math.PI;
private string transform => $"rotate({angle}deg)";
protected override void OnParametersSet()
{
base.OnParametersSet();
styleProperties.BorderTopLeftRadius = BorderRadius;
styleProperties.BorderTopRightRadius = BorderRadius;
styleProperties.BorderBottomLeftRadius = BorderRadius;
styleProperties.BorderBottomRightRadius = BorderRadius;
styleProperties.TransitionProperty = TransitionSelector;
styleProperties.TransitionDuration = TransitionDuration;
styleProperties.TransitionTimingFunction = TransitionTiming;
styleProperties.Height = LineWidth;
styleProperties.BackgroundColor = Colour;
styleProperties.Transform = transform;
styleProperties.Width = $"{length}{Units}";
styleProperties.Left = $"{X1}{Units}";
styleProperties.Top = $"{Y1}{Units}";
styleProperties.ZIndex = ZIndex.ToString();
styles = styleProperties.ToString();
}
}
@scottcate
Copy link

Nice work. Thank You.

@SQL-MisterMagoo
Copy link
Author

Nice work. Thank You.

Thanks very much for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment