private void btn_Caption_Click(object sender, EventArgs e) { int sld_num = ppApp.ActiveWindow.Selection.SlideRange.SlideNumber; float top_adjust = 0; int cnt = 0; Formatshapes obj = new Formatshapes(); string CAGR, dText = null; List <string> SelectedCharts = new List <string>(); try { SelectedCharts = PPTshpchk.FindSelectedCharts(); string shp_nam = SelectedCharts[0]; PowerPoint.Shape myShape = ActivePPT.Slides[sld_num].Shapes[shp_nam]; int num_shapes = ActivePPT.Slides[sld_num].Shapes.Count; for (int i = 1; i <= num_shapes; i++) { if (ActivePPT.Slides[sld_num].Shapes[i].Name == shp_nam + " CAGR Box") { cnt++; } } if (cnt > 0) { top_adjust = (float)18.13 * cnt + 5; } CAGR = lbl_Value.Text; string cmbText = cmb_calcType.Text; if (cmbText == "AAGR") { dText = "AAGR (" + cmb_stDate.Text + "–" + cmb_endDate.Text + "): " + CAGR; } else { if (CAGR.Substring(0, 1) != "-") { dText = "CAGR (" + cmb_stDate.Text + "–" + cmb_endDate.Text + "): " + CAGR; } else if (CAGR.Substring(0, 1) == "-") { dText = "CARC (" + cmb_stDate.Text + "–" + cmb_endDate.Text + "): " + CAGR; } } float tp = ActivePPT.Slides[sld_num].Shapes[shp_nam].Top; foreach (PowerPoint.Shape shp in ActivePPT.Slides[sld_num].Shapes) { if (shp.Name == shp_nam + " CAGR Box") { shp.Delete(); break; } } PowerPoint.Shape aShp = ActivePPT.Slides[sld_num].Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, myShape.Left + myShape.Width, myShape.Top + top_adjust, 120, (float)23.5); aShp.TextFrame.TextRange.Text = dText; aShp.TextEffect.Alignment = MsoTextEffectAlignment.msoTextEffectAlignmentCentered; aShp.TextFrame.TextRange.Font.Bold = MsoTriState.msoTrue; aShp.TextFrame.TextRange.Font.Size = 12; aShp.TextFrame.TextRange.Font.Color.RGB = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb(); aShp.TextFrame.TextRange.Font.Name = "Calibri"; aShp.Fill.Visible = MsoTriState.msoFalse; aShp.Line.Weight = (float)0.75; aShp.Line.DashStyle = MsoLineDashStyle.msoLineSolid; aShp.Line.Style = MsoLineStyle.msoLineSingle; aShp.Line.Transparency = 0; aShp.Line.Visible = MsoTriState.msoTrue; aShp.Line.ForeColor.RGB = System.Drawing.Color.FromArgb(23, 94, 84).ToArgb(); aShp.Line.BackColor.RGB = System.Drawing.Color.FromArgb(23, 94, 84).ToArgb(); aShp.Name = shp_nam + " CAGR Box"; string objType = "Cagr Box"; PPTActions actionObj = new PPTActions(); DataTable dt = actionObj.get_specification(objType); obj.FormatShape(sld_num, aShp.Name, dt, false, false); this.Close(); } catch (Exception err) { this.Close(); string errtext = err.Message; PPTAttribute.ErrorLog(errtext, "btn_Caption_Click"); MessageBox.Show("Check chart type and chart value", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Submit_Click(object sender, EventArgs e) { pptfunctions funObj = new pptfunctions(); PPTActions actionObj = new PPTActions(); Formatshapes PPTshpFormat = new Formatshapes(); ppApp.DisplayAlerts = PowerPoint.PpAlertLevel.ppAlertsNone; try { if (rbselectedppt.Checked == true) // Work on Current PPT { OpenedPPT.PageSetup.SlideWidth = 960; OpenedPPT.PageSetup.SlideHeight = 540; ppApp.ActivePresentation.ApplyTheme(PPTAttribute.mPPTPath); funObj.DeleteOldTSCMasters(); foreach (PowerPoint.Slide sld in OpenedPPT.Slides) { foreach (PowerPoint.Shape shp in sld.Shapes) { if (shp.Name == "Road Map" || shp.Name == "Title Box" || shp.Name == "Note Box" || shp.Name == "Source Box") { DataTable dt = actionObj.get_specification(shp.Name); FormatShape(sld.SlideIndex, shp.Name, dt); } } } this.Close(); } else if (rbselectedslide.Checked == true) // Work on Current Slide { OpenedPPT.PageSetup.SlideWidth = 960; OpenedPPT.PageSetup.SlideHeight = 540; ppApp.ActivePresentation.ApplyTheme(PPTAttribute.mPPTPath); funObj.DeleteOldTSCMasters(); int sldnum = ppApp.ActiveWindow.Selection.SlideRange.SlideNumber; PowerPoint.Slide sld = OpenedPPT.Slides[sldnum]; foreach (PowerPoint.Shape shp in sld.Shapes) { if (shp.Name == "Road Map" || shp.Name == "Title Box" || shp.Name == "Note Box" || shp.Name == "Source Box") { DataTable dt = actionObj.get_specification(shp.Name); FormatShape(sld.SlideIndex, shp.Name, dt); } } this.Close(); } else if (rbtn_selectfolder.Checked == true) { string pathString = System.IO.Path.Combine(selectedFolder, "TSC_PPT_29032018"); System.IO.Directory.CreateDirectory(pathString); string pptPath = null, newfilepath = null; int rowscount = fileGridView.Rows.Count; foreach (DataGridViewRow row in fileGridView.Rows) { //for templated control if (Convert.ToBoolean(row.Cells[2].Value) == true) { string fileName = row.Cells[0].Value.ToString(); newfilepath = pathString + "\\" + fileName; pptPath = selectedFolder + "\\" + fileName; OpenedPPT = ppApp.Presentations.Open(pptPath); //-- Apply New TSC Theme ppApp.DisplayAlerts = PowerPoint.PpAlertLevel.ppAlertsNone; OpenedPPT.PageSetup.SlideWidth = 960; OpenedPPT.PageSetup.SlideHeight = 540; ppApp.ActivePresentation.ApplyTheme(PPTAttribute.mPPTPath); funObj.DeleteOldTSCMasters(); // -- Format Slide foreach (PowerPoint.Slide sld in OpenedPPT.Slides) { foreach (PowerPoint.Shape shp in sld.Shapes) { if (shp.Name == "Road Map" || shp.Name == "Title Box" || shp.Name == "Note Box" || shp.Name == "Source Box") { DataTable dt = actionObj.get_specification(shp.Name); FormatShape(sld.SlideIndex, shp.Name, dt); } } } row.Cells[1].Value = "Done"; OpenedPPT.SaveAs(newfilepath); OpenedPPT.Close(); // If Process has been done the update the status Done } } // Close Outer For loop ppApp.DisplayAlerts = PowerPoint.PpAlertLevel.ppAlertsAll; } } catch (Exception err) { string errtext = err.Message; PPTAttribute.ErrorLog(errtext, "Format -All Slide"); } }