コード例 #1
0
 /// <summary>
 /// Assumes the number of paragraphs >= 3.
 /// The check should have been done before this function is called.
 /// </summary>
 public static BulletFormats ExtractFormats(Shape contentShape)
 {
     var paragraphs = contentShape.TextFrame2.TextRange.Paragraphs.Cast<TextRange2>().ToList();
     return new BulletFormats(paragraphs[0],
                             paragraphs[1],
                             paragraphs[2]);
 }
コード例 #2
0
        private void PrepareForZoomToArea(PowerPointSlide slideToPanFrom, PowerPointSlide slideToPanTo)
        {
            //Delete all shapes from slide excpet last magnified shape
            List<PowerPoint.Shape> shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            var matchingShapes = shapes.Where(current => (!current.Name.Contains("PPTLabsMagnifyAreaGroup")));
            foreach (PowerPoint.Shape s in matchingShapes)
                s.Delete();

            panShapeFrom = GetShapesWithPrefix("PPTLabsMagnifyAreaGroup")[0];
            panShapeTo = slideToPanTo.GetShapesWithPrefix("PPTLabsMagnifyAreaGroup")[0];

            //Add fade animation to existing shapes
            shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            matchingShapes = shapes.Where(current => (!(current.Equals(indicatorShape) || current.Equals(panShapeFrom))));
            foreach (PowerPoint.Shape s in matchingShapes)
            {
                DeleteShapeAnimations(s);
                PowerPoint.Effect effectFade = _slide.TimeLine.MainSequence.AddEffect(s, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                effectFade.Exit = Office.MsoTriState.msoTrue;
                effectFade.Timing.Duration = 0.25f;
            }

            DeleteSlideNotes();
            DeleteSlideMedia();
            ManageSlideTransitions();
            indicatorShape = AddPowerPointLabsIndicator();
        }
コード例 #3
0
ファイル: TildaShape.cs プロジェクト: parris/tilda
 /**
  * Creates a new TildaShape Object from a powerpoint shape
  * @param PowerPoint.Shape
  */
 public TildaShape(PowerPoint.Shape shape, int id = 0)
 {
     this.shape = shape;
     this.scaler = Settings.Scaler();
     this.id = id;
     animations = new List<TildaAnimation>();
 }
コード例 #4
0
        private void PrepareForZoomToArea(PowerPoint.Shape zoomShape)
        {
            MoveMotionAnimation();

            //Delete zoom shapes and shapes with exit animations
            List<PowerPoint.Shape> shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            var matchingShapes = shapes.Where(current => (HasExitAnimation(current) || current.Equals(zoomShape)));
            foreach (PowerPoint.Shape s in matchingShapes)
                s.Delete();

            AddZoomSlideCroppedPicture();

            DeleteSlideNotes();
            DeleteSlideMedia();
            ManageSlideTransitions();
            indicatorShape = AddPowerPointLabsIndicator();

            //Add fade out effect for non-zoom shapes
            shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            matchingShapes = shapes.Where(current => (!(current.Equals(indicatorShape) || current.Equals(zoomSlideCroppedShapes))));
            foreach (PowerPoint.Shape s in matchingShapes)
            {
                DeleteShapeAnimations(s);
                if (!ZoomToArea.backgroundZoomChecked)
                {
                    PowerPoint.Effect effectFade = _slide.TimeLine.MainSequence.AddEffect(s, PowerPoint.MsoAnimEffect.msoAnimEffectFade, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                    effectFade.Exit = Office.MsoTriState.msoTrue;
                    effectFade.Timing.Duration = 0.25f;
                }
                else
                    s.Visible = Office.MsoTriState.msoFalse;
            }
        }
コード例 #5
0
ファイル: Graphics.cs プロジェクト: youthinkk/PowerPointLabs
        public static void ExportShape(Shape shape, string exportPath)
        {
            var slideWidth = (int)PowerPointPresentation.Current.SlideWidth;
            var slideHeight = (int)PowerPointPresentation.Current.SlideHeight;

            shape.Export(exportPath, PpShapeFormat.ppShapeFormatPNG, slideWidth,
                         slideHeight, PpExportMode.ppScaleToFit);
        }
コード例 #6
0
ファイル: Graphics.cs プロジェクト: youthinkk/PowerPointLabs
 public static void FitShapeToSlide(ref Shape shapeToMove)
 {
     shapeToMove.LockAspectRatio = MsoTriState.msoFalse;
     shapeToMove.Left = 0;
     shapeToMove.Top = 0;
     shapeToMove.Width = PowerPointPresentation.Current.SlideWidth;
     shapeToMove.Height = PowerPointPresentation.Current.SlideHeight;
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: kahn520/App
 private static void DeleteTag(Shape shp)
 {
     if (shp.Tags.Count > 0)
     {
         for (int i = shp.Tags.Count - 1; i >= 0; i--)
         {
             string name = shp.Tags.Name(i);
             shp.Tags.Delete(name);
         }
     }
 }
コード例 #8
0
ファイル: Graphics.cs プロジェクト: youthinkk/PowerPointLabs
 public static bool IsCorrupted(Shape shape)
 {
     try
     {
         return shape.Parent == null;
     }
     catch (Exception)
     {
         return true;
     }
 }
コード例 #9
0
ファイル: Graphics.cs プロジェクト: youthinkk/PowerPointLabs
        public static bool IsSamePosition(Shape refShape, Shape candidateShape,
                                          bool exactMatch = true, float blurRadius = float.Epsilon)
        {
            if (exactMatch)
            {
                blurRadius = float.Epsilon;
            }

            return refShape != null &&
                   candidateShape != null &&
                   Math.Abs(refShape.Left - candidateShape.Left) < blurRadius &&
                   Math.Abs(refShape.Top - candidateShape.Top) < blurRadius;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: kahn520/App
 private static void DeleteText(Shape shp)
 {
     if(shp.TextFrame.HasText == MsoTriState.msoFalse)
         return;
     if(shp.TextFrame.TextRange.Text.Trim() == "")
         return;
     //if (shp.Type == MsoShapeType.msoPlaceholder)
     //{
     //    shp.TextFrame.TextRange.Delete();
     //    return;
     //}
     if(HasChinese(shp.TextFrame.TextRange.Text))
         shp.TextFrame.TextRange.Delete();
 }
コード例 #11
0
        public PPShape(PowerPoint.Shape shape, bool redefineBoundingBox = true)
        {
            _shape = shape;
            _originalRotation = _shape.Rotation;

            if (redefineBoundingBox && (int) _shape.Rotation%90 != 0)
            {
                ConvertToFreeform();
            }

            UpdateAbsoluteWidth();
            UpdateAbsoluteHeight();

            UpdateVisualTop();
            UpdateVisualLeft();
        }
コード例 #12
0
        //Stores slide-size crop of the current slide as a global variable
        private void AddZoomSlideCroppedPicture()
        {
            PowerPointSlide zoomSlideCopy = this.Duplicate();
            Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(zoomSlideCopy.Index);

            PowerPoint.Shape cropShape = zoomSlideCopy.Shapes.AddShape(Office.MsoAutoShapeType.msoShapeRectangle, 0, 0, PowerPointPresentation.Current.SlideWidth - 0.01f, PowerPointPresentation.Current.SlideHeight - 0.01f);
            cropShape.Select();
            PowerPoint.Selection sel = Globals.ThisAddIn.Application.ActiveWindow.Selection;
            PowerPoint.Shape croppedShape = CropToShape.Crop(sel);
            croppedShape.Cut();

            zoomSlideCroppedShapes = _slide.Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            zoomSlideCroppedShapes.Name = "PPTLabsMagnifyAreaGroup" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
            Utils.Graphics.FitShapeToSlide(ref zoomSlideCroppedShapes);
            zoomSlideCopy.Delete();
        }
コード例 #13
0
        private void PrepareForZoomToArea()
        {
            //Delete all shapes on slide except slide-size crop copied from magnifying slide
            List<PowerPoint.Shape> shapes = _slide.Shapes.Cast<PowerPoint.Shape>().ToList();
            var matchingShapes = shapes.Where(current => (!current.Name.Contains("PPTLabsMagnifyAreaGroup")));
            foreach (PowerPoint.Shape s in matchingShapes)
                s.Delete();

            zoomSlideCroppedShapes = GetShapesWithPrefix("PPTLabsMagnifyAreaGroup")[0];
            zoomSlideCroppedShapes.Visible = Office.MsoTriState.msoTrue;
            DeleteShapeAnimations(zoomSlideCroppedShapes);

            DeleteSlideNotes();
            DeleteSlideMedia();
            ManageSlideTransitions();
            indicatorShape = AddPowerPointLabsIndicator();
        }
コード例 #14
0
ファイル: MyUserControl.cs プロジェクト: caerang/TIL
        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            try
            {
                if (textbox != null)
                {
                    textbox.Delete();
                }
                PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActivePresentation.Slides[1];
                textbox = slide.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal, 50, 100, 600, 50);
                textbox.TextFrame.TextRange.Text = e.Start.ToLongDateString();
                textbox.TextFrame.TextRange.Font.Size = 48;
                textbox.TextFrame.TextRange.Font.Color.RGB = Color.DarkViolet.ToArgb();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
        }
コード例 #15
0
ファイル: Align_More.cs プロジェクト: tw-lws/OneKeyTools8
        private void button9_Click(object sender, EventArgs e)
        {
            PowerPoint.Selection sel = app.ActiveWindow.Selection;
            if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
            {
                forms.MessageBox.Show("请至少选择三个形状");
            }
            else
            {
                PowerPoint.ShapeRange range = sel.ShapeRange;
                if (sel.HasChildShapeRange)
                {
                    range = sel.ChildShapeRange;
                }
                else
                {
                    range = sel.ShapeRange;
                }
                int count = range.Count;
                if (count == 1)
                {
                    if (range[1].Type == Office.MsoShapeType.msoGroup && range[1].GroupItems.Count > 2)
                    {
                        float nw  = range[1].GroupItems[range[1].GroupItems.Count].Left - range[1].GroupItems[1].Left - range[1].GroupItems[1].Width;
                        float nw2 = range[1].GroupItems[range[1].GroupItems.Count].Left - range[1].GroupItems[1].Left - range[1].GroupItems[1].Width;
                        float cw  = 0;
                        if (range[1].GroupItems.Count == 3)
                        {
                            if (range[1].GroupItems[2].Width >= nw)
                            {
                                range[1].GroupItems[2].Left = range[1].GroupItems[1].Left + range[1].GroupItems[1].Width + nw / 3;
                            }
                            else
                            {
                                nw = nw - range[1].GroupItems[2].Width;
                                range[1].GroupItems[2].Left = range[1].GroupItems[1].Left + range[1].GroupItems[1].Width + nw / 3;
                            }
                        }
                        else
                        {
                            List <float> widths = new List <float>();
                            foreach (PowerPoint.Shape item in range.GroupItems)
                            {
                                widths.Add(item.Width);
                            }

                            for (int j = 2; j < range[1].GroupItems.Count; j++)
                            {
                                PowerPoint.Shape item = range[1].GroupItems[j];
                                cw = cw + item.Width;
                                nw = nw - item.Width;
                            }

                            for (int k = 3; k < range[1].GroupItems.Count; k++)
                            {
                                float avgnw = 0;
                                if (cw > nw2)
                                {
                                    if (range[1].GroupItems.Count % 2 != 0)
                                    {
                                        avgnw = 2 * nw2 / (range[1].GroupItems.Count * range[1].GroupItems.Count);
                                    }
                                    else
                                    {
                                        avgnw = 2 * nw2 / (range[1].GroupItems.Count * (range[1].GroupItems.Count - 1));
                                    }
                                    range[1].GroupItems[2].Left = range[1].GroupItems[1].Left + range[1].GroupItems[1].Width + avgnw;
                                    range[1].GroupItems[k].Left = range[1].GroupItems[k - 1].Left + avgnw * (k - 1);
                                }
                                else
                                {
                                    if (range[1].GroupItems.Count % 2 != 0)
                                    {
                                        avgnw = 2 * nw / (range[1].GroupItems.Count * range[1].GroupItems.Count);
                                    }
                                    else
                                    {
                                        avgnw = 2 * nw / (range[1].GroupItems.Count * (range[1].GroupItems.Count - 1));
                                    }
                                    range[1].GroupItems[2].Left = range[1].GroupItems[1].Left + range[1].GroupItems[1].Width + avgnw;
                                    range[1].GroupItems[k].Left = range[1].GroupItems[k - 1].Left + range[1].GroupItems[k - 1].Width + avgnw * (k - 1);
                                }
                            }
                        }
                    }
                    else if (range[1].Type == Office.MsoShapeType.msoGroup && range[1].GroupItems.Count == 2)
                    {
                        MessageBox.Show("组合内至少要有三个形状");
                    }
                    else
                    {
                        MessageBox.Show("请至少选中三个形状,或一个组合内至少要有三个形状");
                    }
                }
                else if (count == 2)
                {
                    MessageBox.Show("请选择至少三个形状");
                }
                else
                {
                    float nw  = range[count].Left - range[1].Left - range[1].Width;
                    float nw2 = range[count].Left - range[1].Left - range[1].Width;
                    float cw  = 0;
                    if (count == 3)
                    {
                        if (range[2].Width >= nw)
                        {
                            range[2].Left = range[1].Left + range[1].Width + nw / 3;
                        }
                        else
                        {
                            nw            = nw - range[2].Width;
                            range[2].Left = range[1].Left + range[1].Width + nw / 3;
                        }
                    }
                    else
                    {
                        List <float> widths = new List <float>();
                        foreach (PowerPoint.Shape item in range)
                        {
                            widths.Add(item.Width);
                        }

                        for (int j = 2; j < count; j++)
                        {
                            PowerPoint.Shape item = range[j];
                            cw = cw + item.Width;
                            nw = nw - item.Width;
                        }

                        for (int k = 3; k < count; k++)
                        {
                            float avgnw = 0;
                            if (cw > nw2)
                            {
                                if (count % 2 != 0)
                                {
                                    avgnw = 2 * nw2 / (count * count);
                                }
                                else
                                {
                                    avgnw = 2 * nw2 / (count * (count - 1));
                                }
                                range[2].Left = range[1].Left + range[1].Width + avgnw;
                                range[k].Left = range[k - 1].Left + avgnw * (k - 1);
                            }
                            else
                            {
                                if (count % 2 != 0)
                                {
                                    avgnw = 2 * nw / (count * count);
                                }
                                else
                                {
                                    avgnw = 2 * nw / (count * (count - 1));
                                }
                                range[2].Left = range[1].Left + range[1].Width + avgnw;
                                range[k].Left = range[k - 1].Left + range[k - 1].Width + avgnw * (k - 1);
                            }
                        }
                    }
                }
            }
        }
コード例 #16
0
        public async Task <bool> WriteDataFor164()
        {
            try
            {
                JObject jsonData = await RequestData.GetPredictData("164");

                if (jsonData.Value <String>("code").Equals("200") && jsonData.Value <JObject>("data") != null)
                {
                    JObject dataObj = jsonData["data"].ToObject <JObject>();
                    string  mbnrStr = dataObj.Value <String>("mbnr");
                    JArray  mbnrArr = JsonConvert.DeserializeObject <JArray>(mbnrStr);
                    foreach (JObject jObject in mbnrArr)
                    {
                        if (jObject.Value <String>("index").Equals("3"))
                        {
                            PowerPoint.Shapes shapes = Globals.ThisAddIn.Application.ActivePresentation.Slides[3].Shapes;

                            JObject tableObj = jObject.Value <JObject>("table");

                            PowerPoint.Shape shape = PPTAPI.getShape(shapes, "table_1");
                            if (shape != null)
                            {
                                PowerPoint.Table table = shape.Table;
                                shape = PPTAPI.getShape(shapes, "chart_1");
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb1");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    table.Cell(row, col).Shape.TextFrame.TextRange.Text = tb1[i].Value <String>("c2");;
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c2");;
                                    table.Cell(row, col).Shape.TextFrame.TextRange.Text = tb1[i].Value <String>("c3");;
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c3");;
                                    col++;
                                    colStart++;
                                }
                            }
                        }
                        else if (jObject.Value <String>("index").Equals("4"))
                        {
                            PowerPoint.Shapes shapes   = Globals.ThisAddIn.Application.ActivePresentation.Slides[4].Shapes;
                            JObject           tableObj = jObject.Value <JObject>("table");
                            PowerPoint.Shape  shape    = PPTAPI.getShape(shapes, "chart_1");
                            if (shape != null)
                            {
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb1");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c2");;
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c3");;
                                    col++;
                                    colStart++;
                                }
                            }
                            shape = PPTAPI.getShape(shapes, "chart_2");
                            if (shape != null)
                            {
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb2");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    row++;
                                    step = colStart + row.ToString();
                                    string[] lsArr  = tb1[i].Value <String>("c2").Split(',');
                                    int      length = lsArr.Length;
                                    if (length < 5)
                                    {
                                        Array.Resize(ref lsArr, 5);
                                    }
                                    for (int j = length; j < 5; j++)
                                    {
                                        lsArr[j] = "0.0%";
                                    }
                                    ws.Range[step].Value = lsArr[0];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[1];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[2];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[3];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[4];
                                    col++;
                                    colStart++;
                                }
                            }
                        }
                        else if (jObject.Value <String>("index").Equals("5"))
                        {
                            PowerPoint.Shapes shapes = Globals.ThisAddIn.Application.ActivePresentation.Slides[5].Shapes;

                            JObject          tableObj = jObject.Value <JObject>("table");
                            PowerPoint.Shape shape    = PPTAPI.getShape(shapes, "chart_1");
                            if (shape != null)
                            {
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb1");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c2");;
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c3");;
                                    col++;
                                    colStart++;
                                }
                            }
                            shape = PPTAPI.getShape(shapes, "chart_2");
                            if (shape != null)
                            {
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb2");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    row++;
                                    step = colStart + row.ToString();
                                    string[] lsArr  = tb1[i].Value <String>("c2").Split(',');
                                    int      length = lsArr.Length;
                                    if (length < 5)
                                    {
                                        Array.Resize(ref lsArr, 5);
                                    }
                                    for (int j = length; j < 5; j++)
                                    {
                                        lsArr[j] = "0.0%";
                                    }
                                    ws.Range[step].Value = lsArr[0];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[1];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[2];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[3];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[4];
                                    col++;
                                    colStart++;
                                }
                            }
                        }
                        else if (jObject.Value <String>("index").Equals("6"))
                        {
                            PowerPoint.Shapes shapes = Globals.ThisAddIn.Application.ActivePresentation.Slides[6].Shapes;

                            JObject          tableObj = jObject.Value <JObject>("table");
                            PowerPoint.Shape shape    = PPTAPI.getShape(shapes, "chart_1");
                            if (shape != null)
                            {
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb1");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c2");;
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c3");;
                                    col++;
                                    colStart++;
                                }
                            }
                            shape = PPTAPI.getShape(shapes, "chart_2");
                            if (shape != null)
                            {
                                PowerPoint.Chart chart = shape.Chart;
                                var    ws       = chart.ChartData.Workbook.Worksheets[1];
                                JArray tb1      = tableObj.Value <JArray>("tb2");
                                int    col      = 2;
                                char   colStart = 'B';
                                for (int i = 0; i < tb1.Count(); i++)
                                {
                                    int    row  = 1;
                                    String step = colStart + row.ToString();
                                    ws.Range[step].Value = tb1[i].Value <String>("c1");
                                    row++;
                                    step = colStart + row.ToString();
                                    string[] lsArr  = tb1[i].Value <String>("c2").Split(',');
                                    int      length = lsArr.Length;
                                    if (length < 5)
                                    {
                                        Array.Resize(ref lsArr, 5);
                                    }
                                    for (int j = length; j < 5; j++)
                                    {
                                        lsArr[j] = "0.0%";
                                    }
                                    ws.Range[step].Value = lsArr[0];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[1];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[2];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[3];
                                    row++;
                                    step = colStart + row.ToString();
                                    ws.Range[step].Value = lsArr[4];
                                    col++;
                                    colStart++;
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
            }

            return(true);
        }
