예제 #1
0
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            var database = Cache.Database;

            DateTime convertedDate;
            if ((Cache.DbInfo != null) && (Cache.DbInfo.Details.Modified != null))
            {
                convertedDate = DateTime.Parse(Cache.DbInfo.Details.Modified);
                ApplicationTitle.Text = "WinPass - " + Cache.DbInfo.Details.Name + " (" + convertedDate + ")";
            }

            if (database == null)
            {
                this.BackToDBs();
                return;
            }

            //if (Cache.DbInfo != null && Cache.DbInfo.Details.Type.ToString() == "OneTime")
            //    mnuSync.IsEnabled = false;
            _group = GetGroup(database);
            lstHistory.ItemsSource = null;
            pivotGroup.Header = _group.Name;

            ThreadPool.QueueUserWorkItem(_ =>
                ListItems(_group, database.RecycleBin));

            ThreadPool.QueueUserWorkItem(_ =>
                ListHistory(database));
            ItemRemovedAction();
        }
예제 #2
0
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            _database = Cache.Database;
            if (_database == null)
            {
                this.BackToDBs();
                return;
            }

            string id;
            var queries = NavigationContext.QueryString;

            if (queries.TryGetValue("entry", out id))
                _entry = _database.GetEntry(id);
            else
            {
                id = queries["group"];
                _group = _database.GetGroup(id);
            }

            _target = _database.Root;
            Refresh();
        }
예제 #3
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);
        }
예제 #4
0
파일: Database.cs 프로젝트: nthobois/7Pass
        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);
        }
예제 #5
0
        /// <summary>
        /// Deletes the specified group.
        /// </summary>
        /// <param name="group">The group.</param>
        public void Delete(Group group)
        {
            if (group == null)
                throw new ArgumentNullException("group");

            var time = GetTime(DateTime.Now);

            _deletedObjs.Add(new XElement("DeletedObject",
                new XElement("UUID", group.ID),
                new XElement("DeletionTime", time)));

            _groups[group.ID].Remove();
            Remove(group);
        }
예제 #6
0
파일: GroupItem.cs 프로젝트: nthobois/7Pass
        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);

            _data = group;
            _targetUri = Navigation.GetPathTo
                <GroupDetails>("id={0}", group.ID);
        }
예제 #7
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;
           // RecycleBin = _root.Entries.FirstOrDefault(p=>p.Group.Icon == 43)
            _customIcons = customIcons;
            Configuration = new DatabaseConfiguration();
            _groups = new Dictionary<string, Group>();
            _entries = new Dictionary<string, Entry>();

            Index(root);
        }
예제 #8
0
        private static string GetPath(Group group)
        {
            var sb = new StringBuilder(
                group.Name);

            while (group.Parent != null)
            {
                group = group.Parent;

                sb.Insert(0, " � ");
                sb.Insert(0, group.Name);
            }

            return sb.ToString();
        }
예제 #9
0
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            var database = Cache.Database;
            if (database == null)
            {
                GoBack<MainPage>();
                return;
            }

            _group = GetGroup(database);
            lstHistory.ItemsSource = null;
            pivotGroup.Header = _group.Name;

            ThreadPool.QueueUserWorkItem(_ =>
                ListItems(_group, database.RecycleBin));

            ThreadPool.QueueUserWorkItem(_ =>
                ListHistory(database));
        }
예제 #10
0
파일: Database.cs 프로젝트: nthobois/7Pass
        /// <summary>
        /// Adds the new group.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="name">The name.</param>
        public Group AddNew(Group parent, string name)
        {
            if (parent == null)
                throw new ArgumentNullException("parent");

            var group = new Group
            {
                Name = name,
            };

            parent.Add(group);
            group.ID = Uuid.NewUuid();

            _groups.Add(group.ID, group);

            return group;
        }
예제 #11
0
 private static bool Matches(
     Group group, string text)
 {
     return Matches(text, new[]
     {
         group.Name,
         group.Notes,
     });
 }
예제 #12
0
        private void Remove(Group group)
        {
            foreach (var entry in group.Entries)
                _entries.Remove(entry.ID);

            foreach (var child in group.Groups)
                Remove(child);

            _groups.Remove(group.ID);
        }
예제 #13
0
        private void SetRecycleBin(Group recycleBin)
        {
            var recycleBinId = recycleBin != null
                ? recycleBin.ID
                : EMPTY_ID;

            var meta = _doc.Root
                .Element("Meta");

            var idElement = meta
                .Element("RecycleBinUUID");

            if (idElement.Value == recycleBinId)
                return;

            idElement.Value = recycleBinId;
            meta.Element("RecycleBinChanged")
                .Value = GetTime(DateTime.Now);
        }
예제 #14
0
 /// <summary>
 /// Updates the details of the specified group.
 /// </summary>
 /// <param name="group">The group.</param>
 public void Details(Group group)
 {
     _xmlWriter.Details(group);
 }
예제 #15
0
파일: Database.cs 프로젝트: nthobois/7Pass
        /// <summary>
        /// Removes the specified entry.
        /// </summary>
        /// <param name="group">The group.</param>
        public void Remove(Group group)
        {
            foreach (var entry in group.Entries.ToList())
                Remove(entry);

            foreach (var child in group.Groups.ToList())
                Remove(child);

            group.Remove();
            _groups.Remove(group.ID);
        }
예제 #16
0
        public void Save(Stream stream, Group recycleBin)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            // Encrypt protected fields
            var crypto = CryptoSerializer
                .Create(_headers);
            _xmlWriter.Encrypt(crypto);

            // Headers
            var bw = new BinaryWriter(stream);
            new HeadersWriter(bw)
                .Write(_headers, _version);

            // Main XML
            using (var encrypted = Encrypt(stream,
                _headers, _masterKey))
            {
                _xmlWriter.Save(encrypted,
                    recycleBin);
            }
        }
