示例#1
0
文件: Form1.cs 项目: Alp4ka/Storage
        /// <summary>
        /// Создать новую категорию(клик).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createNewCategory_Click(object sender, EventArgs e)
        {
            var selectedNode = (StorageNode)storageTree.SelectedNode;
            var ccvDialog    = new CategoryCreationView(selectedNode);

            ccvDialog.ShowDialog();
            var result = ccvDialog.Result;

            if (result != null)
            {
                Cathegory cathegory = new Cathegory(result.Text);
                result.Cathegory = cathegory;
                if (selectedNode != null)
                {
                    selectedNode.Cathegory.Cathegories.Add(cathegory);
                    selectedNode.Nodes.Add(result);
                }
                else
                {
                    Storage.Cathegories.Add(cathegory);
                    storageTree.Nodes.Add(result);
                }
                Utils.CreateCategoryInPath(result);
            }
        }
示例#2
0
文件: Form1.cs 项目: Alp4ka/Storage
        /// <summary>
        /// Сменить имя категории.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void changeSubCategoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var selectedNode = storageTree.SelectedNode;

            if (selectedNode != null)
            {
                CategoryCreationView ccv = new CategoryCreationView((StorageNode)selectedNode.Parent);
                ccv.ShowDialog();
                if (ccv.Result != null)
                {
                    Utils.RenameCategoryTo((StorageNode)selectedNode, ccv.Result.Text);
                }
            }
        }