コード例 #17
0
        public void makeBibleSlide(string str, int verse, int chapter, string bible)
        {
            PowerPoint.Application  CurrentApplication = Globals.ThisAddIn.Application;
            PowerPoint.Presentation currentPT          = CurrentApplication.ActivePresentation;
            PowerPoint.CustomLayout customLayout       = currentPT.SlideMaster.CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutTitleOnly];
            int    fontSize = 50;
            string fontName = "Adobe 고딕 Std B";

            //PowerPoint.Slide newSlide = currentPT.Slides.AddSlide((currentPT.Slides.Count + 1), currentPT.SlideMaster.CustomLayouts._Index(6));
            //Color myBackgroundColor = Color.Beige;
            //int oleColor = ColorTranslator.ToOle(myBackgroundColor);
            //newSlide.FollowMasterBackground = Core.MsoTriState.msoFalse;
            //newSlide.Background.Fill.ForeColor.RGB = oleColor;

            //currentPT.SlideMaster.Shapes.AddPicture(@"D:\성경송출\BackgroundDB\BooksoftheBible-1440x900.jpg", Core.MsoTriState.msoFalse, Core.MsoTriState.msoTrue, 0, 0);
            //특정 슬라이드 마스터에 그림을 추가한다.
            float slideHeight = currentPT.PageSetup.SlideHeight;
            float slidewidth  = currentPT.PageSetup.SlideWidth;

            PowerPoint.CustomLayout bibleLayout = currentPT.SlideMaster.CustomLayouts._Index(6);
            if (!wallpaper)
            {
                bibleLayout.Shapes.AddPicture(@"D:\성경송출\BackgroundDB\wallpaper.jpg", Core.MsoTriState.msoFalse, Core.MsoTriState.msoTrue, 0, 0, slidewidth, slideHeight);
                bibleLayout.Shapes.Title.ZOrder(Core.MsoZOrderCmd.msoBringToFront);
                wallpaper = true;

                bibleLayout.Shapes.Title.TextFrame.DeleteText();
                bibleLayout.Shapes.Title.TextFrame.TextRange.Font.NameFarEast = fontName;
                bibleLayout.Shapes.Title.TextFrame.TextRange.Font.Name        = fontName;
            }

            PowerPoint.Slide newSlide = currentPT.Slides.AddSlide((currentPT.Slides.Count + 1), bibleLayout);



            //성경 구절 다자인
            newSlide.Shapes.Title.TextEffect.Alignment          = Core.MsoTextEffectAlignment.msoTextEffectAlignmentLeft;
            newSlide.Shapes.Title.TextFrame.TextRange.Font.Size = fontSize;

            newSlide.Shapes.Title.TextFrame.TextRange.Text = str;
            newSlide.Shapes.Title.Width = newSlide.Shapes.Title.Width - 50;
            newSlide.Shapes.Title.Left  = newSlide.Shapes.Title.Left + 50;
            newSlide.Shapes.Title.TextFrame.VerticalAnchor = Core.MsoVerticalAnchor.msoAnchorTop;
            //newSlide.Shapes.Title.TextFrame.TextRange.ParagraphFormat.


            newSlide.Shapes.Title.TextFrame.TextRange.Text = verse + " " + str;
            //newSlide.Shapes.Title.TextFrame.AutoSize = PowerPoint.PpAutoSize.ppAutoSizeShapeToFitText;
            //newSlide.Shapes.Title.TextFrame.TextRange.Font.Name = fontName;
            newSlide.Shapes.Title.Top = (slideHeight / 2) - (newSlide.Shapes[1].Height / 2);

            //절 디자인
            //PowerPoint.Shape verseText = newSlide.Shapes.AddTextbox(Core.MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 100, 100);
            //verseText.TextEffect.Alignment = Core.MsoTextEffectAlignment.msoTextEffectAlignmentRight;
            //verseText.TextFrame.TextRange.Text = verse + "";
            //verseText.TextFrame.TextRange.Font.Size = fontSize;
            ////verseText.TextFrame.TextRange.Font.Name = fontName;
            //verseText.TextFrame.AutoSize = PowerPoint.PpAutoSize.ppAutoSizeShapeToFitText;
            //float verseTop = newSlide.Shapes.Title.Top;
            //float verseLeft = newSlide.Shapes.Title.Left - verseText.Width - 10;
            //verseText.Left = verseLeft;
            //verseText.Top = verseTop;

            //성경, 장 디자인
            PowerPoint.Shape chapterText = newSlide.Shapes.AddTextbox(Core.MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 250, 100);
            chapterText.TextEffect.Alignment          = Core.MsoTextEffectAlignment.msoTextEffectAlignmentCentered;
            chapterText.TextFrame.TextRange.Text      = bible + " " + chapter + "장";
            chapterText.TextFrame.TextRange.Font.Size = 25;
            //chapterText.TextFrame.TextRange.Font.Name = fontName;
            chapterText.TextFrame.AutoSize = PowerPoint.PpAutoSize.ppAutoSizeShapeToFitText;
            float chapterTop  = 20;
            float chapterLeft = slidewidth - chapterText.Width - 20;

            chapterText.Left = chapterLeft;
            chapterText.Top  = chapterTop;
        }
