Пример #1
0
        protected static void GetDimensions(XElement element, XamlDomObject domObject)
        {
            // Look for dimensions and location
            var frame = GetElementWithMatchingAttribute(element, "key", "frame");

            if (frame != null)
            {
                var xAttr      = frame.Attribute(XName.Get("x"));
                var yAttr      = frame.Attribute(XName.Get("y"));
                var widthAttr  = frame.Attribute(XName.Get("width"));
                var heightAttr = frame.Attribute(XName.Get("height"));

                // Certain controls have a 12 pixel border around them.  Make them look normal
                if (domObject.Type.CanAssignTo(domObject.SchemaContext.GetXamlType(typeof(TextBox))) ||
                    domObject.Type.CanAssignTo(domObject.SchemaContext.GetXamlType(typeof(Button)))
                    )
                {
                    var left   = int.Parse(xAttr.Value) - 12;      // XamlXibReader.WIDTHMULTIPLIER);
                    var top    = int.Parse(yAttr.Value) - 12;      // * XamlXibReader.HEIGHTMULTIPLIER);
                    var width  = int.Parse(widthAttr.Value) + 24;  // * XamlXibReader.WIDTHMULTIPLIER);
                    var height = int.Parse(heightAttr.Value) + 24; // * XamlXibReader.HEIGHTMULTIPLIER);

                    domObject.SetAttachableMemberValue(typeof(Canvas), "Left", left.ToString());
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Top", top.ToString());

                    domObject.SetMemberValue("Width", width.ToString());
                    domObject.SetMemberValue("Height", height.ToString());

                    domObject.SetMemberValue("MinWidth", "0");
                    domObject.SetMemberValue("MinHeight", "0");
                }
                else
                {
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Left", xAttr.Value);
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Top", yAttr.Value);
                    domObject.SetMemberValue("Width", widthAttr.Value);
                    domObject.SetMemberValue("Height", heightAttr.Value);
                }
            }
            else
            {
                SetFrameSize(element, domObject);
            }
        }
Пример #2
0
        protected static void GetDimensions(XElement element, XamlDomObject domObject)
        {
            var frame = GetElementWithMatchingAttribute(element, "key", "NSFrame");

            // Look for dimensions and location
            if (frame != null)
            {
                var dimensions = frame.Value;
                var matches    = Regex.Matches(dimensions, @"\d+");
                // Certain controls have a 12 pixel border around them.  Make them look normal
                if (domObject.Type.CanAssignTo(domObject.SchemaContext.GetXamlType(typeof(TextBox))) ||
                    domObject.Type.CanAssignTo(domObject.SchemaContext.GetXamlType(typeof(Button)))
                    )
                {
                    var left   = int.Parse(matches[0].Value) - 12; // XamlLegacyXibReader.WIDTHMULTIPLIER);
                    var top    = int.Parse(matches[1].Value) - 12; // * XamlLegacyXibReader.HEIGHTMULTIPLIER);
                    var width  = int.Parse(matches[2].Value) + 24; // * XamlLegacyXibReader.WIDTHMULTIPLIER);
                    var height = int.Parse(matches[3].Value) + 24; // * XamlLegacyXibReader.HEIGHTMULTIPLIER);

                    domObject.SetAttachableMemberValue(typeof(Canvas), "Left", left.ToString());
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Top", top.ToString());
                    domObject.SetMemberValue("Width", width.ToString());
                    domObject.SetMemberValue("Height", height.ToString());

                    domObject.SetMemberValue("MinWidth", "0");
                    domObject.SetMemberValue("MinHeight", "0");
                }
                else
                {
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Left", matches[0].Value);
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Top", matches[1].Value);
                    domObject.SetMemberValue("Width", matches[2].Value);
                    domObject.SetMemberValue("Height", matches[3].Value);
                }
            }
            else
            {
                SetFrameSize(element, domObject);
            }
        }
Пример #3
0
        protected static void GetDimensions(XElement element, XamlDomObject domObject)
        {
            // Look for dimensions and location
            var frame = GetElementWithMatchingAttribute(element, "key", "frame");

            if (frame != null)
            {
                var xAttr      = frame.Attribute(XName.Get("x"));
                var yAttr      = frame.Attribute(XName.Get("y"));
                var widthAttr  = frame.Attribute(XName.Get("width"));
                var heightAttr = frame.Attribute(XName.Get("height"));

                domObject.SetAttachableMemberValue(typeof(Canvas), "Left", xAttr.Value);
                domObject.SetAttachableMemberValue(typeof(Canvas), "Top", yAttr.Value);
                domObject.SetMemberValue("Width", widthAttr.Value);
                domObject.SetMemberValue("Height", heightAttr.Value);
            }
            else
            {
                SetFrameSize(element, domObject);
            }
        }
Пример #4
0
        protected static void GetDimensions(XElement element, XamlDomObject domObject)
        {
            var frame = GetElementWithMatchingAttribute(element, "key", "NSFrame");

            // Look for dimensions and location
            if (frame != null)
            {
                var dimensions = frame.Value;
                var matches = Regex.Matches(dimensions, @"\d+");
                // Certain controls have a 12 pixel border around them.  Make them look normal
                if (domObject.Type.CanAssignTo(domObject.SchemaContext.GetXamlType(typeof(TextBox))) ||
                    domObject.Type.CanAssignTo(domObject.SchemaContext.GetXamlType(typeof(Button)))
                    )
                {
                    var left = int.Parse(matches[0].Value) - 12; // XamlLegacyXibReader.WIDTHMULTIPLIER);
                    var top = int.Parse(matches[1].Value) - 12; // * XamlLegacyXibReader.HEIGHTMULTIPLIER);
                    var width = int.Parse(matches[2].Value) + 24; // * XamlLegacyXibReader.WIDTHMULTIPLIER);
                    var height = int.Parse(matches[3].Value) + 24; // * XamlLegacyXibReader.HEIGHTMULTIPLIER);

                    domObject.SetAttachableMemberValue(typeof(Canvas), "Left", left.ToString());
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Top", top.ToString());
                    domObject.SetMemberValue("Width", width.ToString());
                    domObject.SetMemberValue("Height", height.ToString());

                    domObject.SetMemberValue("MinWidth", "0");
                    domObject.SetMemberValue("MinHeight", "0");
                }
                else
                {
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Left", matches[0].Value);
                    domObject.SetAttachableMemberValue(typeof(Canvas), "Top", matches[1].Value);
                    domObject.SetMemberValue("Width", matches[2].Value);
                    domObject.SetMemberValue("Height", matches[3].Value);
                }
            }
            else
            {
                SetFrameSize(element, domObject);
            }
        }
Пример #5
0
        protected static void GetDimensions(XElement element, XamlDomObject domObject)
        {
            // Look for dimensions and location
            var frame = GetElementWithMatchingAttribute(element, "key", "frame");
            if (frame != null)
            {
                var xAttr = frame.Attribute(XName.Get("x"));
                var yAttr = frame.Attribute(XName.Get("y"));
                var widthAttr = frame.Attribute(XName.Get("width"));
                var heightAttr = frame.Attribute(XName.Get("height"));

                domObject.SetAttachableMemberValue(typeof(Canvas), "Left", xAttr.Value);
                domObject.SetAttachableMemberValue(typeof(Canvas), "Top", yAttr.Value);
                domObject.SetMemberValue("Width", widthAttr.Value);
                domObject.SetMemberValue("Height", heightAttr.Value);
            }
            else
            {
                SetFrameSize(element, domObject);
            }
        }