コード例 #1
0
        public static Category CreateCategory(IWin32Window owner)
        {
            Category category = new Category
            {
                ID   = Tuid.Next,
                Name = "<New>"
            };

            using (EditCategoryDialog editCategoryDialog = new EditCategoryDialog(category))
            {
                editCategoryDialog.Text = "New Category";
                if (editCategoryDialog.ShowDialog(owner) == DialogResult.OK)
                {
                    return(category);
                }
            }
            return(null);
        }
コード例 #2
0
        public override void EditItem(IWin32Window owner, object item)
        {
            Category category = item as Category;

            if (category == null)
            {
                return;
            }
            Category category2 = category.Duplicate();

            using (EditCategoryDialog editCategoryDialog = new EditCategoryDialog(category2))
            {
                editCategoryDialog.Text = string.Format("Edit {0}", category.Name);
                if (editCategoryDialog.ShowDialog(owner) == DialogResult.OK)
                {
                    int num = this.categories.IndexOf(category);
                    this.categories[num] = category2;
                    this.categories.ResetItem(num);
                }
            }
        }