コード例 #18
0
 private void button2_Click(object sender, EventArgs e)
 {
     PowerPoint.Selection sel = app.ActiveWindow.Selection;
     if (sel.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
     {
         PowerPoint.ShapeRange range = sel.ShapeRange;
         if (sel.HasChildShapeRange)
         {
             range = sel.ChildShapeRange;
         }
         int   count  = range.Count;
         int   ncount = int.Parse(textBox1.Text.Trim());
         float nw     = float.Parse(textBox2.Text.Trim()) * 72 / 2.54f;
         if (count >= ncount)
         {
             for (int i = 2; i <= count; i++)
             {
                 PowerPoint.Shape shape = range[i];
                 if (shape.LockAspectRatio == Office.MsoTriState.msoFalse)
                 {
                     shape.LockAspectRatio = Office.MsoTriState.msoTrue;
                 }
                 if (radioButton1.Checked)
                 {
                     if (i > ncount)
                     {
                         int n = (i - 1) % ncount;
                         if (n == 0)
                         {
                             shape.Width = range[1].Width;
                             shape.Left  = range[1].Left;
                         }
                         else
                         {
                             shape.Width = range[n + 1].Width;
                             shape.Left  = range[n].Left + range[n].Width + nw;
                         }
                         shape.Top = range[i - ncount].Top + range[i - ncount].Height + nw;
                     }
                     else
                     {
                         shape.Left = range[i - 1].Left + range[i - 1].Width + nw;
                         shape.Top  = range[1].Top;
                     }
                 }
                 else if (radioButton2.Checked)
                 {
                     if (i > ncount)
                     {
                         int n = (i - 1) % ncount;
                         if (n == 0)
                         {
                             shape.Height = range[1].Height;
                             shape.Top    = range[1].Top;
                         }
                         else
                         {
                             shape.Height = range[n + 1].Height;
                             shape.Top    = range[n].Top + range[n].Height + nw;
                         }
                         shape.Left = range[i - ncount].Left + range[i - ncount].Width + nw;
                     }
                     else
                     {
                         shape.Left = range[1].Left;
                         shape.Top  = range[i - 1].Top + range[i - 1].Height + nw;
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("多来几个图形再试试吧←_←");
         }
     }
     else
     {
         MessageBox.Show("请先选中图形");
     }
 }
コード例 #19
0
 public static bool IsNotTemplateSlideMarker(Shape shape)
 {
     return !IsTemplateSlideMarker(shape);
 }
コード例 #20
0
 public bool HasExitAnimation(Shape shape)
 {
     Sequence sequence = _slide.TimeLine.MainSequence;
     for (int x = sequence.Count; x >= 1; x--)
     {
         Effect effect = sequence[x];
         if (effect.Shape.Name == shape.Name && effect.Shape.Id == shape.Id)
             if (effect.Exit == Office.MsoTriState.msoTrue)
                 return true;
     }
     return false;
 }
コード例 #21
0
ファイル: PPTPaneManager.cs プロジェクト: zhujingcheng/CP3
 /// <summary>
 /// Gives the shape a tagged value if it does not already have one
 /// (or its subshapes if it's a group).
 /// </summary>
 private void NormalizeShape(PowerPoint.Shape shape)
 {
     this.NormalizeShape(shape, this.Mode);
 }
コード例 #22
0
ファイル: PPTPaneManager.cs プロジェクト: zhujingcheng/CP3
 public void ClearModes(PowerPoint.Shape shape)
 {
     this.SetMode(shape, DEFAULT_MODE);
 }
コード例 #23
0
ファイル: PPTPaneManager.cs プロジェクト: zhujingcheng/CP3
 /// <summary>
 /// Get the modes of the supplied shape.
 /// </summary>
 /// <param name="shape">must be non-null shape actually in the current presentation</param>
 /// <returns>Guaranteed to return a list with at least one element.</returns>
 public string[] GetModes(PowerPoint.Shape shape)
 {
     return(this.GetShapeModes(shape.Tags));
 }
コード例 #24
0
        public void insertDocument(string relativePath, string nodeRef)
        {
            object missingValue = Type.Missing;
            object trueValue    = true;
            object falseValue   = false;

            try
            {
                // Create a new document if no document currently open
                if (m_PowerPointApplication.ActivePresentation == null)
                {
                    m_PowerPointApplication.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue);
                }

                // WebDAV or CIFS?
                string strFullPath = m_ServerDetails.getFullPath(relativePath, m_PowerPointApplication.ActivePresentation.FullName, true);
                string strExtn     = Path.GetExtension(relativePath).ToLower();
                string fileName    = Path.GetFileName(relativePath);
                string nativeExtn  = ".ppt" + (m_SupportsPptx ? "x" : "");

                // If we're using WebDAV, then download file locally before inserting
                if (strFullPath.StartsWith("http"))
                {
                    // Need to unescape the the original path to get the filename
                    fileName = Path.GetFileName(Uri.UnescapeDataString(relativePath));
                    string strTempFile = Path.GetTempPath() + fileName;
                    if (File.Exists(strTempFile))
                    {
                        try
                        {
                            File.Delete(strTempFile);
                        }
                        catch (Exception)
                        {
                            strTempFile = Path.GetTempFileName();
                        }
                    }
                    WebClient fileReader = new WebClient();
                    string    url        = m_ServerDetails.WebClientURL + "download/direct/" + nodeRef.Replace(":/", "") + "/" + Path.GetFileName(relativePath);
                    fileReader.Headers.Add("Cookie: " + webBrowser.Document.Cookie);
                    fileReader.DownloadFile(url, strTempFile);
                    strFullPath = strTempFile;
                }

                // Store the active pane to restore it later
                PowerPoint.Pane activePane = m_PowerPointApplication.ActiveWindow.ActivePane;
                // Loop through all the panes available looking for the ppViewSlide type
                foreach (PowerPoint.Pane pane in m_PowerPointApplication.ActiveWindow.Panes)
                {
                    if (pane.ViewType == PowerPoint.PpViewType.ppViewSlide)
                    {
                        pane.Activate();
                        break;
                    }
                }

                // Now we can get the current slide index
                PowerPoint.Slide currentSlide = (PowerPoint.Slide)m_PowerPointApplication.ActiveWindow.View.Slide;
                int currentSlideIndex         = currentSlide.SlideIndex;
                PowerPoint.Shapes shapes      = currentSlide.Shapes;

                // Is another PowerPoint presentation being inserted?
                if (nativeExtn.IndexOf(strExtn) != -1)
                {
                    // Load the presentation in a hidden state
                    PowerPoint.Presentation insertPres = m_PowerPointApplication.Presentations.Open(
                        strFullPath, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse,
                        Microsoft.Office.Core.MsoTriState.msoFalse);

                    if (insertPres != null)
                    {
                        // Loop through copy-pasting the slides to be inserted
                        int insertIndex          = currentSlideIndex + 1;
                        PowerPoint.Slides slides = m_PowerPointApplication.ActivePresentation.Slides;
                        foreach (PowerPoint.Slide insertSlide in insertPres.Slides)
                        {
                            insertSlide.Copy();
                            slides.Paste(insertIndex++);
                        }
                        // Close the hidden presentation, flagging that we should ignore the close event
                        m_SuppressCloseEvent = true;
                        insertPres.Close();
                    }
                }
                else
                {
                    // Get default coords for inserting an object
                    object top  = m_PowerPointApplication.ActiveWindow.Top;
                    object left = m_PowerPointApplication.ActiveWindow.Left;

                    // Do we have a selection?
                    if (m_PowerPointApplication.ActiveWindow.Selection != null)
                    {
                        if (m_PowerPointApplication.ActiveWindow.Selection.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
                        {
                            // We can refine the insert location
                            top  = m_PowerPointApplication.ActiveWindow.Selection.ShapeRange.Top;
                            left = m_PowerPointApplication.ActiveWindow.Selection.ShapeRange.Left;
                        }
                    }

                    if (".bmp .gif .jpg .jpeg .png".IndexOf(strExtn) != -1)
                    {
                        try
                        {
                            // Inserting a bitmap picture
                            PowerPoint.Shape picture = shapes.AddPicture(strFullPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue,
                                                                         1, 2, 3, 4);
                            picture.Top  = Convert.ToSingle(top);
                            picture.Left = Convert.ToSingle(left);
                            picture.ScaleWidth(1, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft);
                            picture.ScaleHeight(1, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoScaleFrom.msoScaleFromTopLeft);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, Properties.Resources.MessageBoxTitle);
                        }
                    }
                    else
                    {
                        // Inserting a different file type - do it as an OLE object
                        string iconFilename = String.Empty;
                        int    iconIndex    = 0;
                        string iconLabel    = fileName;
                        string defaultIcon  = Util.DefaultIcon(strExtn);
                        if (defaultIcon.Contains(","))
                        {
                            string[] iconData = defaultIcon.Split(new char[] { ',' });
                            iconFilename = iconData[0];
                            iconIndex    = Convert.ToInt32(iconData[1]);
                        }
                        object filename = strFullPath;
                        float  size     = 48;
                        shapes.AddOLEObject((float)left, (float)top, size, size, String.Empty, strFullPath, Microsoft.Office.Core.MsoTriState.msoTrue,
                                            iconFilename, iconIndex, iconLabel, Microsoft.Office.Core.MsoTriState.msoFalse);
                    }
                }

                // Restore the previously-active pane
                if (activePane != null)
                {
                    activePane.Activate();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(Properties.Resources.UnableToInsert + ": " + e.Message, Properties.Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #25
0
        //public void LoadEmbeddedExcel()
        //{

        //}

        private void Button3_Click(object sender, EventArgs e)
        {
            //Microsoft.Office.Interop.PowerPoint.Application app = Globals.ThisAddIn.Application as Microsoft.Office.Interop.PowerPoint.Application;
            //Presentation p = Globals.ThisAddIn.Application.ActivePresentation as Presentation;
            PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActivePresentation.Slides[1];
            string           temp  = "E:/Dev/OfficeAddInLearning/PowerPointAddInLearning/embeddedExcel.xlsx";

            //string temp = AppDomain.CurrentDomain.BaseDirectory + "temp.xls";
            //File.Copy(Path, temp, true);
            //Excel.Application xlApp = new Excel.Application();
            //var missing = Type.Missing;
            //Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(temp, missing, missing, missing, missing, missing,
            //    missing, missing, missing, missing, missing, missing, missing, missing, missing);
            //Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets[1];
            //string areaA = "Aarea";
            //string areaB = "Barea";
            //string areaC = "Carea";
            //string areaARange = string.Empty;
            //string areaBRange = string.Empty;
            //string areaCRange = string.Empty;

            //foreach (Excel.Name name in xlWorksheet.Names)
            //{

            //    if (name.NameLocal.Contains(areaA))
            //    {
            //        areaARange = name.RefersToLocal;
            //    }
            //    else if (name.NameLocal.Contains(areaB))
            //    {
            //        areaBRange = name.RefersToLocal;
            //    }
            //    else if(name.NameLocal.Contains(areaB))
            //    {
            //        areaCRange = name.RefersToLocal;
            //    }
            //}
            //Excel.Range range = xlWorksheet.get_Range(areaARange, missing);

            ////range.CopyPicture(Excel.XlPictureAppearance.xlScreen, Excel.XlCopyPictureFormat.xlPicture);

            ////range.Copy(missing);
            ////slide.Design.Application.ActiveWindow.View.Paste();

            ////ShapeRange sr = slide.Shapes.PasteSpecial(
            ////    IconIndex: 0,
            ////    IconLabel: string.Empty,
            ////    IconFileName: string.Empty,
            ////    DisplayAsIcon: Office.MsoTriState.msoFalse,
            ////    DataType:PpPasteDataType.ppPasteDefault,
            ////    Link: Office.MsoTriState.msoFalse);

            //slide.Shapes[2].ScaleHeight(Factor: 1, Office.MsoTriState.msoCTrue);
            //slide.Shapes[2].ScaleWidth(Factor: 1, Office.MsoTriState.msoCTrue);
            //}
            try
            {
                PowerPoint.Shape shap = slide.Shapes.AddOLEObject(
                    0,
                    0,
                    -1,
                    -1,
                    string.Empty,
                    //ClassName
                    temp,   //FileName
                    Office.MsoTriState.msoFalse,
                    temp,   //IconFileName
                    1,      //IconIndex
                    "test", //IconLabel
                    Office.MsoTriState.msoFalse
                    );

                shap.ScaleHeight(Factor: 1, Office.MsoTriState.msoCTrue);
                shap.ScaleWidth(Factor: 1, Office.MsoTriState.msoCTrue);
                slide.Shapes.Range(new int[] { 1, 2 }).ShapeStyle = Office.MsoShapeStyleIndex.msoLineStylePreset11;

                //shap.
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
            finally
            {
                //File.Delete(temp);
                //Close();
            }
        }
コード例 #26
0
        public void CorrectFormat_ShapeInSlide(int sldNum, string shpName)
        {
            Reviewformat formatobj = new Reviewformat();

            try
            {
                float sldLeft   = 0;
                float sldTop    = 0;
                float sldRight  = ActivePPT.PageSetup.SlideWidth;
                float sldBottom = ActivePPT.PageSetup.SlideHeight;

                PowerPoint.Shape tShp = ActivePPT.Slides[sldNum].Shapes[shpName];
                if (tShp.Type != MsoShapeType.msoLine)
                {
                    float sngCenterH = tShp.Left + tShp.Width / 2;
                    //fFindHorizontalDistance
                    float sngDistH      = formatobj.fFindHorizontalDistance(tShp); //This is half of horizontal distance
                    float sngShapeLeft  = sngCenterH - sngDistH;                   //Actual Left
                    float sngShapeRight = sngCenterH + sngDistH;                   //Actual Right
                                                                                   //Vertical Distances
                    float sngCenterV     = tShp.Top + tShp.Height / 2;
                    float sngDistV       = formatobj.fFindVerticalDistance(tShp);  //This is half of vertical distance
                    float sngShapeTop    = sngCenterV - sngDistV;                  //Actual Top
                    float sngShapeBottom = sngCenterV + sngDistV;                  //Actual Bottom
                    if ((tShp.Left + tShp.Width) > sldRight)
                    {
                        tShp.Left = sldRight - tShp.Width;
                    }
                    if ((tShp.Top + tShp.Height) > sldBottom)
                    {
                        tShp.Top = sldBottom - tShp.Height;
                    }
                    if (tShp.Top < sldTop)
                    {
                        tShp.Top = sldTop;
                    }
                    if (tShp.Left < sldLeft)
                    {
                        tShp.Left = sldLeft;
                    }
                    //if (sngShapeLeft < sldLeft) { tShp.Left = tShp.Left + (sldLeft - sngShapeLeft); }
                    //if (sngShapeRight > sldRight) { tShp.Left = sldRight-tShp.Width; }  //tShp.Left - (sngShapeRight - sldRight)
                    //if (sngShapeTop < sldTop) { tShp.Top = tShp.Top + (sldTop - sngShapeTop); }
                    //if (sngShapeBottom > sldBottom) { tShp.Top = tShp.Top - (sngShapeBottom - sldBottom); }
                }
                else
                {
                    if (tShp.Left < sldLeft)
                    {
                        tShp.Left = sldLeft;
                    }
                    if ((tShp.Left + tShp.Width) > sldRight)
                    {
                        tShp.Left = tShp.Left - (tShp.Left + tShp.Width - sldRight);
                    }
                    if (tShp.Top < sldTop)
                    {
                        tShp.Top = sldTop;
                    }
                    if ((tShp.Top + tShp.Height) > sldBottom)
                    {
                        tShp.Top = tShp.Top - (tShp.Top + tShp.Height - sldBottom);
                    }
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "CorrectFormat_ShapeInSlide");
            }
        }
コード例 #27
0
        public void FormatShape(int sldNum, string shpNum, DataTable dt, bool textAdjust = true, bool sizeAdjust = true)
        {
            CMsoTriState pptMsoObject = new CMsoTriState();

            try
            {
                PowerPoint.Shape Activeshape = ActivePPT.Slides[sldNum].Shapes[shpNum];
                List <int>       rgbVal      = new List <int>();
                List <int>       rgbVal1     = new List <int>();
                //if (textAdjust == false) { textAdjust = true; }
                //if (sizeAdjust == false) { sizeAdjust = true; }
                if (Convert.ToString(dt.Rows[0]["Name"]) != "Cagr Box")
                {
                    Activeshape.Name = Convert.ToString(dt.Rows[0]["Name"]);
                }
                //-- Selected object is line --
                Activeshape.Line.Visible = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LineVisible"])); //MsoTriState.msoTrue;                               // Apply a msoValue Condition
                Activeshape.Fill.Visible = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["FillVisible"])); //MsoTriState.msoFalse;
                if (Convert.ToInt32(dt.Rows[0]["LineVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineForeColor"]));
                    Activeshape.Line.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();              // Apply a msoValue Condition
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineBackColor"]));
                    Activeshape.Line.BackColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();              // Apply a msoValue Condition
                    Activeshape.Line.Weight        = (float)Convert.ToDouble(dt.Rows[0]["LineWeight"]);
                    Activeshape.Line.Style         = MsoLineStyle.msoLineSingle;
                    // Apply a msoValue Condition
                    //Activeshape.Line.Visible = MsoTriState.msoTrue;
                }// Apply a msoValue Condition
                 //'Shape Fill
                 //Activeshape.Fill.Visible = MsoTriState.msoCTrue;

                if (Convert.ToInt32(dt.Rows[0]["FillVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["FillColor"]));
                    Activeshape.Fill.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();               // Apply a msoValue Condition
                    Activeshape.Fill.Transparency  = Convert.ToInt32(dt.Rows[0]["FillTransparency"]);
                }

                //Shape Shadow
                Activeshape.Shadow.Visible = MsoTriState.msoFalse;                                // Apply a msoValue Condition
                if (Convert.ToInt32(dt.Rows[0]["ShadowVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineForeColor"]));
                    Activeshape.TextFrame.TextRange.Font.Name = Convert.ToString(dt.Rows[0]["FontName"]);
                    //LineForeColor
                    Activeshape.Shadow.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();            // Apply a msoValue Condition
                    Activeshape.Shadow.Blur          = Convert.ToInt32(dt.Rows[0]["ShadowBlur"]);
                    Activeshape.Shadow.Size          = Convert.ToInt32(dt.Rows[0]["ShadowSize"]);
                    Activeshape.Shadow.Transparency  = Convert.ToInt32(dt.Rows[0]["ShadowTransparency"]);
                    Activeshape.Shadow.OffsetX       = Convert.ToInt32(dt.Rows[0]["ShadowOffsetX"]);
                    Activeshape.Shadow.OffsetY       = Convert.ToInt32(dt.Rows[0]["ShadowOffsetY"]);
                }
                Activeshape.Rotation = Convert.ToInt32(dt.Rows[0]["Rotaion"]);

                Activeshape.LockAspectRatio = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LockAspectRatio"]));

                //Shape Position


                // -- Set a Text Frame -
                Activeshape.TextFrame.Orientation    = pptMsoObject.getOrientation(Convert.ToInt32(dt.Rows[0]["Orientation"]));
                Activeshape.TextFrame.VerticalAnchor = pptMsoObject.getVerticalAnchor(Convert.ToInt32(dt.Rows[0]["VerticalAnchor"]));
                Activeshape.TextFrame.AutoSize       = pptMsoObject.TxtAutoSize(0);                                       // Only for test -
                Activeshape.TextFrame.AutoSize       = pptMsoObject.TxtAutoSize(Convert.ToInt32(dt.Rows[0]["AutoSize"])); // Apply a msoValue Condition
                Activeshape.TextFrame.MarginLeft     = (float)Convert.ToDouble((dt.Rows[0]["MarginLeft"]));
                Activeshape.TextFrame.MarginRight    = (float)Convert.ToDouble((dt.Rows[0]["MarginRight"]));
                Activeshape.TextFrame.MarginTop      = (float)Convert.ToDouble((dt.Rows[0]["MarginTop"]));
                Activeshape.TextFrame.MarginBottom   = (float)Convert.ToDouble((dt.Rows[0]["MarginBottom"]));
                Activeshape.TextFrame.WordWrap       = MsoTriState.msoCTrue;
                if (Activeshape.Name == "Road Map")
                {
                    Activeshape.TextFrame2.TextRange.Font.Spacing = 1;
                }
                //----- Set shape text range format --
                if (textAdjust == true)
                {
                    if (Activeshape.Name == "Note Box" || Activeshape.Name == "Text Box")
                    {
                        string   defaultText = Convert.ToString(dt.Rows[0]["DefaultText"]).Replace("\n", "");
                        string[] text        = defaultText.Split(splitChar).ToArray();
                        if (Activeshape.Name == "Note Box")
                        {
                            Activeshape.TextFrame.TextRange.Text = text[0] + '\n' + text[1];
                        }
                        else if (Activeshape.Name == "Text Box")
                        {
                            Activeshape.TextFrame2.TextRange.Text = text[0] + "\r\n" + text[1] + "\r\n" + text[2] + "\r\n" + text[3];
                            //Activeshape.TextFrame.TextRange.Text = text[0] + '\n' + text[1] + '\n' + text[2] + '\n' + text[3];
                        }
                    }
                    else
                    {
                        Activeshape.TextFrame.TextRange.Text = Convert.ToString(dt.Rows[0]["DefaultText"]);
                    }
                }
                //List<int> rgbVal = new List<int>();
                rgbVal = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["FontColor"]));
                Activeshape.TextFrame.TextRange.Font.Name      = Convert.ToString(dt.Rows[0]["FontName"]);
                Activeshape.TextFrame.TextRange.Font.Bold      = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Bold"]));        //MsoTriState.msoCTrue;                        // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Italic    = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Italics"]));     //MsoTriState.msoFalse;                       // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Underline = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Underline"]));   //MsoTriState.msoFalse;                    // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Size      = Convert.ToInt32(dt.Rows[0]["FontSize"]);
                Activeshape.TextFrame.TextRange.Font.Color.RGB = System.Drawing.Color.FromArgb(rgbVal[0], rgbVal[1], rgbVal[2]).ToArgb(); // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Shadow    = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Shadow"]));      //MsoTriState.msoFalse;                       // Apply a msoValue Condition

                //Activeshape.TextFrame.TextRange.Paragraphs(1).ParagraphFormat.Bullet.Type = pptMsoObject.getPpBulletType(Convert.ToInt32(dt.Rows[0]["ParagraphBullet"]));  // Apply a msoValue Condition(Need to Check)

                // ---- Set the ParagraphFormat --
                Activeshape.TextFrame.TextRange.ParagraphFormat.Alignment          = pptMsoObject.ParagraphFormatAlignment(Convert.ToInt32(dt.Rows[0]["ParagraphAlignment"])); //PowerPoint.PpParagraphAlignment.ppAlignRight;               // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.ParagraphFormat.HangingPunctuation = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["ParagraphHangingPunctuation"]));  // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceBefore        = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceBefore"]));
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceAfter         = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceAfter"]));
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceWithin        = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceWithin"]));
                //Activeshape.TextFrame.Ruler.TabStops.DefaultSpacing = 45;


                Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = (float)Convert.ToDouble((dt.Rows[0]["RulerLevel1FirstMargin"]));
                Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = (float)Convert.ToDouble((dt.Rows[0]["RulerLevel1LeftMargin"]));

                // -'------------------- Specific Adjustments -----------------
                if (sizeAdjust == true)
                {
                    Activeshape.Left   = (float)Convert.ToDouble((dt.Rows[0]["ShapeLeft"]));
                    Activeshape.Top    = (float)Convert.ToDouble((dt.Rows[0]["ShapeTop"]));
                    Activeshape.Width  = (float)Convert.ToDouble((dt.Rows[0]["ShapeWidth"]));
                    Activeshape.Height = (float)Convert.ToDouble((dt.Rows[0]["ShapeHeight"]));
                }



                if (Activeshape.TextFrame.TextRange.Text.PadLeft(1) == " ")
                {
                    Activeshape.TextFrame.TextRange.Text = Activeshape.TextFrame.TextRange.Text.Trim();
                }

                var txtRange  = Activeshape.TextFrame.TextRange;
                int txtLength = Activeshape.TextFrame.TextRange.Count;
                //                                                      Check it why we do the comment -
                //byte result = Convert.ToByte(txtRange.Characters(1,1));
                //if(result==9 || result==10||result==11 || result==13|| result == 32) { txtRange.Text = txtRange.Text.PadRight(txtRange.Text.Length - 1); }
                //- - IF note box

                if (Convert.ToString(dt.Rows[0]["Name"]) == "Note Box")
                {
                    Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = 0;
                    Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = 0;
                    for (int x = 1; x <= txtRange.Paragraphs().Count; x++)
                    {
                        txtRange.Paragraphs(x).ParagraphFormat.HangingPunctuation = MsoTriState.msoFalse;
                    }
                    //int txtLen = Convert.ToString(dt.Rows[0]["DefaultText"]).Length;
                    //if (txtRange.Text.PadLeft(txtLen) != Convert.ToString(dt.Rows[0]["DefaultText"]))
                    //{
                    //    if (txtRange.Text.PadLeft(6) == "Notes:") { txtRange.Text = txtRange.Text.Substring(7, txtRange.Text.Length); }
                    //    else if (txtRange.Text.PadLeft(5) == "Notes:") { txtRange.Text = txtRange.Text.Substring(6, txtRange.Text.Length); }
                    //    txtRange.Text = Convert.ToString(dt.Rows[0]["DefaultText"]) + txtRange.Text;
                    //}
                }
                //- - IF Source Box
                if (Convert.ToString(dt.Rows[0]["Name"]) == "Source Box")
                {
                    Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = 0;
                    Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = 0;
                    for (int x = 1; x <= txtRange.Paragraphs().Count; x++)
                    {
                        txtRange.Paragraphs(x).ParagraphFormat.HangingPunctuation = MsoTriState.msoFalse;
                    }
                    //int txtLen = Convert.ToString(dt.Rows[0]["DefaultText"]).Length;
                    //if (txtRange.Text.PadLeft(txtLen) != Convert.ToString(dt.Rows[0]["DefaultText"]))
                    //{
                    //    if (txtRange.Text.Substring(0,8) == "Sources:") { txtRange.Text = txtRange.Text.Substring(9, txtRange.Text.Length); }
                    //    else if (txtRange.Text.PadLeft(5) == "Sources:") { txtRange.Text = txtRange.Text.Substring(8, txtRange.Text.Length); }
                    //    txtRange.Text = Convert.ToString(dt.Rows[0]["DefaultText"]) + txtRange.Text;
                    //}
                }
                //- - IF Road Map

                if (Convert.ToString(dt.Rows[0]["Name"]) == "Road Map")
                {
                    txtRange.ChangeCase(pptMsoObject.txtChangeCase(Convert.ToInt32(dt.Rows[0]["Case"])));
                }                                                                                                                                                    // Apply a msoValue Condition


                // --"Quote Box"
                int sn = 0, en = 0;
                if (Convert.ToString(dt.Rows[0]["Name"]) == "Quote Box")
                {
                    var rngs = txtRange.Find("–", 0, MsoTriState.msoCTrue, MsoTriState.msoFalse);
                    var rngE = txtRange.Find(")", 0, MsoTriState.msoCTrue, MsoTriState.msoFalse);
                    if (rngs != null)
                    {
                        sn = rngs.Start;
                    }
                    if (rngE != null)
                    {
                        en = rngE.Start + 3;
                    }
                    if (rngE != null && rngs != null)
                    {
                        txtRange.Characters(sn, en).Font.Italic = MsoTriState.msoCTrue;
                        txtRange.Characters(sn, en).Font.Italic = MsoTriState.msoFalse;
                        txtRange.Characters(sn, en).Font.Bold   = MsoTriState.msoCTrue;
                    }
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "FormatShape");
            }
        }
コード例 #28
0
 /// <summary>
 /// Copies the shape into this slide, without the usual position offset when an existing shape is already there.
 /// </summary>
 public Shape CopyShapeToSlide(Shape shape)
 {
     try
     {
         shape.Copy();
         var newShape = _slide.Shapes.Paste()[1];
         newShape.Left = shape.Left;
         newShape.Top = shape.Top;
         return newShape;
     }
     catch (COMException)
     {
         // invalid shape for copy paste (e.g. a placeholder title box with no content)
         return null;
     }
 }
コード例 #29
0
        public void RemoveAnimationsForShape(Shape shape)
        {
            IEnumerable<Effect> mainEffects = _slide.TimeLine.MainSequence.Cast<Effect>();
            DeleteEffectsForShape(shape, mainEffects);

            foreach (Sequence sequence in _slide.TimeLine.InteractiveSequences)
            {
                DeleteEffectsForShape(shape, sequence.Cast<Effect>());
            }
        }
コード例 #30
0
 public void ShowShapeAfterClick(Shape shape, int clickNumber)
 {
     SetShapeAsClickTriggered(shape, clickNumber, MsoAnimEffect.msoAnimEffectAppear);
 }
コード例 #31
0
 /// <summary>
 /// Returns the index of the first effect in the slide that belongs to the shape.
 /// </summary>
 public int IndexOfFirstEffect(Shape shape)
 {
     Sequence sequence = _slide.TimeLine.MainSequence;
     for (int i = 1; i <= sequence.Count; i++)
     {
         Effect effect = sequence[i];
         if (effect.Shape.Name == shape.Name && effect.Shape.Id == shape.Id)
             return i;
     }
     return -1;
 }
コード例 #32
0
        public void HideShapeAfterClick(Shape shape, int clickNumber)
        {
            Effect addedEffect = SetShapeAsClickTriggered(shape, clickNumber, MsoAnimEffect.msoAnimEffectAppear);

            addedEffect.Exit = MsoTriState.msoTrue;
        }
コード例 #33
0
        public void AddAppearDisappearAnimation(Shape sh)
        {
            Sequence sequence = _slide.TimeLine.MainSequence;
            Effect effectAppear = sequence.AddEffect(sh, MsoAnimEffect.msoAnimEffectAppear, MsoAnimateByLevel.msoAnimateLevelNone, MsoAnimTriggerType.msoAnimTriggerWithPrevious);
            effectAppear.Timing.Duration = 0;

            Effect effectDisappear = sequence.AddEffect(sh, MsoAnimEffect.msoAnimEffectAppear, MsoAnimateByLevel.msoAnimateLevelNone, MsoAnimTriggerType.msoAnimTriggerWithPrevious);
            effectDisappear.Exit = Office.MsoTriState.msoTrue;
            effectDisappear.Timing.Duration = 0;
        }
コード例 #34
0
 public static bool IsTemplateSlideMarker(Shape shape)
 {
     return(shape.Name == PptLabsTemplateMarkerShapeName);
 }
コード例 #35
0
        public static void AddFrameMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape initialShape, PowerPoint.Shape finalShape, float duration)
        {
            float initialX        = (initialShape.Left + (initialShape.Width) / 2);
            float initialY        = (initialShape.Top + (initialShape.Height) / 2);
            float initialRotation = initialShape.Rotation;
            float initialWidth    = initialShape.Width;
            float initialHeight   = initialShape.Height;
            float initialFont     = 0.0f;

            float finalX        = (finalShape.Left + (finalShape.Width) / 2);
            float finalY        = (finalShape.Top + (finalShape.Height) / 2);
            float finalRotation = finalShape.Rotation;
            float finalWidth    = finalShape.Width;
            float finalHeight   = finalShape.Height;
            float finalFont     = 0.0f;

            bool isFlippedHorizontally = initialShape.HorizontalFlip != finalShape.HorizontalFlip;
            bool isFlippedVertically   = initialShape.VerticalFlip != finalShape.VerticalFlip;

            if (isFlippedHorizontally)
            {
                finalWidth = -finalWidth;
            }
            if (isFlippedVertically)
            {
                finalHeight = -finalHeight;
            }

            if (initialShape.HasTextFrame == Office.MsoTriState.msoTrue && (initialShape.TextFrame.HasText == Office.MsoTriState.msoTriStateMixed || initialShape.TextFrame.HasText == Office.MsoTriState.msoTrue) && initialShape.TextFrame.TextRange.Font.Size != finalShape.TextFrame.TextRange.Font.Size)
            {
                finalFont   = finalShape.TextFrame.TextRange.Font.Size;
                initialFont = initialShape.TextFrame.TextRange.Font.Size;
            }

            if (Utils.ShapeUtil.IsStraightLine(initialShape))
            {
                double initialAngle = GetLineAngle(initialShape);
                double finalAngle   = GetLineAngle(finalShape);
                double deltaAngle   = initialAngle - finalAngle;
                finalRotation = (float)(RadiansToDegrees(deltaAngle));

                float initialLength      = (float)Math.Sqrt(initialWidth * initialWidth + initialHeight * initialHeight);
                float finalLength        = (float)Math.Sqrt(finalWidth * finalWidth + finalHeight * finalHeight);
                float initialAngleCosine = initialWidth / initialLength;
                float initialAngleSine   = initialHeight / initialLength;
                finalWidth  = finalLength * initialAngleCosine;
                finalHeight = finalLength * initialAngleSine;

                initialShape = MakePivotCenteredLine(animationSlide, initialShape);
            }

            int numFrames = (int)(duration / 0.04f);

            numFrames = (numFrames > 30) ? 30 : numFrames;

            initialWidth  = SetToPositiveMinIfIsZero(initialWidth);
            initialHeight = SetToPositiveMinIfIsZero(initialHeight);
            finalWidth    = SetToPositiveMinIfIsZero(finalWidth);
            finalHeight   = SetToPositiveMinIfIsZero(finalHeight);

            float incrementWidth    = ((finalWidth / initialWidth) - 1.0f) / numFrames;
            float incrementHeight   = ((finalHeight / initialHeight) - 1.0f) / numFrames;
            float incrementRotation = LegacyShapeUtil.GetMinimumRotation(initialRotation, finalRotation) / numFrames;
            float incrementLeft     = (finalX - initialX) / numFrames;
            float incrementTop      = (finalY - initialY) / numFrames;
            float incrementFont     = (finalFont - initialFont) / numFrames;

            AddFrameAnimationEffects(animationSlide, initialShape, incrementLeft, incrementTop, incrementWidth, incrementHeight, isFlippedHorizontally, isFlippedVertically, incrementRotation, incrementFont, duration, numFrames);
        }
