Пример #1
0
        //--- Correct Format -For method 3
        public void CorrectFormat(int sldnum)
        {
            Reviewformat  fobj     = new Reviewformat();
            List <string> shpNames = new List <string>();

            try
            {
                shpNames = fobj.NameAllShapes(sldnum);
                if (shpNames.Count == 0)
                {
                    return;
                }
                foreach (string shp in shpNames)
                {
                    CorrectFormat_ShapeInSlide(sldnum, shp);
                    if (ActivePPT.Slides[sldnum].CustomLayout.Name == "Title Slide")
                    {
                        CorrectFormat_TitleSlide(sldnum, shp);
                    }
                    else if (ActivePPT.Slides[sldnum].CustomLayout.Name == "Content Slide")
                    {
                        CorrectFormat_ContentSlide(sldnum, shp);
                    }
                    else if (ActivePPT.Slides[sldnum].CustomLayout.Name == "Divider Slide")
                    {
                        CorrectFormat_DividerSlide(sldnum, shp);
                    }
                    else
                    {
                        CorrectFormat_MainSlide(sldnum, shp);
                    }
                }
                DeleteFormatComments_M3(sldnum);
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "CorrectFormat");
            }
        }
Пример #2
0
        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");
            }
        }
Пример #3
0
        public void CorrectFormat_ShapeInSlide(int sldNum, string shpName)
        {
            Reviewformat formatobj = new Reviewformat();

            try
            {
                float sldLeft   = 0;
                float sldTop    = 0;
                float sldRight  = ActivePPT.PageSetup.SlideWidth;
                float sldBottom = ActivePPT.PageSetup.SlideHeight;

                PowerPoint.Shape tShp = ActivePPT.Slides[sldNum].Shapes[shpName];
                if (tShp.Type != MsoShapeType.msoLine)
                {
                    float sngCenterH = tShp.Left + tShp.Width / 2;
                    //fFindHorizontalDistance
                    float sngDistH      = formatobj.fFindHorizontalDistance(tShp); //This is half of horizontal distance
                    float sngShapeLeft  = sngCenterH - sngDistH;                   //Actual Left
                    float sngShapeRight = sngCenterH + sngDistH;                   //Actual Right
                                                                                   //Vertical Distances
                    float sngCenterV     = tShp.Top + tShp.Height / 2;
                    float sngDistV       = formatobj.fFindVerticalDistance(tShp);  //This is half of vertical distance
                    float sngShapeTop    = sngCenterV - sngDistV;                  //Actual Top
                    float sngShapeBottom = sngCenterV + sngDistV;                  //Actual Bottom
                    if ((tShp.Left + tShp.Width) > sldRight)
                    {
                        tShp.Left = sldRight - tShp.Width;
                    }
                    if ((tShp.Top + tShp.Height) > sldBottom)
                    {
                        tShp.Top = sldBottom - tShp.Height;
                    }
                    if (tShp.Top < sldTop)
                    {
                        tShp.Top = sldTop;
                    }
                    if (tShp.Left < sldLeft)
                    {
                        tShp.Left = sldLeft;
                    }
                    //if (sngShapeLeft < sldLeft) { tShp.Left = tShp.Left + (sldLeft - sngShapeLeft); }
                    //if (sngShapeRight > sldRight) { tShp.Left = sldRight-tShp.Width; }  //tShp.Left - (sngShapeRight - sldRight)
                    //if (sngShapeTop < sldTop) { tShp.Top = tShp.Top + (sldTop - sngShapeTop); }
                    //if (sngShapeBottom > sldBottom) { tShp.Top = tShp.Top - (sngShapeBottom - sldBottom); }
                }
                else
                {
                    if (tShp.Left < sldLeft)
                    {
                        tShp.Left = sldLeft;
                    }
                    if ((tShp.Left + tShp.Width) > sldRight)
                    {
                        tShp.Left = tShp.Left - (tShp.Left + tShp.Width - sldRight);
                    }
                    if (tShp.Top < sldTop)
                    {
                        tShp.Top = sldTop;
                    }
                    if ((tShp.Top + tShp.Height) > sldBottom)
                    {
                        tShp.Top = tShp.Top - (tShp.Top + tShp.Height - sldBottom);
                    }
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "CorrectFormat_ShapeInSlide");
            }
        }