Beispiel #1
0
        private void Simpleanswerbutton_Click(object sender, RibbonControlEventArgs e)
        {
            //Microsoft.Office.Interop.PowerPoint.Slides slides = null;//PPT中所有的幻灯片
            Microsoft.Office.Interop.PowerPoint.Presentation MyPres = Globals.ThisAddIn.Application.ActivePresentation;                                                                    // 当前ppt应用实例
            //slides = Globals.ThisAddIn.Application.ActivePresentation.Slides;//获取当前PPT中的所有幻灯片
            Microsoft.Office.Interop.PowerPoint.Slide MySlide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;                                                                     //获取当前选中的幻灯片
            Microsoft.Office.Interop.PowerPoint.Slide NewSimpleQuestionSlide = MyPres.Slides.Add(MySlide.SlideIndex + 1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank); //插入新的幻灯片

            #region 插入简答题题目类型
            Microsoft.Office.Interop.PowerPoint.TextRange SATextRng = null;

            NewSimpleQuestionSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 21.5F, 40F, 100F, 30F).Name = "SimpleAnswerQuestion";
            NewSimpleQuestionSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name            = "questionType";
            NewSimpleQuestionSlide.Shapes["questionType"].TextFrame.TextRange.Text = "4";
            NewSimpleQuestionSlide.Shapes["questionType"].Visible = MsoTriState.msoFalse;

            NewSimpleQuestionSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name = "questionScore";
            NewSimpleQuestionSlide.Shapes["questionScore"].TextFrame.TextRange.Text = "0";
            NewSimpleQuestionSlide.Shapes["questionScore"].Visible = MsoTriState.msoFalse;
            NewSimpleQuestionSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name = "questionLimitTime";
            NewSimpleQuestionSlide.Shapes["questionLimitTime"].TextFrame.TextRange.Text = "0";
            NewSimpleQuestionSlide.Shapes["questionLimitTime"].Visible = MsoTriState.msoFalse;
            NewSimpleQuestionSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name = "questionAnswer";
            NewSimpleQuestionSlide.Shapes["questionAnswer"].TextFrame.TextRange.Text = "0";
            NewSimpleQuestionSlide.Shapes["questionAnswer"].Visible = MsoTriState.msoFalse;

            SATextRng = NewSimpleQuestionSlide.Shapes[1].TextFrame.TextRange;                                           //请注意此处Shapes的索引,由于文本框是第一个添加的Shapes,所以此处索引是1。

            SATextRng.Font.NameFarEast          = "微软雅黑";                                                               //文本框中,中文的字体
            SATextRng.Font.NameAscii            = "Calibri";                                                            //文本框中,英文和数字的字体
            SATextRng.Text                      = "简答题";                                                                //显示的内容
            SATextRng.Font.Bold                 = MsoTriState.msoTrue;                                                  //是否加粗
            SATextRng.Font.Color.RGB            = 1 + 1 * 256 + 1 * 256 * 256;                                          //字体颜色,其中ABC直接用自定义颜色中的数字代替即可。
            SATextRng.Font.Size                 = 24;                                                                   //字体大小是24.
            SATextRng.ParagraphFormat.Alignment = Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft; //文本对齐方式(水平方向)
            NewSimpleQuestionSlide.Shapes[1].TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;              //文本对齐方式(垂直方向)
            #endregion

            #region 插入简答题题目
            Microsoft.Office.Interop.PowerPoint.TextRange SQTextRng = null;

            NewSimpleQuestionSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 21.5F, 150F, 777F, 300F).Name = "questionDescribe";
            SQTextRng = NewSimpleQuestionSlide.Shapes["questionDescribe"].TextFrame.TextRange;;                         //请注意此处Shapes的索引,由于文本框是第二个添加的Shapes,所以此处索引是2。

            SQTextRng.Font.NameFarEast          = "微软雅黑";                                                               //文本框中,中文的字体
            SQTextRng.Font.NameAscii            = "Calibri";                                                            //文本框中,英文和数字的字体
            SQTextRng.Text                      = "请编写题干";                                                              //显示的内容
            SQTextRng.Font.Bold                 = MsoTriState.msoFalse;                                                 //是否加粗
            SQTextRng.Font.Color.RGB            = 1 + 1 * 256 + 1 * 256 * 256;                                          //字体颜色,其中ABC直接用自定义颜色中的数字代替即可。
            SQTextRng.Font.Size                 = 24;                                                                   //字体大小是24.
            SQTextRng.ParagraphFormat.Alignment = Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft; //文本对齐方式(水平方向)
            NewSimpleQuestionSlide.Shapes[2].TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;              //文本对齐方式(垂直方向)
            #endregion

            AddSubmitOleForm(NewSimpleQuestionSlide, 822F, 466F, 89F, 46F, EnumExtend.GetDisplayText(ButtonNameEnum.SUMBIT), "sumbitButton"); //插入发布按钮
            AddSubmitOleForm(NewSimpleQuestionSlide, 727F, 466F, 80F, 46F, EnumExtend.GetDisplayText(ButtonNameEnum.GETANS), "answerButton"); //插入答案按钮
            NewSimpleQuestionSlide.Select();
        }