コード例 #36
0
 public static bool IsNotTemplateSlideMarker(Shape shape)
 {
     return(!IsTemplateSlideMarker(shape));
 }
コード例 #37
0
        private static void AddFrameAnimationEffects(PowerPointSlide animationSlide, PowerPoint.Shape initialShape, float incrementLeft, float incrementTop, float incrementWidth, float incrementHeight, bool isFlippedHorizontally, bool isFlippedVertically, float incrementRotation, float incrementFont, float duration, int numFrames)
        {
            PowerPoint.Shape    lastShape = initialShape;
            PowerPoint.Sequence sequence  = animationSlide.TimeLine.MainSequence;
            for (int i = 1; i <= numFrames; i++)
            {
                PowerPoint.Shape dupShape = initialShape.Duplicate()[1];

                if (animationType == FrameMotionAnimationType.kInSlideAnimate ||
                    animationType == FrameMotionAnimationType.kZoomToAreaPan ||
                    animationType == FrameMotionAnimationType.kZoomToAreaDeMagnify ||
                    (i != 1 && animationType != FrameMotionAnimationType.kZoomToAreaDeMagnify))
                {
                    animationSlide.DeleteShapeAnimations(dupShape);
                }

                if (animationType == FrameMotionAnimationType.kZoomToAreaPan)
                {
                    dupShape.Name = "PPTLabsMagnifyPanAreaGroup" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
                }

                dupShape.LockAspectRatio = Office.MsoTriState.msoFalse;
                dupShape.Left            = initialShape.Left;
                dupShape.Top             = initialShape.Top;

                if (incrementWidth != 0.0f)
                {
                    dupShape.ScaleWidth(Math.Abs(1.0f + (incrementWidth * i)), Office.MsoTriState.msoFalse, Office.MsoScaleFrom.msoScaleFromMiddle);
                }

                if (incrementHeight != 0.0f)
                {
                    dupShape.ScaleHeight(Math.Abs(1.0f + (incrementHeight * i)), Office.MsoTriState.msoFalse, Office.MsoScaleFrom.msoScaleFromMiddle);
                }

                if (incrementRotation != 0.0f)
                {
                    dupShape.Rotation += (incrementRotation * i);
                }

                if (incrementLeft != 0.0f)
                {
                    dupShape.Left += (incrementLeft * i);
                }

                if (incrementTop != 0.0f)
                {
                    dupShape.Top += (incrementTop * i);
                }

                if (incrementFont != 0.0f)
                {
                    dupShape.TextFrame.TextRange.Font.Size += (incrementFont * i);
                }

                if (isFlippedHorizontally && 1.0f + (incrementWidth * i) < 0)
                {
                    dupShape.Flip(Office.MsoFlipCmd.msoFlipHorizontal);
                    dupShape.Rotation = -dupShape.Rotation;
                }

                if (isFlippedVertically && 1.0f + (incrementHeight * i) < 0)
                {
                    dupShape.Flip(Office.MsoFlipCmd.msoFlipVertical);
                    dupShape.Rotation = -dupShape.Rotation;
                }

                if (i == 1 && (animationType == FrameMotionAnimationType.kInSlideAnimate || animationType == FrameMotionAnimationType.kZoomToAreaPan))
                {
                    PowerPoint.Effect appear = sequence.AddEffect(dupShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick);
                }
                else
                {
                    PowerPoint.Effect appear = sequence.AddEffect(dupShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                    appear.Timing.TriggerDelayTime = ((duration / numFrames) * i);
                }

                PowerPoint.Effect disappear = sequence.AddEffect(lastShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious);
                disappear.Exit = Office.MsoTriState.msoTrue;
                disappear.Timing.TriggerDelayTime = ((duration / numFrames) * i);

                lastShape = dupShape;
            }

            if (animationType == FrameMotionAnimationType.kInSlideAnimate || animationType == FrameMotionAnimationType.kZoomToAreaPan || animationType == FrameMotionAnimationType.kZoomToAreaDeMagnify)
            {
                PowerPoint.Effect disappearLast = sequence.AddEffect(lastShape, PowerPoint.MsoAnimEffect.msoAnimEffectAppear, PowerPoint.MsoAnimateByLevel.msoAnimateLevelNone, PowerPoint.MsoAnimTriggerType.msoAnimTriggerAfterPrevious);
                disappearLast.Exit = Office.MsoTriState.msoTrue;
                disappearLast.Timing.TriggerDelayTime = duration;
            }
        }
コード例 #38
0
 public static bool IsIndicator(Shape shape)
 {
     return(shape.Name.StartsWith(PptLabsIndicatorShapeName));
 }
コード例 #39
0
        public async Task <bool> WriteData(String strID)
        {
            PowerPoint.Shapes shapes = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes;
            try
            {
                JObject jsonData = await RequestData.GetPredictData(strID);

                JObject          dataObj = jsonData["data"].ToObject <JObject>();
                PowerPoint.Shape shape   = PPTAPI.getShape(shapes, "Label_1");
                if (shape != null)
                {
                    shape.TextFrame.TextRange.Text = dataObj.Value <String>("labelInfo");
                }
                shape = PPTAPI.getShape(shapes, "DateLabel");
                if (shape != null)
                {
                    String strText = shape.TextFrame.TextRange.Text;
                    strText = strText.Replace("{Date}", dataObj.Value <String>("date"));
                    shape.TextFrame.TextRange.Text = strText;
                }

                shape = PPTAPI.getShape(shapes, "Table_1");
                if (shape != null)
                {
                    PowerPoint.Table table = shape.Table;

                    shape = PPTAPI.getShape(shapes, "Chart_1");
                    PowerPoint.Chart chart      = shape.Chart;
                    var                ws       = chart.ChartData.Workbook.Worksheets[1];
                    JArray             array    = dataObj.Value <JArray>("salesData");
                    List <PredictData> predicts = CoreAPI.Deserialize <List <PredictData> >(array.ToString());

                    int  col      = 2;
                    char colStart = 'B';
                    foreach (PredictData predict in predicts)
                    {
                        int    row  = 1;
                        String step = colStart + row.ToString();
                        ws.Range[step].Value = predict.Month;
                        table.Cell(row, col).Shape.TextFrame.TextRange.Text = predict.Sales;
                        row++;
                        step = colStart + row.ToString();
                        ws.Range[step].Value = predict.Sales;
                        table.Cell(row, col).Shape.TextFrame.TextRange.Text = predict.Ratio;
                        row++;
                        step = colStart + row.ToString();
                        ws.Range[step].Value = predict.Ratio;
                        col++;
                        colStart++;
                    }
                }

                shape = PPTAPI.getShape(shapes, "Image_1");
                if (shape != null)
                {
                    String strUrl = dataObj.Value <String>("imageUrl");
                    if (!String.IsNullOrEmpty(strUrl))
                    {
                        string strPath = Request.HttpDownload(strUrl).Result;
                        shapes.AddPicture(strPath, Microsoft.Office.Core.MsoTriState.msoCTrue, Microsoft.Office.Core.MsoTriState.msoCTrue,
                                          shape.Left, shape.Top, shape.Width, shape.Height);
                        shape.Delete();
                    }
                }
            }
            catch
            {
            }

            return(true);
        }
コード例 #40
0
        private int IsValidShapes(PowerPoint.ShapeRange selectedShapes)
        {
            PowerPoint.Shape referenceShape = selectedShapes[1];

            if (referenceShape.Type == Microsoft.Office.Core.MsoShapeType.msoGroup)
            {
                return(ResizeLabErrorHandler.ErrorCodeGroupShapeNotSupported);
            }

            PowerPoint.Adjustments referenceAdjustments = referenceShape.Adjustments;
            bool isAutoShapeOrCallout = referenceShape.Type == Microsoft.Office.Core.MsoShapeType.msoAutoShape ||
                                        referenceShape.Type == Microsoft.Office.Core.MsoShapeType.msoCallout;
            bool isFreeform = referenceShape.Type == Microsoft.Office.Core.MsoShapeType.msoFreeform;

            Utils.PPShape referencePPShape;
            List <System.Drawing.PointF> referenceShapePoints = null;

            if (isFreeform)
            {
                referencePPShape     = new Utils.PPShape(referenceShape, false);
                referenceShapePoints = referencePPShape.Points;
            }

            for (int i = 2; i <= selectedShapes.Count; i++)
            {
                PowerPoint.Shape currentShape = selectedShapes[i];

                if (currentShape.Type == Microsoft.Office.Core.MsoShapeType.msoGroup)
                {
                    return(ResizeLabErrorHandler.ErrorCodeGroupShapeNotSupported);
                }

                if (currentShape.Type != referenceShape.Type || currentShape.AutoShapeType != referenceShape.AutoShapeType)
                {
                    return(ResizeLabErrorHandler.ErrorCodeNotSameShapes);
                }

                if (isAutoShapeOrCallout)
                {
                    PowerPoint.Adjustments currentAdjustments = currentShape.Adjustments;

                    if (currentAdjustments.Count != referenceAdjustments.Count)
                    {
                        return(ResizeLabErrorHandler.ErrorCodeNotSameShapes);
                    }

                    for (int j = 1; j <= referenceAdjustments.Count; j++)
                    {
                        if (currentAdjustments[j] != referenceAdjustments[j])
                        {
                            return(ResizeLabErrorHandler.ErrorCodeNotSameShapes);
                        }
                    }
                }
                else if (isFreeform)
                {
                    Microsoft.Office.Core.MsoTriState isAspectRatio = selectedShapes.LockAspectRatio;
                    selectedShapes.LockAspectRatio = Microsoft.Office.Core.MsoTriState.msoFalse;

                    PowerPoint.Shape duplicateCurrentShape = currentShape.Duplicate()[1];
                    duplicateCurrentShape.Width    = referenceShape.Width;
                    duplicateCurrentShape.Height   = referenceShape.Height;
                    duplicateCurrentShape.Rotation = referenceShape.Rotation;
                    duplicateCurrentShape.Left     = referenceShape.Left;
                    duplicateCurrentShape.Top      = referenceShape.Top;
                    Utils.PPShape currentPPShape = new Utils.PPShape(duplicateCurrentShape, false);
                    List <System.Drawing.PointF> currentShapePoints = currentPPShape.Points;
                    duplicateCurrentShape.SafeDelete();

                    selectedShapes.LockAspectRatio = isAspectRatio;

                    if (!currentShapePoints.SequenceEqual(referenceShapePoints))
                    {
                        return(ResizeLabErrorHandler.ErrorCodeNotSameShapes);
                    }
                }
            }

            return(-1);
        }
コード例 #41
0
ファイル: Align_More.cs プロジェクト: tw-lws/OneKeyTools8
        private void button10_Click(object sender, EventArgs e)
        {
            PowerPoint.Selection sel = app.ActiveWindow.Selection;
            if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
            {
                forms.MessageBox.Show("请至少选择三个形状");
            }
            else
            {
                PowerPoint.ShapeRange range = sel.ShapeRange;
                if (sel.HasChildShapeRange)
                {
                    range = sel.ChildShapeRange;
                }
                else
                {
                    range = sel.ShapeRange;
                }
                int count = range.Count;
                if (count == 1)
                {
                    if (range[1].Type == Office.MsoShapeType.msoGroup && range[1].GroupItems.Count > 2)
                    {
                        float nt  = range[1].GroupItems[count].Top - range[1].GroupItems[1].Top - range[1].GroupItems[1].Height;
                        float nt2 = range[1].GroupItems[range[1].GroupItems.Count].Top - range[1].GroupItems[1].Top - range[1].GroupItems[1].Height;
                        float ct  = 0;
                        if (range[1].GroupItems.Count == 3)
                        {
                            if (range[1].GroupItems[2].Height >= nt)
                            {
                                range[1].GroupItems[2].Top = range[1].GroupItems[1].Top + range[1].GroupItems[1].Height + nt / 3;
                            }
                            else
                            {
                                nt = nt - range[1].GroupItems[2].Height;
                                range[1].GroupItems[2].Top = range[1].GroupItems[1].Top + range[1].GroupItems[1].Height + nt / 3;
                            }
                        }
                        else
                        {
                            List <float> heights = new List <float>();
                            foreach (PowerPoint.Shape item in range.GroupItems)
                            {
                                heights.Add(item.Height);
                            }

                            for (int j = 2; j < range[1].GroupItems.Count; j++)
                            {
                                PowerPoint.Shape item = range[1].GroupItems[j];
                                ct = ct + item.Height;
                                nt = nt - item.Height;
                            }

                            for (int k = 3; k < range[1].GroupItems.Count; k++)
                            {
                                float avgnt = 0;
                                if (ct > nt2)
                                {
                                    if (range[1].GroupItems.Count % 2 != 0)
                                    {
                                        avgnt = 2 * nt2 / (range[1].GroupItems.Count * range[1].GroupItems.Count);
                                    }
                                    else
                                    {
                                        avgnt = 2 * nt2 / (range[1].GroupItems.Count * (range[1].GroupItems.Count - 1));
                                    }
                                    range[1].GroupItems[2].Top = range[1].GroupItems[1].Top + range[1].GroupItems[1].Height + avgnt;
                                    range[1].GroupItems[k].Top = range[1].GroupItems[k - 1].Top + avgnt * (k - 1);
                                }
                                else
                                {
                                    if (range[1].GroupItems.Count % 2 != 0)
                                    {
                                        avgnt = 2 * nt / (range[1].GroupItems.Count * range[1].GroupItems.Count);
                                    }
                                    else
                                    {
                                        avgnt = 2 * nt / (range[1].GroupItems.Count * (range[1].GroupItems.Count - 1));
                                    }
                                    range[1].GroupItems[2].Top = range[1].GroupItems[1].Top + range[1].GroupItems[1].Height + avgnt;
                                    range[1].GroupItems[k].Top = range[1].GroupItems[k - 1].Top + range[1].GroupItems[k - 1].Height + avgnt * (k - 1);
                                }
                            }
                        }
                    }
                    else if (range[1].Type == Office.MsoShapeType.msoGroup && range[1].GroupItems.Count == 2)
                    {
                        MessageBox.Show("组合内至少要有三个形状");
                    }
                }
                else if (count == 2)
                {
                    MessageBox.Show("请选择至少三个形状");
                }
                else
                {
                    float nt  = range[count].Top - range[1].Top - range[1].Height;
                    float nt2 = range[count].Top - range[1].Top - range[1].Height;
                    float ct  = 0;
                    if (count == 3)
                    {
                        if (range[2].Height >= nt)
                        {
                            range[2].Top = range[1].Top + range[1].Height + nt / 3;
                        }
                        else
                        {
                            nt           = nt - range[2].Height;
                            range[2].Top = range[1].Top + range[1].Height + nt / 3;
                        }
                    }
                    else
                    {
                        List <float> heights = new List <float>();
                        foreach (PowerPoint.Shape item in range)
                        {
                            heights.Add(item.Height);
                        }

                        for (int j = 2; j < count; j++)
                        {
                            PowerPoint.Shape item = range[j];
                            ct = ct + item.Height;
                            nt = nt - item.Height;
                        }

                        for (int k = 3; k < count; k++)
                        {
                            float avgnt = 0;
                            if (ct > nt2)
                            {
                                if (count % 2 != 0)
                                {
                                    avgnt = 2 * nt2 / (count * count);
                                }
                                else
                                {
                                    avgnt = 2 * nt2 / (count * (count - 1));
                                }
                                range[2].Top = range[1].Top + range[1].Height + avgnt;
                                range[k].Top = range[k - 1].Top + avgnt * (k - 1);
                            }
                            else
                            {
                                if (count % 2 != 0)
                                {
                                    avgnt = 2 * nt / (count * count);
                                }
                                else
                                {
                                    avgnt = 2 * nt / (count * (count - 1));
                                }
                                range[2].Top = range[1].Top + range[1].Height + avgnt;
                                range[k].Top = range[k - 1].Top + range[k - 1].Height + avgnt * (k - 1);
                            }
                        }
                    }
                }
            }
        }
コード例 #42
0
        public static void AddStepBackFrameMotionAnimation(PowerPointSlide animationSlide, PowerPoint.Shape initialShape)
        {
            float initialX      = (initialShape.Left + (initialShape.Width) / 2);
            float initialY      = (initialShape.Top + (initialShape.Height) / 2);
            float initialWidth  = initialShape.Width;
            float initialHeight = initialShape.Height;

            float finalX      = PowerPointPresentation.Current.SlideWidth / 2;
            float finalY      = PowerPointPresentation.Current.SlideHeight / 2;
            float finalWidth  = PowerPointPresentation.Current.SlideWidth;
            float finalHeight = PowerPointPresentation.Current.SlideHeight;

            int   numFrames = 10;
            float duration  = numFrames * 0.04f;

            float incrementWidth  = ((finalWidth / initialWidth) - 1.0f) / numFrames;
            float incrementHeight = ((finalHeight / initialHeight) - 1.0f) / numFrames;
            float incrementLeft   = (finalX - initialX) / numFrames;
            float incrementTop    = (finalY - initialY) / numFrames;

            AddFrameAnimationEffects(animationSlide, initialShape, incrementLeft, incrementTop, incrementWidth, incrementHeight, isFlippedHorizontally: false, isFlippedVertically: false, incrementRotation: 0.0f, incrementFont: 0.0f, duration: duration, numFrames: numFrames);
        }
コード例 #43
0
ファイル: Table_Borders.cs プロジェクト: tw-lws/OneKeyTools8
        private void button2_Click(object sender, EventArgs e)
        {
            int   n1 = 0;
            float tr = 0f;

            try
            {
                tr = float.Parse(textBox1.Text.Trim()) / 100f;
            }
            catch {}

            float lw = 1f;

            try
            {
                lw = (float)numericUpDown1.Value;
            }
            catch {}

            int color1 = panel1.BackColor.R + panel1.BackColor.G * 256 + panel1.BackColor.B * 256 * 256;

            PowerPoint.Selection sel = app.ActiveWindow.Selection;
            if (sel.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
            {
                PowerPoint.ShapeRange range = sel.ShapeRange;
                if (sel.HasChildShapeRange)
                {
                    range = sel.ChildShapeRange;
                }

                for (int i = 1; i <= range.Count; i++)
                {
                    PowerPoint.Shape shape = range[i];
                    if (shape.Type == Office.MsoShapeType.msoTable)
                    {
                        List <int> numi = new List <int>();
                        List <int> numj = new List <int>();

                        for (int k = 1; k <= shape.Table.Rows.Count; k++)
                        {
                            for (int j = 1; j <= shape.Table.Columns.Count; j++)
                            {
                                if (shape.Table.Rows[k].Cells[j].Selected)
                                {
                                    numi.Add(k);
                                    numj.Add(j);
                                }
                            }
                        }

                        numi = numi.Distinct().ToList();
                        numj = numj.Distinct().ToList();
                        int rwcnt = numi.Count();
                        int clcnt = numj.Count();

                        if (checkBox1.Checked)
                        {
                            for (int m = 0; m < rwcnt; m++)
                            {
                                for (int n = 0; n < clcnt; n++)
                                {
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderTop].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderTop].Weight = lw;
                                    }
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderLeft].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderLeft].Weight = lw;
                                    }
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderBottom].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderBottom].Weight = lw;
                                    }
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderRight].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderRight].Weight = lw;
                                    }
                                }
                            }
                        }
                        if (checkBox2.Checked)
                        {
                            for (int m = 0; m < rwcnt; m++)
                            {
                                for (int n = 0; n < clcnt; n++)
                                {
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderTop].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderTop].ForeColor.RGB = color1;
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderTop].Transparency  = tr;
                                    }
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderLeft].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderLeft].ForeColor.RGB = color1;
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderLeft].Transparency  = tr;
                                    }
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderBottom].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderBottom].ForeColor.RGB = color1;
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderBottom].Transparency  = tr;
                                    }
                                    if (shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderRight].Visible == Office.MsoTriState.msoTrue)
                                    {
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderRight].ForeColor.RGB = color1;
                                        shape.Table.Rows[numi[m]].Cells[numj[n]].Borders[PowerPoint.PpBorderType.ppBorderRight].Transparency  = tr;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        n1 += 1;
                    }
                }
                if (n1 != 0)
                {
                    MessageBox.Show("有 " + n1 + "个图形不是表格元素,请选中表格或单元格区域之一");
                }
            }
            else if (sel.Type == PowerPoint.PpSelectionType.ppSelectionSlides)
            {
                PowerPoint.SlideRange slides = sel.SlideRange;
                foreach (PowerPoint.Slide slide in slides)
                {
                    foreach (PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.Type == Office.MsoShapeType.msoTable)
                        {
                            if (checkBox1.Checked)
                            {
                                for (int m = 1; m <= shape.Table.Rows.Count; m++)
                                {
                                    for (int n = 1; n <= shape.Table.Columns.Count; n++)
                                    {
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderTop].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderTop].Weight = lw;
                                        }
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderLeft].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderLeft].Weight = lw;
                                        }
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderBottom].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderBottom].Weight = lw;
                                        }
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderRight].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderRight].Weight = lw;
                                        }
                                    }
                                }
                            }
                            if (checkBox2.Checked)
                            {
                                for (int m = 1; m <= shape.Table.Rows.Count; m++)
                                {
                                    for (int n = 1; n <= shape.Table.Columns.Count; n++)
                                    {
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderTop].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderTop].ForeColor.RGB = color1;
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderTop].Transparency  = tr;
                                        }
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderLeft].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderLeft].ForeColor.RGB = color1;
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderLeft].Transparency  = tr;
                                        }
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderBottom].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderBottom].ForeColor.RGB = color1;
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderBottom].Transparency  = tr;
                                        }
                                        if (shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderRight].Visible == Office.MsoTriState.msoTrue)
                                        {
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderRight].ForeColor.RGB = color1;
                                            shape.Table.Rows[m].Cells[n].Borders[PowerPoint.PpBorderType.ppBorderRight].Transparency  = tr;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("请选中表格、单元格区域、幻灯片缩略图之一");
            }
        }
