예제 #1
0
        public void AddText()
        {
            var shapes = GetCurrentlySelectedShapes();

            if (shapes.Count <= 0)
            {
                Error(TextCollection.DrawingsLabSelectAtLeastOneShape);
                return;
            }

            var text = DrawingsLabDialogs.ShowInsertTextDialog();

            if (text == null)
            {
                return;
            }

            Globals.ThisAddIn.Application.StartNewUndoEntry();
            foreach (var shape in shapes)
            {
                try
                {
                    Graphics.SetText(shape, text);
                }
                catch (ArgumentException)
                {
                    Debug.WriteLine("Unable to write text to " + shape.Name);
                }
            }
        }
예제 #2
0
        public void RemoveText()
        {
            var shapes = GetCurrentlySelectedShapes();

            if (shapes.Count <= 0)
            {
                Error(TextCollection.DrawingsLabSelectAtLeastOneShape);
                return;
            }

            Globals.ThisAddIn.Application.StartNewUndoEntry();
            foreach (var shape in shapes)
            {
                Graphics.SetText(shape, String.Empty);
            }
        }
예제 #3
0
        private static void SyncBulletAgendaSlide(PowerPointSlide refSlide, List <AgendaSection> sections,
                                                  AgendaSection currentSection, List <string> deletedShapeNames, PowerPointSlide targetSlide)
        {
            SyncShapesFromReferenceSlide(refSlide, targetSlide, deletedShapeNames);

            var referenceContentShape = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape));
            var targetContentShape    = targetSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape));
            var bulletFormats         = BulletFormats.ExtractFormats(referenceContentShape);

            Graphics.SetText(targetContentShape, sections.Where(section => section.Index > 1)
                             .Select(section => section.Name));
            Graphics.SyncShape(referenceContentShape, targetContentShape, pickupTextContent: false,
                               pickupTextFormat: false);

            ApplyBulletFormats(targetContentShape.TextFrame2.TextRange, bulletFormats, currentSection);
            targetSlide.DeletePlaceholderShapes();
        }
예제 #4
0
        public void ApplyFormat(bool applyAllSettings = false)
        {
            var shapes = GetCurrentlySelectedShapes();

            if (shapes.Count <= 0)
            {
                Error(TextCollection.DrawingsLabSelectAtLeastOneShape);
                return;
            }

            Globals.ThisAddIn.Application.StartNewUndoEntry();

            Action <bool, bool, Action> apply = (isDefaultSetting, condition, action) =>
            {
                if (applyAllSettings && !isDefaultSetting)
                {
                    return;
                }
                if (!applyAllSettings && !condition)
                {
                    return;
                }

                try
                {
                    action();
                }
                catch (ArgumentException)
                {
                    // ArgumentException is thrown if the shape does not have this property.
                }
            };

            foreach (var s in shapes)
            {
                var shape = s;

                // Sync Text Style
                apply(false, _dataSource.FormatSyncTextStyle && _dataSource.FormatIncludeText,
                      () => Graphics.SetText(shape, _dataSource.FormatText));
                apply(true, _dataSource.FormatSyncTextStyle && _dataSource.FormatIncludeTextColor,
                      () => shape.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = _dataSource.FormatTextColor);
                apply(true, _dataSource.FormatSyncTextStyle && _dataSource.FormatIncludeTextFontSize,
                      () => shape.TextFrame2.TextRange.Font.Size = _dataSource.FormatTextFontSize);
                apply(true, _dataSource.FormatSyncTextStyle && _dataSource.FormatIncludeTextFont,
                      () => shape.TextFrame2.TextRange.Font.Name = _dataSource.FormatTextFont);
                apply(true, _dataSource.FormatSyncTextStyle && _dataSource.FormatIncludeTextWrap,
                      () => shape.TextFrame2.WordWrap = _dataSource.FormatTextWrap ? MsoTriState.msoTrue : MsoTriState.msoFalse);
                apply(true, _dataSource.FormatSyncTextStyle && _dataSource.FormatIncludeTextAutoSize,
                      () => shape.TextFrame2.AutoSize = _dataSource.FormatTextAutoSize);

                // Sync Line Style
                apply(true, _dataSource.FormatSyncLineStyle && _dataSource.FormatIncludeHasLine,
                      () => shape.Line.Visible = _dataSource.FormatHasLine ? MsoTriState.msoTrue : MsoTriState.msoFalse);
                apply(true, _dataSource.FormatSyncLineStyle && _dataSource.FormatIncludeLineColor,
                      () => shape.Line.ForeColor.RGB = _dataSource.FormatLineColor);
                apply(true, _dataSource.FormatSyncLineStyle && _dataSource.FormatIncludeLineWeight,
                      () => shape.Line.Weight = _dataSource.FormatLineWeight);
                apply(true, _dataSource.FormatSyncLineStyle && _dataSource.FormatIncludeLineDashStyle,
                      () => shape.Line.DashStyle = _dataSource.FormatLineDashStyle);

                // Sync Fill Style
                apply(true, _dataSource.FormatSyncFillStyle && _dataSource.FormatIncludeHasFill,
                      () => shape.Fill.Visible = _dataSource.FormatHasFill ? MsoTriState.msoTrue : MsoTriState.msoFalse);
                apply(true, _dataSource.FormatSyncFillStyle && _dataSource.FormatIncludeFillColor,
                      () => shape.Fill.ForeColor.RGB = _dataSource.FormatFillColor);

                // Sync Size
                apply(false, _dataSource.FormatSyncSize && _dataSource.FormatIncludeWidth,
                      () => shape.Width = _dataSource.FormatWidth);
                apply(false, _dataSource.FormatSyncSize && _dataSource.FormatIncludeHeight,
                      () => shape.Height = _dataSource.FormatHeight);
            }
        }