Switch to property accessor for styles

This commit is contained in:
Frank A. Krueger 2017-06-18 13:30:22 -07:00
parent 6c4711dc2c
commit 81d770967f
1 changed files with 131 additions and 121 deletions

View File

@ -13,252 +13,263 @@ namespace Ooui
new Dictionary<string, Value> (); new Dictionary<string, Value> ();
public Value BackgroundColor { public Value BackgroundColor {
get => GetProperty ("background-color"); get => this["background-color"];
set => SetProperty ("background-color", value); set => this["background-color"] = value;
} }
public Value BackgroundImage { public Value BackgroundImage {
get => GetProperty ("background-image"); get => this["background-image"];
set => SetProperty ("background-image", value); set => this["background-image"] = value;
} }
public Value BorderTopColor { public Value BorderTopColor {
get => GetProperty ("border-top-color"); get => this["border-top-color"];
set => SetProperty ("border-top-color", value); set => this["border-top-color"] = value;
} }
public Value BorderRightColor { public Value BorderRightColor {
get => GetProperty ("border-right-color"); get => this["border-right-color"];
set => SetProperty ("border-right-color", value); set => this["border-right-color"] = value;
} }
public Value BorderBottomColor { public Value BorderBottomColor {
get => GetProperty ("border-bottom-color"); get => this["border-bottom-color"];
set => SetProperty ("border-bottom-color", value); set => this["border-bottom-color"] = value;
} }
public Value BorderLeftColor { public Value BorderLeftColor {
get => GetProperty ("border-left-color"); get => this["border-left-color"];
set => SetProperty ("border-left-color", value); set => this["border-left-color"] = value;
} }
public Value BorderColor { public Value BorderColor {
get => GetProperty ("border-top-color"); get => this["border-top-color"];
set { set {
SetProperty ("border-top-color", value); this["border-top-color"] = value;
SetProperty ("border-right-color", value); this["border-right-color"] = value;
SetProperty ("border-bottom-color", value); this["border-bottom-color"] = value;
SetProperty ("border-left-color", value); this["border-left-color"] = value;
} }
} }
public Value BorderTopStyle { public Value BorderTopStyle {
get => GetProperty ("border-top-style"); get => this["border-top-style"];
set => SetProperty ("border-top-style", value); set => this["border-top-style"] = value;
} }
public Value BorderRightStyle { public Value BorderRightStyle {
get => GetProperty ("border-right-style"); get => this["border-right-style"];
set => SetProperty ("border-right-style", value); set => this["border-right-style"] = value;
} }
public Value BorderBottomStyle { public Value BorderBottomStyle {
get => GetProperty ("border-bottom-style"); get => this["border-bottom-style"];
set => SetProperty ("border-bottom-style", value); set => this["border-bottom-style"] = value;
} }
public Value BorderLeftStyle { public Value BorderLeftStyle {
get => GetProperty ("border-left-style"); get => this["border-left-style"];
set => SetProperty ("border-left-style", value); set => this["border-left-style"] = value;
} }
public Value BorderStyle { public Value BorderStyle {
get => GetProperty ("border-top-style"); get => this["border-top-style"];
set { set {
SetProperty ("border-top-style", value); this["border-top-style"] = value;
SetProperty ("border-right-style", value); this["border-right-style"] = value;
SetProperty ("border-bottom-style", value); this["border-bottom-style"] = value;
SetProperty ("border-left-style", value); this["border-left-style"] = value;
} }
} }
public Value BorderTopWidth { public Value BorderTopWidth {
get => GetProperty ("border-top-width"); get => this["border-top-width"];
set => SetProperty ("border-top-width", value); set => this["border-top-width"] = value;
} }
public Value BorderRightWidth { public Value BorderRightWidth {
get => GetProperty ("border-right-width"); get => this["border-right-width"];
set => SetProperty ("border-right-width", value); set => this["border-right-width"] = value;
} }
public Value BorderBottomWidth { public Value BorderBottomWidth {
get => GetProperty ("border-bottom-width"); get => this["border-bottom-width"];
set => SetProperty ("border-bottom-width", value); set => this["border-bottom-width"] = value;
} }
public Value BorderLeftWidth { public Value BorderLeftWidth {
get => GetProperty ("border-left-width"); get => this["border-left-width"];
set => SetProperty ("border-left-width", value); set => this["border-left-width"] = value;
} }
public Value BorderWidth { public Value BorderWidth {
get => GetProperty ("border-top-width"); get => this["border-top-width"];
set { set {
SetProperty ("border-top-width", value); this["border-top-width"] = value;
SetProperty ("border-right-width", value); this["border-right-width"] = value;
SetProperty ("border-bottom-width", value); this["border-bottom-width"] = value;
SetProperty ("border-left-width", value); this["border-left-width"] = value;
} }
} }
public Value Bottom { public Value Bottom {
get => GetProperty ("bottom"); get => this["bottom"];
set => SetProperty ("bottom", value); set => this["bottom"] = value;
} }
public Value Clear { public Value Clear {
get => GetProperty ("clear"); get => this["clear"];
set => SetProperty ("clear", value); set => this["clear"] = value;
} }
public Value Color { public Value Color {
get => GetProperty ("color"); get => this["color"];
set => SetProperty ("color", value); set => this["color"] = value;
} }
public Value Cursor { public Value Cursor {
get => GetProperty ("cursor"); get => this["cursor"];
set => SetProperty ("cursor", value); set => this["cursor"] = value;
} }
public Value Float { public Value Float {
get => GetProperty ("float"); get => this["float"];
set => SetProperty ("float", value); set => this["float"] = value;
} }
public Value FontFamily { public Value FontFamily {
get => GetProperty ("font-family"); get => this["font-family"];
set => SetProperty ("font-family", value); set => this["font-family"] = value;
} }
public Value FontSize { public Value FontSize {
get => GetProperty ("font-size"); get => this["font-size"];
set => SetProperty ("font-size", value); set => this["font-size"] = value;
} }
public Value FontStyle { public Value FontStyle {
get => GetProperty ("font-style"); get => this["font-style"];
set => SetProperty ("font-style", value); set => this["font-style"] = value;
} }
public Value FontVariant { public Value FontVariant {
get => GetProperty ("font-variant"); get => this["font-variant"];
set => SetProperty ("font-variant", value); set => this["font-variant"] = value;
} }
public Value FontWeight { public Value FontWeight {
get => GetProperty ("font-weight"); get => this["font-weight"];
set => SetProperty ("font-weight", value); set => this["font-weight"] = value;
} }
public Value Height { public Value Height {
get => GetProperty ("height"); get => this["height"];
set => SetProperty ("height", value); set => this["height"] = value;
} }
public Value Left { public Value Left {
get => GetProperty ("left"); get => this["left"];
set => SetProperty ("left", value); set => this["left"] = value;
} }
public Value LineHeight { public Value LineHeight {
get => GetProperty ("line-height"); get => this["line-height"];
set => SetProperty ("line-height", value); set => this["line-height"] = value;
} }
public Value MarginTop { public Value MarginTop {
get => GetProperty ("margin-top"); get => this["margin-top"];
set => SetProperty ("margin-top", value); set => this["margin-top"] = value;
} }
public Value MarginRight { public Value MarginRight {
get => GetProperty ("margin-right"); get => this["margin-right"];
set => SetProperty ("margin-right", value); set => this["margin-right"] = value;
} }
public Value MarginBottom { public Value MarginBottom {
get => GetProperty ("margin-bottom"); get => this["margin-bottom"];
set => SetProperty ("margin-bottom", value); set => this["margin-bottom"] = value;
} }
public Value MarginLeft { public Value MarginLeft {
get => GetProperty ("margin-left"); get => this["margin-left"];
set => SetProperty ("margin-left", value); set => this["margin-left"] = value;
} }
public Value Margin { public Value Margin {
get => GetProperty ("margin-top"); get => this["margin-top"];
set { set {
SetProperty ("margin-top", value); this["margin-top"] = value;
SetProperty ("margin-right", value); this["margin-right"] = value;
SetProperty ("margin-bottom", value); this["margin-bottom"] = value;
SetProperty ("margin-left", value); this["margin-left"] = value;
} }
} }
public Value PaddingTop { public Value PaddingTop {
get => GetProperty ("padding-top"); get => this["padding-top"];
set => SetProperty ("padding-top", value); set => this["padding-top"] = value;
} }
public Value PaddingRight { public Value PaddingRight {
get => GetProperty ("padding-right"); get => this["padding-right"];
set => SetProperty ("padding-right", value); set => this["padding-right"] = value;
} }
public Value PaddingBottom { public Value PaddingBottom {
get => GetProperty ("padding-bottom"); get => this["padding-bottom"];
set => SetProperty ("padding-bottom", value); set => this["padding-bottom"] = value;
} }
public Value PaddingLeft { public Value PaddingLeft {
get => GetProperty ("padding-left"); get => this["padding-left"];
set => SetProperty ("padding-left", value); set => this["padding-left"] = value;
} }
public Value Padding { public Value Padding {
get => GetProperty ("padding-top"); get => this["padding-top"];
set { set {
SetProperty ("padding-top", value); this["padding-top"] = value;
SetProperty ("padding-right", value); this["padding-right"] = value;
SetProperty ("padding-bottom", value); this["padding-bottom"] = value;
SetProperty ("padding-left", value); this["padding-left"] = value;
} }
} }
public Value Right { public Value Right {
get => GetProperty ("right"); get => this["right"];
set => SetProperty ("right", value); set => this["right"] = value;
}
public Value TextAlign {
get => this["text-align"];
set => this["text-align"] = value;
} }
public Value Top { public Value Top {
get => GetProperty ("top"); get => this["top"];
set => SetProperty ("top", value); set => this["top"] = value;
}
public Value VerticalAlign {
get => this["vertical-align"];
set => this["vertical-align"] = value;
} }
public Value Visibility { public Value Visibility {
get => GetProperty ("visibility"); get => this["visibility"];
set => SetProperty ("visibility", value); set => this["visibility"] = value;
} }
public Value Width { public Value Width {
get => GetProperty ("width"); get => this["width"];
set => SetProperty ("width", value); set => this["width"] = value;
} }
public Value GetProperty (string propertyName) public Value this [string propertyName]
{ {
get {
lock (properties) { lock (properties) {
Value p; Value p;
if (!properties.TryGetValue (propertyName, out p)) { if (!properties.TryGetValue (propertyName, out p)) {
@ -267,9 +278,7 @@ namespace Ooui
return p; return p;
} }
} }
set {
public void SetProperty (string propertyName, Value value)
{
var safeValue = value ?? "inherit"; var safeValue = value ?? "inherit";
lock (properties) { lock (properties) {
Value old; Value old;
@ -282,4 +291,5 @@ namespace Ooui
PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (propertyName)); PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (propertyName));
} }
} }
}
} }