//Growth Rates public void TSCP_Callback51(Office.IRibbonControl rib) { PowerPoint.Application ppApp = Globals.ThisAddIn.Application; pptfunctions funObj = new pptfunctions(); Shapecheck shpObj = new Shapecheck(); frmChartcalc chartObj = new frmChartcalc(); //frmCalculator frmObj = new frmCalculator(); Shapecheck PPTshpchk = new Shapecheck(); List <string> SelectedCharts = new List <string>(); SelectedCharts = PPTshpchk.FindSelectedCharts(); PowerPoint.Presentation ActivePPT = Globals.ThisAddIn.Application.ActivePresentation; int numSelCht = SelectedCharts.Count; if (numSelCht == 0) { MessageBox.Show("Please select a chart for CAGR/AAGR calculation.", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int sld_num = ppApp.ActiveWindow.Selection.SlideRange.SlideNumber; PowerPoint.Chart myChart = ActivePPT.Slides[sld_num].Shapes[SelectedCharts[0]].Chart; string chType = shpObj.chartType(myChart); if (funObj.TSCThemeLoaded()) { if (numSelCht == 0) { //frmObj.Show(); MessageBox.Show("Please select a chart CAGR/AAGR calculation.", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (numSelCht > 1) { MessageBox.Show("Please select a single chart CAGR/AAGR calculation.", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (numSelCht == 1) { //PPT.Chart myChart = //string chType = PPTshpchk.chartType(); if (chType != "Pie") { chartObj.ShowDialog(); } else { MessageBox.Show("Please select a column chart for CAGR/AAGR Calculation.", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("This functionality works with TSC Theme. Please Load TSC theme and try again. Thanks", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } PPTAttribute.UserTracker(rib); }
private void frmChartcalc_Load(object sender, EventArgs e) { List <string> SelectedCharts = new List <string>(); List <String> xxVals = new List <string>(); List <String> yyVals = new List <string>(); List <string> Seriesname = new List <string>(); try { int sld_num = ppApp.ActiveWindow.Selection.SlideRange.SlideNumber; SelectedCharts = PPTshpchk.FindSelectedCharts(); string shp_nam = SelectedCharts[0]; PowerPoint.Chart myChart = ActivePPT.Slides[sld_num].Shapes[shp_nam].Chart; PowerPoint.SeriesCollection series = ActivePPT.Slides[sld_num].Shapes[shp_nam].Chart.SeriesCollection(); num_points = ActivePPT.Slides[sld_num].Shapes[shp_nam].Chart.SeriesCollection(1).Points.Count; num_series = series.Count; chtData = new string[num_points, num_series + 1]; for (int x = 0; x < num_series; x++) { string sName = myChart.SeriesCollection(x + 1).Name; Seriesname.Add(sName); PowerPoint.Series tseries = (PowerPoint.Series)myChart.SeriesCollection(x + 1); xxVals.Clear(); foreach (object item in tseries.Values as Array) { xxVals.Add(Convert.ToString(item)); } string[] yVals = xxVals.ToArray(); yyVals.Clear(); foreach (object item in tseries.XValues as Array) { yyVals.Add(Convert.ToString(item)); } string[] xVals = yyVals.ToArray(); //string[] yVals = myChart.SeriesCollection(x).Values.toArray(); //string[] xVals = myChart.SeriesCollection(x).XValues.toArray(); //chtData[0, x ] = sName; for (int y = 0; y < yVals.Length; y++) { chtData[y, 0] = xVals[y]; chtData[y, x + 1] = yVals[y]; } } //for(int x=0;x< chtData.Length; x++) { cmb_stDate.Items.Add(Convert.ToString(chtData[x, 0])); } //for (int x = 0; x < chtData.Length; x++) { cmb_stDate.Items.Add(Convert.ToString(chtData[x, 0])); } cmb_stDate.Items.Clear(); cmb_endDate.Items.Clear(); cmb_Series.Items.Clear(); foreach (string item in yyVals) { //Regex.Match(item, @"\d+").Value cmb_stDate.Items.Add(Regex.Match(item, @"\d+").Value); cmb_stDate.SelectedIndex = 0; //cmb_endDate.Items.Add(item); //cmb_endDate.SelectedIndex = 0; } txt_period.Enabled = false; foreach (string item in Seriesname) { cmb_Series.Items.Add(item); cmb_Series.SelectedIndex = 0; } //Calculate_CAGR(); string cmbText = cmb_calcType.Text; cmb_calcType.Items.Add("CAGR"); cmb_calcType.Items.Add("AAGR"); cmb_calcType.SelectedIndex = 0; if (cmbText == "AAGR") { Calculate_AAGR(); } else { Calculate_CAGR(); } } catch (Exception err) { this.Close(); string errtext = err.Message; PPTAttribute.ErrorLog(errtext, "frmChartcalc_Load"); MessageBox.Show("Check chart type and chart value", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }