Read() public méthode

public Read ( Wrapper baseWidget, XmlElement elem ) : void
baseWidget Wrapper
elem System.Xml.XmlElement
Résultat void
Exemple #1
0
        public void Read(Wrapper.Widget baseWidget, XmlElement elem)
        {
            name = elem.GetAttribute("name");
            if (elem.HasAttribute("type"))
            {
                type = (Gtk.UIManagerItemType)Enum.Parse(typeof(Gtk.UIManagerItemType), elem.GetAttribute("type"));
            }

            // The name of an action may be empty in some situations (e.g. when adding a new action but before entering the name)
            XmlAttribute actionAt = elem.Attributes ["action"];

            if (actionAt != null)
            {
                string aname = actionAt.Value;
                foreach (ActionGroup grp in baseWidget.LocalActionGroups)
                {
                    action = grp.GetAction(aname);
                    if (action != null)
                    {
                        break;
                    }
                }
                if (action == null)
                {
                    foreach (ActionGroup group in baseWidget.Project.ActionGroups)
                    {
                        action = group.GetAction(aname);
                        if (action != null)
                        {
                            break;
                        }
                    }
                }
                if (action != null)
                {
                    lastActionName        = action.Name;
                    action.Deleted       += OnActionDeleted;
                    action.ObjectChanged += OnActionChanged;
                }
            }

            try
            {
                loading = true;
                foreach (XmlElement child in elem.SelectNodes("node"))
                {
                    ActionTreeNode node = new ActionTreeNode();
                    node.Read(baseWidget, child);
                    Children.Add(node);
                }
            }
            finally
            {
                loading = false;
            }
        }
Exemple #2
0
        public void Read(Wrapper.Widget baseWidget, XmlElement elem)
        {
            name = elem.GetAttribute ("name");
            if (elem.HasAttribute ("type"))
                type = (Gtk.UIManagerItemType) Enum.Parse (typeof(Gtk.UIManagerItemType), elem.GetAttribute ("type"));

            // The name of an action may be empty in some situations (e.g. when adding a new action but before entering the name)
            XmlAttribute actionAt = elem.Attributes ["action"];
            if (actionAt != null) {
                string aname = actionAt.Value;
                foreach (ActionGroup grp in baseWidget.LocalActionGroups) {
                    action = grp.GetAction (aname);
                    if (action != null)
                        break;
                }
                if (action == null) {
                    foreach (ActionGroup group in baseWidget.Project.ActionGroups) {
                        action = group.GetAction (aname);
                        if (action != null)
                            break;
                    }
                }
                if (action != null) {
                    lastActionName = action.Name;
                    action.Deleted += OnActionDeleted;
                    action.ObjectChanged += OnActionChanged;
                }
            }

            try {
                loading = true;
                foreach (XmlElement child in elem.SelectNodes ("node")) {
                    ActionTreeNode node = new ActionTreeNode ();
                    node.Read (baseWidget, child);
                    Children.Add (node);
                }
            } finally {
                loading = false;
            }
        }