예제 #1
0
 XElement GetTab(TabModel tab)
 {
     return
         ((from sectionXml in _database.Element("Tabs").Elements("Tab")
           where sectionXml.Element("Title").Value == tab.Title ||
           sectionXml.Element("Title").Value == tab.OldTitle
           select sectionXml).Single());
 }
예제 #2
0
        void Update(TabModel updateThis)
        {
            Log.DebugFormat("Update {0}", updateThis.OldTitle);

            var tab = GetTab(updateThis);

            tab.ReplaceWith(TabToXml(updateThis));
        }
예제 #3
0
        void Remove(TabModel removeThis)
        {
            Log.DebugFormat("Remove {0}", removeThis.Title);

            var section = GetTab(removeThis);

            section.Remove();
        }
예제 #4
0
        XElement TabToXml(TabModel section)
        {
            XElement xml = new XElement("Tab",
                                        new XElement("Title", section.Title),
                                        new XElement("IsExpanded", section.IsExpanded),
                                        new XElement("TabOrder", section.TabOrder));

            return(xml);
        }
예제 #5
0
        public IEnumerable <ApplicationModel> LoadApplications(TabModel forThis)
        {
            if (forThis == null)
            {
                throw new ArgumentNullException("forThis");
            }

            return(from elem in _database.Element("Applications").Elements("Application")
                   where elem.GetValue("Tab") == forThis.Title
                   select ApplicationFromXml(elem));
        }
예제 #6
0
        void Move(TabModel moveThis, TabModel moveToThis)
        {
            Log.DebugFormat("Move {0} to {1}", moveThis.Title, moveToThis.Title);

            var moveThisXml   = GetTab(moveThis);
            var moveToThisXml = GetTab(moveToThis);

            // Move xml from current position to just above the other tab.
            moveThisXml.Remove();
            moveToThisXml.AddBeforeSelf(moveThisXml);
        }
예제 #7
0
        public IEnumerable <TabModel> LoadTabs()
        {
            var xml = from elem in _database.Element("Tabs").Elements("Tab")
                      select elem;

            foreach (XElement xmlSection in xml)
            {
                TabModel tabModel = TabFromXml(xmlSection);
                foreach (var appModel in LoadApplications(tabModel))
                {
                    tabModel.Applications.Add(appModel);
                }
                yield return(tabModel);
            }
        }
예제 #8
0
        void Add(TabModel addThis)
        {
            Log.DebugFormat("Add {0}", addThis.Title);

            _database.Element("Tabs").Add(TabToXml(addThis));
        }