/// <summary>
        /// Retrieves selected shapes or text.
        /// </summary>
        private void SelectShapes()
        {
            try
            {
                PowerPoint.Selection selection = this.GetCurrentSelection();
                if (selection == null)
                {
                    return;
                }

                if (selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
                {
                    _selectedShapes = ShapeUtil.GetShapeRange(selection);
                }
                else if (selection.Type == PowerPoint.PpSelectionType.ppSelectionText)
                {
                    _selectedText = selection.TextRange;
                }
                else
                {
                    _selectedShapes = null;
                    _selectedText   = null;
                }
            }
            catch (Exception)
            {
                _selectedShapes = null;
                _selectedText   = null;
            }
        }
示例#2
0
        public PaintServer Parse(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            if (value == "none")
            {
                return(null);
            }
            if (value[0] == '#')
            {
                return(this.ParseSolidColor(value));
            }
            PaintServer result = null;

            if (this.m_servers.TryGetValue(value, out result))
            {
                return(result);
            }
            if (value.StartsWith("url"))
            {
                string id = ShapeUtil.ExtractBetween(value, '(', ')');
                if (id.Length > 0 && id[0] == '#')
                {
                    id = id.Substring(1);
                }
                this.m_servers.TryGetValue(id, out result);
                return(result);
            }
            return(this.ParseKnownColor(value));
        }
        public static void Execute(PowerPointPresentation pres, PowerPointSlide slide, ShapeRange pastingShapes, float slideWidth, float slideHeight)
        {
            pastingShapes = ShapeUtil.GetShapesWhenTypeNotMatches(slide, pastingShapes, Microsoft.Office.Core.MsoShapeType.msoPlaceholder);
            if (pastingShapes.Count == 0)
            {
                return;
            }

            Shape pastingShape = pastingShapes[1];

            if (pastingShapes.Count > 1)
            {
                pastingShape = pastingShapes.Group();
            }

            // Temporary house the latest clipboard shapes
            ShapeRange origClipboardShapes = ClipboardUtil.PasteShapesFromClipboard(pres, slide);
            // Compression of large image(s)
            Shape shapeToFitSlide = GraphicsUtil.CompressImageInShape(pastingShape, slide);

            // Bring the same original shapes back into clipboard, preserving original size
            origClipboardShapes.Cut();

            shapeToFitSlide.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue;

            PPShape ppShapeToFitSlide = new PPShape(shapeToFitSlide);

            ResizeShape(ppShapeToFitSlide, slideWidth, slideHeight);
            ppShapeToFitSlide.VisualCenter = new System.Drawing.PointF(slideWidth / 2, slideHeight / 2);
        }
        public static ShapeRange Execute(PowerPointPresentation presentation, PowerPointSlide slide,
                                         ShapeRange pastingShapes, float positionX, float positionY)
        {
            if (pastingShapes.Count > 1)
            {
                // Get Left and Top of pasting shapes as a group
                float pastingGroupLeft = int.MaxValue;
                float pastingGroupTop  = int.MaxValue;
                foreach (Shape shape in pastingShapes)
                {
                    pastingGroupLeft = Math.Min(shape.Left, pastingGroupLeft);
                    pastingGroupTop  = Math.Min(shape.Top, pastingGroupTop);
                }

                foreach (Shape shape in pastingShapes)
                {
                    if (ShapeUtil.IsAChild(shape))
                    {
                        continue;
                    }
                    shape.IncrementLeft(positionX - pastingGroupLeft);
                    shape.IncrementTop(positionY - pastingGroupTop);
                }
            }
            else
            {
                pastingShapes[1].Left = positionX;
                pastingShapes[1].Top  = positionY;
            }

            return(pastingShapes);
        }
示例#5
0
        protected override bool GetEnabled(string ribbonId)
        {
            Selection currentSelection = this.GetCurrentSelection();

            return(ShapeUtil.IsSelectionSingleShape(currentSelection) &&
                   ShapeUtil.IsSelectionAllRectangle(currentSelection));
        }
示例#6
0
        public void OnUpdate(float dt)
        {
            snap1 = snap2;
            snap2 = new WeatherSnapshot()
            {
                hoursTotal = world.Calendar.TotalHours
            };

            IPlayer[] players;

            if (world is IClientWorldAccessor)
            {
                players = new IPlayer[] { ((IClientWorldAccessor)world).Player };
            }
            else
            {
                players = world.AllOnlinePlayers;
            }

            for (int i = 0; i < players.Length; i++)
            {
                int     viewdistance = players[i].WorldData.LastApprovedViewDistance;
                int     chunksize    = world.BlockAccessor.ChunkSize;
                int     chunkRadius  = (int)Math.Ceiling((float)viewdistance / chunksize) + 1;
                Vec2i[] points       = ShapeUtil.GetOctagonPoints(
                    (int)players[i].Entity.Pos.X / chunksize,
                    (int)players[i].Entity.Pos.Z / chunksize,
                    chunkRadius
                    );

                GenWeatherForPoints(points, snap2);
            }
        }
        protected override void ExecuteAction(string ribbonId)
        {
            Selection  selection      = this.GetCurrentSelection();
            ShapeRange selectedShapes = ShapeUtil.GetShapeRange(selection);

            selectedShapes.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
        }
        public void TestCopyPicture()
        {
            Shape picture = GetShape(PicturePlaceholderSlide, Picture);
            Shape copy    = ShapeUtil.CopyMsoPlaceHolder(new Format[0], picture, _templateShapes);

            Assert.AreEqual(copy, null);
        }
        protected override void ExecuteAction(string ribbonId)
        {
            this.StartNewUndoEntry();

            IMessageService     cropLabMessageService = MessageServiceFactory.GetCropLabMessageService();
            CropLabErrorHandler errorHandler          = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService);

            if (!ShapeUtil.IsSelectionShape(this.GetCurrentSelection()))
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShape, 1, errorHandler);
                return;
            }
            ShapeRange shapeRange = this.GetCurrentSelection().ShapeRange;

            if (shapeRange.Count < 1)
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShape, 1, errorHandler);
                return;
            }
            if (!ShapeUtil.IsAllShape(shapeRange))
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBeShape, FeatureName, errorHandler);
                return;
            }
            try
            {
                CropToShape.Crop(this.GetCurrentSlide(), this.GetCurrentSelection());
            }
            catch (CropLabException)
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeUndefined, FeatureName, errorHandler);
            }
        }
