コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public bool Matches(IStyledObject styledObject)
 {
     if (TypeName == null)
     {
         return(true);
     }
     return(typeNames.Contains(styledObject.NodeType));
 }
コード例 #5
0
 public bool Matches(IStyledObject styledObject)
 {
     if (Selector.Matches(styledObject))
     {
         return(Condition.Matches(styledObject));
     }
     return(false);
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
        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);
        }
コード例 #8
0
            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));
            }
コード例 #9
0
            public IWatchRule CreatePseudoClassWatcher(IStyledObject styledObject, string styleClass)
            {
                var widget = styledObject as IWidget;

                if (widget == null)
                {
                    throw new ArgumentException();
                }
                return(new PseudoClassWatchRule(widget, styleClass));
            }
コード例 #10
0
        public bool Matches(IStyledObject styledObject)
        {
            var propertyValue = styledObject.GetPropertyValue(Property);

            if (Value == null)
            {
                return(propertyValue != null);
            }
            return(Equals(propertyValue, Value));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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)));
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        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);
            }
        }
コード例 #20
0
        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);
            }
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
        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);
        }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
        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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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))));
        }
コード例 #29
0
        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();
            }
        }
コード例 #30
0
        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);
        }
コード例 #31
0
ファイル: ScreenFactory.cs プロジェクト: Fedorm/core-master
        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());
        }
コード例 #32
0
        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;
        }
コード例 #33
0
 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;
 }
コード例 #34
0
 public IStyleHelper CreateHelper(IDictionary<Type, IStyle> styles, IStyleSheet styleSheet, IStyledObject subject)
 {
     return new StyleHelper(styles, styleSheet, subject);
 }