예제 #1
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

            AddChildren(tag, domObject.Type.ContentProperty, domObject);
        }
예제 #2
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);
            }
        }
예제 #3
0
 internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
 {
     ViewHandler.SetCommonProperties(tag, domObject);
 }
예제 #4
0
        internal new static void SetCommonProperties(XElement tag, XamlDomObject domObject)
        {
            ViewHandler.SetCommonProperties(tag, domObject);

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