示例#10
0
        public Group(SVG svg, XmlNode node, Shape parent)
            : base(svg, node)
        {
            // parent on group must be set before children are added
            var clp = XmlUtil.AttrValue(node, "clip-path", null);

            if (!string.IsNullOrEmpty(clp))
            {
                Shape  result;
                string id = ShapeUtil.ExtractBetween(clp, '(', ')');
                if (id.Length > 0 && id[0] == '#')
                {
                    id = id.Substring(1);
                }
                svg.m_shapes.TryGetValue(id, out result);
                this.m_clip = result as Clip;
            }

            this.Parent = parent;
            foreach (XmlNode childnode in node.ChildNodes)
            {
                Shape shape = AddToList(svg, this.m_elements, childnode, this);
                if (shape != null)
                {
                    shape.Parent = this;
                }
            }
        }
示例#11
0
        protected override ShapeRange ExecutePasteAction(string ribbonId, PowerPointPresentation presentation, PowerPointSlide slide,
                                                         ShapeRange selectedShapes, ShapeRange selectedChildShapes)
        {
            if (selectedShapes.Count <= 0)
            {
                Logger.Log("PasteIntoGroup failed. No valid shape is selected.");
                return(null);
            }

            if (selectedShapes.Count == 1 && !ShapeUtil.IsAGroup(selectedShapes[1]))
            {
                Logger.Log("PasteIntoGroup failed. Selection is only a single shape.");
                return(null);
            }

            ShapeRange pastingShapes = ClipboardUtil.PasteShapesFromClipboard(presentation, slide);

            if (pastingShapes == null)
            {
                Logger.Log("PasteLab: Could not paste clipboard contents.");
                MessageBox.Show(PasteLabText.ErrorPaste, PasteLabText.ErrorDialogTitle);
                return(null);
            }

            return(PasteIntoGroup.Execute(presentation, slide, selectedShapes, pastingShapes));
        }
