Ooui-tws-port/Ooui/Style.cs

301 lines
8.3 KiB
C#
Raw Normal View History

2017-06-18 19:52:51 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Value = System.Object;
namespace Ooui
{
public class Style : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
readonly Dictionary<string, Value> properties =
new Dictionary<string, Value> ();
public Value BackgroundColor {
2017-06-18 20:30:22 +00:00
get => this["background-color"];
set => this["background-color"] = value;
2017-06-18 19:52:51 +00:00
}
2017-06-18 20:00:07 +00:00
public Value BackgroundImage {
2017-06-18 20:30:22 +00:00
get => this["background-image"];
set => this["background-image"] = value;
2017-06-18 20:00:07 +00:00
}
2017-06-18 20:23:51 +00:00
public Value BorderTopColor {
2017-06-18 20:30:22 +00:00
get => this["border-top-color"];
set => this["border-top-color"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderRightColor {
2017-06-18 20:30:22 +00:00
get => this["border-right-color"];
set => this["border-right-color"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderBottomColor {
2017-06-18 20:30:22 +00:00
get => this["border-bottom-color"];
set => this["border-bottom-color"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderLeftColor {
2017-06-18 20:30:22 +00:00
get => this["border-left-color"];
set => this["border-left-color"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderColor {
2017-06-18 20:30:22 +00:00
get => this["border-top-color"];
2017-06-18 20:23:51 +00:00
set {
2017-06-18 20:30:22 +00:00
this["border-top-color"] = value;
this["border-right-color"] = value;
this["border-bottom-color"] = value;
this["border-left-color"] = value;
2017-06-18 20:23:51 +00:00
}
}
public Value BorderTopStyle {
2017-06-18 20:30:22 +00:00
get => this["border-top-style"];
set => this["border-top-style"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderRightStyle {
2017-06-18 20:30:22 +00:00
get => this["border-right-style"];
set => this["border-right-style"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderBottomStyle {
2017-06-18 20:30:22 +00:00
get => this["border-bottom-style"];
set => this["border-bottom-style"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderLeftStyle {
2017-06-18 20:30:22 +00:00
get => this["border-left-style"];
set => this["border-left-style"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderStyle {
2017-06-18 20:30:22 +00:00
get => this["border-top-style"];
2017-06-18 20:23:51 +00:00
set {
2017-06-18 20:30:22 +00:00
this["border-top-style"] = value;
this["border-right-style"] = value;
this["border-bottom-style"] = value;
this["border-left-style"] = value;
2017-06-18 20:23:51 +00:00
}
}
public Value BorderTopWidth {
2017-06-18 20:30:22 +00:00
get => this["border-top-width"];
set => this["border-top-width"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderRightWidth {
2017-06-18 20:30:22 +00:00
get => this["border-right-width"];
set => this["border-right-width"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderBottomWidth {
2017-06-18 20:30:22 +00:00
get => this["border-bottom-width"];
set => this["border-bottom-width"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderLeftWidth {
2017-06-18 20:30:22 +00:00
get => this["border-left-width"];
set => this["border-left-width"] = value;
2017-06-18 20:23:51 +00:00
}
public Value BorderWidth {
2017-06-18 20:30:22 +00:00
get => this["border-top-width"];
2017-06-18 20:23:51 +00:00
set {
2017-06-18 20:30:22 +00:00
this["border-top-width"] = value;
this["border-right-width"] = value;
this["border-bottom-width"] = value;
this["border-left-width"] = value;
2017-06-18 20:23:51 +00:00
}
}
public Value Bottom {
2017-06-18 20:30:22 +00:00
get => this["bottom"];
set => this["bottom"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Clear {
2017-06-18 20:30:22 +00:00
get => this["clear"];
set => this["clear"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Color {
2017-06-18 20:30:22 +00:00
get => this["color"];
set => this["color"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Cursor {
2017-06-18 20:30:22 +00:00
get => this["cursor"];
set => this["cursor"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Float {
2017-06-18 20:30:22 +00:00
get => this["float"];
set => this["float"] = value;
2017-06-18 20:23:51 +00:00
}
public Value FontFamily {
2017-06-18 20:30:22 +00:00
get => this["font-family"];
set => this["font-family"] = value;
2017-06-18 20:23:51 +00:00
}
public Value FontSize {
2017-06-18 20:30:22 +00:00
get => this["font-size"];
set => this["font-size"] = value;
2017-06-18 20:23:51 +00:00
}
public Value FontStyle {
2017-06-18 20:30:22 +00:00
get => this["font-style"];
set => this["font-style"] = value;
2017-06-18 20:23:51 +00:00
}
public Value FontVariant {
2017-06-18 20:30:22 +00:00
get => this["font-variant"];
set => this["font-variant"] = value;
2017-06-18 20:23:51 +00:00
}
public Value FontWeight {
2017-06-18 20:30:22 +00:00
get => this["font-weight"];
set => this["font-weight"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Height {
2017-06-18 20:30:22 +00:00
get => this["height"];
set => this["height"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Left {
2017-06-18 20:30:22 +00:00
get => this["left"];
set => this["left"] = value;
2017-06-18 20:23:51 +00:00
}
public Value LineHeight {
2017-06-18 20:30:22 +00:00
get => this["line-height"];
set => this["line-height"] = value;
2017-06-18 20:23:51 +00:00
}
public Value MarginTop {
2017-06-18 20:30:22 +00:00
get => this["margin-top"];
set => this["margin-top"] = value;
2017-06-18 20:23:51 +00:00
}
public Value MarginRight {
2017-06-18 20:30:22 +00:00
get => this["margin-right"];
set => this["margin-right"] = value;
2017-06-18 20:23:51 +00:00
}
public Value MarginBottom {
2017-06-18 20:30:22 +00:00
get => this["margin-bottom"];
set => this["margin-bottom"] = value;
2017-06-18 20:23:51 +00:00
}
public Value MarginLeft {
2017-06-18 20:30:22 +00:00
get => this["margin-left"];
set => this["margin-left"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Margin {
2017-06-18 20:30:22 +00:00
get => this["margin-top"];
2017-06-18 20:23:51 +00:00
set {
2017-06-18 20:30:22 +00:00
this["margin-top"] = value;
this["margin-right"] = value;
this["margin-bottom"] = value;
this["margin-left"] = value;
2017-06-18 20:23:51 +00:00
}
}
public Value PaddingTop {
2017-06-18 20:30:22 +00:00
get => this["padding-top"];
set => this["padding-top"] = value;
2017-06-18 20:23:51 +00:00
}
public Value PaddingRight {
2017-06-18 20:30:22 +00:00
get => this["padding-right"];
set => this["padding-right"] = value;
2017-06-18 20:23:51 +00:00
}
public Value PaddingBottom {
2017-06-18 20:30:22 +00:00
get => this["padding-bottom"];
set => this["padding-bottom"] = value;
2017-06-18 20:23:51 +00:00
}
public Value PaddingLeft {
2017-06-18 20:30:22 +00:00
get => this["padding-left"];
set => this["padding-left"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Padding {
2017-06-18 20:30:22 +00:00
get => this["padding-top"];
2017-06-18 20:23:51 +00:00
set {
2017-06-18 20:30:22 +00:00
this["padding-top"] = value;
this["padding-right"] = value;
this["padding-bottom"] = value;
this["padding-left"] = value;
2017-06-18 20:23:51 +00:00
}
}
public Value Right {
2017-06-18 20:30:22 +00:00
get => this["right"];
set => this["right"] = value;
}
public Value TextAlign {
get => this["text-align"];
set => this["text-align"] = value;
2017-06-18 20:23:51 +00:00
}
2017-06-18 21:00:06 +00:00
public Value TextDecoration {
get => this["text-decoration"];
set => this["text-decoration"] = value;
}
2017-06-18 20:23:51 +00:00
public Value Top {
2017-06-18 20:30:22 +00:00
get => this["top"];
set => this["top"] = value;
}
public Value VerticalAlign {
get => this["vertical-align"];
set => this["vertical-align"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Visibility {
2017-06-18 20:30:22 +00:00
get => this["visibility"];
set => this["visibility"] = value;
2017-06-18 20:23:51 +00:00
}
public Value Width {
2017-06-18 20:30:22 +00:00
get => this["width"];
set => this["width"] = value;
2017-06-18 20:23:51 +00:00
}
2017-06-18 20:30:22 +00:00
public Value this [string propertyName]
2017-06-18 19:52:51 +00:00
{
2017-06-18 20:30:22 +00:00
get {
lock (properties) {
Value p;
if (!properties.TryGetValue (propertyName, out p)) {
p = "inherit";
}
return p;
2017-06-18 19:52:51 +00:00
}
}
2017-06-18 20:30:22 +00:00
set {
var safeValue = value ?? "inherit";
lock (properties) {
Value old;
if (properties.TryGetValue (propertyName, out old)) {
if (EqualityComparer<Value>.Default.Equals (old, safeValue))
return;
}
properties[propertyName] = safeValue;
2017-06-18 19:52:51 +00:00
}
2017-06-18 20:30:22 +00:00
PropertyChanged?.Invoke (this, new PropertyChangedEventArgs (propertyName));
2017-06-18 19:52:51 +00:00
}
}
}
}