コード例 #44
0
        private string RetrieveCategoryName(Shape categoryNameBox)
        {
            var categoryNamePattern = new Regex(CategoryNameBoxSearchPattern);
            var namePatternMatch = categoryNamePattern.Match(categoryNameBox.TextFrame.TextRange.Text);
            var categoryName = namePatternMatch.Groups[1].Value;

            return categoryName;
        }
コード例 #45
0
        public void TransferAnimation(Shape source, Shape destination)
        {
            Sequence sequence = _slide.TimeLine.MainSequence;
            var enumerableSequence = sequence.Cast<Effect>().ToList();

            Effect entryDetails = enumerableSequence.FirstOrDefault(effect => effect.Shape.Equals(source));
            if (entryDetails != null)
            {
                InsertAnimationAtIndex(destination, entryDetails.Index, entryDetails.EffectType, entryDetails.Timing.TriggerType);
            }

            Effect exitDetails = enumerableSequence.Last(effect => effect.Shape.Equals(source));
            if (exitDetails != null && !exitDetails.Equals(entryDetails))
            {
                InsertAnimationAtIndex(destination, exitDetails.Index, exitDetails.EffectType,
                    exitDetails.Timing.TriggerType);
            }
        }
コード例 #46
0
        //Store cropped version of slide picture as global variable
        private void AddZoomSlideCroppedPicture(PowerPoint.Shape zoomShape)
        {
            zoomSlideCroppedShapes = GetShapesWithPrefix("PPTLabsMagnifyAreaGroup")[0];
            zoomSlideCroppedShapes.Visible = Office.MsoTriState.msoTrue;
            DeleteShapeAnimations(zoomSlideCroppedShapes);

            if (!ZoomToArea.backgroundZoomChecked)
            {
                zoomSlideCroppedShapes.PictureFormat.CropLeft += zoomShape.Left;
                zoomSlideCroppedShapes.PictureFormat.CropTop += zoomShape.Top;
                zoomSlideCroppedShapes.PictureFormat.CropRight += (PowerPointPresentation.Current.SlideWidth - (zoomShape.Left + zoomShape.Width));
                zoomSlideCroppedShapes.PictureFormat.CropBottom += (PowerPointPresentation.Current.SlideHeight - (zoomShape.Top + zoomShape.Height));

                LegacyShapeUtil.CopyShapePosition(zoomShape, ref zoomSlideCroppedShapes);
            }
        }
