public float FontSize(IStyledObject control, float parentHeight) { IDictionary <Type, IStyle> styles = _getStyles(control); long currentDepth = 0; var measure = Measure.Pixels; float size = 0; if (styles.ContainsKey(typeof(Font))) { var font = (Font)styles[typeof(Font)]; currentDepth = font.Depth; measure = font.Measure; size = font.Value; } if (styles.ContainsKey(typeof(FontSize))) { var fontSize = (FontSize)styles[typeof(FontSize)]; if (fontSize.Depth > currentDepth) { measure = fontSize.Measure; size = fontSize.Size; } } float result = ConvertSize(measure, size, parentHeight, ApplicationContext.Current.DisplayProvider.Height); return((int)Math.Round(result)); }
public string FontName(IStyledObject control) { IDictionary <Type, IStyle> styles = _getStyles(control); long currentDepth = 0; string result = null; if (styles.ContainsKey(typeof(Font))) { var font = (Font)styles[typeof(Font)]; currentDepth = font.Depth; result = font.Family; } if (styles.ContainsKey(typeof(FontFamily))) { var fontFamily = (FontFamily)styles[typeof(FontFamily)]; if (fontFamily.Depth > currentDepth) { result = fontFamily.Family; } } return(result); }
float Size <T> (IStyledObject control, float parentSize, float displayMetric) where T : Size { float result = 0; Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(T))) { Size size = (Size)styles [typeof(T)]; if (size.Measure == Measure.Pixels) { result = size.Value / UIScreen.MainScreen.Scale; } else if (size.Measure == Measure.Percent) { result = size.Value * parentSize / 100; } else if (size.Measure == Measure.ScreenPercent) { result = size.Value * displayMetric / 100; } else if (size.Measure == Measure.Millimetre) { float pixelPerMM = JMABarcodeMT.DeviceHardware.Dpi / 25.4f; result = size.Value * pixelPerMM / UIScreen.MainScreen.Scale; } else { result = size.Value; } } return(result); }
public bool Matches(IStyledObject styledObject) { if (TypeName == null) { return(true); } return(typeNames.Contains(styledObject.NodeType)); }
public bool Matches(IStyledObject styledObject) { if (Selector.Matches(styledObject)) { return(Condition.Matches(styledObject)); } return(false); }
public void CollectConditionTargets(IStyledObject node, IWatchRuleFactory watchRuleFactory, ICollection <IWatchRule> affectedNodes) { // node types and composition are not changing. If the composition changed, we rebuild the // whole monitoring from scratch. if (Selector.Matches(node)) { Condition.CollectConditionTargets(node, watchRuleFactory, affectedNodes); } }
static Typeface Font(this IStyleSheet styleSheet, IStyledObject control) { string name = styleSheet.Helper.FontName(control); if (name != null) { return(Typeface.Create(name, TypefaceStyle.Normal)); } return(null); }
public IWatchRule CreatePropertyWatcher(IStyledObject styledObject, string property, object value) { var widget = styledObject as IWidget; if (widget == null) { throw new ArgumentException(); } return(new PropertyWatchRule(widget, property, value)); }
public IWatchRule CreatePseudoClassWatcher(IStyledObject styledObject, string styleClass) { var widget = styledObject as IWidget; if (widget == null) { throw new ArgumentException(); } return(new PseudoClassWatchRule(widget, styleClass)); }
public bool Matches(IStyledObject styledObject) { var propertyValue = styledObject.GetPropertyValue(Property); if (Value == null) { return(propertyValue != null); } return(Equals(propertyValue, Value)); }
public TextAlignValues TextAlign(IStyledObject control, TextAlignValues defaultValue = TextAlignValues.Left) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(TextAlign))) { var align = (TextAlign)styles[typeof(TextAlign)]; return(align.Align); } return(defaultValue); }
public string BackgroundImage(IStyledObject control) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(BackgroundImage))) { var img = (BackgroundImage)styles[typeof(BackgroundImage)]; return(img.Path); } return(null); }
public VerticalAlignValues VerticalAlign(IStyledObject control) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(VerticalAlign))) { var align = (VerticalAlign)styles[typeof(VerticalAlign)]; return(align.Align); } return(VerticalAlignValues.Top); }
public HorizontalAlignValues HorizontalAlign(IStyledObject control) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(HorizontalAlign))) { var align = (HorizontalAlign)styles[typeof(HorizontalAlign)]; return(align.Align); } return(HorizontalAlignValues.Left); }
public TextFormatValues TextFormat(IStyledObject control, TextFormatValues defaulValue = TextFormatValues.Text) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(TextFormat))) { var format = (TextFormat)styles[typeof(TextFormat)]; return(format.Format); } return(defaulValue); }
public WhiteSpaceKind WhiteSpace(IStyledObject control, WhiteSpaceKind defaultValue = WhiteSpaceKind.Nowrap) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(WhiteSpace))) { var ws = (WhiteSpace)styles[typeof(WhiteSpace)]; return(ws.Kind); } return(defaultValue); }
public static Drawable Background(this IStyleSheet styleSheet, IStyledObject control, IBound bound, bool whithoutImage = false) { Drawable background = null; if (!whithoutImage) { string path = styleSheet.Helper.BackgroundImage(control); if (path != null) background = styleSheet.GetCache<ImageCache>().GetImage(path, bound.Width, bound.Height); } return background ?? ColorWithBorders(styleSheet, control, ToColorOrTransparent(styleSheet.Helper.BackgroundColor(control))); }
public TextFormat.Format TextFormat(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(TextFormat))) { TextFormat format = (TextFormat)styles[typeof(TextFormat)]; return(format.Value); } else { return(BitMobile.Controls.StyleSheet.TextFormat.Format.Text); } }
public WhiteSpace.Kind WhiteSpaceKind(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(WhiteSpace))) { WhiteSpace ws = (WhiteSpace)styles[typeof(WhiteSpace)]; return(ws.Value); } else { return(WhiteSpace.Kind.Nowrap); } }
public TextAlign.Align TextAlign(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(TextAlign))) { TextAlign align = (TextAlign)styles[typeof(TextAlign)]; return(align.Value); } else { return(Controls.StyleSheet.TextAlign.Align.Left); } }
private float Size <T>(IStyledObject control, float parentSize, float displayMetric) where T : Size { float result = 0; IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(T))) { var size = (Size)styles[typeof(T)]; result = ConvertSize(size.Measure, size.Amount, parentSize, displayMetric); } return(result); }
public DockAlign.Align DockAlign(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(DockAlign))) { DockAlign align = (DockAlign)styles[typeof(DockAlign)]; return(align.Value); } else { return(Controls.StyleSheet.DockAlign.Align.Top); } }
public VerticalAlign.Align VerticalAlign(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(VerticalAlign))) { VerticalAlign align = (VerticalAlign)styles [typeof(VerticalAlign)]; return(align.Value); } else { return(BitMobile.Controls.StyleSheet.VerticalAlign.Align.Top); } }
bool SizeToContent <T>(IStyledObject control) { bool result = false; Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(T))) { var size = (Size)styles [typeof(T)]; result = size.SizeToContent; } return(result); }
public HorizontalAlign.Align HorizontalAlign(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(HorizontalAlign))) { HorizontalAlign align = (HorizontalAlign)styles [typeof(HorizontalAlign)]; return(align.Value); } else { return(BitMobile.Controls.StyleSheet.HorizontalAlign.Align.Left); } }
public bool HasBorder(IStyledObject control) { Dictionary <Type, Style> styles = _stylesheet.GetStyles(control); if (styles.ContainsKey(typeof(Border))) { Border border = (Border)styles [typeof(Border)]; if (border.Value == "solid") { return(true); } } return(false); }
public bool HasBorder(IStyledObject control) { IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(Border))) { var border = (Border)styles[typeof(Border)]; if (border.Style == BorderStyleValues.Solid) { return(true); } return(false); } return(false); }
public static Drawable Background(this IStyleSheet styleSheet, IStyledObject control, IBound bound, bool whithoutImage = false) { Drawable background = null; if (!whithoutImage) { string path = styleSheet.Helper.BackgroundImage(control); if (path != null) { background = styleSheet.GetCache <ImageCache>().GetImage(path, bound.Width, bound.Height); } } return(background ?? ColorWithBorders(styleSheet, control, ToColorOrTransparent(styleSheet.Helper.BackgroundColor(control)))); }
public void CollectConditionTargets(IStyledObject node, IWatchRuleFactory watchRuleFactory, ICollection <IWatchRule> affectedNodes) { Selector.CollectConditionTargets(node, watchRuleFactory, affectedNodes); var parent = node.GetStyleParent(); while (parent != null) { AnchestorSelector.CollectConditionTargets(parent, watchRuleFactory, affectedNodes); if (DirectChild) { break; } parent = parent.GetStyleParent(); } }
IColorInfo Color <T>(IStyledObject control) where T : Color { IColorInfo result; IDictionary <Type, IStyle> styles = _getStyles(control); if (styles.ContainsKey(typeof(T))) { var color = (Color)styles[typeof(T)]; result = color.Value; } else { result = null; } return(result); }
private void ApplyStyles(String screenName, IStyledObject scr, StyleSheet styleSheet) { String cssFile = null; if (scr is ICustomStyleSheet) { if (!String.IsNullOrEmpty(((ICustomStyleSheet)scr).StyleSheet)) { cssFile = ((ICustomStyleSheet)scr).StyleSheet; } } InitStyles(ref styleSheet, screenName, cssFile); styleSheet.Assign(scr); scr.Apply(styleSheet, new Bound(), new Bound()); }
public static Drawable ColorWithBorders(this IStyleSheet styleSheet, IStyledObject control, Color color) { IStyleSheetHelper helper = styleSheet.Helper; Drawable drawable; if (styleSheet.Helper.HasBorder(control)) { var shape = new GradientDrawable(); var borderWidth = (int)Math.Round(helper.BorderWidth(control)); Color borderColor = ToColorOrTransparent(helper.BorderColor(control)); shape.SetShape(ShapeType.Rectangle); shape.SetColor(color); shape.SetCornerRadius(helper.BorderRadius(control)); shape.SetStroke(borderWidth, borderColor); drawable = shape; } else drawable = new ColorDrawable(color); return drawable; }
static Typeface Font(this IStyleSheet styleSheet, IStyledObject control) { string name = styleSheet.Helper.FontName(control); if (name != null) return Typeface.Create(name, TypefaceStyle.Normal); return null; }
public IStyleHelper CreateHelper(IDictionary<Type, IStyle> styles, IStyleSheet styleSheet, IStyledObject subject) { return new StyleHelper(styles, styleSheet, subject); }