示例#12
0
        public static bool Crop(Shape shape, PowerPointSlide currentSlide, float slideWidth, float slideHeight)
        {
            Shape      toCrop      = shape;
            RectangleF shapeBounds = GetAbsoluteBounds(shape);

            if (!CrossesSlideBoundary(shapeBounds, slideWidth, slideHeight))
            {
                return(false);
            }
            if (!ShapeUtil.IsPicture(shape) || shape.Rotation != 0)
            {
                GraphicsUtil.ExportShape(shape, ShapePicture);
                Shape newShape = currentSlide.Shapes.AddPicture(ShapePicture,
                                                                Office.MsoTriState.msoFalse,
                                                                Office.MsoTriState.msoTrue,
                                                                shapeBounds.Left, shapeBounds.Top, shapeBounds.Width, shapeBounds.Height);
                toCrop      = newShape;
                toCrop.Name = shape.Name;
                shape.Delete();
            }
            RectangleF cropArea = GetCropArea(toCrop, slideWidth, slideHeight);

            toCrop.PictureFormat.Crop.ShapeHeight = cropArea.Height;
            toCrop.PictureFormat.Crop.ShapeWidth  = cropArea.Width;
            toCrop.PictureFormat.Crop.ShapeLeft   = cropArea.Left;
            toCrop.PictureFormat.Crop.ShapeTop    = cropArea.Top;
            return(true);
        }
        /// <summary>
        /// Saves shape in storage
        /// Returns a key to find the shape by,
        /// or null if the shape cannot be copied
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="formats">Required for msoPlaceholder</param>
        /// <returns>identifier of copied shape</returns>
        public string CopyShape(Shape shape, Format[] formats)
        {
            Shape copiedShape = null;

            if (shape.Type == MsoShapeType.msoPlaceholder)
            {
                copiedShape = ShapeUtil.CopyMsoPlaceHolder(formats, shape, GetTemplateShapes());
            }
            else
            {
                try
                {
                    shape.Copy();
                    copiedShape = Slides[0].Shapes.Paste()[1];
                }
                catch
                {
                    copiedShape = null;
                }
            }

            if (copiedShape == null)
            {
                return(null);
            }

            string shapeKey = nextKey.ToString();

            nextKey++;
            copiedShape.Name = shapeKey;
            ForceSave();
            return(shapeKey);
        }
        private Bitmap[] ShapeTypesToBitmaps(Array types, string shapeType)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();

            Bitmap[] bitmaps = new Bitmap[types.Length];
            for (int i = 0; i < types.Length; i++)
            {
                if (!((MsoAutoShapeType)types.GetValue(i)).ToString().Contains(shapeType))
                {
                    continue;
                }
                try
                {
                    Shape shape = shapes.AddShape(
                        (MsoAutoShapeType)types.GetValue(i), 0, 0,
                        TooltipsLabConstants.DisplayImageSize.Width,
                        TooltipsLabConstants.DisplayImageSize.Height);
                    ShapeUtil.FormatCalloutToDefaultStyle(shape);
                    bitmaps[i] = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));
                    shape.SafeDelete();
                }
                catch
                {
                }
            }
            return(bitmaps);
        }
示例#15
0
        public void TestCopyTable()
        {
            Shape table = GetShape(TablePlaceholderSlide, Table);
            Shape copy  = ShapeUtil.CopyMsoPlaceHolder(new Format[0], table, _templateShapes);

            Assert.AreEqual(copy, null);
        }