コード例 #47
0
 public void DeleteShapeAnimations(Shape sh)
 {
     Sequence sequence = _slide.TimeLine.MainSequence;
     for (int x = sequence.Count; x >= 1; x--)
     {
         Effect effect = sequence[x];
         if (effect.Shape.Name == sh.Name && effect.Shape.Id == sh.Id)
             effect.Delete();
     }
 }
コード例 #48
0
 /**
  * Creates a new TildaPicture Object from a Powerpoint Shape that is actually an image
  * @param PowerPoint.Shape
  */
 public TildaPicture(PowerPoint.Shape shape, int id = 0)
     : base(shape, id)
 {
 }
コード例 #49
0
 public bool HasEntryAnimation(Shape shape)
 {
     Sequence sequence = _slide.TimeLine.MainSequence;
     for (int x = sequence.Count; x >= 1; x--)
     {
         Effect effect = sequence[x];
         if (effect.Shape.Name == shape.Name && effect.Shape.Id == shape.Id)
             if (IsEntryEffect(effect))
                 return true;
     }
     return false;
 }
コード例 #50
0
 private static float GetSizeRatio(PowerPoint.Shape shape)
 {
     return(shape.Height / shape.Width);
 }
コード例 #51
0
 public static bool IsTemplateSlideMarker(Shape shape)
 {
     return shape.Name == PptLabsTemplateMarkerShapeName;
 }
