Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditToolsForm"/> class, styles all buttons and sets list of fonts.
        /// </summary>
        /// <param name="shapes">The shapes.</param>
        public EditToolsForm(RangeOfShapes shapes)
        {
            InitializeComponent();
            this.shapes         = shapes;
            MakeBoldButton.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold);
            MakeBoldButton.FlatAppearance.BorderColor = Color.White;
            MakeItalicButton.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Italic);
            MakeItalicButton.FlatAppearance.BorderColor = Color.White;
            MakeUnderlineButton.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Underline);
            MakeUnderlineButton.FlatAppearance.BorderColor = Color.White;
            MakeStrikeButton.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Strikeout);
            MakeStrikeButton.FlatAppearance.BorderColor   = Color.White;
            UnformatTextButton.FlatAppearance.BorderColor = Color.White;
            List <string> fonts = new List <string>();

            foreach (FontFamily font in System.Drawing.FontFamily.Families)
            {
                fonts.Add(font.Name);
            }
            ListOfFonts.Items.AddRange(fonts.ToArray());
            flagBold      = Office.MsoTriState.msoFalse;
            flagUnderline = Office.MsoTriState.msoFalse;
            flagStrike    = Office.MsoTriState.msoFalse;
            flagItalic    = Office.MsoTriState.msoFalse;
        }
Пример #2
0
        /// <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();
            }
        }
Пример #3
0
        /// <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;
            }
        }