private static bool Sync(Shape formatShape, Shape newShape) { try { PictureEffects dest = newShape.Fill.PictureEffects; PictureEffects source = formatShape.Fill.PictureEffects; // clear current effects for (int i = 1; i <= dest.Count; i++) { dest.Delete(i); } // add new effects for (int i = 1; i <= source.Count; i++) { PictureEffect effect = source[i]; dest.Insert(effect.Type, i); } } catch (Exception) { return(false); } return(true); }
public static void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync PictureEffect Format"); } }
public override void SyncFormat(Shape formatShape, Shape newShape) { ShadowFormat srcFormat = formatShape.Shadow; ShadowFormat destFormat = newShape.Shadow; destFormat.Visible = srcFormat.Visible; if (srcFormat.Type != MsoShadowType.msoShadowMixed) { destFormat.Type = srcFormat.Type; // only set ForeColor manually, // setting non-mixed types automatically sets other shadow settings to the shape destFormat.ForeColor = srcFormat.ForeColor; } else { // setting Type to MixedType throws an error, skip it // MixedType requires manual configuration of each shadow setting // we are unable to figure out of a shape has a custom perspective shadow or custom outer shadow // see MightHaveCustomPerspectiveShadow(..) for more information // setting style sets RotateWithShape, skip RotateWithShape // setting style sets Obscured, skip Obscured destFormat.Style = srcFormat.Style; destFormat.ForeColor = srcFormat.ForeColor; destFormat.Blur = srcFormat.Blur; destFormat.OffsetX = srcFormat.OffsetX; destFormat.OffsetY = srcFormat.OffsetY; destFormat.Size = srcFormat.Size; destFormat.Transparency = srcFormat.Transparency; } }
public void ApplyFrostedGlassTextBoxEffect(string overlayColor, int transparency, Shape blurImage, int fontSizeToIncrease) { var shape = ShapeUtil.GetTextShapeToProcess(Shapes); if (shape == null) return; var margin = CalculateTextBoxMargin(fontSizeToIncrease); // multiple paragraphs.. foreach (TextRange2 textRange in shape.TextFrame2.TextRange.Paragraphs) { if (StringUtil.IsNotEmpty(textRange.TrimText().Text)) { var paragraph = textRange.TrimText(); var left = paragraph.BoundLeft - margin; var top = paragraph.BoundTop - margin; var width = paragraph.BoundWidth + margin * 2; var height = paragraph.BoundHeight + margin * 2; var blurTextBox = blurImage.Duplicate()[1]; blurTextBox.Left = blurImage.Left; blurTextBox.Top = blurImage.Top; CropPicture(blurTextBox, left, top, width, height); ChangeName(blurTextBox, EffectName.TextBox); var overlayShape = ApplyOverlayEffect(overlayColor, transparency, left, top, width, height); ChangeName(overlayShape, EffectName.TextBox); Graphics.MoveZToJustBehind(blurTextBox, shape); Graphics.MoveZToJustBehind(overlayShape, shape); } } }
public override Bitmap DisplayImage(Shape formatShape) { return(SyncFormatUtil.GetTextDisplay( $"{formatShape.ThreeD.LightAngle}{SyncFormatConstants.DisplayDegreeSymbol}", SyncFormatConstants.DisplayImageFont, SyncFormatConstants.DisplayImageSize)); }
public override void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync ArtisticEffect Format"); } }
public override Bitmap DisplayImage(Shape formatShape) { Shapes shapes = SyncFormatUtil.GetTemplateShapes(); Shape shape = shapes.AddShape( MsoAutoShapeType.msoShapeRectangle, 0, 0, SyncFormatConstants.DisplayImageSize.Width, SyncFormatConstants.DisplayImageSize.Height); shape.Line.Visible = MsoTriState.msoFalse; shape.ThreeD.Depth = SyncFormatConstants.DisplayImageDepth; shape.ThreeD.BevelTopType = SyncFormatConstants.DisplayBevelType; shape.ThreeD.BevelTopDepth = SyncFormatConstants.DisplayBevelHeight; shape.ThreeD.BevelTopInset = SyncFormatConstants.DisplayBevelWidth; shape.ThreeD.BevelBottomType = SyncFormatConstants.DisplayBevelType; shape.ThreeD.BevelBottomDepth = SyncFormatConstants.DisplayBevelHeight; shape.ThreeD.BevelBottomInset = SyncFormatConstants.DisplayBevelWidth; // setting mixed throws an exception if (formatShape.ThreeD.PresetLighting != MsoLightRigType.msoLightRigMixed) { shape.ThreeD.PresetLighting = formatShape.ThreeD.PresetLighting; } shape.ThreeD.SetPresetCamera(SyncFormatConstants.DisplayCameraPreset); Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape)); shape.Delete(); return(image); }
private static bool Sync(Shape formatShape, Shape newShape) { ThreeDFormat source = formatShape.ThreeD; ThreeDFormat dest = newShape.ThreeD; try { // set lighting manually if type Mixed, setting type to Mixed throws an exception if (source.PresetLighting == MsoLightRigType.msoLightRigMixed) { dest.PresetLightingDirection = source.PresetLightingDirection; dest.PresetLightingSoftness = source.PresetLightingSoftness; } else { // set lighting preset if not type Mixed dest.PresetLighting = source.PresetLighting; } return(true); } catch (Exception e) { Logger.LogException(e, "Sync LightingEffectFormat"); return(false); } }
public SyncFormatDialog(Shape shape, string formatName, FormatTreeNode[] formats) { InitializeComponent(); this.shape = shape; formatName = formatName.Trim(); if (SyncFormatUtil.IsValidFormatName(formatName)) { originalName = formatName; } else { originalName = SyncLabText.DefaultFormatName; } originalName = formatName; ObjectName = originalName; this.Formats = formats; foreach (FormatTreeNode format in formats) { Object treeItem = DialogItemFromFormatTree(shape, format); if (treeItem != null) { treeView.Items.Add(treeItem); } } ScrollToTop(); }
public static void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync Font Color"); } }
public override void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync ContourColor Format"); } }
private static bool Sync(Shape formatShape, Shape newShape) { ThreeDFormat source = formatShape.ThreeD; ThreeDFormat dest = newShape.ThreeD; try { // don't set type if type is TypeMixed, it throws an exception if (source.ExtrusionColorType != MsoExtrusionColorType.msoExtrusionColorTypeMixed) { dest.ExtrusionColorType = source.ExtrusionColorType; } if (source.ExtrusionColorType != MsoExtrusionColorType.msoExtrusionColorAutomatic) { // do not set SchemeColor & Brightness, setting them throws exceptions dest.ExtrusionColor.ObjectThemeColor = source.ExtrusionColor.ObjectThemeColor; dest.ExtrusionColor.RGB = source.ExtrusionColor.RGB; dest.ExtrusionColor.TintAndShade = source.ExtrusionColor.TintAndShade; } return(true); } catch { return(false); } }
public override Bitmap DisplayImage(Shape formatShape) { return(SyncFormatUtil.GetTextDisplay( Math.Round(formatShape.Glow.Transparency * 100).ToString() + "%", SyncFormatConstants.DisplayImageFont, SyncFormatConstants.DisplayImageSize)); }
public override void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync GlowTransparency Format"); } }
private static void CreateRotatedFillInBackground(Shape shape, Bitmap slideImage, double magnifyRatio = 1.0) { PPShape rotatedShape = new PPShape(shape, false); PointF topLeftPoint = new PointF(rotatedShape.ActualTopLeft.X * GraphicsUtil.PictureExportingRatio, rotatedShape.ActualTopLeft.Y * GraphicsUtil.PictureExportingRatio); Bitmap rotatedImage = new Bitmap(slideImage.Width, slideImage.Height); using (Graphics g = Graphics.FromImage(rotatedImage)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; using (System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix()) { mat.Translate(-topLeftPoint.X, -topLeftPoint.Y); mat.RotateAt(-shape.Rotation, topLeftPoint); g.Transform = mat; g.DrawImage(slideImage, new Rectangle(0, 0, slideImage.Width, slideImage.Height)); } } Bitmap magnifiedImage = KiCut(rotatedImage, 0, 0, shape.Width * GraphicsUtil.PictureExportingRatio, shape.Height * GraphicsUtil.PictureExportingRatio, magnifyRatio); magnifiedImage.Save(FillInBackgroundPicture, ImageFormat.Png); }
public override bool CanCopy(Shape formatShape) { SoftEdgeFormat softEdge = formatShape.SoftEdge; // do not check softEdge.Type, it can sometimes == msoSoftEdgeTypeNone when there is a soft edge return(softEdge.Radius > 0); }
public void ApplyTextboxEffect(string overlayColor, int transparency, int fontSizeToIncrease) { Microsoft.Office.Interop.PowerPoint.Shape shape = Util.ShapeUtil.GetTextShapeToProcess(Shapes); if (shape == null) { return; } int margin = CalculateTextBoxMargin(fontSizeToIncrease); // multiple paragraphs.. foreach (TextRange2 textRange in shape.TextFrame2.TextRange.Paragraphs) { if (StringUtil.IsNotEmpty(textRange.TrimText().Text)) { TextRange2 paragraph = textRange.TrimText(); float left = paragraph.BoundLeft - margin; float top = paragraph.BoundTop - margin; float width = paragraph.BoundWidth + margin * 2; float height = paragraph.BoundHeight + margin * 2; Microsoft.Office.Interop.PowerPoint.Shape overlayShape = ApplyOverlayEffect(overlayColor, transparency, left, top, width, height); ChangeName(overlayShape, EffectName.TextBox); Utils.ShapeUtil.MoveZToJustBehind(overlayShape, shape); } } }
public override Bitmap DisplayImage(Shape formatShape) { Shapes shapes = SyncFormatUtil.GetTemplateShapes(); Shape shape = shapes.AddShape( MsoAutoShapeType.msoShapeRectangle, 0, 0, SyncFormatConstants.DisplayImageSize.Width, SyncFormatConstants.DisplayImageSize.Height); shape.Line.Visible = MsoTriState.msoFalse; shape.ThreeD.Depth = SyncFormatConstants.DisplayImageDepth; // don't set type if type is TypeMixed, it throws an exception if (formatShape.ThreeD.BevelTopType != MsoBevelType.msoBevelTypeMixed) { shape.ThreeD.BevelTopType = formatShape.ThreeD.BevelTopType; // set depth & inset only if type is not none, // adjusting these 2 will automatically set type from None to Round if (shape.ThreeD.BevelTopType != MsoBevelType.msoBevelNone) { shape.ThreeD.BevelTopDepth = SyncFormatConstants.DisplayBevelHeight; shape.ThreeD.BevelTopInset = SyncFormatConstants.DisplayBevelWidth; } } shape.ThreeD.BevelBottomType = MsoBevelType.msoBevelNone; shape.ThreeD.SetPresetCamera(MsoPresetCamera.msoCameraPerspectiveAbove); shape.ThreeD.PresetLighting = MsoLightRigType.msoLightRigBalanced; Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape)); shape.Delete(); return(image); }
private static bool Sync(Shape formatShape, Shape newShape) { ThreeDFormat source = formatShape.ThreeD; ThreeDFormat dest = newShape.ThreeD; try { // don't set type if type is TypeMixed, it throws an exception if (source.BevelTopType != MsoBevelType.msoBevelTypeMixed) { dest.BevelTopType = source.BevelTopType; // set depth & inset only if type is not none, // adjusting these 2 will automatically set type from None to Round if (source.BevelTopType != MsoBevelType.msoBevelNone) { // set the settings anyway, setting the type alone is insufficient dest.BevelTopDepth = source.BevelTopDepth; dest.BevelTopInset = source.BevelTopInset; } } return(true); } catch { return(false); } }
public override void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync BevelTop Format"); } }
private static bool Sync(Shape formatShape, Shape newShape) { try { GlowFormat dest = newShape.Glow; GlowFormat source = formatShape.Glow; // Color.SchemeColor must be skipped, setting it sometimes throws an exception for unknown reasons. // Color.ObjectThemeColor must be set despite the unrelated description in documentation. // The color intensity of glow will not match otherwise // syncing NotThemeColor throws an exception if (source.Color.ObjectThemeColor != MsoThemeColorIndex.msoNotThemeColor) { dest.Color.ObjectThemeColor = source.Color.ObjectThemeColor; } dest.Color.RGB = source.Color.RGB; dest.Color.Brightness = source.Color.Brightness; dest.Color.TintAndShade = source.Color.TintAndShade; } catch (Exception) { return(false); } return(true); }
public static Bitmap DisplayImage(Shape formatShape) { return(SyncFormatUtil.GetTextDisplay( Math.Round(formatShape.Width).ToString(), SyncFormatConstants.DisplayImageFont, SyncFormatConstants.DisplayImageSize)); }
public override Bitmap DisplayImage(Shape formatShape) { return(SyncFormatUtil.GetTextDisplay( Math.Round(formatShape.Height).ToString(), SyncFormatConstants.DisplayImageFont, SyncFormatConstants.DisplayImageSize)); }
private static bool Sync(Shape formatShape, Shape newShape) { ThreeDFormat source = formatShape.ThreeD; ThreeDFormat dest = newShape.ThreeD; try { if (HasErrorneousDepth(formatShape) && HasErrorneousDepth(newShape)) { // both have no 3d settings, do nothing // setting depth here changes the color of the shape slightly for unknown reasons // we cannot revert this change return(true); } float depth = source.Depth; if (HasErrorneousDepth(formatShape)) { // fresh shapes actually have 0 depth depth = 0f; } dest.Depth = depth; return(true); } catch { return(false); } }
public override void SyncFormat(Shape formatShape, Shape newShape) { if (!Sync(formatShape, newShape)) { Logger.Log(newShape.Type + " unable to sync ReflectionDistance format"); } }
private static bool Sync(Shape formatShape, Shape newShape) { ThreeDFormat source = formatShape.ThreeD; ThreeDFormat dest = newShape.ThreeD; try { // setting Mixed throws an exception // the user is unable to set Mixed type manually // it seems to be reserved for shapes that have all 3d settings set to default // show Flat type instead, which looks very similar if (source.PresetMaterial == MsoPresetMaterial.msoPresetMaterialMixed) { dest.PresetMaterial = MsoPresetMaterial.msoMaterialFlat; } else { dest.PresetMaterial = source.PresetMaterial; } return(true); } catch { return(false); } }
public override Bitmap DisplayImage(Shape formatShape) { return(SyncFormatUtil.GetTextDisplay( Math.Round(formatShape.Reflection.Size, 1).ToString() + "%", SyncFormatConstants.DisplayImageFont, SyncFormatConstants.DisplayImageSize)); }
public override Bitmap DisplayImage(Shape formatShape) { Shapes shapes = SyncFormatUtil.GetTemplateShapes(); Shape shape = shapes.AddShape( MsoAutoShapeType.msoShapeRectangle, 0, 0, SyncFormatConstants.DisplayImageSize.Width, SyncFormatConstants.DisplayImageSize.Height); shape.Line.Visible = MsoTriState.msoFalse; shape.ThreeD.Depth = SyncFormatConstants.DisplayImageDepth; shape.ThreeD.BevelTopType = SyncFormatConstants.DisplayBevelType; shape.ThreeD.BevelTopDepth = SyncFormatConstants.DisplayBevelHeight; shape.ThreeD.BevelTopInset = SyncFormatConstants.DisplayBevelWidth; shape.ThreeD.BevelBottomType = SyncFormatConstants.DisplayBevelType; shape.ThreeD.BevelBottomDepth = SyncFormatConstants.DisplayBevelHeight; shape.ThreeD.BevelBottomInset = SyncFormatConstants.DisplayBevelWidth; // setting mixed throws an exception // show flat type instead, which looks very similar if (formatShape.ThreeD.PresetMaterial == MsoPresetMaterial.msoPresetMaterialMixed) { shape.ThreeD.PresetMaterial = MsoPresetMaterial.msoMaterialFlat; } else { shape.ThreeD.PresetMaterial = formatShape.ThreeD.PresetMaterial; } shape.ThreeD.SetPresetCamera(SyncFormatConstants.DisplayCameraPreset); Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape)); shape.Delete(); return(image); }
public override Bitmap DisplayImage(Shape formatShape) { return(SyncFormatUtil.GetTextDisplay( $"{Math.Round(formatShape.ThreeD.ContourWidth, 1)} {SyncFormatConstants.DisplaySizeUnit}", SyncFormatConstants.DisplayImageFont, SyncFormatConstants.DisplayImageSize)); }
public void CropMultipleShapesSuccessfully() { Microsoft.Office.Interop.PowerPoint.Slide actualSlide = PpOperations.SelectSlide(7); Microsoft.Office.Interop.PowerPoint.ShapeRange shapesBeforeCrop = PpOperations.SelectShapesByPrefix("selectMe"); Assert.AreEqual(6, shapesBeforeCrop.Count); // Execute the Crop To Shape feature PplFeatures.AutoCrop(); // the result shape after crop multiple shapes will have name starts with // Group Microsoft.Office.Interop.PowerPoint.Shape resultShape = PpOperations.SelectShapesByPrefix("Group")[1]; System.IO.FileInfo resultShapeInPic = PpOperations.ExportSelectedShapes(); Microsoft.Office.Interop.PowerPoint.Slide expSlide = PpOperations.SelectSlide(8); Microsoft.Office.Interop.PowerPoint.Shape expShape = PpOperations.SelectShapesByPrefix("Group")[1]; System.IO.FileInfo expShapeInPic = PpOperations.ExportSelectedShapes(); // remove elements that affect comparing slides // e.g. "Expected" textbox PpOperations.SelectShapesByPrefix("text").Delete(); SlideUtil.IsSameLooking(expShape, expShapeInPic, resultShape, resultShapeInPic); SlideUtil.IsSameLooking(expSlide, actualSlide); }
public static bool IsNormalShape(this Shape shape) { return(shape.Type == MsoShapeType.msoAutoShape || shape.Type == MsoShapeType.msoLine || shape.Type == MsoShapeType.msoPicture || shape.Type == MsoShapeType.msoTextBox); }
public void ApplyFrostedGlassTextBoxEffect(string overlayColor, int transparency, Shape blurImage) { foreach (Shape shape in Shapes) { if ((shape.Type != MsoShapeType.msoPlaceholder && shape.Type != MsoShapeType.msoTextBox) || shape.TextFrame.HasText == MsoTriState.msoFalse || StringUtil.IsNotEmpty(shape.Tags[Tag.AddedTextbox]) || StringUtil.IsNotEmpty(shape.Tags[Tag.ImageReference])) { continue; } // multiple paragraphs.. foreach (TextRange2 textRange in shape.TextFrame2.TextRange.Paragraphs) { if (StringUtil.IsNotEmpty(textRange.TrimText().Text)) { var paragraph = textRange.TrimText(); var left = paragraph.BoundLeft - 10; var top = paragraph.BoundTop - 10; var width = paragraph.BoundWidth + 20; var height = paragraph.BoundHeight + 20; blurImage.Copy(); var blurTextBox = Shapes.Paste()[1]; blurTextBox.Left = blurImage.Left; blurTextBox.Top = blurImage.Top; CropPicture(blurTextBox, left, top, width, height); ChangeName(blurTextBox, EffectName.TextBox); var overlayShape = ApplyOverlayEffect(overlayColor, transparency, left, top, width, height); ChangeName(overlayShape, EffectName.TextBox); Graphics.MoveZToJustBehind(blurTextBox, shape); Graphics.MoveZToJustBehind(overlayShape, shape); shape.Tags.Add(Tag.AddedTextbox, overlayShape.Name); } } } foreach (Shape shape in Shapes) { shape.Tags.Add(Tag.AddedTextbox, ""); } }
public PivotAroundToolDialog(Shape sourceShape, Shape pivotShape) { _sourceLeft = sourceShape.Left; _sourceTop = sourceShape.Top; _sourceRight = sourceShape.Left + sourceShape.Width; _sourceBottom = sourceShape.Top + sourceShape.Height; _sourceRotation = sourceShape.Rotation; _pivotLeft = pivotShape.Left; _pivotTop = pivotShape.Top; _pivotRight = pivotShape.Left + pivotShape.Width; _pivotBottom = pivotShape.Top + pivotShape.Height; InitializeComponent(); InitialiseDataSource(); SetDefaultAngle(); dataSource.PropertyChanged += OnPropertyChanged; }
public Shape ApplyFrostedGlassBannerEffect(BannerDirection direction, Position textPos, Shape blurImage, string overlayColor, int transparency) { var tbInfo = new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight) .GetTextBoxesInfo(); if (tbInfo == null) return null; TextBoxes.AddMargin(tbInfo); Shape overlayShape; blurImage.Copy(); Shape blurBanner = Shapes.Paste()[1]; blurBanner.Left = blurImage.Left; blurBanner.Top = blurImage.Top; direction = HandleAutoDirection(direction, textPos); switch (direction) { case BannerDirection.Horizontal: overlayShape = ApplyOverlayEffect(overlayColor, transparency, 0, tbInfo.Top, SlideWidth, tbInfo.Height); CropPicture(blurBanner, 0, tbInfo.Top, SlideWidth, tbInfo.Height); break; // case BannerDirection.Vertical: default: overlayShape = ApplyOverlayEffect(overlayColor, transparency, tbInfo.Left, 0, tbInfo.Width, SlideHeight); CropPicture(blurBanner, tbInfo.Left, 0, tbInfo.Width, SlideHeight); break; } ChangeName(overlayShape, EffectName.Banner); ChangeName(blurBanner, EffectName.Banner); overlayShape.ZOrder(MsoZOrderCmd.msoSendToBack); Graphics.MoveZToJustBehind(blurBanner, overlayShape); var range = Shapes.Range(new[] {blurBanner.Name, overlayShape.Name}); var resultShape = range.Group(); ChangeName(resultShape, EffectName.Banner); return resultShape; }
private void AdjustShapeLeft(Shape textShape, TextBoxInfo boxesInfo, TextBoxInfo singleBoxInfo) { ShapeUtil.AddTag(textShape, Tag.OriginalShapeLeft, textShape.Left.ToString(CultureInfo.InvariantCulture)); switch (_align) { case Alignment.Left: textShape.Left = _left + textShape.Left - (singleBoxInfo.Left - 0f); break; case Alignment.Centre: textShape.Left = _left + textShape.Left - (singleBoxInfo.Left - (boxesInfo.Width/2 - singleBoxInfo.Width/2)); break; case Alignment.Right: textShape.Left = _left + textShape.Left - (singleBoxInfo.Left - (boxesInfo.Width - singleBoxInfo.Width)); break; } }
private static void SnapTo0Or180(Shape shape) { var rotation = shape.Rotation; if (rotation >= 90 && rotation < 270) { shape.Rotation = 180; } else { shape.Rotation = 0; } }
public static void SnapShapeHorizontal(Shape shape) { if (IsVertical(shape)) { SnapTo90Or270(shape); } else { SnapTo0Or180(shape); } }
private static bool IsVertical(Shape shape) { var shapeIsVertical = shape.Height > shape.Width; if (NearlyEqual(shape.Height, shape.Width, Epsilon)) { float defaultUpAngle = 0; var hasDefaultDirection = shapeDefaultUpAngle.TryGetValue(shape.AutoShapeType, out defaultUpAngle); if (hasDefaultDirection) { if (NearlyEqual(defaultUpAngle, 0.0f, Epsilon) || NearlyEqual(defaultUpAngle, 180.0f, Epsilon)) { shapeIsVertical = true; } else { shapeIsVertical = false; } } } return shapeIsVertical; }
private static void SnapTo90Or270(Shape shape) { var rotation = shape.Rotation; if (rotation >= 0 && rotation < 180) { shape.Rotation = 90; } else { shape.Rotation = 270; } }
private static int GetDirectionWrtRefShape(Shape shape, float angleFromRefShape) { float defaultUpAngle; var hasDefaultDirection = shapeDefaultUpAngle.TryGetValue(shape.AutoShapeType, out defaultUpAngle); if (!hasDefaultDirection) { if (IsVertical(shape)) { defaultUpAngle = 0; } else { defaultUpAngle = 90; } } var angle = AddAngles(angleFromRefShape, defaultUpAngle); var diff = SubtractAngles(shape.Rotation, angle); var phaseInFloat = diff/90; if (!NearlyEqual(phaseInFloat, (float) Math.Round(phaseInFloat), Epsilon)) { return None; } var phase = (int) Math.Round(phaseInFloat); return phase % 4; }
private void AdjustShapeTop(Shape textShape, TextBoxInfo singleBoxInfo, float accumulatedHeight) { textShape.Top = _top + textShape.Top - (singleBoxInfo.Top - accumulatedHeight); }
private void AdjustShapeLeft(Shape textShape, TextBoxInfo boxesInfo, TextBoxInfo singleBoxInfo) { switch (_align) { case Alignment.Left: textShape.Left = _left + textShape.Left - (singleBoxInfo.Left - 0f); break; case Alignment.Centre: textShape.Left = _left + textShape.Left - (singleBoxInfo.Left - (boxesInfo.Width/2 - singleBoxInfo.Width/2)); break; case Alignment.Right: textShape.Left = _left + textShape.Left - (singleBoxInfo.Left - (boxesInfo.Width - singleBoxInfo.Width)); break; } }
private void AdjustShapeTop(Shape textShape, TextBoxInfo singleBoxInfo, float accumulatedHeight) { ShapeUtil.AddTag(textShape, Tag.OriginalShapeTop, textShape.Top.ToString(CultureInfo.InvariantCulture)); textShape.Top = _top + textShape.Top - (singleBoxInfo.Top - accumulatedHeight); }
private TextBoxInfo GetTextBoxInfo(Shape textShape) { var result = new TextBoxInfo(); var paragraphs = textShape.TextFrame2.TextRange.Paragraphs; var rightMost = 0f; var bottomMost = 0f; foreach (TextRange2 textRange in paragraphs) { var paragraph = textRange.TrimText(); if (StringUtil.IsNotEmpty(paragraph.Text)) { result.Left = paragraph.BoundLeft < result.Left ? paragraph.BoundLeft : result.Left; result.Top = paragraph.BoundTop < result.Top ? paragraph.BoundTop : result.Top; rightMost = paragraph.BoundLeft + paragraph.BoundWidth > rightMost ? paragraph.BoundLeft + paragraph.BoundWidth : rightMost; bottomMost = paragraph.BoundTop + paragraph.BoundHeight > bottomMost ? paragraph.BoundTop + paragraph.BoundHeight : bottomMost; } } result.Width = rightMost - result.Left; result.Height = bottomMost - result.Top; AddMargin(result, ExtendMargin); return result; }