Beispiel #2
0
        private void GEN_Student_Record_Chart(PowerPoint.Slide Sld)
        {
            Sld.Select();
            Sld.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank;

            //Add a default chart in slide
            Sld.Shapes.AddChart(Microsoft.Office.Core.XlChartType.xl3DColumn, 200F, 200F, 400F, 300F);

            //Add a heading
            PowerPoint.Shape textBox = Sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 0, 20, 1000, 70);
            textBox.TextFrame.TextRange.InsertAfter("Student-wise Consolidated Attendance Record");
            textBox.TextFrame.TextRange.Font.Size = 30;
            textBox.TextFrame.VerticalAnchor      = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorMiddle;
            textBox.TextFrame.HorizontalAnchor    = Microsoft.Office.Core.MsoHorizontalAnchor.msoAnchorCenter;

            //Access the added chart
            Microsoft.Office.Interop.PowerPoint.Chart ppChart = Sld.Shapes[1].Chart;

            //Access the chart data
            Microsoft.Office.Interop.PowerPoint.ChartData chartData = ppChart.ChartData;

            //Create instance to Excel workbook to work with chart data
            Microsoft.Office.Interop.Excel.Workbook dataWorkbook = (Microsoft.Office.Interop.Excel.Workbook)chartData.Workbook;

            //Accessing the data worksheet for chart
            Microsoft.Office.Interop.Excel.Worksheet dataSheet = dataWorkbook.Worksheets[1];

            //Setting the range of chart
            Microsoft.Office.Interop.Excel.Range tRange = dataSheet.Cells.get_Range("A1", "C4");

            //Create a Table and applying the set range on chart data table
            Microsoft.Office.Interop.Excel.ListObject tbl1 = dataSheet.ListObjects["Table1"];
            tbl1.Resize(tRange);

            //Setting values for categories and respective series data
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A2"))).FormulaR1C1 = "";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A3"))).FormulaR1C1 = "";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A4"))).FormulaR1C1 = "";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B2"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B3"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B4"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("C2"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("C3"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("C4"))).FormulaR1C1 = 0;

            //Delete the legend for neatness
            Microsoft.Office.Interop.PowerPoint.Legend legend = null;
            legend = ppChart.Legend;
            legend.Delete();

            //Setting chart title
            ppChart.ChartTitle.Font.Italic               = false;
            ppChart.ChartTitle.Text                      = "Attendance Results";
            ppChart.ChartTitle.Font.Size                 = 18;
            ppChart.ChartTitle.Font.Color                = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
            ppChart.ChartTitle.Format.Line.Visible       = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppChart.ChartTitle.Format.Line.ForeColor.RGB = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);

            //Accessing Chart value axis
            Microsoft.Office.Interop.PowerPoint.Axis valaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlValue, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);

            //Setting values axis units
            valaxis.MajorUnit    = 2000.0F;
            valaxis.MinorUnit    = 1000.0F;
            valaxis.MinimumScale = 0.0F;
            valaxis.MaximumScale = 30.0F;

            //Accessing Chart Depth axis
            Microsoft.Office.Interop.PowerPoint.Axis Depthaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlSeriesAxis, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);
            Depthaxis.Delete();

            //Setting chart rotation
            ppChart.Rotation       = 20; //Y-Value
            ppChart.Elevation      = 15; //X-Value
            ppChart.RightAngleAxes = false;

            var ws          = new WebSocket("ws://localhost:1234");
            var the_message = "";

            ws.OnMessage += (sender12, sent) =>
            {
                try
                {
                    the_message = sent.Data;
                    var the_message2 = JsonConvert.DeserializeObject <List <StudentRecordNode> >(the_message);

                    var hiba_p   = 0;
                    var jeehan_p = 0;
                    var shiza_p  = 0;
                    var hiba_a   = 0;
                    var jeehan_a = 0;
                    var shiza_a  = 0;

                    foreach (var m in the_message2)
                    {
                        if (m.name == "Hiba")
                        {
                        }
                    }
                }
                catch (InvalidCastException e)
                {
                    Debug.WriteLine("Source: ", e.Source);
                }
            };
            ws.Connect();

            ws.OnError += (sender12, sent) =>
            {
                Debug.WriteLine("error " + sent.Message);
            };

            ws.OnClose += (sender12, sent) =>
            {
                Debug.WriteLine("disconnect with host");
            };
        }