コード例 #52
0
 private static void MoveToCenterForFitToHeight(PowerPoint.Shape selectedShape, float slideWidth)
 {
     selectedShape.Left = (slideWidth - selectedShape.Width) / 2;
     selectedShape.Top  = TopMost;
 }
コード例 #53
0
 public static bool IsIndicator(Shape shape)
 {
     return shape.Name.StartsWith(PptLabsIndicatorShapeName);
 }
コード例 #54
0
        private static PowerPoint.Shape MakePivotCenteredLine(PowerPointSlide animationSlide, PowerPoint.Shape line)
        {
            // Add a 180 degree rotated line to offset its pivot shift caused by arrowhead
            PowerPoint.Shape transparentLine = line.Duplicate()[1];
            transparentLine.Line.Transparency = 1.0f;
            transparentLine.Rotation          = 180.0f;
            transparentLine.Left = line.Left;
            transparentLine.Top  = line.Top;

            PowerPoint.Shape tempAnimationHolder = line.Duplicate()[1];
            animationSlide.TransferAnimation(line, tempAnimationHolder);

            List <PowerPoint.Shape> toGroup = new List <PowerPoint.Shape> {
                line, transparentLine
            };

            PowerPoint.Shape newLine = animationSlide.ToShapeRange(toGroup).Group();

            animationSlide.TransferAnimation(tempAnimationHolder, newLine);
            tempAnimationHolder.Delete();

            return(newLine);
        }
コード例 #55
0
 public Shape GetShapeWithSameIDAndName(Shape shapeToMatch)
 {
     Shape tempMatchingShape = null;
     foreach (Shape sh in _slide.Shapes)
     {
         if (shapeToMatch.Id == sh.Id && HaveSameNames(shapeToMatch, sh))
         {
             if (tempMatchingShape == null)
                 tempMatchingShape = sh;
             else
             {
                 if (GetDistanceBetweenShapes(shapeToMatch, sh) < GetDistanceBetweenShapes(shapeToMatch, tempMatchingShape))
                     tempMatchingShape = sh;
             }
         }
     }
     return tempMatchingShape;
 }
コード例 #56
0
        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 = DuplicateShapeInPlace(blurShape);
            }

            Utils.Graphics.MoveZToJustInFront(overlayShape, blurShape);

            var rgb = Utils.Graphics.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);
        }
