Esempio n. 1
0
        /////////////////////////////////////////

        protected override void OnRenderScroll(UIScroll control, CanvasRenderer renderer)
        {
            base.OnRenderScroll(control, renderer);
        }
Esempio n. 2
0
        public UIData(Transform root, Transform tr)
        {
            Vector2 piv = new Vector2(0.5f, 0.5f);

            if (tr is RectTransform)
            {
                piv = (tr as RectTransform).pivot;
            }
            Vector2 pos = root.InverseTransformPoint(tr.position);

            name          = tr.name;
            pivot         = new Float2(piv.x, piv.y);
            scale         = new Float2(tr.localScale.x, tr.localScale.y);
            position      = new Int2(pos.x, pos.y);
            localPosition = new Int2(tr.localPosition.x * 1, tr.localPosition.y * 1);
            go            = tr.gameObject;

            Component comp = tr.GetComponent <SpriteRenderer>();

            if (comp != null)
            {
                SpriteRenderer c = comp as SpriteRenderer;
                if (c.sprite != null)
                {
                    component = new UIComponentSprite(c.sprite.name, Utill.Utill.ColorToHex(c.color), c.color.a
                                                      , comp.GetComponent <UIInteractive>() != null ? true : false);
                }
                else
                {
                    component = new UIComponentSprite("null", Utill.Utill.ColorToHex(c.color), c.color.a
                                                      , comp.GetComponent <UIInteractive>() != null ? true : false);
                    (component as UIComponentSprite).width  = (tr as RectTransform).sizeDelta.x;
                    (component as UIComponentSprite).height = (tr as RectTransform).sizeDelta.y;
                }
            }

            comp = tr.GetComponent <Image>();
            if (comp != null)
            {
                Image  image  = comp as Image;
                Button button = tr.GetComponent <Button>();

                if (button != null)
                {
                    string    normal     = "";
                    string    over       = "";
                    string    push       = "";
                    string    disabled   = "";
                    int       transition = 0;
                    bool      isBorder   = false;
                    IntBorder border     = new IntBorder();
                    int       width      = 0;
                    int       height     = 0;

                    if (image.type == Image.Type.Sliced)
                    {
                        isBorder = true;
                        float   rate = image.sprite.pixelsPerUnit / 100f;
                        Vector4 bor  = image.sprite.border;
                        bor   /= rate;
                        border = new IntBorder(bor);
                        width  = (int)image.rectTransform.sizeDelta.x;
                        height = (int)image.rectTransform.sizeDelta.y;
                    }


                    if (button.transition == Selectable.Transition.SpriteSwap)
                    {
                        transition = 2;
                        normal     = image.sprite.name;
                        over       = button.spriteState.highlightedSprite != null ? button.spriteState.highlightedSprite.name : normal;
                        push       = button.spriteState.pressedSprite != null ? button.spriteState.pressedSprite.name : normal;
                        disabled   = button.spriteState.disabledSprite != null ? button.spriteState.disabledSprite.name : "";
                        component  = new UIComponentButton(transition, normal, over, push, disabled);

                        if (isBorder)
                        {
                            UIComponentButton componentButton = component as UIComponentButton;
                            componentButton.isBorder = isBorder;
                            componentButton.border   = border;
                            componentButton.width    = width;
                            componentButton.height   = height;
                        }
                    }
                    else if (button.transition == Selectable.Transition.ColorTint)
                    {
                        transition = 1;
                        normal     = "0x" + Utill.Utill.ColorToHex(button.colors.normalColor);
                        over       = "0x" + Utill.Utill.ColorToHex(button.colors.highlightedColor);
                        push       = "0x" + Utill.Utill.ColorToHex(button.colors.pressedColor);
                        disabled   = "0x" + Utill.Utill.ColorToHex(button.colors.disabledColor);
                        component  = new UIComponentButton(transition, normal, over, push, disabled);
                        UIComponentButton componentButton = component as UIComponentButton;
                        componentButton.spriteName = image.sprite.name;

                        if (isBorder)
                        {
                            componentButton.isBorder = isBorder;
                            componentButton.border   = border;
                            componentButton.width    = width;
                            componentButton.height   = height;
                        }
                    }
                }
                else if (image.sprite != null && image.type == Image.Type.Sliced)
                {
                    float   rate = image.sprite.pixelsPerUnit / 100f;
                    Vector4 bor  = image.sprite.border;
                    bor /= rate;

                    component = new UIComponentSpriteBorder(image.sprite.name
                                                            , new IntBorder(bor)
                                                            , image.rectTransform.sizeDelta.x
                                                            , image.rectTransform.sizeDelta.y
                                                            , Utill.Utill.ColorToHex(image.color)
                                                            , image.color.a
                                                            , comp.GetComponent <UIInteractive>() != null ? true : false
                                                            );
                }
                else if (image.sprite != null && image.type == Image.Type.Tiled)
                {
                    float rate = image.sprite.pixelsPerUnit / 100f;

                    component = new UIComponentSpriteTiled(image.sprite.name
                                                           , image.rectTransform.sizeDelta.x
                                                           , image.rectTransform.sizeDelta.y
                                                           , Utill.Utill.ColorToHex(image.color)
                                                           , image.color.a
                                                           , comp.GetComponent <UIInteractive>() != null ? true : false
                                                           );
                }
                else
                {
                    //component = new UIComponentSprite(image.sprite.name, Utill.Utill.ColorToHex(image.color), image.color.a
                    //    , comp.GetComponent<UIInteractive>() != null ? true : false);

                    if (image.sprite != null)
                    {
                        component = new UIComponentSprite(image.sprite.name, Utill.Utill.ColorToHex(image.color), image.color.a
                                                          , comp.GetComponent <UIInteractive>() != null ? true : false);
                    }
                    else
                    {
                        component = new UIComponentSprite("null", Utill.Utill.ColorToHex(image.color), image.color.a
                                                          , comp.GetComponent <UIInteractive>() != null ? true : false);
                        (component as UIComponentSprite).width  = (tr as RectTransform).sizeDelta.x;
                        (component as UIComponentSprite).height = (tr as RectTransform).sizeDelta.y;
                    }
                }
            }

            comp = tr.GetComponent <Text>();
            if (comp != null)
            {
                Text text  = comp as Text;
                int  width = 0;

                if (text.horizontalOverflow == HorizontalWrapMode.Wrap)
                {
                    width = (int)text.rectTransform.sizeDelta.x;
                }

                bool isNormal = tr.GetComponent <UINormalFont>() == null ? false : true;

                string align = text.alignment.ToString().Replace("Upper", "").Replace("Middle", "").Replace("Lower", "");
                component = new UIComponentText(text.font.name, text.text.Replace("\n", "\\n").Replace("\r", ""), text.fontSize
                                                , Utill.Utill.ColorToHex(text.color), align.ToLower(), width, isNormal);
            }

            comp = tr.GetComponent <UIInputField>();
            if (comp != null)
            {
                UIInputField  input = comp as UIInputField;
                RectTransform rtr   = comp.GetComponent <RectTransform>();
                component = new UIComponentInput(input.placeholder, (int)rtr.sizeDelta.x, (int)rtr.sizeDelta.y
                                                 , input.fontSize, Utill.Utill.ColorToHex(input.fontColor), Utill.Utill.ColorToHex(input.placeholderColor)
                                                 , input.isTextArea, input.isPassword, input.isNumberOnly);
            }

            comp = tr.GetComponent <UIScroll>();
            if (comp != null)
            {
                UIScroll scroll = comp as UIScroll;
                component = new UIComponentScroll(scroll.scrollArea.name, scroll.scrollMask.name,
                                                  scroll.scrollbar_bar.name, scroll.scrollbar_bg.name);
            }

            comp = tr.GetComponent <UIMask>();
            if (comp != null)
            {
                RectTransform rtr = comp.GetComponent <RectTransform>();
                component = new UIComponentMask((int)rtr.sizeDelta.x, (int)rtr.sizeDelta.y);
            }

            comp = tr.GetComponent <UIToggleGroup>();
            if (comp != null)
            {
                UIToggleGroup tg = comp as UIToggleGroup;
                component = new UIComponentToggleGroup(tg.toggles, tg.defaultIndex);
            }

            int count = tr.childCount;

            for (int i = 0; i < count; i++)
            {
                children.Add(new UIData(root, tr.transform.GetChild(i)));
            }
        }