示例#16
0
        protected override void ExecuteAction(string ribbonId)
        {
            this.StartNewUndoEntry();
            PowerPointSlide currentSlide = this.GetCurrentSlide();
            Selection       selection    = this.GetCurrentSelection();

            if (currentSlide == null || !ShapeUtil.IsSelectionShape(selection))
            {
                return;
            }

            try
            {
                bool success = ConvertToTooltip.AddTriggerAnimation(currentSlide, selection);
                if (success)
                {
                    // Open the animation custom pane if it is not opened
                    if (!this.GetApplication().CommandBars.GetPressedMso("AnimationCustom"))
                    {
                        this.GetApplication().CommandBars.ExecuteMso("AnimationCustom");
                    }
                }
            }
            catch (Exception e)
            {
                ErrorDialogBox.ShowDialog("PowerPointLabs", e.Message, e);
            }
        }
        /// <summary>
        /// Applies font highlighting by section to the text in the bullet agenda.
        /// Set currentSection to the first section for everything to be unvisited.
        /// Set currentSection to AgendaSection.None for everything to be visited.
        /// </summary>
        private static void ApplyBulletFormats(TextRange2 textRange, BulletFormats bulletFormats, AgendaSection currentSection)
        {
            // - 1 because first section in agenda is at index 2 (exclude first section)
            int focusIndex = currentSection.IsNone() ? int.MaxValue : currentSection.Index - 1;

            textRange.Font.StrikeThrough = MsoTriState.msoFalse;

            for (int i = 1; i <= textRange.Paragraphs.Count; i++)
            {
                TextRange2 currentParagraph = textRange.Paragraphs[i];

                if (i == focusIndex)
                {
                    ShapeUtil.SyncTextRange(bulletFormats.Highlighted, currentParagraph, pickupTextContent: false);
                }
                else if (i < focusIndex)
                {
                    ShapeUtil.SyncTextRange(bulletFormats.Visited, currentParagraph, pickupTextContent: false);
                }
                else
                {
                    ShapeUtil.SyncTextRange(bulletFormats.Unvisited, currentParagraph, pickupTextContent: false);
                }
            }
        }
示例#18
0
        public void TestCopyChart()
        {
            Shape chart = GetShape(ChartPlaceholderSlide, Chart);
            Shape copy  = ShapeUtil.CopyMsoPlaceHolder(new Format[0], chart, _templateShapes);

            Assert.AreEqual(copy, null);
        }
        protected override void ExecuteAction(string ribbonId)
        {
            IMessageService     cropLabMessageService = MessageServiceFactory.GetCropLabMessageService();
            CropLabErrorHandler errorHandler          = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService);
            Selection           selection             = this.GetCurrentSelection();

            if (!ShapeUtil.IsSelectionShape(selection))
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 1, errorHandler);
                return;
            }

            ShapeRange shapeRange = ShapeUtil.GetShapeRange(selection);

            if (shapeRange.Count < 1)
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 1, errorHandler);
                return;
            }
            if (!ShapeUtil.IsAllPicture(shapeRange))
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBePicture, FeatureName, errorHandler);
                return;
            }

            try
            {
                ShapeRange result = CropOutPadding.Crop(shapeRange);
                result?.Select();
            }
            catch (CropLabException e)
            {
                HandleCropLabException(e, FeatureName, errorHandler);
            }
        }
示例#20
0
        protected override void ExecuteAction(string ribbonId)
        {
            IMessageService     cropLabMessageService = MessageServiceFactory.GetCropLabMessageService();
            CropLabErrorHandler errorHandler          = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService);

            if (!ShapeUtil.IsSelectionShape(this.GetCurrentSelection()))
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 2, errorHandler);
                return;
            }
            ShapeRange shapeRange = this.GetCurrentSelection().ShapeRange;

            if (shapeRange.Count < 2)
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypePicture, 2, errorHandler);
                return;
            }
            if (!ShapeUtil.IsAllPictureWithReferenceObject(shapeRange))
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBePicture, FeatureName, errorHandler);
                return;
            }

            bool hasChange = CropToSame.CropSelection(shapeRange);

            if (!hasChange)
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeNoDimensionCropped, FeatureName, errorHandler);
            }
        }