Beispiel #3
0
        public static void GEN_Poll_Chart(PowerPoint.Slide Sld)
        {
            //Select the slide and set its layout
            Sld.Select();
            Sld.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank;

            //Add a default chart in slide
            Sld.Shapes.AddChart(Microsoft.Office.Core.XlChartType.xl3DColumn, 200F, 200F, 400F, 300F);

            //Add a heading
            PowerPoint.Shape textBox = Sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 0, 20, 1000, 70);
            textBox.TextFrame.TextRange.InsertAfter("Daily Class Poll");
            textBox.TextFrame.TextRange.Font.Size = 30;
            textBox.TextFrame.VerticalAnchor      = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorMiddle;
            textBox.TextFrame.HorizontalAnchor    = Microsoft.Office.Core.MsoHorizontalAnchor.msoAnchorCenter;

            //Access the added chart
            Microsoft.Office.Interop.PowerPoint.Chart ppChart = Sld.Shapes[1].Chart;

            //Access the chart data
            Microsoft.Office.Interop.PowerPoint.ChartData chartData = ppChart.ChartData;

            //Create instance to Excel workbook to work with chart data
            Microsoft.Office.Interop.Excel.Workbook dataWorkbook = (Microsoft.Office.Interop.Excel.Workbook)chartData.Workbook;

            //Accessing the data worksheet for chart
            Microsoft.Office.Interop.Excel.Worksheet dataSheet = dataWorkbook.Worksheets[1];

            //Setting the range of chart
            Microsoft.Office.Interop.Excel.Range tRange = dataSheet.Cells.get_Range("A1", "B5");

            //Create a Table and applying the set range on chart data table
            Microsoft.Office.Interop.Excel.ListObject tbl1 = dataSheet.ListObjects["Table1"];
            tbl1.Resize(tRange);

            //Thread.Sleep(3000);
            Debug.WriteLine("over 1");

            //Setting values for categories and respective series data
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A2"))).FormulaR1C1 = "A";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A3"))).FormulaR1C1 = "B";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A4"))).FormulaR1C1 = "C";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A5"))).FormulaR1C1 = "D";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B2"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B3"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B4"))).FormulaR1C1 = 0;
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B5"))).FormulaR1C1 = 0;

            //Delete the legend for neatness
            Microsoft.Office.Interop.PowerPoint.Legend legend = null;
            legend = ppChart.Legend;
            legend.Delete();

            //Setting chart title
            ppChart.ChartTitle.Font.Italic               = false;
            ppChart.ChartTitle.Text                      = "Poll Results";
            ppChart.ChartTitle.Font.Size                 = 18;
            ppChart.ChartTitle.Font.Color                = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
            ppChart.ChartTitle.Format.Line.Visible       = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppChart.ChartTitle.Format.Line.ForeColor.RGB = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);

            //setting all to red bars
            var series = ppChart.SeriesCollection(1) as PowerPoint.Series;

            var point = series.Points(1) as PowerPoint.Point;

            point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

            point = series.Points(2) as PowerPoint.Point;
            point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

            point = series.Points(3) as PowerPoint.Point;
            point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

            point = series.Points(4) as PowerPoint.Point;
            point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

            //Accessing Chart value axis
            Microsoft.Office.Interop.PowerPoint.Axis valaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlValue, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);

            //Setting values axis units
            valaxis.MajorUnit    = 2000.0F;
            valaxis.MinorUnit    = 1000.0F;
            valaxis.MinimumScale = 0.0F;
            valaxis.MaximumScale = 30.0F;

            //Accessing Chart Depth axis
            Microsoft.Office.Interop.PowerPoint.Axis Depthaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlSeriesAxis, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);
            Depthaxis.Delete();

            //Setting chart rotation
            ppChart.Rotation       = 20; //Y-Value
            ppChart.Elevation      = 15; //X-Value
            ppChart.RightAngleAxes = false;

            //Thread.Sleep(5000);
            Debug.WriteLine("over 2");

            var ws          = new WebSocket("ws://localhost:1234");
            var the_message = "";

            ws.OnMessage += (sender12, sent) =>
            {
                try
                {
                    the_message = sent.Data;

                    var the_message2 = JsonConvert.DeserializeObject <List <PollNode> >(the_message);

                    var ques        = "";
                    var ans_a       = "";
                    var ans_b       = "";
                    var ans_c       = "";
                    var ans_d       = "";
                    var num_a       = "";
                    var num_b       = "";
                    var num_c       = "";
                    var num_d       = "";
                    var correct_ans = "";

                    foreach (var m in the_message2)
                    {
                        ques        = m.Question;
                        ans_a       = m.A;
                        ans_b       = m.B;
                        ans_c       = m.C;
                        ans_d       = m.D;
                        num_a       = m.Freq_A;
                        num_b       = m.Freq_B;
                        num_c       = m.Freq_C;
                        num_d       = m.Freq_D;
                        correct_ans = m.Correct;
                    }
                    Debug.WriteLine("The message recieved from Node.js:");
                    Debug.WriteLine(the_message);

                    textBox = Sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 50, 90, 500, 70);
                    textBox.TextFrame.TextRange.InsertAfter(ques + "\n A: " + ans_a + "\n B: " + ans_b + "\n C: " + ans_c + "\n D: " + ans_d);
                    textBox.TextFrame.TextRange.Font.Size = 20;

                    if (correct_ans == "A")
                    {
                        point = series.Points(1) as PowerPoint.Point;
                        point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Green);
                    }
                    else if (correct_ans == "B")
                    {
                        point = series.Points(1) as PowerPoint.Point;
                        point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Green);
                    }
                    else if (correct_ans == "C")
                    {
                        point = series.Points(3) as PowerPoint.Point;
                        point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Green);
                    }
                    else if (correct_ans == "D")
                    {
                        point = series.Points(4) as PowerPoint.Point;
                        point.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Green);
                    }

                    ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B2"))).FormulaR1C1 = Convert.ToInt32(num_a);
                    ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B3"))).FormulaR1C1 = Convert.ToInt32(num_b);
                    ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B4"))).FormulaR1C1 = Convert.ToInt32(num_c);
                    ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B5"))).FormulaR1C1 = Convert.ToInt32(num_d);
                }
                catch (InvalidCastException e)
                {
                    Debug.WriteLine("Source: ", e.Source);
                }
            };
            ws.Connect();

            ws.OnError += (sender12, sent) =>
            {
                Debug.WriteLine("error " + sent.Message);
            };

            ws.OnClose += (sender12, sent) =>
            {
                Debug.WriteLine("disconnect with host");
            };
        }