コード例 #57
0
ファイル: correctPowerpoint.cs プロジェクト: kaiss78/hustoes
 //评分核心函数
 public int check_Kernel(List<OfficeElement> ls)
 {
     int points = 0, i;
     int curPart = -1;               //当前正在分析哪一部分的考点
     for (i = 0; i < ls.Count; i++)
     {
         OfficeElement oe = ls[i];
         #region 具体考点对象定位
         if (oe.AttribName == "Root")
             continue;
         if (oe.AttribName == "Presentations")
             continue;
         if (oe.AttribName == "Slide")
         {
             #region 幻灯片定位
             try
             {
                 int slideId = int.Parse(oe.AttribValue);
                 stuSld = stuPpt.Slides[slideId];
                 ansSld = ansPpt.Slides[slideId];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_SLIDE;
             continue;
         }
         if (oe.AttribName == "Background")
         {
             #region 幻灯片背景定位
             try
             {
                 stuBg = stuSld.Background;
                 ansBg = ansSld.Background;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_BACKGROUND;
             continue;
         }
         if (oe.AttribName == "Transition")
         {
             #region 过渡动画定位
             try
             {
                 stuTrans = stuSld.SlideShowTransition;
                 ansTrans = ansSld.SlideShowTransition;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_TRANSITION;
             continue;
         }
         if (oe.AttribName == "Effects")
         {
             continue;
         }
         if (oe.AttribName == "Effect")
         {
             #region 幻灯片动画定位
             try
             {
                 int effId = int.Parse(oe.AttribValue);
                 stuEffect = stuSld.TimeLine.MainSequence[effId];
                 ansEffect = ansSld.TimeLine.MainSequence[effId];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_EFFECT;
             continue;
         }
         if (oe.AttribName == "Shape")
         {
             #region Shape定位
             try
             {
                 int shapeId = int.Parse(oe.AttribValue);
                 stuShape = stuSld.Shapes[shapeId];
                 ansShape = ansSld.Shapes[shapeId];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_SHAPE;
             continue;
         }
         if (oe.AttribName == "Location")
         {
             curPart = PART_LOCATION;
             continue;
         }
         if (oe.AttribName == "Picture")
         {
             #region 图片属性定位
             try
             {
                 stuPf = stuShape.PictureFormat;
                 ansPf = ansShape.PictureFormat;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_PICTURE;
             continue;
         }
         if (oe.AttribName == "Run")
         {
             #region 文字部分定位
             try
             {
                 int runId = int.Parse(oe.AttribValue);
                 stuTr = stuShape.TextFrame.TextRange.Runs(0, 100);
                 ansTr = ansShape.TextFrame.TextRange.Runs(0, 100);
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_TEXTRANGE;
             continue;
         }
         if (oe.AttribName == "WordArt")
         {
             #region 艺术字定位
             try
             {
                 stuTf = stuShape.TextEffect;
                 ansTf = ansShape.TextEffect;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_WORDART;
             continue;
         }
         if (oe.AttribName == "ThreeD")
         {
             #region 三维属性定位
             try
             {
                 stu3d = stuShape.ThreeD;
                 ans3d = ansShape.ThreeD;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_3D;
             continue;
         }
         if (oe.AttribName == "Animation")
         {
             #region 自定义动画定位
             try
             {
                 stuAm = stuShape.AnimationSettings;
                 ansAm = ansShape.AnimationSettings;
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_ANIMATION;
             continue;
         }
         if (oe.AttribName == "ClickAction")
         {
             #region 单击动作定位
             try
             {
                 stuAcs = stuShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick];
                 ansAcs = ansShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseClick];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_ACTION;
             continue;
         }
         if (oe.AttribName == "MoveAction")
         {
             #region 鼠标移动动作定位
             try
             {
                 stuAcs = stuShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseOver];
                 ansAcs = ansShape.ActionSettings[PowerPoint.PpMouseActivation.ppMouseOver];
             }
             catch
             {
                 points = 0;
                 break;
             }
             #endregion
             curPart = PART_ACTION;
             continue;
         }
         #endregion
         #region 幻灯片判分
         if (curPart == PART_SLIDE)
         {
             switch (oe.AttribName)
             {
                 case "SlideName":
                     if (stuSld.Name == ansSld.Name)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "SlideIndex":
                     if (stuSld.SlideIndex == ansSld.SlideIndex)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Layout":
                     if (stuSld.Layout == ansSld.Layout)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 幻灯片背景判分
         if (curPart == PART_BACKGROUND)
         {
             switch (oe.AttribName)
             {
                 case "Fill":
                     if (stuBg.Fill.Type.Equals(ansBg.Fill.Type))
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "GradientType":
                     if (stuBg.Fill.PresetGradientType == ansBg.Fill.PresetGradientType)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "GradientStyle":
                     if (stuBg.Fill.GradientStyle == ansBg.Fill.GradientStyle)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 幻灯片过渡动画判分
         if (curPart == PART_TRANSITION)
         {
             switch (oe.AttribName)
             {
                 case "AdvanceOnClick":
                     if (stuTrans.AdvanceOnClick.Equals(ansTrans.AdvanceOnClick))
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "AdvanceOnTime":
                     if (stuTrans.AdvanceOnTime.Equals(ansTrans.AdvanceOnTime))
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "AdvanceTime":
                     if (stuTrans.AdvanceTime == ansTrans.AdvanceTime)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "EntryEffect":
                     if (stuTrans.EntryEffect.Equals(ansTrans.EntryEffect))
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Speed":
                     if (stuTrans.Speed.Equals(ansTrans.Speed))
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 幻灯片动画判分
         if (curPart == PART_EFFECT)
         {
             switch (oe.AttribName)
             {
                 case "DisplayName":
                     if (stuEffect.DisplayName == ansEffect.DisplayName)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "EffectType":
                     if (stuEffect.EffectType.Equals(ansEffect.EffectType))
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Exit":
                     if (stuEffect.Exit.Equals(ansEffect.Exit))
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Index":
                     if (stuEffect.Index == ansEffect.Index)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "ShapeName":
                     if (stuEffect.Shape.Name == ansEffect.Shape.Name)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Duration":
                     if (stuEffect.Timing.Duration == ansEffect.Timing.Duration)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Paragraph":
                     try
                     {
                         if (stuEffect.Paragraph == ansEffect.Paragraph)
                             points = int.Parse(oe.AttribValue);
                     }
                     catch { points = 0; }
                     break;
                 case "TextRangeStart":
                     try
                     {
                         if (stuEffect.TextRangeStart == ansEffect.TextRangeStart)
                             points = int.Parse(oe.AttribValue);
                     }
                     catch { points = 0; }
                     break;
                 case "TextRangeLength":
                     try
                     {
                         if (stuEffect.TextRangeLength == ansEffect.TextRangeLength)
                             points = int.Parse(oe.AttribValue);
                     }
                     catch { points = 0; }
                     break;
             }
             continue;
         }
         #endregion
         #region 幻灯片对象判分
         if (curPart == PART_SHAPE)
         {
             continue;
         }
         #endregion
         #region 对象类型、定位判分
         if (curPart == PART_LOCATION)
         {
             switch (oe.AttribName)
             {
                 case "ShapeName":
                     if (stuShape.Name == ansShape.Name)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Type":
                     if (stuShape.Type == ansShape.Type)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Top":
                     if (stuShape.Top == ansShape.Top)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Left":
                     if (stuShape.Left == ansShape.Left)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Height":
                     if (stuShape.Height == ansShape.Height)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Width":
                     if (stuShape.Width == ansShape.Width)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 图片属性判分
         if (curPart == PART_PICTURE)
         {
             switch (oe.AttribName)
             {
                 case "CropLeft":
                     if (stuPf.CropLeft == ansPf.CropLeft)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "CropTop":
                     if (stuPf.CropTop == ansPf.CropTop)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "CropRight":
                     if (stuPf.CropRight == ansPf.CropRight)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "CropBottom":
                     if (stuPf.CropBottom == ansPf.CropBottom)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 文本属性判分
         if (curPart == PART_TEXTRANGE)
         {
             switch (oe.AttribName)
             {
                 case "Text":
                     if (stuTr.Text == ansTr.Text)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Bold":
                     if (stuTr.Font.Bold == ansTr.Font.Bold)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Italic":
                     if (stuTr.Font.Italic == ansTr.Font.Italic)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Underline":
                     if (stuTr.Font.Underline == ansTr.Font.Underline)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontName":
                     if (stuTr.Font.Name == ansTr.Font.Name)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontSize":
                     if (stuTr.Font.Size == ansTr.Font.Size)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Shadow":
                     if (stuTr.Font.Shadow == ansTr.Font.Shadow)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Superscript":
                     if (stuTr.Font.Superscript == ansTr.Font.Superscript)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Subscript":
                     if (stuTr.Font.Subscript == ansTr.Font.Subscript)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "ForeColor":
                     if (stuTr.Font.Color.RGB == ansTr.Font.Color.RGB)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 艺术字属性判分
         if (curPart == PART_WORDART)
         {
             switch (oe.AttribName)
             {
                 case "Text":
                     if (stuTf.Text == ansTf.Text)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Bold":
                     if (stuTf.FontBold == ansTf.FontBold)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Italic":
                     if (stuTf.FontItalic == ansTf.FontItalic)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontName":
                     if (stuTf.FontName == ansTf.FontName)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "FontSize":
                     if (stuTf.FontSize == ansTf.FontSize)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Alignment":
                     if (stuTf.Alignment.ToString() == ansTf.Alignment.ToString())
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "PresetShape":
                     if (stuTf.PresetShape.ToString() == ansTf.PresetShape.ToString())
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "RotatedChars":
                     if (stuTf.RotatedChars.ToString() == ansTf.RotatedChars.ToString())
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Tracking":
                     if (stuTf.Tracking.ToString() == ansTf.Tracking.ToString())
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 三维属性判分
         if (curPart == PART_3D)
         {
             switch (oe.AttribName)
             {
                 case "ThreeDFormat":
                     if (stu3d.PresetThreeDFormat == ans3d.PresetThreeDFormat)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LightingDirection":
                     if (stu3d.PresetLightingDirection == ans3d.PresetLightingDirection)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "LightingSoftness":
                     if (stu3d.PresetLightingSoftness == ans3d.PresetLightingSoftness)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Material":
                     if (stu3d.PresetMaterial == ans3d.PresetMaterial)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "Depth":
                     if (stu3d.Depth == ans3d.Depth)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "ExtrusionDirection":
                     if (stu3d.PresetExtrusionDirection == ans3d.PresetExtrusionDirection)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 自定义动画判分
         if (curPart == PART_ANIMATION)
         {
             switch (oe.AttribName)
             {
                 case "AnimationOrder":
                     if (stuAm.AnimationOrder == ansAm.AnimationOrder)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "EntryEffect":
                     if (stuAm.EntryEffect == ansAm.EntryEffect)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "AdvanceMode":
                     if (stuAm.AdvanceMode == ansAm.AdvanceMode)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "AdvanceTime":
                     if (stuAm.AdvanceTime == ansAm.AdvanceTime)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
         #region 对象动作判分
         if (curPart == PART_ACTION)
         {
             switch (oe.AttribName)
             {
                 case "Action":
                     if (stuAcs.Action == ansAcs.Action)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "HyperlinkAddr":
                     if (stuAcs.Hyperlink.Address == ansAcs.Hyperlink.Address)
                         points = int.Parse(oe.AttribValue);
                     break;
                 case "HyperlinkSubAddr":
                     if (stuAcs.Hyperlink.SubAddress == ansAcs.Hyperlink.SubAddress)
                         points = int.Parse(oe.AttribValue);
                     break;
             }
             continue;
         }
         #endregion
     }
     return points;
 }
コード例 #58
0
        public static PowerPoint.ShapeRange Crop(PowerPoint.ShapeRange shapeRange)
        {
            bool hasChange = false;

            for (int i = 1; i <= shapeRange.Count; i++)
            {
                PowerPoint.Shape shape = shapeRange[i];

                // Store initial properties
                float currentRotation = shape.Rotation;
                float cropLeft        = shape.PictureFormat.CropLeft;
                float cropRight       = shape.PictureFormat.CropRight;
                float cropTop         = shape.PictureFormat.CropTop;
                float cropBottom      = shape.PictureFormat.CropBottom;

                // Set properties to zero to do proper calculations
                shape.PictureFormat.CropLeft   = 0;
                shape.PictureFormat.CropRight  = 0;
                shape.PictureFormat.CropTop    = 0;
                shape.PictureFormat.CropBottom = 0;
                shape.Rotation = 0;

                // Get unscaled dimensions
                PowerPoint.ShapeRange origShape = shape.Duplicate();
                origShape.ScaleWidth(1, Office.MsoTriState.msoTrue);
                origShape.ScaleHeight(1, Office.MsoTriState.msoTrue);
                float origWidth  = origShape.Width;
                float origHeight = origShape.Height;
                origShape.SafeDelete();

                Rectangle origImageRect    = new Rectangle();
                Rectangle croppedImageRect = new Rectangle();

                Utils.GraphicsUtil.ExportShape(shape, TempPngFileExportPath);
                using (Bitmap shapeBitmap = new Bitmap(TempPngFileExportPath))
                {
                    origImageRect = new Rectangle(0, 0, shapeBitmap.Width, shapeBitmap.Height);
                    try
                    {
                        croppedImageRect = GetImageBoundingRect(shapeBitmap, shape.Name);
                    }
                    catch (NotSupportedException e)
                    {
                        throw e;
                    }
                }

                float cropRatioLeft   = croppedImageRect.Left / (float)origImageRect.Width;
                float cropRatioRight  = (origImageRect.Width - croppedImageRect.Width) / (float)origImageRect.Width;
                float cropRatioTop    = croppedImageRect.Top / (float)origImageRect.Height;
                float cropRatioBottom = (origImageRect.Height - croppedImageRect.Height) / (float)origImageRect.Height;

                float newCropLeft   = Math.Max(origWidth * cropRatioLeft, cropLeft);
                float newCropRight  = Math.Max(origWidth * cropRatioRight, cropRight);
                float newCropTop    = Math.Max(origHeight * cropRatioTop, cropTop);
                float newCropBottom = Math.Max(origHeight * cropRatioBottom, cropBottom);

                if (!hasChange &&
                    (!IsApproximatelySame(newCropLeft, cropLeft) ||
                     !IsApproximatelySame(newCropRight, cropRight) ||
                     !IsApproximatelySame(newCropTop, cropTop) ||
                     !IsApproximatelySame(newCropBottom, cropBottom)))
                {
                    hasChange = true;
                }

                shape.Rotation = currentRotation;
                shape.PictureFormat.CropLeft   = newCropLeft;
                shape.PictureFormat.CropRight  = newCropRight;
                shape.PictureFormat.CropTop    = newCropTop;
                shape.PictureFormat.CropBottom = newCropBottom;
            }

            if (!hasChange)
            {
                throw new CropLabException(CropLabErrorHandler.ErrorCodeNoPaddingCropped.ToString());
            }

            return(shapeRange);
        }
コード例 #59
0
        private void PrepareForZoomToArea(PowerPoint.Shape zoomShape)
        {
            RemoveAnimationsForShapes(_slide.Shapes.Cast<PowerPoint.Shape>().ToList());
            DeleteIndicator();
            DeleteShapesWithPrefix("PPTLabsMagnifyAreaSlide");

            AddZoomSlideCroppedPicture(zoomShape);

            DeleteSlideNotes();
            DeleteSlideMedia();
            ManageSlideTransitions();
            indicatorShape = AddPowerPointLabsIndicator();
        }
コード例 #60
0
 private static float GetDiagonal(PowerPoint.Shape shape)
 {
     return((float)Math.Sqrt(Math.Pow(shape.Width / 2, 2) + Math.Pow(shape.Height / 2, 2)));
 }