示例#21
0
        private static PowerPoint.Shape GetStepBackWithBackgroundShapeToZoom(PowerPointSlide currentSlide, PowerPointSlide addedSlide, PowerPoint.Shape previousSlidePicture, out PowerPoint.Shape backgroundShape)
        {
            currentSlide.Copy();
            PowerPoint.Shape currentSlideCopy = addedSlide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            ShapeUtil.FitShapeToSlide(ref currentSlideCopy);
            currentSlideCopy.Name = "PPTZoomOutShape" + DateTime.Now.ToString("yyyyMMddHHmmssffff");

            previousSlidePicture.Copy();
            PowerPoint.Shape previousSlidePictureCopy = addedSlide.Shapes.Paste()[1];

            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(addedSlide.Index);

            // Scale everything up by this ratio.
            float ratio = PowerPointPresentation.Current.SlideWidth / previousSlidePictureCopy.Width;

            currentSlideCopy.Width  *= ratio;
            currentSlideCopy.Height *= ratio;
            currentSlideCopy.Left    = -ratio * previousSlidePictureCopy.Left;
            currentSlideCopy.Top     = -ratio * previousSlidePictureCopy.Top;

            // for some reason height is locked to width, so we only need to change width here.
            previousSlidePictureCopy.Width *= ratio;
            previousSlidePictureCopy.Left   = 0;
            previousSlidePictureCopy.Top    = 0;

            backgroundShape = currentSlideCopy;
            return(previousSlidePictureCopy);
        }
示例#22
0
        public Shape AddTemplateSlideMarker()
        {
            if (HasTemplateSlideMarker())
            {
                return(null);
            }

            float ratio       = 22.5f;
            float slideWidth  = PowerPointPresentation.Current.SlideWidth;
            float slideHeight = PowerPointPresentation.Current.SlideHeight;
            float shapeWidth  = Math.Min(slideWidth, 900);
            float shapeHeight = shapeWidth / ratio;

            Shape markerShape = _slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, shapeWidth, shapeHeight);

            markerShape.TextEffect.Alignment = MsoTextEffectAlignment.msoTextEffectAlignmentCentered;

            markerShape.TextFrame2.TextRange.Text      = AgendaLabText.TemplateSlideInstructions;
            markerShape.Fill.ForeColor.RGB             = 0x0000C0;
            markerShape.TextFrame2.TextRange.Font.Bold = MsoTriState.msoTrue;
            markerShape.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = 0x00FFFF;
            markerShape.TextFrame2.TextRange.Paragraphs[2].Font.Fill.ForeColor.RGB = 0xFFFFFF;
            markerShape.TextFrame2.TextRange.Paragraphs[2].Font.Bold = MsoTriState.msoFalse;

            markerShape.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape;
            markerShape.ZOrder(MsoZOrderCmd.msoSendToBack);

            markerShape.Left = (slideWidth - markerShape.Width) / 2;
            markerShape.Top  = slideHeight - markerShape.Height;
            markerShape.Name = PptLabsTemplateMarkerShapeName;

            ShapeUtil.MakeShapeViewTimeInvisible(markerShape, _slide);
            return(markerShape);
        }
