Exemplo n.º 1
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            // TODO: Hardcoded to wrap - should align with lineBreakMode
            domObject.SetMemberValue(domObject.Type.GetMember("TextWrapping"), "Wrap");

            var textColor = GetElementWithMatchingAttribute(tag, "key", "textColor");

            if (textColor != null)
            {
                SetColor(domObject, textColor, domObject.Type.GetMember("Foreground"));
            }

            var isEnabled = GetElementWithMatchingAttribute(tag, "key", "enabled");

            if (isEnabled != null)
            {
                if (isEnabled.Value.Equals("no", StringComparison.InvariantCultureIgnoreCase))
                {
                    domObject.SetMemberValue(domObject.Type.GetMember("IsEnabled"), "false");
                }
            }

            // TextBlock doesn't like inlines as content in attribute form
            GetAndSetValue(tag, domObject, "text", domObject.Type.GetMember("Text"));
        }
Exemplo n.º 2
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            var value    = float.Parse(tag.Attribute(XName.Get("value")).Value);
            var minValue = float.Parse(tag.Attribute(XName.Get("minValue")).Value);
            var maxValue = float.Parse(tag.Attribute(XName.Get("maxValue")).Value);

            domObject.SetMemberValue("Value", value.ToString());
            domObject.SetMemberValue("Minimum", minValue.ToString());
            domObject.SetMemberValue("Maximum", maxValue.ToString());
        }
Exemplo n.º 3
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            // TextBlock doesn't like inlines as content in attribute form...
            GetAndSetValue(tag, domObject, "text", domObject.Type.GetMember("Text"));

            var backgroundColor = GetElementWithMatchingAttribute(tag, "key", "textColor");

            if (backgroundColor != null)
            {
                SetColor(domObject, backgroundColor, domObject.Type.GetMember("Foreground"));
            }
        }
Exemplo n.º 4
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            AddChildren(tag, domObject.Type.ContentProperty, domObject);
        }
Exemplo n.º 5
0
 internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
 {
     ViewHandler.SetCommonProperties(tag, domObject);
 }
Exemplo n.º 6
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            // Find the normal state which translates into the default attributes on a XAML button
            var state = GetElementWithMatchingAttribute(tag, "key", "normal");

            if (state != null)
            {
                GetAndSetValue(state, domObject, "title", domObject.Type.ContentProperty);

                var normalColor = GetElementWithMatchingAttribute(state, "key", "titleColor");
                if (normalColor != null)
                {
                    SetColor(domObject, normalColor, domObject.Type.GetMember("Foreground"));
                }
            }

            var normalTitle      = GetValueWithMatchingAttribute(tag, "key", "normalTitle");
            var highlightedTitle = GetValueWithMatchingAttribute(tag, "key", "highlightedTitle");
            var disabledTitle    = GetValueWithMatchingAttribute(tag, "key", "disabledTitle");
            var selectedTitle    = GetValueWithMatchingAttribute(tag, "key", "selectedTitle");

            if (highlightedTitle != normalTitle && !string.IsNullOrEmpty(highlightedTitle))
            {
                throw new NotImplementedException();
            }
            if (disabledTitle != normalTitle && !string.IsNullOrEmpty(disabledTitle))
            {
                throw new NotImplementedException();
            }
            if (selectedTitle != normalTitle && !string.IsNullOrEmpty(selectedTitle))
            {
                throw new NotImplementedException();
            }

            string normalImagePath      = null;
            string selectedImagePath    = null;
            string disabledImagePath    = null;
            string highlightedImagePath = null;

            // Check for images
            var normalImage = GetElementWithMatchingAttribute(tag, "key", "normalImage");

            if (normalImage != null)
            {
                Debug.Assert("NSImage" == GetElementWithMatchingAttribute(normalImage, "key", "NSClassName").Value);
                normalImagePath = GetElementWithMatchingAttribute(normalImage, "key", "NSResourceName").Value;
            }

            var selectedImage = GetElementWithMatchingAttribute(tag, "key", "selectedImage");

            if (selectedImage != null)
            {
                Debug.Assert("NSImage" == GetElementWithMatchingAttribute(normalImage, "key", "NSClassName").Value);
                selectedImagePath = GetElementWithMatchingAttribute(normalImage, "key", "NSResourceName").Value;
            }

            var disabledImage = GetElementWithMatchingAttribute(tag, "key", "selectedImage");

            if (disabledImage != null)
            {
                Debug.Assert("NSImage" == GetElementWithMatchingAttribute(normalImage, "key", "NSClassName").Value);
                disabledImagePath = GetElementWithMatchingAttribute(normalImage, "key", "NSResourceName").Value;
            }

            var highlightedImage = GetElementWithMatchingAttribute(tag, "key", "selectedImage");

            if (highlightedImage != null)
            {
                Debug.Assert("NSImage" == GetElementWithMatchingAttribute(normalImage, "key", "NSClassName").Value);
                highlightedImagePath = GetElementWithMatchingAttribute(normalImage, "key", "NSResourceName").Value;
            }

            if (highlightedImagePath != normalImagePath)
            {
                throw new NotImplementedException();
            }

            if (disabledImagePath != normalImagePath)
            {
                throw new NotImplementedException();
            }

            if (selectedImagePath != normalImagePath)
            {
                throw new NotImplementedException();
            }

            Debug.Assert(string.IsNullOrEmpty(normalImagePath) || string.IsNullOrEmpty(normalTitle));

            if (normalImagePath != null)
            {
                var controlTemplateObject =
                    new XamlDomObject(domObject.SchemaContext.GetXamlType(typeof(ControlTemplate)),
                                      new XamlDomMember("TargetType", "Button"),
                                      new XamlDomMember(domObject.SchemaContext.GetXamlType(typeof(ControlTemplate)).ContentProperty,
                                                        new XamlDomObject(typeof(Image),
                                                                          new XamlDomMember("Source", normalImagePath)
                                                                          )
                                                        )
                                      );

                var sourceMember = new XamlDomMember(domObject.Type.GetMember("Template"));
                sourceMember.Items.Add(controlTemplateObject);

                domObject.MemberNodes.Add(sourceMember);
            }
        }
Exemplo n.º 7
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            GetAndSetValue(tag, domObject, "title", domObject.Type.ContentProperty);
        }