private void ContextMenuStripRenameCategoryClicked() { var categoryInfoDialog = new ShapesLabCategoryInfoForm(CurrentCategory); categoryInfoDialog.ShowDialog(); if (categoryInfoDialog.UserOption == ShapesLabCategoryInfoForm.Option.Ok) { var categoryName = categoryInfoDialog.CategoryName; // if current category is the default category, change ShapeConfig if (Globals.ThisAddIn.ShapesLabConfigs.DefaultCategory == CurrentCategory) { Globals.ThisAddIn.ShapesLabConfigs.DefaultCategory = categoryName; } // rename the category in ShapeGallery Globals.ThisAddIn.ShapePresentation.RenameCategory(categoryName); // rename the category on the disk var newPath = Path.Combine(ShapeRootFolderPath, categoryName); try { Directory.Move(CurrentShapeFolderPath, newPath); } catch (Exception) { // this may occur when the newCategoryName.tolower() == oldCategoryName.tolower() } // rename the category in combo box var categoryIndex = categoryBox.SelectedIndex; _categoryBinding[categoryIndex] = categoryName; // update current category reference CurrentCategory = categoryName; } myShapeFlowLayout.Focus(); }
private void ContextMenuStripAddCategoryClicked() { var categoryInfoDialog = new ShapesLabCategoryInfoForm(string.Empty); categoryInfoDialog.ShowDialog(); if (categoryInfoDialog.UserOption == ShapesLabCategoryInfoForm.Option.Ok) { var categoryName = categoryInfoDialog.CategoryName; Globals.ThisAddIn.ShapePresentation.AddCategory(categoryName); _categoryBinding.Add(categoryName); categoryBox.SelectedIndex = _categoryBinding.Count - 1; } myShapeFlowLayout.Focus(); }