public ToolbarItemDef(StyleDef style, ToolbarItemAlign align, bool hasText)
        {
            _Style   = style;
            _Align   = align;
            _HasText = hasText;

            _Children = new List <ToolbarItemDef>();
        }
        internal ToolbarItemDef(ComponentDef componentDef, XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "Style":
                    _Style = componentDef.GetStyle(reader.Value);
                    break;

                case "Align":
                    _Align = (ToolbarItemAlign)Enum.Parse(typeof(ToolbarItemAlign), reader.Value);
                    break;

                case "HasText":
                    _HasText = bool.Parse(reader.Value);
                    break;

                case "Command":
                    _Command = reader.Value;
                    break;

                default:
                    Log.Warning("Unknown attribute {0}", reader.LocalName);
                    break;
                }
            }

            reader.MoveToElement();

            if (reader.IsEmptyElement)
            {
                return;
            }

            _Children = new List <ToolbarItemDef>();

            while (reader.Read())
            {
                if (reader.MoveToContent() == XmlNodeType.EndElement)
                {
                    break;
                }

                switch (reader.LocalName)
                {
                case "Item":
                    ToolbarItemDef MyItem = new ToolbarItemDef(componentDef, reader);

                    _Children.Add(MyItem);
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }
        }
Esempio n. 3
0
        public ComponentDef(GuiComponent component, XmlReader reader)
        {               //****************************************
            StyleDef      NewStyle;
            ToolbarDef    NewToolbar;
            IGuiConverter NewConverter;

            //****************************************

            _Component = component;

            //****************************************

            reader.ReadToFollowing("GuiComponent");

            while (reader.Read())
            {
                if (reader.MoveToContent() == XmlNodeType.EndElement)
                {
                    break;
                }

                switch (reader.LocalName)
                {
                case "Styles":
                    reader.MoveToElement();

                    if (reader.IsEmptyElement)
                    {
                        continue;
                    }

                    while (true)
                    {
                        reader.Read();
                        if (reader.MoveToContent() == XmlNodeType.EndElement)
                        {
                            break;
                        }

                        switch (reader.LocalName)
                        {
                        case "Style":
                            NewStyle = new StyleDef(this, reader);

                            _Styles.Add(NewStyle.Name, NewStyle);
                            break;

                        default:
                            reader.Skip();
                            break;
                        }
                    }
                    break;

                case "Toolbars":
                    reader.MoveToElement();

                    if (reader.IsEmptyElement)
                    {
                        continue;
                    }

                    while (true)
                    {
                        reader.Read();
                        if (reader.MoveToContent() == XmlNodeType.EndElement)
                        {
                            break;
                        }

                        switch (reader.LocalName)
                        {
                        case "Toolbar":
                            NewToolbar = new ToolbarDef(this, reader);

                            _Toolbars.Add(NewToolbar.Name, NewToolbar);
                            break;

                        default:
                            reader.Skip();
                            break;
                        }
                    }
                    break;

                case "Converters":
                    reader.MoveToElement();

                    if (reader.IsEmptyElement)
                    {
                        continue;
                    }

                    while (true)
                    {
                        reader.Read();
                        if (reader.MoveToContent() == XmlNodeType.EndElement)
                        {
                            break;
                        }

                        switch (reader.LocalName)
                        {
                        case "Converter":
                            reader.Skip();

                            // TODO: Custom Converters

                            break;

                        default:
                            reader.Skip();
                            break;
                        }
                    }
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }
        }
        public ToolbarItemDef(StyleDef style, IList <ToolbarItemDef> children)
        {
            _Style = style;

            _Children = new List <ToolbarItemDef>(children);
        }
        //****************************************

        public ToolbarItemDef(StyleDef style)
        {
            _Style = style;

            _Children = new List <ToolbarItemDef>();
        }