Beispiel #4
0
        private void Judgquesbtn_Click(object sender, RibbonControlEventArgs e)
        {
            //if (Globals.ThisAddIn._JudgeTaskPane != null)
            //{
            //    Globals.ThisAddIn._JudgeTaskPane.Visible = true;
            //}
            //SetQuestForm setQuestForm = new SetQuestForm();
            //setQuestForm.Show();
            //Microsoft.Office.Interop.PowerPoint.Presentation MyPres = null;//ppt实例
            Microsoft.Office.Interop.PowerPoint.Slides AllSlides = null;         //PPT中所有的幻灯片
            Microsoft.Office.Interop.PowerPoint.Slide  MySlide   = null;         //当前幻灯片
            Microsoft.Office.Interop.PowerPoint.Slide  NewSlide  = null;         //新插入的幻灯片
            AllSlides = Globals.ThisAddIn.Application.ActivePresentation.Slides; //获取当前PPT中的所有幻灯片
            MySlide   = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;   //获取选中幻灯片

            #region 插入判断题 题目类型
            NewSlide = AllSlides.Add(MySlide.SlideIndex + 1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank); //插入幻灯片

            Microsoft.Office.Interop.PowerPoint.TextRange FillTextRng = null;                                                  //设置第一个文本框
            NewSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 21.5F, 40F, 100F, 30F).Name = "JudgeQuestion";
            NewSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name            = "questionType";
            NewSlide.Shapes["questionType"].TextFrame.TextRange.Text = "2";
            NewSlide.Shapes["questionType"].Visible = MsoTriState.msoFalse;



            NewSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name = "questionScore";
            NewSlide.Shapes["questionScore"].TextFrame.TextRange.Text = "0";
            NewSlide.Shapes["questionScore"].Visible = MsoTriState.msoFalse;
            NewSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name = "questionLimitTime";
            NewSlide.Shapes["questionLimitTime"].TextFrame.TextRange.Text = "0";
            NewSlide.Shapes["questionLimitTime"].Visible = MsoTriState.msoFalse;
            NewSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 0, 0).Name = "questionAnswer";
            NewSlide.Shapes["questionAnswer"].TextFrame.TextRange.Text = "0";
            NewSlide.Shapes["questionAnswer"].Visible = MsoTriState.msoFalse;


            FillTextRng = NewSlide.Shapes["JudgeQuestion"].TextFrame.TextRange;                                                 //请注意此处Shapes的索引,由于文本框是第一个添加的Shapes,所以此处索引是1。

            FillTextRng.Font.NameFarEast                = "微软雅黑";                                                               //文本框中,中文的字体
            FillTextRng.Font.NameAscii                  = "Calibri";                                                            //文本框中,英文和数字的字体
            FillTextRng.Text                            = "判断题";                                                                //显示的内容
            FillTextRng.Font.Bold                       = MsoTriState.msoTrue;                                                  //是否加粗
            FillTextRng.Font.Color.RGB                  = 1 + 1 * 256 + 1 * 256 * 256;                                          //字体颜色,其中ABC直接用自定义颜色中的数字代替即可。
            FillTextRng.Font.Size                       = 24;                                                                   //字体大小是24.
            FillTextRng.ParagraphFormat.Alignment       = Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft; //文本对齐方式(水平方向)
            NewSlide.Shapes[1].TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;                                    //文本对齐方式(垂直方向)
            NewSlide.Select();
            #endregion
            #region 插入判断题题目
            Microsoft.Office.Interop.PowerPoint.TextRange FQTextRng = null;

            NewSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 21.5F, 150F, 400F, 300F).Name = "questionDescribe";

            //添加True & False图片 从网上获取
            NewSlide.Shapes.AddPicture("http://pic.616pic.com/ys_b_img/00/57/95/CLa3kvD1Kw.jpg", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 21, 400, 70, 50).Name  = "answerisTrue";
            NewSlide.Shapes.AddPicture("http://pic.616pic.com/ys_b_img/00/11/88/mktrxpmh8r.jpg", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 200, 400, 70, 50).Name = "answerisFalse";
            NewSlide.Shapes["answerisTrue"].Visible  = MsoTriState.msoTrue;
            NewSlide.Shapes["answerisFalse"].Visible = MsoTriState.msoTrue;
            FQTextRng = NewSlide.Shapes["questionDescribe"].TextFrame.TextRange;                                                //请注意此处Shapes的索引,由于文本框是第二个添加的Shapes,所以此处索引是2。

            FQTextRng.Font.NameFarEast                  = "微软雅黑";                                                               //文本框中,中文的字体
            FQTextRng.Font.NameAscii                    = "Calibri";                                                            //文本框中,英文和数字的字体
            FQTextRng.Text                              = "请编写题干";                                                              //cxFlatTextArea1.Text;//显示的内容
            FQTextRng.Font.Bold                         = MsoTriState.msoFalse;                                                 //是否加粗
            FQTextRng.Font.Color.RGB                    = 1 + 1 * 256 + 1 * 256 * 256;                                          //字体颜色,其中ABC直接用自定义颜色中的数字代替即可。
            FQTextRng.Font.Size                         = 24;                                                                   //字体大小是24.
            FQTextRng.ParagraphFormat.Alignment         = Microsoft.Office.Interop.PowerPoint.PpParagraphAlignment.ppAlignLeft; //文本对齐方式(水平方向)
            NewSlide.Shapes[2].TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;                                    //文本对齐方式(垂直方向)
            #endregion
            #region 添加对错按钮
            //AddOleForm1(NewSlide, 21.5F, 400F, 70F, 50F, "True", 1);
            //AddOleForm1(NewSlide, 200F, 400F, 70F, 50F, "False", 2);

            //Image image1 = Properties.Resources.Oke_true;
            //Image image2 = Properties.Resources.Oke_false;
            //String image_path1 = Application.StartupPath + @"..\\..\\Resources\\Oke_true.png";
            //String image_path2 = @"..\\..\\Resources\\Oke_false.png";
            //MySlide.Shapes.AddPicture(image_path1, MsoTriState.msoFalse, MsoTriState.msoTrue, 27F, 24F, 665F, 333F);

            //presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
            //AddSubmitOleForm1(NewSlide, 822F, 466F, 89F, 46F);
            AddSubmitOleForm(NewSlide, 727F, 466F, 80F, 46F, EnumExtend.GetDisplayText(ButtonNameEnum.GETANS), "answerButton");
            AddSubmitOleForm(NewSlide, 822F, 466F, 80F, 46F, EnumExtend.GetDisplayText(ButtonNameEnum.SUMBIT), "sumbitButton");

            #endregion
        }
