private static List <string> ApplyBlurEffectTextBox(Models.PowerPointSlide slide, string imageFile, PowerPoint.Shape textBox) { List <string> shapeNames = new List <string>(); shapeNames.Add(textBox.Name); textBox.ZOrder(Office.MsoZOrderCmd.msoBringToFront); textBox.Fill.Visible = Office.MsoTriState.msoFalse; textBox.Line.Visible = Office.MsoTriState.msoFalse; PowerPoint.Shape blurShape = slide.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, textBox.Left, textBox.Top, textBox.Width, textBox.Height); blurShape.Rotation = textBox.Rotation; Utils.ShapeUtil.MoveZToJustBehind(blurShape, textBox); CropToShape.FillInShapeWithImage(slide, imageFile, blurShape, isInPlace: true); shapeNames.Add(blurShape.Name); if (EffectsLabSettings.IsTintSelected) { PowerPoint.Shape overlayShape = GenerateOverlayShape(slide, blurShape); shapeNames.Add(overlayShape.Name); } // cannot group placeholders if (textBox.Type != Office.MsoShapeType.msoPlaceholder) { PowerPoint.ShapeRange subRange = slide.Shapes.Range(shapeNames.ToArray()); PowerPoint.Shape groupedShape = subRange.Group(); shapeNames.Clear(); shapeNames.Add(groupedShape.Name); } return(shapeNames); }
protected override void ExecuteAction(string ribbonId) { this.StartNewUndoEntry(); bool isButton = false; bool isCustom = ribbonId.Contains(EffectsLabText.BlurrinessCustom); int keywordIndex; if (ribbonId.Contains(CommonText.DynamicMenuButtonId)) { isButton = true; keywordIndex = ribbonId.IndexOf(CommonText.DynamicMenuButtonId); } else { keywordIndex = ribbonId.IndexOf(CommonText.DynamicMenuOptionId); } string feature = ribbonId.Substring(0, keywordIndex); Selection selection = this.GetCurrentSelection(); Models.PowerPointSlide slide = this.GetCurrentSlide(); if (isButton) { EffectsLabSettings.ShowBlurSettingsDialog(feature); this.GetRibbonUi().RefreshRibbonControl(feature + CommonText.DynamicMenuOptionId + EffectsLabText.BlurrinessCustom); } else { int startIndex = keywordIndex + CommonText.DynamicMenuOptionId.Length; int percentage = isCustom ? GetCustomPercentage(feature) : int.Parse(ribbonId.Substring(startIndex, ribbonId.Length - startIndex)); ExecuteBlurAction(feature, selection, slide, percentage); } }
public static PowerPoint.Shape GenerateOverlayShape(Models.PowerPointSlide slide, PowerPoint.Shape blurShape) { PowerPoint.Shape overlayShape = null; if (blurShape.Type == Office.MsoShapeType.msoPicture) { overlayShape = slide.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, blurShape.Left, blurShape.Top, blurShape.Width, blurShape.Height); overlayShape.Rotation = blurShape.Rotation; } else { overlayShape = EffectsLabUtil.DuplicateShapeInPlace(blurShape); } Utils.ShapeUtil.MoveZToJustInFront(overlayShape, blurShape); int rgb = Utils.GraphicsUtil.ConvertColorToRgb(Utils.StringUtil.GetColorFromHexValue(HexColor)); overlayShape.Fill.Solid(); overlayShape.Fill.ForeColor.RGB = rgb; overlayShape.Fill.Transparency = Transparency; overlayShape.Line.ForeColor.RGB = rgb; overlayShape.Line.Transparency = Transparency; overlayShape.Line.Visible = Office.MsoTriState.msoFalse; return(overlayShape); }
public static void ExecuteBlurBackground(Models.PowerPointSlide slide, PowerPoint.Selection selection, int percentage) { Models.PowerPointBgEffectSlide effectSlide = EffectsLabUtil.GenerateEffectSlide(slide, selection, false); if (effectSlide == null) { return; } effectSlide.BlurBackground(percentage, EffectsLabSettings.IsTintBackground); effectSlide.GetNativeSlide().Select(); }
public static PowerPoint.ShapeRange ExecuteBlurSelected(Models.PowerPointSlide slide, PowerPoint.Selection selection, int percentage) { if (!IsValidSelection(selection)) { return(null); } PowerPoint.ShapeRange range = BlurSelected(slide, selection, percentage); if (range != null) { range.Select(); } return(range); }
public static PowerPoint.ShapeRange BlurSelected(Models.PowerPointSlide slide, PowerPoint.Selection selection, int percentage) { var shapeRange = selection.ShapeRange; if (selection.HasChildShapeRange) { shapeRange = selection.ChildShapeRange; } try { var hasManyShapes = shapeRange.Count > 1; var shape = hasManyShapes ? shapeRange.Group() : shapeRange[1]; var left = shape.Left; var top = shape.Top; shapeRange.Cut(); Utils.GraphicsUtil.ExportSlide(slide, BlurPicture); BlurImage(BlurPicture, percentage); shapeRange = slide.Shapes.Paste(); shapeRange.Left = left; shapeRange.Top = top; if (hasManyShapes) { shapeRange = shapeRange.Ungroup(); } var ungroupedRange = EffectsLabUtil.UngroupAllShapeRange(slide, shapeRange); var shapeGroupNames = ApplyBlurEffect(slide, BlurPicture, ungroupedRange); var range = slide.Shapes.Range(shapeGroupNames.ToArray()); return(range); } catch (Exception e) { ActionFramework.Common.Log.Logger.LogException(e, "BlurSelectedEffect"); EffectsLabUtil.ShowErrorMessageBox(e.Message, e); return(null); } }
public static PowerPoint.ShapeRange BlurSelected(Models.PowerPointSlide slide, PowerPoint.Selection selection, int percentage) { PowerPoint.ShapeRange shapeRange = ShapeUtil.GetShapeRange(selection); try { bool hasManyShapes = shapeRange.Count > 1; PowerPoint.Shape shape = hasManyShapes ? shapeRange.Group() : shapeRange[1]; float left = shape.Left; float top = shape.Top; PPLClipboard.Instance.LockAndRelease(() => { shapeRange.Cut(); Utils.GraphicsUtil.ExportSlide(slide, BlurPicture); BlurImage(BlurPicture, percentage); shapeRange = slide.Shapes.Paste(); }); shapeRange.Left = left; shapeRange.Top = top; if (hasManyShapes) { shapeRange = shapeRange.Ungroup(); } PowerPoint.ShapeRange ungroupedRange = EffectsLabUtil.UngroupAllShapeRange(slide, shapeRange); List <string> shapeGroupNames = ApplyBlurEffect(slide, BlurPicture, ungroupedRange); PowerPoint.ShapeRange range = slide.Shapes.Range(shapeGroupNames.ToArray()); return(range); } catch (Exception e) { ActionFramework.Common.Log.Logger.LogException(e, "BlurSelectedEffect"); EffectsLabUtil.ShowErrorMessageBox(e.Message, e); return(null); } }
private void ExecuteBlurAction(string feature, Selection selection, Models.PowerPointSlide slide, int percentage) { switch (feature) { case EffectsLabText.BlurrinessFeatureSelected: EffectsLabBlur.ExecuteBlurSelected(slide, selection, percentage); break; case EffectsLabText.BlurrinessFeatureRemainder: EffectsLabBlur.ExecuteBlurRemainder(slide, selection, percentage); break; case EffectsLabText.BlurrinessFeatureBackground: EffectsLabBlur.ExecuteBlurBackground(slide, selection, percentage); break; default: Logger.Log(feature + " does not exist!", Common.Logger.LogType.Error); break; } }
protected override void ExecuteAction(string ribbonId) { var isButton = false; int keywordIndex; if (ribbonId.Contains(TextCollection.DynamicMenuButtonId)) { isButton = true; keywordIndex = ribbonId.IndexOf(TextCollection.DynamicMenuButtonId); feature = ribbonId.Substring(0, keywordIndex); } else { keywordIndex = ribbonId.IndexOf(TextCollection.DynamicMenuOptionId); feature = ribbonId.Substring(0, keywordIndex); } selection = this.GetCurrentSelection(); slide = this.GetCurrentSlide(); if (isButton) { if (!IsValidSelection()) { return; } var dialog = new EffectsLab.View.EffectsLabBlurrinessDialogBox(feature); dialog.SettingsHandler += PropertiesEdited; dialog.ShowDialog(); } else { var startIndex = keywordIndex + TextCollection.DynamicMenuOptionId.Length; var percentage = int.Parse(ribbonId.Substring(startIndex, ribbonId.Length - startIndex)); ExecuteBlurAction(percentage); } }
private static List <string> ApplyBlurEffect(Models.PowerPointSlide slide, string imageFile, PowerPoint.ShapeRange shapeRange) { List <string> shapeGroupNames = new List <string>(); for (int i = 0; i < shapeRange.Count; i++) { PowerPoint.Shape shape = shapeRange[i + 1]; if (shape.Type == Office.MsoShapeType.msoPlaceholder || shape.Type == Office.MsoShapeType.msoTextBox) { List <string> shapeNames = ApplyBlurEffectTextBox(slide, imageFile, shape); shapeGroupNames.AddRange(shapeNames); } else // if (shape.Type == Office.MsoShapeType.msoAutoShape || shape.Type == Office.MsoShapeType.msoFreeform) { string shapeName = ApplyBlurEffectShape(slide, imageFile, shape); shapeGroupNames.Add(shapeName); } } return(shapeGroupNames); }
private static string ApplyBlurEffectShape(Models.PowerPointSlide slide, string imageFile, PowerPoint.Shape shape) { List <string> shapeNames = new List <string>(); shapeNames.Add(shape.Name); if (!string.IsNullOrWhiteSpace(shape.TextFrame2.TextRange.Text)) { shape.ZOrder(Office.MsoZOrderCmd.msoBringToFront); PowerPoint.Shape textBox = EffectsLabUtil.DuplicateShapeInPlace(shape); textBox.Fill.Visible = Office.MsoTriState.msoFalse; textBox.Line.Visible = Office.MsoTriState.msoFalse; Utils.ShapeUtil.MoveZToJustInFront(textBox, shape); shapeNames.Add(textBox.Name); } shape.TextFrame2.DeleteText(); CropToShape.FillInShapeWithImage(slide, imageFile, shape, isInPlace: true); if (EffectsLabSettings.IsTintSelected) { PowerPoint.Shape overlayShape = GenerateOverlayShape(slide, shape); shapeNames.Add(overlayShape.Name); } if (shapeNames.Count > 1) { PowerPoint.ShapeRange subRange = slide.Shapes.Range(shapeNames.ToArray()); PowerPoint.Shape groupedShape = subRange.Group(); return(groupedShape.Name); } return(shapeNames[0]); }
private void ExecuteBlurAction(string feature, Selection selection, Models.PowerPointPresentation pres, Models.PowerPointSlide slide, int percentage) { ClipboardUtil.RestoreClipboardAfterAction(() => { switch (feature) { case EffectsLabText.BlurrinessFeatureSelected: EffectsLabBlur.ExecuteBlurSelected(slide, selection, percentage); break; case EffectsLabText.BlurrinessFeatureRemainder: EffectsLabBlur.ExecuteBlurRemainder(slide, selection, percentage); break; case EffectsLabText.BlurrinessFeatureBackground: EffectsLabBlur.ExecuteBlurBackground(slide, selection, percentage); break; default: Logger.Log(feature + " does not exist!", Common.Logger.LogType.Error); break; } return(ClipboardUtil.ClipboardRestoreSuccess); }, pres, slide); }