示例#1
0
        public virtual void LoadFromXml(XElement element)
        {
            var nameAttr = element.Attribute("name");
            Name = nameAttr != null ? nameAttr.Value : "";

            var items = from itm in element.Elements()
                        where itm.Name == "logSourceGroup" ||
                              itm.Name == "logSource"
                        select itm;
            foreach (var item in items)
            {
                if (item.Name == "logSourceGroup")
                {
                    var logGroup = new LogSourceGroup();
                    logGroup.LoadFromXml(item);
                    Items.Add(logGroup);
                }
                else if (item.Name == "logSource")
                {
                    var logSource = new LogSource();
                    logSource.LoadFromXml(item);
                    Items.Add(logSource);
                }
            }
        }
示例#2
0
        private void mnuLogSourceAddGroup_Click(object sender, EventArgs e)
        {
            if (tvLogSources.SelectedNode == null) return;

            var selectedItem = (ILogSourceItem) tvLogSources.SelectedNode.Tag;
            if (selectedItem != null && !(selectedItem is LogSourceGroup)) return;
            var selectedGroup = (LogSourceGroup) selectedItem;

            var newGroup = new LogSourceGroup
                               {
                                   Name = "New Group"
                               };
            selectedGroup.Items.Add(newGroup);

            var newNode = new TreeNode
                              {
                                  Text = newGroup.Name,
                                  Tag = newGroup
                              };
            tvLogSources.SelectedNode.Nodes.Add(newNode);
            tvLogSources.SelectedNode.Expand();
            tvLogSources.SelectedNode = newNode;
            newNode.BeginEdit();

            Config.Save();
        }