コード例 #1
0
ファイル: TemplateField.cs プロジェクト: svn2github/odyssey
 /// <summary>
 /// Creates a new <see cref="T:TemplateField"/>.
 /// </summary>
 /// <param name="id">The id from the database, 0 if not attaced.</param>
 /// <param name="name">The name of the field.</param>
 /// <param name="type">The <see cref="T:Type">type</see> of the field.</param>
 /// <param name="category"></param>
 public TemplateField(int id, string name, FieldType type, Category category, string minRange, string maxRange, short order)
     : base(id, name)
 {
     this.Category = category;
     this.Type = type;
     this.minRange = minRange;
     this.minRange = maxRange;
     this.order = order;
 }
コード例 #2
0
 protected virtual void OnSelectedCategoryChanged(object sender, Category oldCategory, Category newCategory)
 {
 }
コード例 #3
0
        private static void SelectItem(ItemsControl itemsControl, Category category)
        {
            ItemContainerGenerator gen = itemsControl.ItemContainerGenerator;
            if (gen.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
            {
                EventHandler eh = null;
                eh = new EventHandler(delegate
            {
                if (gen.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
                {
                    gen.StatusChanged -= eh;
                    SelectItem(itemsControl, category);
                }
            });
                gen.StatusChanged += eh;
            }
            else
            {
                TreeViewItem root = gen.ContainerFromItem(category) as TreeViewItem;
                if (root != null)
                {
                    root.IsSelected = true;
                    return;
                }

                Category original = category;
                while (category != null)
                {
                    foreach (var item in itemsControl.Items)
                    {
                        TreeViewItem container = gen.ContainerFromItem(item) as TreeViewItem;
                        if (item == original)
                        {
                            if (container != null)
                            {
                                container.IsSelected = true;
                            }
                            return;
                        }
                        else
                        {
                            if (item == category)
                            {

                                if (container != null)
                                {
                                    container.IsExpanded = true;
                                    SelectItem(container, original);
                                }
                            }
                        }
                    }
                    category = category.Parent;
                }
            }
        }
コード例 #4
0
 public static void Select(this TreeView treeView, Category category)
 {
     SelectItem(treeView, category);
 }
コード例 #5
0
ファイル: Category.cs プロジェクト: jogibear9988/OdysseyWPF
 public Category(int id, string name, short order, Category parent)
     : base(id, name)
 {
     this.parent = parent;
     this.order = order;
 }
コード例 #6
0
ファイル: Category.cs プロジェクト: jogibear9988/OdysseyWPF
        /// <summary>
        /// Occurs when the list of passwords has changed.
        /// </summary>
        protected void OnPasswordsChanged(object sender, NotifyEventArgs<Password> e)
        {
            OnPropertyChanged("Passwords");

            Category parent = Parent;
            while (parent != null)
            {
                parent.OnPropertyChanged("NestedPasswords");
                parent = parent.Parent;
            }
        }
コード例 #7
0
ファイル: Main.xaml.cs プロジェクト: jogibear9988/OdysseyWPF
 private bool IsNestedTemplateModified(Category category)
 {
     if (category.IsModified) return true;
     return category.Categories.Any(c => IsNestedTemplateModified(c));
 }
コード例 #8
0
ファイル: Category.cs プロジェクト: jogibear9988/OdysseyWPF
 /// <summary>
 /// Adds a new child Category.
 /// </summary>
 /// <param name="name">The name of the new child Category.</param>
 /// <returns>The new Category.</returns>
 public Category AddCategory(string name)
 {
     Category category = new Category(0, name, (short)Categories.Count, this);
     Categories.Add(category);
     category.Save();
     foreach (TemplateField field in Fields)
     {
         TemplateField copy = new TemplateField(0, field.Name, field.Type, category, field.MinRange, field.MaxRange, (short)Fields.Count);
         copy.IsModified = true;
         category.Fields.Add(copy);
     }
     category.SaveTemplate();
     return category;
 }
コード例 #9
0
ファイル: Main.xaml.cs プロジェクト: jogibear9988/OdysseyWPF
        public void NewPassword(Category category)
        {
            Password password = category.CreatePassword();
            if (password != null)
            {
                password.Name = "New Password";
                SelectedCategory = password.Category;
                this.SelectedPassword = password;
                this.PasswordGrid.FocusPassword();

            }
        }
コード例 #10
0
ファイル: Main.xaml.cs プロジェクト: jogibear9988/OdysseyWPF
        protected virtual void OnSelectedCategoryChanged(object sender, Category oldCategory, Category newCategory)
        {
            if (newCategory != null)
            {
                newCategory.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(SelectedCategoryPropertyChanged);
            }
            if (oldCategory != null)
            {
                oldCategory.PropertyChanged -= SelectedCategoryPropertyChanged;
            }
            if (newCategory != null) this.foldersTreeView.Deselect();
            this.PasswordGrid.DataContext = newCategory;

            templateCategoryTree.Select(newCategory);
            categoriesTree.Select(newCategory);
            SelectedNode = newCategory;
            SelectedTemplateField = null;

            IsTemplateModified = newCategory != null ? newCategory.IsModified : false;
        }
コード例 #11
0
ファイル: Password.cs プロジェクト: svn2github/odyssey
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public Password(int categoryId, int id, string name)
     : base(id, name)
 {
     this.category = Context.GetCategory(categoryId);
 }
コード例 #12
0
ファイル: Password.cs プロジェクト: svn2github/odyssey
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public Password(Category category, int id, string name)
     : base(id, name)
 {
     this.category = category;
 }
コード例 #13
0
ファイル: Password.cs プロジェクト: svn2github/odyssey
        private void SetCategoryByPath(string value)
        {
            if (!string.IsNullOrEmpty(value))
            {
                // first get the root:
                Category category = Category;
                while (category.Parent is Category) category = category.Parent;

                string[] names = value.Split('\\');

                foreach (string name in names)
                {
                    category = GetCategoryByName(category, name);
                    if (category == null) break;
                }
                if (category != null)
                {
                    Category = category;
                }
            }
        }
コード例 #14
0
ファイル: Password.cs プロジェクト: svn2github/odyssey
 private Category GetCategoryByName(Category category, string name)
 {
     return category.Categories.Where(c => c.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
 }
コード例 #15
0
ファイル: Password.cs プロジェクト: svn2github/odyssey
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public Password(Category category)
     : base()
 {
     this.category = category;
 }