Exemplo n.º 1
0
        private void buttonUpdateAllSlides_Click(object sender, RibbonControlEventArgs e)
        {
            string slideNotes = string.Empty;

            PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;

            if (null != slide)
            {
                if (slide.HasNotesPage == Office.MsoTriState.msoTrue)
                {
                    PowerPoint.SlideRange notesPages = slide.NotesPage;
                    foreach (PowerPoint.Shape shape in notesPages.Shapes)
                    {
                        if (shape.Type == Office.MsoShapeType.msoPlaceholder)
                        {
                            if (shape.PlaceholderFormat.Type == PowerPoint.PpPlaceholderType.ppPlaceholderBody)
                            {
                                slideNotes = shape.TextFrame.TextRange.Text;
                                break;
                            }
                        }
                    }
                }
            }

            PowerPoint.Presentation presentation = Globals.ThisAddIn.Application.ActivePresentation;
            foreach (PowerPoint.Slide presentationSlide in presentation.Slides)
            {
                presentationSlide.Select();
                UpdateCurrentSlide();
            }
        }
Exemplo n.º 2
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;
         }
         if (range.Count == 1)
         {
             range[1].Left = app.ActivePresentation.PageSetup.SlideWidth - range[1].Width;
         }
         else
         {
             for (int i = 2; i <= range.Count; i++)
             {
                 range[i].Left = range[1].Left + range[1].Width - range[i].Width;
             }
         }
     }
     else
     {
         PowerPoint.SlideRange srange = sel.SlideRange;
         float swidth = app.ActivePresentation.PageSetup.SlideWidth;
         foreach (PowerPoint.Slide item in srange)
         {
             for (int i = 1; i <= item.Shapes.Count; i++)
             {
                 item.Shapes[i].Left = swidth - item.Shapes[i].Width;
             }
         }
     }
 }
