Esempio n. 1
0
        public GroupItem(Group group, Dispatcher dispatcher)
        {
            if (group == null) throw new ArgumentNullException("group");
            if (dispatcher == null) throw new ArgumentNullException("dispatcher");

            Title = group.Name;
            Icon = ThemeData.GetImage("folder");
            Overlay = Cache.GetOverlay(dispatcher, group.Icon);

            _targetUri = Navigation.GetPathTo
                <GroupDetails>("id={0}", group.ID);
        }
Esempio n. 2
0
        public Database(Group root,
            IDictionary<string, ImageSource> customIcons)
        {
            if (root == null) throw new ArgumentNullException("root");
            if (customIcons == null) throw new ArgumentNullException("customIcons");

            _root = root;
            _customIcons = customIcons;
            _groups = new Dictionary<string, Group>();
            _entries = new Dictionary<string, Entry>();

            Index(root);
        }
Esempio n. 3
0
        private void ListItems(Group group, Group recycleBin)
        {
            var dispatcher = Dispatcher;
            var groups = group.Groups.AsEnumerable();

            if (recycleBin != null)
            {
                var settings = AppSettings.Instance;

                if (settings.HideRecycleBin)
                    groups = groups.Except(new[] { recycleBin });
            }

            var items = new List<GroupItem>();
            items.AddRange(groups
                .OrderBy(x => x.Name)
                .Select(x => new GroupItem(x, dispatcher)));
            items.AddRange(group.Entries
                .OrderBy(x => x.Title)
                .Select(x => new GroupItem(x, dispatcher)));

            if (items.Count > 0)
                Display(items, _items);
        }
Esempio n. 4
0
        private static bool IsRelated(Group group, Group target)
        {
            if (group == target)
                return true;

            var parent = group.Parent;
            if (parent == null)
                return false;

            return IsRelated(parent, target);
        }
Esempio n. 5
0
        private Group ParseGroup(XmlReader reader)
        {
            var id = ReadId(reader);

            if (reader.Name != "Name")
                reader.ReadToNextSibling("Name");

            var name = reader
                .ReadElementContentAsString();

            var icon = ParseIcon(reader);

            var group = new Group
            {
                ID = id,
                Name = name,
                Icon = icon,
            };

            ParseChildren(reader, group);

            return group;
        }
Esempio n. 6
0
        private void ParseChildren(XmlReader reader, Group group)
        {
            while (reader.NodeType == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                    case "Group":
                        using (var subReader = reader.ReadSubtree())
                            group.Add(ParseGroup(subReader));
                        reader.ReadEndElement();
                        break;

                    case "Entry":
                        using (var subReader = reader.ReadSubtree())
                            group.Add(ParseEntry(subReader));
                        reader.ReadEndElement();
                        break;

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

            group.Sort();
        }
Esempio n. 7
0
        private void Index(Group group)
        {
            _groups.AddOrSet(group.ID, group);

            foreach (var entry in group.Entries)
                _entries.AddOrSet(entry.ID, entry);

            foreach (var child in group.Groups)
                Index(child);
        }
Esempio n. 8
0
        /// <summary>
        /// Adds the specified group.
        /// </summary>
        /// <param name="group">The group.</param>
        public void Add(Group group)
        {
            if (group == null)
                throw new ArgumentNullException("group");

            group.Parent = this;
            _groups.Add(group);
        }