Esempio n. 3
0
        private Task Render_List()
        {
            return(new Task()
            {
                Mission = "Render_List",
                Action = (seekTo, currentTask, nextTask, delivery) =>
                {
                    if (Material.Component is UIScrollable)
                    {
                        Material.Component.Type = UIType.LIST;

                        UIScrollable list = Material.Component as UIScrollable;
                        UIIdleList idle = list.Idle as UIIdleList;

                        list.Rect.anchoredPosition = new Vector2(idle.Left - idle.Right, idle.Bottom - idle.Top);
                        list.Rect.sizeDelta = new Vector2(idle.Width, idle.Height);

                        list.Background = list.Object.AddComponent <RawImage>();
                        list.Background.texture = Media.texSolid;
                        list.Background.color = idle.BackgroundColor;

                        list.Container = new UIContainer();
                        list.Container.Object = new GameObject(list.Name + "Container");
                        list.Container.Object.transform.parent = list.Object.transform;

                        list.Container.Rect = list.Container.Object.AddComponent <RectTransform>();
                        list.Container.Rect.anchorMin = new Vector2(0.5f, 1);
                        list.Container.Rect.anchorMax = new Vector2(0.5f, 1);
                        list.Container.Rect.pivot = new Vector2(0.5f, 1);
                        list.Container.Rect.sizeDelta = new Vector2(0, 0);
                        list.Container.Rect.anchoredPosition = new Vector2(0, 0);

                        UIScroll scroll = list.Object.AddComponent <UIScroll>();
                        scroll.vertical = true;
                        scroll.horizontal = false;
                        scroll.movementType = UIScroll.MovementType.Elastic;
                        scroll.content = list.Container.Rect;
                        scroll.elasticity = 0.1f;
                        scroll.decelerationRate = 0.005f;
                        scroll.scrollSensitivity = 0.0001f;
                        scroll.scrollFactor = 2f;

                        scroll.gameObject.AddComponent <Mask>();

                        new EventRegistrar()
                        {
                            Material = new EventRegistrarMaterial()
                            {
                                Listener = new EventListener()
                                {
                                    Owner = list.Name,
                                    Name = list.Name + "OnScrollUp",
                                    Enabled = true,
                                    Event = () =>
                                    {
                                        return (list.Container.Rect.anchoredPosition.y > list.ScrollUp);
                                    },
                                    OnFired = (listener) =>
                                    {
                                        list.ScrollingUp = true;
                                        list.WasScrollingUp = true;
                                        list.WasScrollingDown = false;

                                        if (!list.ScrollUpCalled)
                                        {
                                            list.ScrollUpCalled = true;

                                            if (list.OnScrollUp != null)
                                            {
                                                list.OnScrollUp(list);
                                            }
                                        }

                                        if (list.OnScrollingUp != null)
                                        {
                                            list.OnScrollingUp(list);
                                        }
                                    },
                                    OnMiss = (listener) =>
                                    {
                                        list.ScrollingUp = false;
                                        list.ScrollUpCalled = false;

                                        if (list.OnNoScrollingUp != null)
                                        {
                                            list.OnNoScrollingUp(list);
                                        }
                                    },
                                    OnEither = (listener) =>
                                    {
                                        list.ScrollUp = list.Container.Rect.anchoredPosition.y;
                                    }
                                }
                            }
                        }
                        .Register();

                        new EventRegistrar()
                        {
                            Material = new EventRegistrarMaterial()
                            {
                                Listener = new EventListener()
                                {
                                    Owner = list.Name,
                                    Name = list.Name + "OnScrollDown",
                                    Enabled = true,
                                    Event = () =>
                                    {
                                        return (list.Container.Rect.anchoredPosition.y < list.ScrollDown);
                                    },
                                    OnFired = (listener) =>
                                    {
                                        list.ScrollingDown = true;
                                        list.WasScrollingDown = true;
                                        list.WasScrollingUp = false;

                                        if (!list.ScrollDownCalled)
                                        {
                                            list.ScrollDownCalled = true;

                                            if (list.OnScrollDown != null)
                                            {
                                                list.OnScrollDown(list);
                                            }
                                        }

                                        if (list.OnScrollingDown != null)
                                        {
                                            list.OnScrollingDown(list);
                                        }
                                    },
                                    OnMiss = (listener) =>
                                    {
                                        list.ScrollingDown = false;
                                        list.ScrollDownCalled = false;

                                        if (list.OnNoScrollingDown != null)
                                        {
                                            list.OnNoScrollingDown(list);
                                        }
                                    },
                                    OnEither = (listener) =>
                                    {
                                        list.ScrollDown = list.Container.Rect.anchoredPosition.y;
                                    }
                                }
                            }
                        }
                        .Register();

                        if (list.OnRefresh != null)
                        {
                            new EventRegistrar()
                            {
                                Material = new EventRegistrarMaterial()
                                {
                                    OnTouchListener = new OnTouchListener()
                                    {
                                        Owner = list.Name,
                                        Target = list.Name,
                                        Enabled = true,
                                        Released = true,
                                        OnRelease = (go) =>
                                        {
                                            if (list.Container.Rect.anchoredPosition.y < -Screen.height * 0.15f)
                                            {
                                                if (!list.Refreshing)
                                                {
                                                    list.Refreshing = true;

                                                    (Variables.UI["txtTopRight"] as UIText).Element.text = "Refreshing...";

                                                    new Suspender()
                                                    {
                                                        Suspension = 1f,
                                                        OnFinish = () =>
                                                        {
                                                            if (list.OnRefresh != null)
                                                            {
                                                                list.OnRefresh(list);
                                                            }
                                                        }
                                                    }
                                                    .Suspend();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            .Register();
                        }
                    }

                    nextTask(null);
                }
            });
        }
Esempio n. 4
0
        public Exception Parse(string text, string path)
        {
            var isValid = true;

            try {
                var tmpFileName = string.Format(@"{0}\tmp.xml", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
                File.WriteAllText(tmpFileName, text);
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(tmpFileName);
                Dialog = new UIDialog {
                    Name = xmlDoc.DocumentElement.Attributes["Name"].Value
                };
                if (xmlDoc.DocumentElement.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                {
                    Dialog.Width = Convert.ToDouble(xmlDoc.DocumentElement.Attributes["Width"].Value);
                }
                if (xmlDoc.DocumentElement.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                {
                    Dialog.Height = Convert.ToDouble(xmlDoc.DocumentElement.Attributes["Height"].Value);
                }
                if (xmlDoc.DocumentElement.ChildNodes.Cast <XmlNode>().Any(t => t.Name == "Resource"))
                {
                    var dlgRes = xmlDoc.DocumentElement.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "Resource");
                    if (dlgRes.ChildNodes.Cast <XmlNode>().Any(t => t.Name == "FrameImage"))
                    {
                        Dialog.FrameImage = new UIResourceFrameImage {
                            FileName = string.Format(@"{0}\{1}", path, dlgRes.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "FrameImage").Attributes["FileName"].Value)
                        }
                    }
                    ;
                }

                foreach (XmlNode element in xmlDoc.DocumentElement.ChildNodes)
                {
                    switch (element.Name)
                    {
                    case "IMAGEPICTURE":
                        var imageControl = new UIImagePicture {
                            Name     = element.Attributes["Name"].Value,
                            FileName = element.FirstChild != null && element.FirstChild.FirstChild != null
                                    ? string.Format(@"{0}\{1}", path, element.FirstChild.FirstChild.Attributes["FileName"].Value)
                                    : ""
                        };
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "x"))
                        {
                            imageControl.X = Convert.ToDouble(element.Attributes["x"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "y"))
                        {
                            imageControl.Y = Convert.ToDouble(element.Attributes["y"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                        {
                            imageControl.Width = Convert.ToDouble(element.Attributes["Width"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                        {
                            imageControl.Height = Convert.ToDouble(element.Attributes["Height"].Value);
                        }
                        Dialog.ImagePictures.Add(imageControl);
                        break;

                    case "SCROLL":
                        var scrollControl = new UIScroll {
                            Name = element.Attributes["Name"].Value
                        };
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "x"))
                        {
                            scrollControl.X = Convert.ToDouble(element.Attributes["x"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "y"))
                        {
                            scrollControl.Y = Convert.ToDouble(element.Attributes["y"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                        {
                            scrollControl.Width = Convert.ToDouble(element.Attributes["Width"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                        {
                            scrollControl.Height = Convert.ToDouble(element.Attributes["Height"].Value);
                        }
                        foreach (var node in element.ChildNodes.Cast <XmlNode>().Where(node => node.Name == "Resource"))
                        {
                            var upImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "UpImage");
                            if (upImage != null)
                            {
                                scrollControl.UpImage = string.Format(@"{0}\{1}", path, upImage.Attributes["FileName"].Value);
                            }

                            var downImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "DownImage");
                            if (downImage != null)
                            {
                                scrollControl.DownImage = string.Format(@"{0}\{1}", path, downImage.Attributes["FileName"].Value);
                            }

                            var scrollImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "ScrollImage");
                            if (scrollImage != null)
                            {
                                scrollControl.ScrollImage = string.Format(@"{0}\{1}", path, scrollImage.Attributes["FileName"].Value);
                            }

                            var barFrameImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "BarFrameImage");
                            if (barFrameImage != null)
                            {
                                scrollControl.BarFrameImage = string.Format(@"{0}\{1}", path, barFrameImage.Attributes["FileName"].Value);
                            }
                        }
                        Dialog.Scrolls.Add(scrollControl);
                        break;

                    case "RADIO":
                        var radioControl = new UIRadioButton {
                            Name = element.Attributes["Name"].Value,
                        };
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "x"))
                        {
                            radioControl.X = Convert.ToDouble(element.Attributes["x"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "y"))
                        {
                            radioControl.Y = Convert.ToDouble(element.Attributes["y"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                        {
                            radioControl.Width = Convert.ToDouble(element.Attributes["Width"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                        {
                            radioControl.Height = Convert.ToDouble(element.Attributes["Height"].Value);
                        }
                        if (element.ChildNodes != null && element.ChildNodes[0].Name == "Hint")
                        {
                            radioControl.Hint = element.ChildNodes != null
                                                   ? element.ChildNodes[0].Attributes["String"].Value
                                                   : "";
                        }
                        foreach (var node in element.ChildNodes.Cast <XmlNode>().Where(node => node.Name == "Resource"))
                        {
                            var normalImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "NormalImage");
                            if (normalImage != null)
                            {
                                radioControl.NormalImage = string.Format(@"{0}\{1}", path, normalImage.Attributes["FileName"].Value);
                            }

                            var checkedImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "CheckedImage");
                            if (checkedImage != null)
                            {
                                radioControl.CheckedImage = string.Format(@"{0}\{1}", path, checkedImage.Attributes["FileName"].Value);
                            }
                        }
                        Dialog.RadioButtons.Add(radioControl);
                        break;

                    case "STILLIMAGEBUTTON":
                        var buttonControl = new UIStillImageButton {
                            Name = element.Attributes["Name"].Value,
                        };
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "x"))
                        {
                            buttonControl.X = Convert.ToDouble(element.Attributes["x"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "y"))
                        {
                            buttonControl.Y = Convert.ToDouble(element.Attributes["y"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                        {
                            buttonControl.Width = Convert.ToDouble(element.Attributes["Width"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                        {
                            buttonControl.Height = Convert.ToDouble(element.Attributes["Height"].Value);
                        }
                        if (element.ChildNodes != null && element.ChildNodes[0].Name == "Hint")
                        {
                            buttonControl.Hint = element.ChildNodes != null
                                                   ? element.ChildNodes[0].Attributes["String"].Value
                                                   : "";
                        }
                        if (element.ChildNodes.Cast <XmlNode>().Any(node => node.Name == "Text"))
                        {
                            var textNode = element.ChildNodes.Cast <XmlNode>().First(node => node.Name == "Text");
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "String"))
                            {
                                buttonControl.Text = textNode.Attributes["String"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "FontSize"))
                            {
                                buttonControl.FontSize = Convert.ToDouble(textNode.Attributes["FontSize"].Value);
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Color"))
                            {
                                buttonControl.Color = textNode.Attributes["Color"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "OutlineColor"))
                            {
                                buttonControl.OutlineColor = textNode.Attributes["OutlineColor"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "InnerColor"))
                            {
                                buttonControl.InnerColor = textNode.Attributes["InnerColor"].Value;
                            }
                        }
                        foreach (var node in element.ChildNodes.Cast <XmlNode>().Where(node => node.Name == "Resource"))
                        {
                            var upImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "FrameUpImage");
                            if (upImage != null)
                            {
                                buttonControl.UpImage = string.Format(@"{0}\{1}", path, upImage.Attributes["FileName"].Value);
                            }

                            var downImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "FrameDownImage");
                            if (downImage != null)
                            {
                                buttonControl.DownImage = string.Format(@"{0}\{1}", path, downImage.Attributes["FileName"].Value);
                            }

                            var hoverImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "FrameOnHoverImage");
                            if (hoverImage != null)
                            {
                                buttonControl.HoverImage = string.Format(@"{0}\{1}", path, hoverImage.Attributes["FileName"].Value);
                            }
                        }
                        Dialog.StillImageButtons.Add(buttonControl);
                        break;

                    case "LABEL":
                        var labelControl = new UILabel {
                            Name = element.Attributes["Name"].Value,
                        };
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "x"))
                        {
                            labelControl.X = Convert.ToDouble(element.Attributes["x"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "y"))
                        {
                            labelControl.Y = Convert.ToDouble(element.Attributes["y"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                        {
                            labelControl.Width = Convert.ToDouble(element.Attributes["Width"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                        {
                            labelControl.Height = Convert.ToDouble(element.Attributes["Height"].Value);
                        }
                        if (element.ChildNodes.Cast <XmlNode>().Any(node => node.Name == "Text"))
                        {
                            var textNode = element.ChildNodes.Cast <XmlNode>().First(node => node.Name == "Text");
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "String"))
                            {
                                labelControl.Text = textNode.Attributes["String"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "FontSize"))
                            {
                                labelControl.FontSize = Convert.ToDouble(textNode.Attributes["FontSize"].Value);
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Color"))
                            {
                                labelControl.Color = textNode.Attributes["Color"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "OutlineColor"))
                            {
                                labelControl.OutlineColor = textNode.Attributes["OutlineColor"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "TextUpperColor"))
                            {
                                labelControl.TextUpperColor = textNode.Attributes["TextUpperColor"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "TextLowerColor"))
                            {
                                labelControl.TextLowerColor = textNode.Attributes["TextLowerColor"].Value;
                            }
                        }
                        Dialog.Labels.Add(labelControl);
                        break;

                    case "EDIT":
                        var editControl = new UIEditBox {
                            Name = element.Attributes["Name"].Value
                        };
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "x"))
                        {
                            editControl.X = Convert.ToDouble(element.Attributes["x"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "y"))
                        {
                            editControl.Y = Convert.ToDouble(element.Attributes["y"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Width"))
                        {
                            editControl.Width = Convert.ToDouble(element.Attributes["Width"].Value);
                        }
                        if (element.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Height"))
                        {
                            editControl.Height = Convert.ToDouble(element.Attributes["Height"].Value);
                        }
                        if (element.ChildNodes.Cast <XmlNode>().Any(node => node.Name == "Text"))
                        {
                            var textNode = element.ChildNodes.Cast <XmlNode>().First(node => node.Name == "Text");
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "String"))
                            {
                                editControl.Text = textNode.Attributes["String"].Value;
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "FontSize"))
                            {
                                editControl.FontSize = Convert.ToDouble(textNode.Attributes["FontSize"].Value);
                            }
                            if (textNode.Attributes.Cast <XmlAttribute>().Any(t => t.Name == "Color"))
                            {
                                editControl.Color = textNode.Attributes["Color"].Value;
                            }
                        }
                        foreach (var node in element.ChildNodes.Cast <XmlNode>().Where(node => node.Name == "Resource"))
                        {
                            var frameImage = node.ChildNodes.Cast <XmlNode>().FirstOrDefault(t => t.Name == "FrameImage");
                            if (frameImage != null)
                            {
                                editControl.FrameImage = new UIResourceFrameImage {
                                    FileName = string.Format(@"{0}\{1}", path, frameImage.Attributes["FileName"].Value)
                                }
                            }
                            ;
                        }
                        Dialog.Edits.Add(editControl);
                        break;
                    }
                }

                File.Delete(tmpFileName);
            }
            catch (Exception e) {
                return(e);
            }

            return(null);
        }