Beispiel #5
0
        public void refresh()
        {
            JObject responses = this.addin.getFormResponses(globalUrl);

            List <Question> questions = parseResponses(responses);

            int i = 0;

            foreach (Excel.ChartObject xlsChart in xlsCharts)
            {
                Excel.Worksheet dataSheet = dataWorkSheets[i];

                //Setting the range of chart

                string[] rangeids   = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
                string   lowerRange = "1";
                int      upRange    = questions[i].Choices.Count() + 1;
                string   upperRange = upperRangeGlobal;

                int lastCellUsed = 0;

                lowerRange = rangeids[lastCellUsed + 2] + lowerRange;

                //Descobrir o initial range

                for (int x = 0; x < 70; x++)
                {
                    if (dataSheet.Cells[2, x + 1].Value != null)
                    {
                        lastCellUsed = x;
                    }
                }

                if (questions[i].Type == "GRID")
                {
                    int    aux        = 0;
                    string categoria1 = questions[i].Choices[0].row;

                    for (int y = 0; y < questions[i].Choices.Count; y++)
                    {
                        if (questions[i].Choices[y].row == categoria1)
                        {
                            aux++;
                        }
                    }

                    upperRange = rangeids[aux + lastCellUsed + 2] + (questions[i].Choices.Count / 2 - 1).ToString();
                }

                else
                {
                    upperRange = rangeids[lastCellUsed + 3] + upRange;
                }

                Excel.Range tRange = dataSheet.Cells.get_Range(lowerRange, upperRange);

                //Setting values for categories and respective series data

                string option = lowerRangeGlobal;
                string count  = upperRangeGlobal;

                List <string> rows = new List <string>();

                if (questions[i].Type == "GRID")
                {
                    if (newTryCount != 0)
                    {
                        option = lowerRangeGlobal + 2;
                    }
                    else
                    {
                        option = lowerRangeGlobal;
                    }

                    int iteraux = 2;

                    for (var j = 0; j < questions[i].Choices.Count; j++)
                    {
                        string optionaux = option + iteraux;

                        if (!rows.Contains(questions[i].Choices[j].row))
                        {
                            dataSheet.Cells.get_Range(optionaux).FormulaR1C1 = questions[i].Choices[j].row;
                            rows.Add(questions[i].Choices[j].row);
                            iteraux++;
                        }
                    }

                    string[] columnids      = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
                    int      column_index   = 0;
                    bool     series_written = false;

                    for (int v = 0; v < rows.Count; v++)
                    {
                        string categoria = rows[v];
                        column_index = Array.IndexOf(columnids, lowerRangeGlobal) + 2 * newTryCount;
                        for (int u = 0; u < questions[i].Choices.Count; u++)
                        {
                            if (questions[i].Choices[u].row == categoria)
                            {
                                string celula = columnids[column_index + 1] + (v + 2).ToString();
                                dataSheet.Cells.get_Range(celula).FormulaR1C1 = questions[i].Choices[u].count.ToString();
                                if (!series_written)
                                {
                                    dataSheet.Cells.get_Range(columnids[column_index + 1] + (v + 1).ToString()).FormulaR1C1 = questions[i].Choices[u].option;
                                }
                                column_index++;
                            }
                        }
                        series_written = true;
                    }
                }

                else if (questions[i].Type == "SCALE")
                {
                    for (var j = 0; j < questions[i].Choices.Count; j++)
                    {
                        int    index1    = j + 2;
                        string optionaux = option + index1;
                        dataSheet.Cells.get_Range(optionaux).FormulaR1C1 = "- " + questions[i].Choices[j].option.ToString() + " -";
                    }

                    for (var k = 0; k < questions[i].Choices.Count; k++)
                    {
                        int    index2   = k + 2;
                        string countaux = count + index2;
                        dataSheet.Cells.get_Range(countaux).FormulaR1C1 = questions[i].Choices[k].count.ToString();
                    }
                }

                else
                {
                    for (var j = 0; j < questions[i].Choices.Count; j++)
                    {
                        int    index1    = j + 2;
                        string optionaux = option + index1;
                        dataSheet.Cells.get_Range(optionaux).FormulaR1C1 = questions[i].Choices[j].option;
                    }

                    for (var k = 0; k < questions[i].Choices.Count; k++)
                    {
                        int    index2   = k + 2;
                        string countaux = count + index2;
                        dataSheet.Cells.get_Range(countaux).FormulaR1C1 = questions[i].Choices[k].count.ToString();
                    }
                }

                float width = 500F;
                float left  = 230F;

                if (questions[i].Choices.Count > 6)
                {
                    width = 750F;
                    left  = 130F;
                }

                else if (questions[i].Choices.Count > 12)
                {
                    width = 1100;
                    left  = 80F;
                }

                Excel.Axis excelaxis = xlsChart.Chart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary);

                if (xlsChart.Chart.ChartType == Excel.XlChartType.xlColumnClustered)
                {
                    int maxScale = 0;
                    for (int h = 0; h < questions[i].Choices.Count; h++)
                    {
                        if (questions[i].Choices[h].count > maxScale)
                        {
                            maxScale = questions[i].Choices[h].count;
                        }
                    }

                    excelaxis.MajorUnit    = (int)(maxScale + 10.0) / 5;
                    excelaxis.MinorUnit    = (int)(maxScale + 10.0) / 10;
                    excelaxis.MinimumScale = 0;
                    excelaxis.MaximumScale = maxScale + 10.0;
                }

                PowerPoint.Slide currentSlide = this.addin.Application.ActiveWindow.View.Slide;

                pptSlides[i].Select();

                xlsChart.Copy();

                shapeRange = pptSlides[i].Shapes.Paste();


                PowerPoint.Shape previousGraph = pptSlides[i].Shapes[2];

                previousGraph.Delete();

                // Position the chart on the slide.

                shapeRange.Left   = left;
                shapeRange.Top    = 160F;
                shapeRange.Height = 350F;
                shapeRange.Width  = width;

                i++;

                currentSlide.Select();
            }
        }