Exemplo n.º 3
0
 private void button3_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;
         }
         if (range.Count == 1)
         {
             range[1].Top = 0;
         }
         else
         {
             for (int i = 2; i <= range.Count; i++)
             {
                 range[i].Top = range[1].Top;
             }
         }
     }
     else
     {
         PowerPoint.SlideRange srange = sel.SlideRange;
         foreach (PowerPoint.Slide item in srange)
         {
             for (int i = 1; i <= item.Shapes.Count; i++)
             {
                 item.Shapes[i].Top = 0;
             }
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Seek for for notes in current PowerPoint slide.
        /// </summary>
        /// <returns>String with notes.</returns>
        static private string GetNotesFromCurrentSlide()
        {
            string slideNotes = string.Empty;

            PowerPoint.Slide slide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;

            if (null != slide)
            {
                if (slide.HasNotesPage == Office.MsoTriState.msoTrue)
                {
                    PowerPoint.SlideRange notesPages = slide.NotesPage;
                    foreach (PowerPoint.Shape shape in notesPages.Shapes)
                    {
                        if (shape.Type == Office.MsoShapeType.msoPlaceholder)
                        {
                            if (shape.PlaceholderFormat.Type == PowerPoint.PpPlaceholderType.ppPlaceholderBody)
                            {
                                slideNotes = shape.TextFrame.TextRange.Text;
                                break;
                            }
                        }
                    }
                }
            }

            return(slideNotes);
        }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var    client = new WebClient();
                String text   = client.DownloadString(maskedTextBox2.Text);

                HtmlDocument htmlDoc = new HtmlDocument();

                htmlDoc.LoadHtml(text);
                string result = htmlDoc.DocumentNode.InnerText;
                result = WebUtility.HtmlDecode(result);

                PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
                PowerPoint.SlideRange  ppSR  = ppApp.ActiveWindow.Selection
                                               .SlideRange;
                PowerPoint.Shape ppShap = ppSR.Shapes
                                          .AddTextbox(Office.MsoTextOrientation
                                                      .msoTextOrientationHorizontal, 0, 0, 900, 25);
                ppShap.TextEffect.Text = result;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 6
0
 private void Highlight(PowerPoint.SlideRange slides)
 {
     foreach (PowerPoint.Slide slide in slides)
     {
         Highlight(slide.Shapes.Cast <PowerPoint.Shape>());
     }
 }
Exemplo n.º 7
0
        /// <summary>
        ///     Clone an existing slide (make a copy)
        /// </summary>
        /// <param name="presentation">PPT.Presentation object instance</param>
        /// <param name="slide">PPT.Slide instance that is to be cloned</param>
        /// <param name="destination">Destination for the cloned slide</param>
        /// <param name="locationIndex">Optional index for the new slide (slide.Index)</param>
        /// <returns></returns>
        public PPT.SlideRange CloneSlide(
            PPT.Presentation presentation,
            PPT.Slide slide,
            Locations.Location destination,
            int locationIndex = 0)
        {
            PPT.SlideRange dupeSlide = slide.Duplicate();

            switch (destination)
            {
            case Locations.Location.First:
                dupeSlide.MoveTo(1);
                break;

            case Locations.Location.Last:
                dupeSlide.MoveTo((presentation.Slides.Count));
                break;

            case Locations.Location.Custom:
                dupeSlide.MoveTo(locationIndex);
                break;
            }

            return(dupeSlide);
        }
Exemplo n.º 8
0
 //Slide moving in edition view
 void ThisAddIn_SlideSelectionChanged(PowerPoint.SlideRange SldRange)
 {
     if (!this.expositionId.Equals(0))
     {
         String slideId = SldRange.SlideNumber.ToString();
         this.updateSlide(slideId);
     }
 }
Exemplo n.º 9
0
 private void Application_SlideSelectionChanged(PowerPoint.SlideRange SldRange)
 {
     //PowerPoint.Presentation actPPT = Globals.ThisAddIn.Application.ActivePresentation;
     //int sld = Globals.ThisAddIn.Application.ActiveWindow.Selection.SlideRange.SlideNumber;
     //string layout = Convert.ToString(actPPT.Slides[sld].CustomLayout.Name);
     //MessageBox.Show("Call Slide Insert Event : " + layout);
     ////throw new NotImplementedException();
 }
Exemplo n.º 10
0
        } // 슬라이드 번호 입력시, 해당 슬라이드로 이동

        private void SlideNoOnEdtbx(PowerPoint.SlideRange SldRange)
        {
            try
            {
                edtGoToSlide.Text = SldRange.SlideNumber.ToString();
            }
            catch // 슬라이드 여러 개 선택하면 에러남
            {
            }
        } // 슬라이드 이동시, 현재 슬라이드 번호를 에디트 박스에 넣어줌 ㅎ.ㅎ
Exemplo n.º 11
0
 /// <summary>
 /// Events cintrols slide selection to always have link on opened slide
 /// </summary>
 /// <param name="slideRange"></param>
 private void OnSlideSelectionChanged(PowerPoint.SlideRange slideRange)
 {
     try
     {
         CurrentSlide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;
     }
     catch
     {
     }
 }
Exemplo n.º 12
0
        public static void ShowPresentationToUser(PowerpointLoadInfo info)
        {
            //if (!System.IO.File.Exists(info.filePath)) return;
            PowerpointLoader loader;

            if (PRESENTATIONS.TryGetValue(info.filePath, out loader))
            {
                loader.saveAndClose();
            }

            MsoTriState ofalse = MsoTriState.msoFalse;
            MsoTriState otrue  = MsoTriState.msoTrue;

            PowerPoint.Application PowerPointApplication = new PowerPoint.Application();
            PowerPointApplication.Presentations.Open(@loader.FilePath, otrue, otrue, ofalse);

            int currrent = PowerPointApplication.Presentations.Count;

            PowerPoint.Presentation Presentation = PowerPointApplication.Presentations[currrent];

            int avanceTime = 2;
            int countSlide = Presentation.Slides.Count;

            int[] SlideIdx = new int[countSlide];
            for (int i = 0; i < countSlide; i++)
            {
                SlideIdx[i] = i + 1;
            }
            PowerPoint.SlideRange range = Presentation.Slides.Range(SlideIdx);
            range.SlideShowTransition.AdvanceOnTime = MsoTriState.msoTrue;
            range.SlideShowTransition.AdvanceTime   = avanceTime;
            range.SlideShowTransition.EntryEffect   = PowerPoint.PpEntryEffect.ppEffectBoxOut;

            Presentation.SlideShowSettings.StartingSlide = 1;
            Presentation.SlideShowSettings.EndingSlide   = countSlide;
            //Presentation.Save();
            Presentation.SlideShowSettings.Run();

            //long wait = (countSlide * avanceTime) * 1000;

            //Wait for the slide show to end.
            //while (PowerPointApplication.SlideShowWindows.Count >= 1)
            //    System.Threading.Thread.Sleep(1000);

            //if (Presentation != null) Presentation.Close();
            if (PowerPointApplication == null)
            {
                return;
            }
            if (PowerPointApplication.Presentations.Count == 0)
            {
                PowerPointApplication.Quit();
            }
        }
Exemplo n.º 13
0
        private static void SelectFragment(PowerPoint.Presentation ppt, string fragment)
        {
            string[] sheet_cell = fragment.Split('!');

            if (!Int32.TryParse(sheet_cell[0], out int pageNo))
            {
                Forms.MessageBox.Show($"Slide number {sheet_cell[0]} is not a number."
                                      , TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
                return;
            }
            if (pageNo <= 0 || ppt.Slides.Count < pageNo)
            {
                Forms.MessageBox.Show($"Slide number {pageNo} is out of range. the presentation has only {ppt.Slides.Count} slide[s]."
                                      , TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                ppt.Application.ActiveWindow.View.GotoSlide(pageNo);
                if (sheet_cell.Length <= 1)
                {
                    return;
                }

                string[] names = sheet_cell[1].Split(',');
                PowerPoint.SlideRange slide = ppt.Slides.Range(pageNo);
                foreach (string name in names)
                {
                    new Action(() =>
                    {
                        for (int i = 0; i < slide.Shapes.Count; i++)
                        {
                            PowerPoint.Shape shape = slide.Shapes[1 + i];
                            if (shape.Name.Equals(name))
                            {
                                shape.Select(MsoTriState.msoFalse);
                                return;
                            }
                        }
                        Forms.MessageBox.Show($"Object \"{name}\" not found", TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
                    })();
                }
            }
            catch (COMException ex)
            {
                Forms.MessageBox.Show(ex.Message + ex.StackTrace, TITLE, Forms.MessageBoxButtons.OK, Forms.MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 自动播放PPT文档.
        /// </summary>
        /// <param name="filePath">PPTy文件路径.</param>
        /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param>
        public void PPTAuto(string filePath, int playTime)
        {
            //防止连续打开多个PPT程序.
            if (this.objApp != null)
            {
                return;
            }

            objApp     = new POWERPOINT.Application();
            objPresSet = objApp.Presentations.Open(filePath, OFFICECORE.MsoTriState.msoCTrue, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse);

            // 自动播放的代码(开始)
            int Slides = objPresSet.Slides.Count;

            int[] SlideIdx = new int[Slides];
            for (int i = 0; i < Slides; i++)
            {
                SlideIdx[i] = i + 1;
            }
            ;
            objSldRng = objPresSet.Slides.Range(SlideIdx);
            objSST    = objSldRng.SlideShowTransition;
            //设置翻页的时间.
            objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue;
            objSST.AdvanceTime   = playTime;
            //翻页时的特效!
            objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut;

            //Prevent Office Assistant from displaying alert messages:
            bAssistantOn        = objApp.Assistant.On;
            objApp.Assistant.On = false;

            //Run the Slide show from slides 1 thru 3.
            objSSS = objPresSet.SlideShowSettings;
            objSSS.StartingSlide = 1;
            objSSS.EndingSlide   = Slides;
            objSSS.Run();

            //Wait for the slide show to end.
            objSSWs = objApp.SlideShowWindows;
            while (objSSWs.Count >= 1)
            {
                System.Threading.Thread.Sleep(playTime * 100);
            }

            this.objPresSet.Close();
            this.objApp.Quit();
        }
Exemplo n.º 15
0
 public void Close()
 {
     pptSST    = null;
     pptSldRng = null;
     if (pptApp != null)
     {
         pptApp.Quit();
     }
     pptApp = null;
     if (pptDoc != null)
     {
         pptDoc.Close();
     }
     pptDoc = null;
     GC.Collect();
 }
Exemplo n.º 16
0
        void ComponentslistViewModel_ReportDragEvent(object sender, TaskPaneComponents.DragEventArgs e)
        {
            try
            {
                PowerPoint.Presentation presentation = Globals.ThisAddIn.Application.ActivePresentation;

                if (presentation != null)
                {
                    PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
                    PowerPoint.SlideRange  ppSR  = ppApp.ActiveWindow.Selection.SlideRange;

                    e.Component.Shape.Copy();
                    ppSR.Shapes.Paste();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Properties.Resources.DragDropErrMsg, ex.Message));
            }
        }
Exemplo n.º 17
0
        public void SetLine()
        {
            int num = PageNum();

            for (int i = 0; i < num; i++)
            {
                if (i > 2)
                {
                    objSldRng = objPresSet.Slides.Range(i);
                    objSldRng.Select();
                    try
                    {
                        objSldRng.Application.ActiveWindow.Selection.SlideRange.Shapes.SelectAll();
                        objSldRng.Application.ActiveWindow.Selection.ShapeRange.Line.Visible = OFFICECORE.MsoTriState.msoFalse;
                    }
                    catch
                    { }
                }
            }
        }
Exemplo n.º 18
0
        private void button1_Click_1(object sender, RibbonControlEventArgs e)
        {
            PowerPoint.Application thisApp = Globals.ThisAddIn.Application;
            PowerPoint.SlideRange  slide   = thisApp.ActiveWindow.Selection
                                             .SlideRange;
            var slideWidth = slide.CustomLayout.Width;

            foreach (PowerPoint.Shape shape in slide.Shapes)
            {
                if (shape.Type == Office.MsoShapeType.msoTextBox)
                {
                    if ((shape.Width + shape.Left + 10) <= slideWidth)
                    {
                        shape.IncrementLeft(10);
                    }
                    shape.TextEffect.FontBold = Office.MsoTriState.msoTrue;
                    shape.TextFrame.TextRange.Font.Color.RGB = 255;
                }
            }
        }
Exemplo n.º 19
0
        public void Open(string PPT)
        {
            if (!System.IO.File.Exists(PPT))
            {
                return;
            }
            try
            {
                axFramerControl1.Open(PPT, true, "PowerPoint.Show", "", "");
                pptDoc = (Presentation)axFramerControl1.ActiveDocument;
                pptApp = pptDoc.Application;
                pptDoc.SlideShowSettings.RangeType        = PpSlideShowRangeType.ppShowNamedSlideShow;
                pptDoc.SlideShowSettings.ShowType         = PpSlideShowType.ppShowTypeWindow;
                pptDoc.SlideShowSettings.LoopUntilStopped = MsoTriState.msoCTrue;
                int   Slides   = pptDoc.Slides.Count;
                int[] SlideIdx = new int[Slides];
                for (int i = 0; i < SlideIdx.Length; i++)
                {
                    SlideIdx[i] = i + 1;
                }
                pptSldRng = pptDoc.Slides.Range(SlideIdx);
                pptSST    = pptSldRng.SlideShowTransition;

                pptSST.AdvanceOnTime = MsoTriState.msoCTrue;
                pptSST.AdvanceTime   = flushSpeed;
                pptSST.EntryEffect   = PpEntryEffect.ppEffectFade;

                pptDoc.Save();


                SendKeys.Send("{F5}");
            }
            catch (Exception e)
            {
                All.Class.Error.Add(e);
            }
        }
Exemplo n.º 20
0
        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("请选中表格、单元格区域、幻灯片缩略图之一");
            }
        }
 private void Application_SlideSelectionChanged(PowerPoint.SlideRange SldRange)
 {
     FlashSketch.Instance.SlideSelection = SldRange;
 }
Exemplo n.º 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            PowerPoint.Slide     slide  = app.ActiveWindow.View.Slide;
            PowerPoint.Slides    slides = app.ActivePresentation.Slides;
            PowerPoint.Selection sel    = app.ActiveWindow.Selection;
            if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
            {
                forms.MessageBox.Show("请选中要导出的幻灯片");
            }
            else if (sel.Type == PowerPoint.PpSelectionType.ppSelectionSlides)
            {
                int      wresolution = int.Parse(textBox1.Text.Trim());
                int      prow        = int.Parse(textBox2.Text.Trim());
                int      pspac       = int.Parse(textBox3.Text.Trim());
                int      pspac2      = int.Parse(textBox4.Text.Trim());
                String[] arr         = textBox5.Text.Trim().Split(char.Parse(","), char.Parse(" "), char.Parse(",")).ToArray();

                if (wresolution <= 0 || prow <= 0 || pspac < 0 || pspac2 < 0 || arr.Count() <= 0)
                {
                    MessageBox.Show("水平宽度/列数必须是正整数,间隔大小必须是非负整数,大图设置中的页码不能为空");
                }
                else
                {
                    PowerPoint.SlideRange srange = sel.SlideRange;
                    int   count = srange.Count;
                    int[] index = new int[count];                      //index数组用于将页面的选择顺序强制从前到后
                    for (int i = 1; i <= count; i++)
                    {
                        index[i - 1] = srange[i].SlideIndex;
                    }
                    Array.Reverse(index);
                    Array.Sort(index);
                    sel.Unselect();
                    slides.Range(index).Select();

                    int[,] arrnew = new int[index.Count(), 2];             //arrnew用于初始化,arrnew[i,0]是所有页面的序号,arrnew[i,1]默认是小图
                    for (int i = 0; i < index.Count(); i++)
                    {
                        arrnew[i, 0] = index[i];
                        arrnew[i, 1] = 0;
                    }

                    if (arr.Count() > 1)                                    //将arr数组中的“n”替换为选择的最后一页的页码
                    {
                        for (int i = 0; i < arr.Count(); i++)
                        {
                            if (arr[i] == "n")
                            {
                                arr[i] = count.ToString();
                            }
                        }
                    }
                    else if (arr[0] == "n")
                    {
                        arr[0] = count.ToString();
                    }

                    int arrprow1 = 0;
                    for (int i = 0; i < arrnew.Length / 2; i++)                  //根据数组arr标记arrnew[i,1]中哪些页面是大图
                    {
                        if (prow == 1)
                        {
                            arrnew[i, 1] = 1;
                            arrprow1    += 1;
                        }
                        else
                        {
                            for (int j = 0; j < arr.Count(); j++)
                            {
                                if (arrnew[i, 0] == int.Parse(arr[j]))
                                {
                                    arrnew[i, 1] = 1;
                                    arrprow1    += 1;
                                }
                            }
                        }
                    }

                    int wlarge = wresolution - pspac2 * 2;         //根据用户设置的分辨率,计算大图和小图的宽度和高度
                    int hlarge = (int)(wlarge * h / w);
                    int wsmall = (int)((wlarge - (prow - 1) * pspac) / prow);
                    int hsmall = (int)(wsmall * h / w);

                    int arrcount = arrnew.Length / 2;
                    int[,] narr = new int[arrcount, 2];  //narr[0,0]是大图小图标识、narr[0,1]是水平序号
                    int wcount  = 0;                     //wcount是水平序号、hcount是垂直序号、hscount是垂直方向上小图的行数、hscan是小图是否重新起一行
                    int hcount  = 0;
                    int hscount = 0;
                    int hscan   = 0;
                    for (int i = 0; i < arrcount; i++)
                    {
                        if (arrnew[i, 1] == 1)
                        {
                            narr[i, 0] = 1;
                            hcount    += 1;
                            wcount     = 0;
                            hscan      = 0;
                        }
                        else
                        {
                            narr[i, 0] = 0;
                            if (wcount == 0)
                            {
                                if (hscan == 0)
                                {
                                    narr[i, 1] = wcount;
                                    wcount    += 1;
                                    hscount   += 1;
                                    hcount    += 1;
                                }
                                else
                                {
                                    wcount    += 1;
                                    narr[i, 1] = wcount;
                                    wcount    += 1;
                                }
                            }
                            else
                            {
                                if (wcount < prow)
                                {
                                    narr[i, 1] = wcount;
                                    wcount    += 1;
                                }
                                else
                                {
                                    wcount     = 0;
                                    narr[i, 1] = wcount;
                                    hscount   += 1;
                                    hcount    += 1;
                                    hscan      = 1;
                                }
                            }
                        }
                    }

                    Bitmap bmp0 = new Bitmap(wresolution, hlarge * arrprow1 + hsmall * hscount + pspac * (hcount - 1) + pspac2 * 2);    //计算长图的尺寸、设置长图的分辨率
                    float  dpi  = Properties.Settings.Default.dpi;
                    bmp0.SetResolution(dpi, dpi);

                    string name = app.ActivePresentation.Name;                  //根据演示文稿的文件名创建长图文件夹
                    if (name.Contains(".pptx"))
                    {
                        name = name.Replace(".pptx", "");
                    }
                    else if (name.Contains(".ppt"))
                    {
                        name = name.Replace(".ppt", "");
                    }
                    string cPath = app.ActivePresentation.Path + @"\" + name + @" 的幻灯片\";

                    if (!Directory.Exists(cPath))
                    {
                        Directory.CreateDirectory(cPath);
                    }

                    for (int i = 1; i <= sel.SlideRange.Count; i++)                //导出所选的页面为图片
                    {
                        PowerPoint.Slide nslide = sel.SlideRange[i];
                        string           shname = name + "_临时_" + i;
                        nslide.Export(cPath + shname + ".jpg", "jpg", wresolution, (int)(wresolution * h / w));
                    }

                    Graphics g = Graphics.FromImage(bmp0);
                    if (!checkBox3.Checked)                                         //设置长图的底色
                    {
                        SolidBrush br = new SolidBrush(panel1.BackColor);
                        g.FillRectangle(br, 0, 0, bmp0.Width, bmp0.Height);
                    }

                    int ny = pspac2;
                    int sc = 1;
                    for (int i = 1; i <= count; i++)                                //读取之前导出的临时图片,根据之前的narr数组计算该图片所在的位置和尺寸
                    {
                        string shname2 = name + "_临时_" + i;
                        Bitmap bmp1    = new Bitmap(cPath + shname2 + ".jpg");
                        int    x       = 0;
                        int    y       = 0;
                        int    wd      = 0;
                        int    ht      = 0;

                        if (narr[i - 1, 0] == 1)
                        {
                            wd = wlarge;
                            ht = hlarge;
                            x  = pspac2;
                            y  = y + ny;
                            ny = ny + ht + pspac;
                        }
                        else
                        {
                            wd = wsmall;
                            ht = hsmall;
                            x  = pspac2 + narr[i - 1, 1] * (wd + pspac);
                            y  = y + ny;
                            if (sc < prow)
                            {
                                if (i < count && narr[i, 0] == 1)
                                {
                                    sc = 1;
                                    ny = ny + ht + pspac;
                                }
                                else
                                {
                                    sc += 1;
                                }
                            }
                            else
                            {
                                sc = 1;
                                ny = ny + ht + pspac;
                            }
                        }
                        g.DrawImage(bmp1, x, y, wd, ht);                          //在长图中进行绘制
                        bmp1.Dispose();
                        File.Delete(cPath + shname2 + ".jpg");
                    }

                    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(cPath);   //保存长图为png或jpg
                    int k = dir.GetFiles().Length + 1;
                    if (checkBox3.Checked)
                    {
                        bmp0.Save(cPath + name + "_" + k + ".png", ImageFormat.Png);
                    }
                    else
                    {
                        bmp0.Save(cPath + name + "_" + k + ".jpg", ImageFormat.Jpeg);
                    }
                    bmp0.Dispose();
                    System.Diagnostics.Process.Start("Explorer.exe", cPath);            //完成后,打开长图所在文件夹
                }
            }
            else
            {
                MessageBox.Show("请选中至少1张幻灯片");
            }
        }
Exemplo n.º 23
0
 private void button1_Click(object sender, EventArgs e)
 {
     PowerPoint.Selection sel = app.ActiveWindow.Selection;
     if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
     {
         MessageBox.Show("请选中需要统一文字的页面或文本框");
     }
     else if (sel.Type == PowerPoint.PpSelectionType.ppSelectionSlides)
     {
         PowerPoint.SlideRange srange = sel.SlideRange;
         foreach (PowerPoint.Slide slide in srange)
         {
             int count = slide.Shapes.Count;
             for (int i = 1; i <= count; i++)
             {
                 if (slide.Shapes[i].HasTextFrame == Office.MsoTriState.msoTrue)
                 {
                     if (slide.Shapes[i].TextFrame.HasText == Office.MsoTriState.msoTrue)
                     {
                         PowerPoint.ParagraphFormat pf = slide.Shapes[i].TextFrame.TextRange.ParagraphFormat;
                         if (checkBox1.Checked)
                         {
                             slide.Shapes[i].TextFrame.TextRange.Font.Name        = font.Name;
                             slide.Shapes[i].TextFrame.TextRange.Font.NameFarEast = font.Name;
                             if (font.Style == FontStyle.Italic)
                             {
                                 slide.Shapes[i].TextFrame.TextRange.Font.Italic = Office.MsoTriState.msoTrue;
                             }
                             if (font.Style == FontStyle.Bold)
                             {
                                 slide.Shapes[i].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoTrue;
                             }
                         }
                         if (checkBox2.Checked)
                         {
                             slide.Shapes[i].TextFrame.TextRange.Font.Size = float.Parse(textBox1.Text.Trim());
                         }
                         if (checkBox3.Checked)
                         {
                             slide.Shapes[i].TextFrame.TextRange.Font.Color.RGB = panel1.BackColor.R + panel1.BackColor.G * 256 + panel1.BackColor.B * 256 * 256;
                         }
                         if (checkBox4.Checked)
                         {
                             pf.WordWrap    = Office.MsoTriState.msoTrue;
                             pf.SpaceWithin = float.Parse(textBox2.Text.Trim());
                         }
                         if (checkBox5.Checked)
                         {
                             if (comboBox1.Text == "两端对齐")
                             {
                                 pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignJustify;
                             }
                             else if (comboBox1.Text == "左对齐")
                             {
                                 pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignLeft;
                             }
                             else if (comboBox1.Text == "右对齐")
                             {
                                 pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignRight;
                             }
                             else if (comboBox1.Text == "居中对齐")
                             {
                                 pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignCenter;
                             }
                             else if (comboBox1.Text == "分散对齐")
                             {
                                 pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignDistribute;
                             }
                             else if (comboBox1.Text == "顶部对齐")
                             {
                                 slide.Shapes[i].TextFrame.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorTop;
                             }
                             else if (comboBox1.Text == "中部对齐")
                             {
                                 slide.Shapes[i].TextFrame.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorMiddle;
                             }
                             else if (comboBox1.Text == "底部对齐")
                             {
                                 slide.Shapes[i].TextFrame.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorBottom;
                             }
                         }
                     }
                     if (slide.Shapes[i].TextFrame2.HasText == Office.MsoTriState.msoTrue)
                     {
                         if (checkBox1.Checked)
                         {
                             slide.Shapes[i].TextFrame2.TextRange.Font.Name        = font.Name;
                             slide.Shapes[i].TextFrame2.TextRange.Font.NameFarEast = font.Name;
                             if (font.Style == FontStyle.Italic)
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.Font.Italic = Office.MsoTriState.msoTrue;
                             }
                             if (font.Style == FontStyle.Bold)
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.Font.Bold = Office.MsoTriState.msoTrue;
                             }
                         }
                         if (checkBox2.Checked)
                         {
                             slide.Shapes[i].TextFrame2.TextRange.Font.Size = float.Parse(textBox1.Text.Trim());
                         }
                         if (checkBox3.Checked)
                         {
                             slide.Shapes[i].TextFrame2.TextRange.Font.Fill.BackColor.RGB = panel1.BackColor.R + panel1.BackColor.G * 256 + panel1.BackColor.B * 256 * 256;
                         }
                         if (checkBox4.Checked)
                         {
                             slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.WordWrap    = Office.MsoTriState.msoTrue;
                             slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.SpaceWithin = float.Parse(textBox2.Text.Trim());
                         }
                         if (checkBox5.Checked)
                         {
                             if (comboBox1.Text == "两端对齐")
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignJustify;
                             }
                             else if (comboBox1.Text == "左对齐")
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignLeft;
                             }
                             else if (comboBox1.Text == "右对齐")
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignRight;
                             }
                             else if (comboBox1.Text == "居中对齐")
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignCenter;
                             }
                             else if (comboBox1.Text == "分散对齐")
                             {
                                 slide.Shapes[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignDistribute;
                             }
                             else if (comboBox1.Text == "顶部对齐")
                             {
                                 slide.Shapes[i].TextFrame2.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorTop;
                             }
                             else if (comboBox1.Text == "中部对齐")
                             {
                                 slide.Shapes[i].TextFrame2.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorMiddle;
                             }
                             else if (comboBox1.Text == "底部对齐")
                             {
                                 slide.Shapes[i].TextFrame2.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorBottom;
                             }
                         }
                     }
                 }
             }
         }
     }
     else if (sel.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
     {
         PowerPoint.ShapeRange range = sel.ShapeRange;
         if (sel.HasChildShapeRange)
         {
             range = sel.ChildShapeRange;
         }
         int count = range.Count;
         for (int i = 1; i <= count; i++)
         {
             if (range[i].HasTextFrame == Office.MsoTriState.msoTrue)
             {
                 if (range[i].TextFrame.HasText == Office.MsoTriState.msoTrue)
                 {
                     PowerPoint.ParagraphFormat pf = range[i].TextFrame.TextRange.ParagraphFormat;
                     if (checkBox1.Checked)
                     {
                         range[i].TextFrame.TextRange.Font.Name        = font.Name;
                         range[i].TextFrame.TextRange.Font.NameFarEast = font.Name;
                         if (font.Style == FontStyle.Italic)
                         {
                             range[i].TextFrame.TextRange.Font.Italic = Office.MsoTriState.msoTrue;
                         }
                         if (font.Style == FontStyle.Bold)
                         {
                             range[i].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoTrue;
                         }
                     }
                     if (checkBox2.Checked)
                     {
                         range[i].TextFrame.TextRange.Font.Size = float.Parse(textBox1.Text.Trim());
                     }
                     if (checkBox3.Checked)
                     {
                         range[i].TextFrame.TextRange.Font.Color.RGB = panel1.BackColor.R + panel1.BackColor.G * 256 + panel1.BackColor.B * 256 * 256;
                     }
                     if (checkBox4.Checked)
                     {
                         pf.WordWrap    = Office.MsoTriState.msoTrue;
                         pf.SpaceWithin = float.Parse(textBox2.Text.Trim());
                     }
                     if (checkBox5.Checked)
                     {
                         if (comboBox1.Text == "两端对齐")
                         {
                             pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignJustify;
                         }
                         else if (comboBox1.Text == "左对齐")
                         {
                             pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignLeft;
                         }
                         else if (comboBox1.Text == "右对齐")
                         {
                             pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignRight;
                         }
                         else if (comboBox1.Text == "居中对齐")
                         {
                             pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignCenter;
                         }
                         else if (comboBox1.Text == "分散对齐")
                         {
                             pf.Alignment = PowerPoint.PpParagraphAlignment.ppAlignDistribute;
                         }
                         else if (comboBox1.Text == "顶部对齐")
                         {
                             range[i].TextFrame.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorTop;
                         }
                         else if (comboBox1.Text == "中部对齐")
                         {
                             range[i].TextFrame.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorMiddle;
                         }
                         else if (comboBox1.Text == "底部对齐")
                         {
                             range[i].TextFrame.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorBottom;
                         }
                     }
                 }
                 if (range[i].TextFrame2.HasText == Office.MsoTriState.msoTrue)
                 {
                     if (checkBox1.Checked)
                     {
                         range[i].TextFrame2.TextRange.Font.Name        = font.Name;
                         range[i].TextFrame2.TextRange.Font.NameFarEast = font.Name;
                         if (font.Style == FontStyle.Italic)
                         {
                             range[i].TextFrame2.TextRange.Font.Italic = Office.MsoTriState.msoTrue;
                         }
                         if (font.Style == FontStyle.Bold)
                         {
                             range[i].TextFrame2.TextRange.Font.Bold = Office.MsoTriState.msoTrue;
                         }
                     }
                     if (checkBox2.Checked)
                     {
                         range[i].TextFrame2.TextRange.Font.Size = float.Parse(textBox1.Text.Trim());
                     }
                     if (checkBox3.Checked)
                     {
                         range[i].TextFrame2.TextRange.Font.Fill.BackColor.RGB = panel1.BackColor.R + panel1.BackColor.G * 256 + panel1.BackColor.B * 256 * 256;
                     }
                     if (checkBox4.Checked)
                     {
                         range[i].TextFrame2.TextRange.ParagraphFormat.WordWrap    = Office.MsoTriState.msoTrue;
                         range[i].TextFrame2.TextRange.ParagraphFormat.SpaceWithin = float.Parse(textBox2.Text.Trim());
                     }
                     if (checkBox5.Checked)
                     {
                         if (comboBox1.Text == "两端对齐")
                         {
                             range[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignJustify;
                         }
                         else if (comboBox1.Text == "左对齐")
                         {
                             range[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignLeft;
                         }
                         else if (comboBox1.Text == "右对齐")
                         {
                             range[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignRight;
                         }
                         else if (comboBox1.Text == "居中对齐")
                         {
                             range[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignCenter;
                         }
                         else if (comboBox1.Text == "分散对齐")
                         {
                             range[i].TextFrame2.TextRange.ParagraphFormat.Alignment = Office.MsoParagraphAlignment.msoAlignDistribute;
                         }
                         else if (comboBox1.Text == "顶部对齐")
                         {
                             range[i].TextFrame2.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorTop;
                         }
                         else if (comboBox1.Text == "中部对齐")
                         {
                             range[i].TextFrame2.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorMiddle;
                         }
                         else if (comboBox1.Text == "底部对齐")
                         {
                             range[i].TextFrame2.VerticalAnchor = Office.MsoVerticalAnchor.msoAnchorBottom;
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 24
0
        private void btCameraSelectata_Click(object sender, EventArgs e)
        {
            if (cmbDisponibile.Text == "SINGLE")
            {
                Hotel = new PP.Application();
                pres  = Hotel.Presentations.Add();

                int nrs = pres.Slides.Count;

                PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle];

                slide = pres.Slides.AddSlide(nrs + 1, cl);

                slide.Shapes.Title.TextFrame.TextRange.Text = "CAMERA SINGLE";

                slide.Shapes[2].TextFrame.TextRange.Text = "Camerele Single ofera oaspetilor o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Camerele single sunt cu vedere spre curtea interioara si asigura liniste deplina atat pe timp de zi cat si pe timp de noapte." +
                                                           "Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei.";

                slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single1.jpg";

                string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single2.jpg";

                string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\single3.jpg";


                float lat   = slide.CustomLayout.Width;
                float inalt = slide.CustomLayout.Height;


                PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);

                slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront);


                slide = pres.Slides.AddSlide(nrs + 2, cl);

                PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);


                slide = pres.Slides.AddSlide(nrs + 3, cl);

                PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);
            }

            if (cmbDisponibile.Text == "DOUBLE")
            {
                Hotel = new PP.Application();
                pres  = Hotel.Presentations.Add();

                int nrs = pres.Slides.Count;

                PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle];

                slide = pres.Slides.AddSlide(nrs + 1, cl);

                slide.Shapes.Title.TextFrame.TextRange.Text = "CAMERA DOUBLE";

                slide.Shapes[2].TextFrame.TextRange.Text = "Camerele Double oferta oaspetilor nostri o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Camerele double au vedere spre cladirea Cercului Militar si Calea Victoriei asigurand o panorama incontestabila asupra arhitecturii de altadata. Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei";


                slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double1.jpg";

                string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double2.jpg";

                string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\double3.jpg";


                float lat   = slide.CustomLayout.Width;
                float inalt = slide.CustomLayout.Height;


                PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);

                slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront);


                slide = pres.Slides.AddSlide(nrs + 2, cl);

                PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);


                slide = pres.Slides.AddSlide(nrs + 3, cl);

                PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);
            }


            if (cmbDisponibile.Text == "APARTAMENT")
            {
                Hotel = new PP.Application();
                pres  = Hotel.Presentations.Add();

                int nrs = pres.Slides.Count;

                PP.CustomLayout cl = pres.SlideMaster.CustomLayouts[PP.PpSlideLayout.ppLayoutTitle];

                slide = pres.Slides.AddSlide(nrs + 1, cl);

                slide.Shapes.Title.TextFrame.TextRange.Text = "APARTAMENT";

                slide.Shapes[2].TextFrame.TextRange.Text = "Apartamentele ofera oaspetilor nostri o atmosfera calda si linistitoare care imbina perfect relaxarea cu utilul. Apartamentele au vedere spre cladirea Cercului Militar si Calea Victoriei, asigurand o panorama incontestabila asupra arhitecturii de altadata. Oaspetii se pot bucura de Internet wireless, televiziune prin cablu si control individual al climei.";


                slide.Shapes.Title.TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes[2].TextFrame.TextRange.Font.Color.RGB = Color.White.ToArgb();

                slide.Shapes.Title.TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                slide.Shapes[2].TextFrame.TextRange.Font.Bold = Office.MsoTriState.msoCTrue;

                string cale = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap1.jpg";

                string cale2 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap2.jpg";

                string cale3 = @"C:\Users\Gabriel Birzu\OneDrive\Desktop\Proiect IPLA\Poze\ap3.jpg";


                float lat   = slide.CustomLayout.Width;
                float inalt = slide.CustomLayout.Height;


                PP.Shape shape = slide.Shapes.AddPicture(cale, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);

                slide.Shapes[2].ZOrder(Office.MsoZOrderCmd.msoBringToFront);

                slide.Shapes.Title.ZOrder(Office.MsoZOrderCmd.msoBringToFront);


                slide = pres.Slides.AddSlide(nrs + 2, cl);

                PP.Shape shape2 = slide.Shapes.AddPicture(cale2, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);


                slide = pres.Slides.AddSlide(nrs + 3, cl);

                PP.Shape shape3 = slide.Shapes.AddPicture(cale3, Office.MsoTriState.msoCTrue, Office.MsoTriState.msoFalse, 0, 0, lat - 0, inalt - 0);
            }


            PP.SlideRange          ssr = pres.Slides.Range();
            PP.SlideShowTransition sst = ssr.SlideShowTransition;
            sst.AdvanceOnTime = Office.MsoTriState.msoTrue;
            sst.AdvanceTime   = 3;
            sst.EntryEffect   = PP.PpEntryEffect.ppEffectRevealSmoothRight;
            PP.SlideShowSettings ssp = pres.SlideShowSettings;
            ssp.StartingSlide = 1;
            ssp.EndingSlide   = pres.Slides.Count;
            ssp.Run();
        }
Exemplo n.º 25
0
        /// <summary>
        /// 自动播放PPT文档.
        /// </summary>
        /// <param name="filePath">PPT文件路径.</param>
        /// <param name="playTime">翻页的时间间隔.【以秒为单位】</param>
        /// <param name="timeout">超时限制【以秒为单位】</param>
        public void PPTAuto(object presSet, int playTime, int timeout)
        {
            iSlideShowTime = playTime;
            objPresSet = (POWERPOINT.Presentation)presSet;

            if (timeout > 0 && objPresSet.Slides.Count * playTime > timeout)
            {
                objApp_SlideShowNextSlide(null);
                return;
            }

            objApp = objPresSet.Application;
            iSlideIndex = 0;
            try
            {
                // 自动播放的代码(开始)
                int Slides = objPresSet.Slides.Count;
                int[] SlideIdx = new int[Slides];
                for (int i = 0; i < Slides; i++) { SlideIdx[i] = i + 1; };
                objSldRng = objPresSet.Slides.Range(SlideIdx);
                objSST = objSldRng.SlideShowTransition;
                //关闭助手显示
                objApp.Assistant.On = false;
                objApp.Assistant.Visible = false;
                //设置翻页的时间.
                objSST.AdvanceOnTime = OFFICECORE.MsoTriState.msoCTrue;
                objSST.AdvanceTime = playTime;
                //翻页时的特效!
                objSST.EntryEffect = POWERPOINT.PpEntryEffect.ppEffectCircleOut;
                //Run the Slide show from slides 1 thru 3.
                objSSS = objPresSet.SlideShowSettings;
                objSSS.StartingSlide = 1;
                objSSS.EndingSlide = Slides;
                objApp.SlideShowNextSlide += new POWERPOINT.EApplication_SlideShowNextSlideEventHandler(objApp_SlideShowNextSlide);

                hook.Hook_Clear();
                hook.Hook_Start();

                objSSS.Run();
            }
            catch
            {
                hook.Hook_Clear();
            }
        }
Exemplo n.º 26
0
        public static void IncludeOthers(string path)
        {
            //Build Slide #2:
            //Add text to the slide title, format the text. Also add a chart to the
            //slide and change the chart type to a 3D pie chart.
            objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
            objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
            objTextRng.Text = "My Chart";
            objTextRng.Font.Name = "Comic Sans MS";
            objTextRng.Font.Size = 48;
            objChart = (Graph.Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320,
              "MSGraph.Chart.8", "", MsoTriState.msoFalse, "", 0, "",
              MsoTriState.msoFalse).OLEFormat.Object;
            objChart.ChartType = Graph.XlChartType.xl3DPie;
            objChart.Legend.Position = Graph.XlLegendPosition.xlLegendPositionBottom;
            objChart.HasTitle = true;
            objChart.ChartTitle.Text = "Here it is...";

            //Build Slide #3:
            //Change the background color of this slide only. Add a text effect to the slide
            //and apply various color schemes and shadows to the text effect.
            objSlide = objSlides.Add(objSlides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank);
            objSlide.FollowMasterBackground = MsoTriState.msoFalse;
            objShapes = objSlide.Shapes;
            objShape = objShapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect27,
              "The End", "Impact", 96, MsoTriState.msoFalse, MsoTriState.msoFalse, 230, 200);

            //Save the presentation to disk
            objPres.SaveAs(path,
                  PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
                  Microsoft.Office.Core.MsoTriState.msoFalse);
            //Modify the slide show transition settings for all 3 slides in
            //the presentation.
            int[] SlideIdx = new int[3];
            for (int k = 0; k < 3; k++) SlideIdx[k] = k + 1;
            objSldRng = objSlides.Range(SlideIdx);
            objSST = objSldRng.SlideShowTransition;
            objSST.AdvanceOnTime = MsoTriState.msoTrue;
            objSST.AdvanceTime = 3;
            objSST.EntryEffect = PowerPoint.PpEntryEffect.ppEffectBoxOut;

            //Prevent Office Assistant from displaying alert messages:
            // bAssistantOn = objApp.Assistant.On;
            // objApp.Assistant.On = false;

            //Run the Slide show from slides 1 thru 3.
            objSSS = objPres.SlideShowSettings;
            objSSS.StartingSlide = 1;
            objSSS.EndingSlide = 3;
            objSSS.Run();

            //Wait for the slide show to end.
            objSSWs = objApp.SlideShowWindows;
            while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);

            ////Reenable Office Assisant, if it was on:
            //if (bAssistantOn)
            //{
            //    objApp.Assistant.On = true;
            //    objApp.Assistant.Visible = false;
            //}

            //Close the presentation without saving changes and quit PowerPoint.
            //  objPres.Close();
            //  objApp.Quit();
        }
