/// <summary> /// Searches copies and launches Edit Tools Form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchCopiesButton_Click(object sender, RibbonControlEventArgs e) { copies = new RangeOfShapes(); var selectedItems = Globals.ThisAddIn.Application.ActiveWindow.Selection; if (selectedItems.Type == PowerPoint.PpSelectionType.ppSelectionShapes && selectedItems.ShapeRange.Count == 1) { PowerPoint.Shape selectedShape = selectedItems.ShapeRange[1]; copies.Add(selectedShape); foreach (PowerPoint.Slide slide in Globals.ThisAddIn.Application.ActivePresentation.Slides) { foreach (PowerPoint.Shape shape in slide.Shapes) { if (ShapesAreEqual(shape, selectedShape)) { copies.Add(shape); } } } } else { MessageBox.Show("Выберите элемент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (copies.Count() == 1) { MessageBox.Show($"Не было найдено копий"); } else { EditToolsForm editTools = new EditToolsForm(copies); editTools.Show(); } }
/// <summary> /// Handles the Click event of the ApplyStyleForAllSimiliarsButton control, looks for similiars and launches Edit Tools /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs" /> instance containing the event data.</param> private void ApplyStyleForAllSimiliarsButton_Click(object sender, RibbonControlEventArgs e) { var selectedItems = Globals.ThisAddIn.Application.ActiveWindow.Selection; if (selectedItems.Type == PowerPoint.PpSelectionType.ppSelectionShapes && selectedItems.ShapeRange.Count == 1) { var originalShape = selectedItems.ShapeRange[1]; var typeOfOriginalShape = originalShape.Type; var style = originalShape.ShapeStyle; RangeOfShapes similiars = new RangeOfShapes(); foreach (PowerPoint.Slide slide in Globals.ThisAddIn.Application.ActivePresentation.Slides) { foreach (PowerPoint.Shape shape in slide.Shapes) { if ((shape.Type == typeOfOriginalShape && shape.ShapeStyle == style && style != Office.MsoShapeStyleIndex.msoShapeStyleNotAPreset) || (typeOfOriginalShape == Office.MsoShapeType.msoTextBox && style == Office.MsoShapeStyleIndex.msoShapeStyleNotAPreset && shape.Type == Office.MsoShapeType.msoTextBox && shape.TextFrame.TextRange.Font == originalShape.TextFrame.TextRange.Font)) { similiars.Add(shape); } } } if (similiars.Count() != 0) { EditToolsForm editTools = new EditToolsForm(similiars); editTools.Show(); } else { MessageBox.Show("Не найдено похожих по стилю элементов", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Выберите элемент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// Handles the Click event of the button1 control and launches Edit Tools /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> private void button1_Click(object sender, EventArgs e) { EditToolsForm editTools = new EditToolsForm(Groups[currentGroupName]); editTools.Show(); }