示例#23
0
        public void ApplyTextboxEffect(string overlayColor, int transparency, 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 overlayShape = ApplyOverlayEffect(overlayColor, transparency,
                                                          left, top, width, height);
                    ChangeName(overlayShape, EffectName.TextBox);
                    Graphics.MoveZToJustBehind(overlayShape, shape);
                }
            }
        }
        protected override void ExecuteAction(string ribbonId)
        {
            IMessageService     cropLabMessageService = MessageServiceFactory.GetCropLabMessageService();
            CropLabErrorHandler errorHandler          = CropLabErrorHandler.InitializeErrorHandler(cropLabMessageService);

            if (!ShapeUtil.IsSelectionShape(this.GetCurrentSelection()))
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShapeOrPicture, 1, errorHandler);
                return;
            }
            ShapeRange shapeRange = this.GetCurrentSelection().ShapeRange;

            if (shapeRange.Count < 1)
            {
                HandleInvalidSelectionError(CropLabErrorHandler.ErrorCodeSelectionIsInvalid, FeatureName, CropLabErrorHandler.SelectionTypeShapeOrPicture, 1, errorHandler);
                return;
            }
            if (!ShapeUtil.IsAllPictureOrShape(shapeRange))
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeSelectionMustBeShapeOrPicture, FeatureName, errorHandler);
                return;
            }
            float slideWidth  = this.GetCurrentPresentation().SlideWidth;
            float slideHeight = this.GetCurrentPresentation().SlideHeight;
            bool  hasChange   = CropToSlide.Crop(shapeRange, this.GetCurrentSlide(), slideWidth, slideHeight);

            if (!hasChange)
            {
                HandleErrorCode(CropLabErrorHandler.ErrorCodeNoShapeOverBoundary, FeatureName, errorHandler);
            }
        }
示例#25
0
        public static void Execute(PowerPointSlide slide, ShapeRange pastingShapes, float slideWidth, float slideHeight)
        {
            pastingShapes = ShapeUtil.GetShapesWhenTypeNotMatches(slide, pastingShapes, Microsoft.Office.Core.MsoShapeType.msoPlaceholder);
            if (pastingShapes.Count == 0)
            {
                return;
            }

            Shape shapeToFillSlide = pastingShapes[1];

            if (pastingShapes.Count > 1)
            {
                shapeToFillSlide = pastingShapes.Group();
            }
            shapeToFillSlide.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoTrue;

            PPShape ppShapeToFillSlide = new PPShape(shapeToFillSlide);

            ppShapeToFillSlide.AbsoluteHeight = slideHeight;
            if (ppShapeToFillSlide.AbsoluteWidth < slideWidth)
            {
                ppShapeToFillSlide.AbsoluteWidth = slideWidth;
            }
            ppShapeToFillSlide.VisualCenter = new System.Drawing.PointF(slideWidth / 2, slideHeight / 2);

            CropLab.CropToSlide.Crop(shapeToFillSlide, slide, slideWidth, slideHeight);
        }
示例#26
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Bitmap sourceImage = null;

            DA.GetData(0, ref sourceImage);
            Rectangle3d rec1 = new Rectangle3d();

            DA.GetData(1, ref rec1);
            List <Rectangle3d> rec2 = new List <Rectangle3d>();

            DA.GetDataList(2, rec2);

            Bitmap clone = new Bitmap(sourceImage.Width, sourceImage.Height, sourceImage.PixelFormat);

            Graphics  g      = Graphics.FromImage(clone);
            Rectangle source = ShapeUtil.toRec2D(rec1);

            foreach (var r in rec2)
            {
                Rectangle dest = ShapeUtil.toRec2D(r);
                g.DrawImage(sourceImage, dest, source, GraphicsUnit.Pixel);
            }

            DA.SetData(0, clone);
        }
        protected override bool GetEnabled(string ribbonId)
        {
            Selection currentSelection = this.GetCurrentSelection();

            return(!ShapeUtil.IsSelectionSingleShape(currentSelection) &&
                   !ShapeUtil.HasPlaceholderInSelection(currentSelection) &&
                   !ShapeUtil.IsSelectionChildShapeRange(currentSelection));
        }
示例#28
0
        protected override bool GetEnabled(string ribbonId)
        {
            Selection currentSelection = this.GetCurrentSelection();

            return(!ClipboardUtil.IsClipboardEmpty() &&
                   ShapeUtil.IsSelectionSingleShape(currentSelection) &&
                   !ShapeUtil.HasPlaceholderInSelection(currentSelection));
        }