예제 #17
0
        private Group ParseGroup(XmlReader reader)
        {
            var id = ReadId(reader);

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

            var name = reader
                .ReadElementContentAsString();

            var notes = string.Empty;
            if (reader.Name == "Notes" ||
                reader.ReadToNextSibling("Notes"))
            {
                notes = reader.ReadElementContentAsString();
            }

            var icon = ParseIcon(reader);
            var lastModified = ReadLastModified(reader);

            var group = new Group
            {
                ID = id,
                Name = name,
                Icon = icon,
                Notes = notes,
                LastModified = lastModified,
            };

            ParseChildren(reader, group);

            return group;
        }
예제 #18
0
        private void lst_SelectionChanged(object sender,
            NavigationListControl.NavigationEventArgs e)
        {
            var item = e.Item as GroupItem;
            if (item == null)
                return;

            _target = (Group)item.Data;
            Refresh();
        }
예제 #19
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)));

            lstGroup.SetItems(items);
        }
예제 #20
0
파일: Database.cs 프로젝트: nthobois/7Pass
        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);
        }
예제 #21
0
        private void ListItems(Group group, Group recycleBin)
        {
            var dispatcher = Dispatcher;
            var groups = group.Groups.ToList();

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

                if (settings.HideRecycleBin)
                    groups.Remove(recycleBin);
            }

            if (IsSameData(groups, group.Entries))
                return;

            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)));

            lstGroup.SetItems(items);
        }
예제 #22
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())
                        {
                            var entry = ParseEntry(subReader);
                            if (entry != null)
                                group.Add(entry);
                        }

                        reader.ReadEndElement();
                        break;

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

            group.Sort();
        }
예제 #23
0
        private void Delete(Group group)
        {
            var database = Cache.Database;
            var pernament = IsPernamentDelete();

            if (!ConfirmDelete(pernament,
                Properties.Resources.Group,
                group.Name))
            {
                return;
            }

            if (!pernament)
            {
                MoveToRecycleBin((writer, recycleBin) =>
                {
                    group.Remove();
                    recycleBin.Add(group);

                    writer.Location(group);
                });
            }
            else
            {
                Save(x =>
                {
                    x.Delete(group);
                    database.Remove(group);
                });
            }
        }
예제 #24
0
        /// <summary>
        /// Updates the details of the specified group.
        /// </summary>
        /// <param name="group">The group.</param>
        public void Details(Group group)
        {
            if (group == null)
                throw new ArgumentNullException("group");

            var element = _groups[group.ID];

            element
                .Element("Name")
                .Value = group.Name;

            var time = DateTime.Now;
            group.LastModified = time;

            element
                .Element("Times")
                .Element("LastModificationTime")
                .Value = GetTime(time);
        }
예제 #25
0
 /// <summary>
 /// Saves the new group.
 /// </summary>
 /// <param name="group">The group.</param>
 public void New(Group group)
 {
     _xmlWriter.New(group);
 }
예제 #26
0
        /// <summary>
        /// Updates the location of the specified group.
        /// </summary>
        /// <param name="group">The group.</param>
        public void Location(Group group)
        {
            if (group == null)
                throw new ArgumentNullException("group");

            var element = _groups[group.ID];
            element.Remove();

            var parent = _groups[group.Parent.ID];
            parent.Add(element);

            var time = DateTime.Now;
            group.LastModified = time;

            element
                .Element("Times")
                .Element("LocationChanged")
                .Value = GetTime(time);
        }
예제 #27
0
 /// <summary>
 /// Deletes the specified group.
 /// </summary>
 /// <param name="group">The group.</param>
 public void Delete(Group group)
 {
     _xmlWriter.Delete(group);
 }
예제 #28
0
        /// <summary>
        /// Saves the new group.
        /// </summary>
        /// <param name="group">The group.</param>
        public void New(Group group)
        {
            if (group == null)
                throw new ArgumentNullException("group");

            var time = DateTime.Now;
            group.LastModified = time;

            var timeValue = GetTime(time);
            var element = new XElement("Group",
                new XElement("UUID", group.ID),
                new XElement("Name", group.Name),
                new XElement("Notes"),
                new XElement("IconID", group.Icon.Standard),
                new XElement("Times",
                    new XElement("LastModificationTime", timeValue),
                    new XElement("CreationTime", timeValue),
                    new XElement("LastAccessTime", timeValue),
                    new XElement("ExpiryTime", timeValue),
                    new XElement("Expires", "False"),
                    new XElement("UsageCount", 0),
                    new XElement("LocationChanged", timeValue)),
                new XElement("IsExpanded", "True"),
                new XElement("DefaultAutoTypeSequence"),
                new XElement("EnableAutoType", "null"),
                new XElement("EnableSearching", "null"),
                new XElement("LastTopVisibleEntry", EMPTY_ID));

            var parent = _groups[group.Parent.ID];
            parent.Add(element);

            parent
                .Element("Times")
                .Element("LastModificationTime")
                .Value = timeValue;

            _groups.Add(group.ID, element);
        }
예제 #29
0
 /// <summary>
 /// Updates the location of the specified group.
 /// </summary>
 /// <param name="group">The group.</param>
 public void Location(Group group)
 {
     _xmlWriter.Location(group);
 }
예제 #30
0
        /// <summary>
        /// Saves the updated XML to the specified stream.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <param name="recycleBin">The recycle bin.</param>
        public void CreateRecycleBin(Stream xml, Group recycleBin)
        {
            if (xml == null)
                throw new ArgumentNullException("xml");

            SetRecycleBin(recycleBin);

            _doc.Save(xml);
        }