Exemple #1
0
        public void CheckFormat(int sldNum, string method)
        {
            shpNames.Clear();                               // Clear the list box -
            shpNames = NameAllShapes(sldNum);
            char          spltChar = '\n';
            List <string> errA     = new List <string>();
            string        shpName;

            try
            {
                if (shpNames.Count != 0)
                {
                    DeleteFormatComments_M1(sldNum);                    // Delete all comment from slide
                    for (int s = 0; s < shpNames.Count; s++)
                    {
                        shpErr = null;
                        PowerPoint.Shape shp = ActivePPT.Slides[sldNum].Shapes[shpNames[s]];
                        shpName = shp.Name;
                        shpErr  = shpErr + CheckFormat_ShapeInSlide(sldNum, shpName);
                        if (ActivePPT.Slides[sldNum].CustomLayout.Name == "Title Slide")
                        {
                            shpErr = shpErr + CheckFormat_TitleSlide(sldNum, shpName) + '\n';
                        }
                        else if (ActivePPT.Slides[sldNum].CustomLayout.Name == "Contents Slide")
                        {
                            shpErr = shpErr + CheckFormat_ContentSlide(sldNum, shpName) + '\n';
                        }
                        else if (ActivePPT.Slides[sldNum].CustomLayout.Name == "Divider Slide")
                        {
                            shpErr = shpErr + CheckFormat_DividerSlide(sldNum, shpName) + '\n';
                        }
                        else
                        {
                            shpErr = shpErr + CheckFormat_MainSlide(sldNum, shpName) + '\n';
                        }

                        errA  = shpErr.Split(spltChar).ToList();
                        errAU = UniqueValues(errA);
                        //string fshpErr = null;
                        //int counter = 1;
                        //foreach (string err in errAU)
                        //{
                        //    fshpErr = fshpErr + (counter + 1) + ")  " + err + '\n';
                        //}

                        if (method == "method1")
                        {
                            float lf = ActivePPT.Slides[sldNum].Shapes[shpName].Left;
                            float wb = ActivePPT.Slides[sldNum].Shapes[shpName].Width;
                            float tp = ActivePPT.Slides[sldNum].Shapes[shpName].Top;
                            if (shpErr != null && string.IsNullOrEmpty(shpErr.Replace("\n", "")) == false)
                            {
                                PowerPoint.Comment cmtNew = ActivePPT.Slides[sldNum].Comments.Add((lf + wb), tp, shpName + " Error", "TFR", shpErr);
                            }
                        }
                        else if (method == "method2")
                        {
                            if (shpErr != null && string.IsNullOrEmpty(shpErr.Replace("\n", "")) == false)
                            {
                                ActivePPT.Slides[sldNum].Shapes[shpName].Select();
                                List <string> lstError = new List <string>();
                                lstError = shpErr.Split('\n').ToList();
                                foreach (string errType in lstError)
                                {
                                    //MessageBox.Show("Static Value: " +Convert.ToString(PPTAttribute.exitFlag));
                                    if (errType != "" && PPTAttribute.exitFlag == false)
                                    {
                                        StreamWriter sw = new StreamWriter(PPTAttribute.supportfile);
                                        //string errtxt = sldNum + "|" + shpErr.Replace("\n", "") + "|" + shpName;
                                        string errtxt = sldNum + "|" + errType + "|" + shpName;
                                        sw.WriteLine(errtxt);
                                        frmErrorlist frmobj = new frmErrorlist();
                                        sw.Close();
                                        frmobj.ShowDialog();
                                    }
                                }
                            }
                        }
                    }// - Close Loop

                    //if (String.IsNullOrWhiteSpace(shpErr)) { MessageBox.Show("There is no error found in format review",PPTAttribute.msgTitle,MessageBoxButtons.OK, MessageBoxIcon.Information); }
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "CheckFormat");
            }
        }
        private void btn_Review_Click(object sender, EventArgs e)
        {
            string       whichSlides = cmb_RType.Text;
            Algorithms   algObj      = new Algorithms();
            List <int>   selSlides   = new List <int>();
            Reviewformat formatObj   = new Reviewformat();
            Formatshapes shpobj      = new Formatshapes();
            frmErrorlist frmObj      = new frmErrorlist();
            //int[] selSlides ;
            int selectedSlides = 0;

            try
            {
                bool uUnload = false, globalErrors = false;
                selectedSlides = ppApp.ActiveWindow.Selection.SlideRange.Count;
                this.Close();
                if (whichSlides == "Current" || whichSlides == "Selected")
                {
                    if (selectedSlides == 0)
                    {
                        MessageBox.Show("Please select a slide and try again"); this.Close();
                    }
                    else
                    {
                        for (int i = 1; i <= selectedSlides; i++)
                        {
                            selSlides.Add(ppApp.ActiveWindow.Selection.SlideRange[i].SlideIndex);
                        }
                        //Array.Sort(selSlides);
                        selSlides.Sort();
                    }
                }
                else if (whichSlides == "All")
                {
                    selectedSlides = ppApp.ActivePresentation.Slides.Count;
                    for (int i = 1; i <= selectedSlides; i++)
                    {
                        selSlides.Add(i);
                    }
                }
                if (selectedSlides == 0)
                {
                    MessageBox.Show("Please select a slide and try again"); this.Close(); return;
                }
                else
                {
                    for (int i = 0; i < selectedSlides; i++)
                    {
                        int sldNum = selSlides[i];
                        algObj.SetNamesUnique(sldNum);                            // -Set the unique name of each object for get the property
                        ppApp.ActiveWindow.View.GotoSlide(sldNum);
                        ActivePPT.Slides[sldNum].Select();
                        if (rb_Review.Checked == true)
                        {
                            formatObj.CheckFormat(sldNum, "method1");
                        }
                        else if (rb_ReviewCorrect.Checked == true)
                        {
                            formatObj.CheckFormat(sldNum, "method2");
                        }
                        else if (rb_CorrectAll.Checked == true)
                        {
                            shpobj.CorrectFormat(sldNum);
                        }
                    }
                    if (PPTAttribute.exitFlag == false)
                    {
                        MessageBox.Show("Format review and correction has been done", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                // - After review select a first slide
                if (rb_CorrectAll.Checked == true)
                {
                    MessageBox.Show("Format review and correction has been done", PPTAttribute.msgTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                this.Close();               // Close the user forms
                if (whichSlides == "All")
                {
                    ActivePPT.Slides[1].Select();
                }
            }
            catch (Exception err)
            {
                PPTAttribute.exitFlag = true;
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "Review Format");
            }
        }