示例#29
0
        protected override bool GetEnabled(string ribbonId)
        {
            Selection currentSelection = this.GetCurrentSelection();

            return(!GraphicsUtil.IsClipboardEmpty() &&
                   ShapeUtil.IsSelectionMultipleOrGroup(currentSelection) &&
                   !ShapeUtil.HasPlaceholderInSelection(currentSelection));
        }
示例#30
0
        internal static PowerPointBgEffectSlide GenerateEffectSlide(PowerPointSlide curSlide, Selection selection, bool generateOnRemainder)
        {
            PowerPointSlide dupSlide = null;

            try
            {
                ShapeRange shapeRange = ShapeUtil.GetShapeRange(selection);

                if (shapeRange.Count != 0)
                {
                    dupSlide = curSlide.Duplicate();
                }

                shapeRange.Cut();

                PowerPointBgEffectSlide effectSlide = PowerPointBgEffectSlide.BgEffectFactory(curSlide.GetNativeSlide(), generateOnRemainder);

                if (dupSlide != null)
                {
                    if (generateOnRemainder)
                    {
                        dupSlide.Delete();
                    }
                    else
                    {
                        dupSlide.MoveTo(curSlide.Index);
                        curSlide.Delete();
                    }
                }

                return(effectSlide);
            }
            catch (InvalidOperationException e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
            catch (COMException)
            {
                if (dupSlide != null)
                {
                    dupSlide.Delete();
                }

                MessageBox.Show(TextCollection.EffectsLabText.ErrorSelectAtLeastOneShape);
                return(null);
            }
            catch (Exception e)
            {
                if (dupSlide != null)
                {
                    dupSlide.Delete();
                }

                ErrorDialogBox.ShowDialog(CommonText.ErrorTitle, e.Message, e);
                return(null);
            }
        }
示例#31
0
            public LineTo(char command, ShapeUtil.StringSplitter value)
                : base(command)
            {
                if (char.ToLower(command) == 'h')
                {
                    this.PositionType = eType.Horizontal;
                    double v = value.ReadNextValue();
                    this.Points = new Point[] { new Point(v, 0) };
                    return;
                }
                if (char.ToLower(command) == 'v')
                {
                    this.PositionType = eType.Vertical;
                    double v = value.ReadNextValue();
                    this.Points = new Point[] { new Point(0, v) };
                    return;
                }

                this.PositionType = eType.Point;
                List<Point> list = new List<Point>();
                while (value.More)
                {
                    Point p = value.ReadNextPoint();
                    list.Add(p);
                }
                this.Points = list.ToArray();
            }
示例#32
0
 public CurveTo(char command, ShapeUtil.StringSplitter value, Point ctrlPoint1)
     : base(command)
 {
     this.CtrlPoint1 = ctrlPoint1;
     this.CtrlPoint2 = value.ReadNextPoint();
     this.Point = value.ReadNextPoint();
 }
示例#33
0
 public EllipticalArcTo(char command, ShapeUtil.StringSplitter value)
     : base(command)
 {
     this.RX = value.ReadNextValue();
     this.RY = value.ReadNextValue();
     this.AxisRotation = value.ReadNextValue();
     double arcflag = value.ReadNextValue();
     this.LargeArc = (arcflag > 0);
     double sweepflag = value.ReadNextValue();
     this.Clockwise = (sweepflag > 0);
     this.X = value.ReadNextValue();
     this.Y = value.ReadNextValue();
 }
示例#34
0
 public MoveTo(char command, ShapeUtil.StringSplitter value)
     : base(command)
 {
     this.Point = value.ReadNextPoint();
 }
示例#35
0
文件: Shape.cs 项目: swcomp/SVGImage
 protected virtual void Parse(SVG svg, ShapeUtil.Attribute attr)
 {
     string name = attr.Name;
     string value = attr.Value;
     this.Parse(svg, name, value);
 }