Exemplo n.º 27
0
        // 感谢ok群群友 yuanyilvhua(QQ:4570848**)提供测试电脑,以修复之前存在的高分屏下的bug :-)
        private void button2_Click(object sender, EventArgs e)
        {
            PowerPoint.Selection sel = app.ActiveWindow.Selection;
            if (sel.Type == PowerPoint.PpSelectionType.ppSelectionSlides && sel.SlideRange.Count > 1)
            {
                PowerPoint.Slides     slides = app.ActivePresentation.Slides;
                PowerPoint.SlideRange srange = sel.SlideRange;
                int scount = srange.Count;

                float wp = app.ActivePresentation.PageSetup.SlideWidth;
                float hp = app.ActivePresentation.PageSetup.SlideHeight;
                int   pw = Properties.Settings.Default.pwidth;
                int   h2 = (int)(pw * hp / wp);

                string name = app.ActivePresentation.Name;
                if (name.Contains(".pptx"))
                {
                    name = name.Replace(".pptx", "");
                }
                if (name.Contains(".ppt"))
                {
                    name = name.Replace(".ppt", "");
                }
                string cPath = app.ActivePresentation.Path + @"\" + name + @" 的GIF图\";
                if (!Directory.Exists(cPath))
                {
                    Directory.CreateDirectory(cPath);
                }
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(cPath);
                int    k     = dir.GetFiles().Length + 1;
                string gpath = cPath + name + "_" + k + ".gif";
                int    time  = int.Parse(textBox1.Text.Trim());

                int[] index = new int[srange.Count];
                for (int i = 1; i <= srange.Count; i++)
                {
                    index[i - 1] = srange[i].SlideIndex;
                }
                if (index[0] > index[1])
                {
                    Array.Sort(index);
                }
                sel.Unselect();
                slides.Range(index).Select();

                List <string> path = new List <string>();
                for (int i = 1; i <= scount; i++)
                {
                    PowerPoint.Slide nslide = slides[index[i - 1]];
                    string           cPath2 = cPath + name + "_" + k + ".jpg";
                    nslide.Export(cPath2, "jpg");
                    path.Add(cPath2);
                    k = k + 1;
                }

                AnimatedGifEncoder gif = new AnimatedGifEncoder();
                gif.Start(gpath);
                gif.SetDelay(time);
                if (checkBox1.Checked)
                {
                    gif.SetRepeat(0);
                }
                else
                {
                    gif.SetRepeat(-1);
                }

                Bitmap   bmp = null;
                Graphics g   = null;

                for (int j = 0; j < scount; j++)
                {
                    Image spic = Image.FromFile(path[j]);
                    if (j == 0)
                    {
                        bmp = new Bitmap(spic.Width, spic.Height);
                        bmp.SetResolution(spic.HorizontalResolution, spic.VerticalResolution);
                        g = Graphics.FromImage(bmp);
                        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    }
                    g.Clear(panel1.BackColor);
                    g.DrawImage(spic, 0, 0);
                    gif.AddFrame(bmp);
                    spic.Dispose();
                    File.Delete(path[j]);
                }
                gif.Finish();
                g.Dispose();
                bmp.Dispose();

                if (!checkBox2.Checked)
                {
                    System.Diagnostics.Process.Start("Explorer.exe", cPath);
                }
                else
                {
                    int n = srange[1].SlideNumber;
                    PowerPoint.Shape nshape = slides[n].Shapes.AddPicture(gpath, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue, -pw, 0, pw, h2);
                    if (pw > app.ActivePresentation.PageSetup.SlideWidth)
                    {
                        nshape.LockAspectRatio = Office.MsoTriState.msoTrue;
                        nshape.Width           = app.ActivePresentation.PageSetup.SlideWidth;
                        nshape.Left            = 0;
                        nshape.Top             = 0;
                    }
                    nshape.Select();
                    File.Delete(gpath);
                    if (dir.GetFiles().Length == 0)
                    {
                        Directory.Delete(cPath, true);
                    }
                }
            }
            else if (sel.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
            {
                PowerPoint.Slide      slide = app.ActiveWindow.View.Slide;
                PowerPoint.ShapeRange range = sel.ShapeRange;
                if (sel.HasChildShapeRange)
                {
                    range = sel.ChildShapeRange;
                }
                int count = range.Count;
                if (count > 1)
                {
                    string name = app.ActivePresentation.Name;
                    if (name.Contains(".pptx"))
                    {
                        name = name.Replace(".pptx", "");
                    }
                    if (name.Contains(".ppt"))
                    {
                        name = name.Replace(".ppt", "");
                    }
                    string cPath = app.ActivePresentation.Path + @"\" + name + @" 的GIF图\";
                    if (!Directory.Exists(cPath))
                    {
                        Directory.CreateDirectory(cPath);
                    }
                    System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(cPath);
                    int    k     = dir.GetFiles().Length + 1;
                    int    time  = int.Parse(textBox1.Text.Trim());
                    string gpath = cPath + name + "_" + k + ".gif";

                    List <int>    w = new List <int>();
                    List <int>    h = new List <int>();
                    List <string> path = new List <string>();
                    Bitmap        spic = null;
                    float         xs = 0; float ys = 0;
                    for (int i = 1; i <= count; i++)
                    {
                        PowerPoint.Shape pic = range[i];
                        pic.Export(cPath + name + "_" + k + ".png", PowerPoint.PpShapeFormat.ppShapeFormatPNG);
                        spic = new Bitmap(cPath + name + "_" + k + ".png");
                        w.Add(spic.Width);
                        h.Add(spic.Height);
                        if (xs == 0)
                        {
                            xs = spic.HorizontalResolution;
                            ys = spic.VerticalResolution;
                        }
                        spic.Dispose();
                        path.Add(cPath + name + "_" + k + ".png");
                        k = k + 1;
                    }
                    int    wmax = w.Max();
                    int    hmax = h.Max();
                    Bitmap bmp  = new Bitmap(wmax, hmax);
                    bmp.SetResolution(xs, ys);
                    Graphics g = Graphics.FromImage(bmp);
                    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                    AnimatedGifEncoder gif = new AnimatedGifEncoder();
                    gif.Start(gpath);
                    gif.SetDelay(time);
                    if (checkBox1.Checked)
                    {
                        gif.SetRepeat(0);
                    }
                    else
                    {
                        gif.SetRepeat(-1);
                    }
                    if (checkBox4.Checked)
                    {
                        gif.SetQuality(300);
                        gif.SetTransparent(panel1.BackColor);
                    }

                    for (int j = 0; j < count; j++)
                    {
                        spic = new Bitmap(path[j]);
                        g.Clear(panel1.BackColor);
                        g.DrawImage(spic, (bmp.Width - spic.Width) / 2, (bmp.Height - spic.Height) / 2);
                        gif.AddFrame(bmp);
                        spic.Dispose();
                        File.Delete(path[j]);
                    }
                    gif.Finish();
                    g.Dispose();
                    bmp.Dispose();

                    if (!checkBox2.Checked)
                    {
                        System.Diagnostics.Process.Start("Explorer.exe", cPath);
                    }
                    else
                    {
                        PowerPoint.Shape nshape = slide.Shapes.AddPicture(gpath, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue, -wmax, 0, wmax, hmax);
                        nshape.Select();
                        //File.Delete(cPath + name + "_" + k + ".gif");
                        //if (dir.GetFiles().Length == 0)
                        //{
                        //    Directory.Delete(cPath, true);
                        //}
                    }
                }
                else
                {
                    MessageBox.Show("请选中多张图片");
                }
            }
            else
            {
                MessageBox.Show("请选中多张图片或幻灯片页面");
            }
        }
Exemplo n.º 28
0
        private void button1_Click(object sender, EventArgs e)
        {
            float tr1 = 0;
            float tr2 = 0;
            float tr3 = 0;

            try
            {
                tr1 = float.Parse(textBox1.Text.Trim()) / 100f;
                tr2 = float.Parse(textBox2.Text.Trim()) / 100f;
                tr3 = float.Parse(textBox3.Text.Trim()) / 100f;
            }
            catch {}

            int color1 = panel1.BackColor.R + panel1.BackColor.G * 256 + panel1.BackColor.B * 256 * 256;
            int color2 = panel2.BackColor.R + panel2.BackColor.G * 256 + panel2.BackColor.B * 256 * 256;
            int color3 = panel3.BackColor.R + panel3.BackColor.G * 256 + panel3.BackColor.B * 256 * 256;

            int n = 0;

            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++)
                {
                    if (range[i].Type == Office.MsoShapeType.msoTable)
                    {
                        n += 1;
                        if (checkBox1.Checked)
                        {
                            int cellcnt = range[i].Table.Rows[1].Cells.Count;
                            for (int j = 1; j <= cellcnt; j++)
                            {
                                range[i].Table.Rows[1].Cells[j].Shape.Fill.ForeColor.RGB = color1;
                                range[i].Table.Rows[1].Cells[j].Shape.Fill.Transparency  = tr1;
                            }
                        }

                        if (checkBox2.Checked)
                        {
                            int rowcnt   = range[i].Table.Rows.Count;
                            int cellcnt  = range[i].Table.Rows[1].Cells.Count;
                            int beginrow = 1;
                            if (checkBox1.Checked)
                            {
                                beginrow = 2;
                            }
                            else
                            {
                                beginrow = 1;
                            }
                            if (rowcnt >= 2)
                            {
                                for (int j = beginrow; j <= rowcnt; j++)
                                {
                                    if (j % 2 == 0)
                                    {
                                        for (int k = 1; k <= cellcnt; k++)
                                        {
                                            range[i].Table.Rows[j].Cells[k].Shape.Fill.ForeColor.RGB = color2;
                                            range[i].Table.Rows[j].Cells[k].Shape.Fill.Transparency  = tr2;
                                        }
                                    }
                                }
                            }
                        }

                        if (checkBox3.Checked)
                        {
                            int rowcnt   = range[i].Table.Rows.Count;
                            int cellcnt  = range[i].Table.Rows[1].Cells.Count;
                            int beginrow = 1;
                            if (checkBox1.Checked)
                            {
                                beginrow = 2;
                            }
                            else
                            {
                                beginrow = 1;
                            }
                            if (rowcnt >= 2)
                            {
                                for (int j = beginrow; j <= rowcnt; j++)
                                {
                                    if (j % 2 == 1)
                                    {
                                        for (int k = 1; k <= cellcnt; k++)
                                        {
                                            range[i].Table.Rows[j].Cells[k].Shape.Fill.ForeColor.RGB = color3;
                                            range[i].Table.Rows[j].Cells[k].Shape.Fill.Transparency  = tr3;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (n == 0)
                {
                    MessageBox.Show("请选中表格、单元格区域、幻灯片缩略图之一");
                }
            }
            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)
                            {
                                int cellcnt = shape.Table.Rows[1].Cells.Count;
                                for (int j = 1; j <= cellcnt; j++)
                                {
                                    shape.Table.Rows[1].Cells[j].Shape.Fill.ForeColor.RGB = color1;
                                    shape.Table.Rows[1].Cells[j].Shape.Fill.Transparency  = tr1;
                                }
                            }

                            if (checkBox2.Checked)
                            {
                                int rowcnt   = shape.Table.Rows.Count;
                                int cellcnt  = shape.Table.Rows[1].Cells.Count;
                                int beginrow = 1;
                                if (checkBox1.Checked)
                                {
                                    beginrow = 2;
                                }
                                else
                                {
                                    beginrow = 1;
                                }
                                if (rowcnt >= 2)
                                {
                                    for (int j = beginrow; j <= rowcnt; j++)
                                    {
                                        if (j % 2 == 0)
                                        {
                                            for (int k = 1; k <= cellcnt; k++)
                                            {
                                                shape.Table.Rows[j].Cells[k].Shape.Fill.ForeColor.RGB = color2;
                                                shape.Table.Rows[j].Cells[k].Shape.Fill.Transparency  = tr2;;
                                            }
                                        }
                                    }
                                }
                            }

                            if (checkBox3.Checked)
                            {
                                int rowcnt   = shape.Table.Rows.Count;
                                int cellcnt  = shape.Table.Rows[1].Cells.Count;
                                int beginrow = 1;
                                if (checkBox1.Checked)
                                {
                                    beginrow = 2;
                                }
                                else
                                {
                                    beginrow = 1;
                                }
                                if (rowcnt >= 2)
                                {
                                    for (int j = beginrow; j <= rowcnt; j++)
                                    {
                                        if (j % 2 == 1)
                                        {
                                            for (int k = 1; k <= cellcnt; k++)
                                            {
                                                shape.Table.Rows[j].Cells[k].Shape.Fill.ForeColor.RGB = color3;
                                                shape.Table.Rows[j].Cells[k].Shape.Fill.Transparency  = tr3;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (sel.Type == PowerPoint.PpSelectionType.ppSelectionNone)
            {
                PowerPoint.Slide slide = app.ActiveWindow.View.Slide;
                foreach (PowerPoint.Shape shape in slide.Shapes)
                {
                    if (shape.Type == Office.MsoShapeType.msoTable)
                    {
                        n = 1;
                        if (checkBox1.Checked)
                        {
                            int cellcnt = shape.Table.Rows[1].Cells.Count;
                            for (int j = 1; j <= cellcnt; j++)
                            {
                                shape.Table.Rows[1].Cells[j].Shape.Fill.ForeColor.RGB = color1;
                                shape.Table.Rows[1].Cells[j].Shape.Fill.Transparency  = tr1;
                            }
                        }

                        if (checkBox2.Checked)
                        {
                            int rowcnt   = shape.Table.Rows.Count;
                            int cellcnt  = shape.Table.Rows[1].Cells.Count;
                            int beginrow = 1;
                            if (checkBox1.Checked)
                            {
                                beginrow = 2;
                            }
                            else
                            {
                                beginrow = 1;
                            }
                            if (rowcnt >= 2)
                            {
                                for (int j = beginrow; j <= rowcnt; j++)
                                {
                                    if (j % 2 == 0)
                                    {
                                        for (int k = 1; k <= cellcnt; k++)
                                        {
                                            shape.Table.Rows[j].Cells[k].Shape.Fill.ForeColor.RGB = color2;
                                            shape.Table.Rows[j].Cells[k].Shape.Fill.Transparency  = tr2;
                                        }
                                    }
                                }
                            }
                        }

                        if (checkBox3.Checked)
                        {
                            int rowcnt   = shape.Table.Rows.Count;
                            int cellcnt  = shape.Table.Rows[1].Cells.Count;
                            int beginrow = 1;
                            if (checkBox1.Checked)
                            {
                                beginrow = 2;
                            }
                            else
                            {
                                beginrow = 1;
                            }
                            if (rowcnt >= 2)
                            {
                                for (int j = beginrow; j <= rowcnt; j++)
                                {
                                    if (j % 2 == 1)
                                    {
                                        for (int k = 1; k <= cellcnt; k++)
                                        {
                                            shape.Table.Rows[j].Cells[k].Shape.Fill.ForeColor.RGB = color3;
                                            shape.Table.Rows[j].Cells[k].Shape.Fill.Transparency  = tr3;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (n == 0)
                {
                    MessageBox.Show("请选中一个表格");
                }
            }
            else
            {
                MessageBox.Show("请选中一个表格");
            }
        }