Esempio n. 1
0
        public void FormatShape(int sldNum, string shpNum, DataTable dt)
        {
            CMsoTriState pptMsoObject = new CMsoTriState();

            try
            {
                PowerPoint.Shape Activeshape = OpenedPPT.Slides[sldNum].Shapes[shpNum];
                List <int>       rgbVal      = new List <int>();
                List <int>       rgbVal1     = new List <int>();
                //if (textAdjust == false) { textAdjust = true; }
                //if (sizeAdjust == false) { sizeAdjust = true; }
                Activeshape.Name = Convert.ToString(dt.Rows[0]["Name"]);
                //-- Selected object is line --
                Activeshape.Line.Visible = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LineVisible"])); //MsoTriState.msoTrue;                               // Apply a msoValue Condition
                Activeshape.Fill.Visible = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["FillVisible"])); //MsoTriState.msoFalse;
                if (Convert.ToInt32(dt.Rows[0]["LineVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineForeColor"]));
                    Activeshape.Line.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();              // Apply a msoValue Condition
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineBackColor"]));
                    Activeshape.Line.BackColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();              // Apply a msoValue Condition
                    Activeshape.Line.Weight        = (float)Convert.ToDouble(dt.Rows[0]["LineWeight"]);
                    Activeshape.Line.Style         = MsoLineStyle.msoLineSingle;
                }// Apply a msoValue Condition


                if (Convert.ToInt32(dt.Rows[0]["FillVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["FillColor"]));
                    Activeshape.Fill.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();               // Apply a msoValue Condition
                    Activeshape.Fill.Transparency  = Convert.ToInt32(dt.Rows[0]["FillTransparency"]);
                }

                //Shape Shadow
                Activeshape.Shadow.Visible = MsoTriState.msoFalse;                                // Apply a msoValue Condition
                if (Convert.ToInt32(dt.Rows[0]["ShadowVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineForeColor"]));
                    Activeshape.TextFrame.TextRange.Font.Name = Convert.ToString(dt.Rows[0]["FontName"]);
                    //LineForeColor
                    Activeshape.Shadow.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();            // Apply a msoValue Condition
                    Activeshape.Shadow.Blur          = Convert.ToInt32(dt.Rows[0]["ShadowBlur"]);
                    Activeshape.Shadow.Size          = Convert.ToInt32(dt.Rows[0]["ShadowSize"]);
                    Activeshape.Shadow.Transparency  = Convert.ToInt32(dt.Rows[0]["ShadowTransparency"]);
                    Activeshape.Shadow.OffsetX       = Convert.ToInt32(dt.Rows[0]["ShadowOffsetX"]);
                    Activeshape.Shadow.OffsetY       = Convert.ToInt32(dt.Rows[0]["ShadowOffsetY"]);
                }
                Activeshape.Rotation = Convert.ToInt32(dt.Rows[0]["Rotaion"]);

                Activeshape.LockAspectRatio = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LockAspectRatio"]));

                //Shape Position


                // -- Set a Text Frame -
                Activeshape.TextFrame.Orientation    = pptMsoObject.getOrientation(Convert.ToInt32(dt.Rows[0]["Orientation"]));
                Activeshape.TextFrame.VerticalAnchor = pptMsoObject.getVerticalAnchor(Convert.ToInt32(dt.Rows[0]["VerticalAnchor"]));
                Activeshape.TextFrame.AutoSize       = pptMsoObject.TxtAutoSize(0);                                       // Only for test -
                Activeshape.TextFrame.AutoSize       = pptMsoObject.TxtAutoSize(Convert.ToInt32(dt.Rows[0]["AutoSize"])); // Apply a msoValue Condition
                Activeshape.TextFrame.MarginLeft     = (float)Convert.ToDouble((dt.Rows[0]["MarginLeft"]));
                Activeshape.TextFrame.MarginRight    = (float)Convert.ToDouble((dt.Rows[0]["MarginRight"]));
                Activeshape.TextFrame.MarginTop      = (float)Convert.ToDouble((dt.Rows[0]["MarginTop"]));
                Activeshape.TextFrame.MarginBottom   = (float)Convert.ToDouble((dt.Rows[0]["MarginBottom"]));
                Activeshape.TextFrame.WordWrap       = MsoTriState.msoCTrue;
                if (Activeshape.Name == "Road Map")
                {
                    Activeshape.TextFrame2.TextRange.Font.Spacing = 1;
                }
                //----- Set shape text range format --

                //List<int> rgbVal = new List<int>();
                rgbVal = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["FontColor"]));
                Activeshape.TextFrame.TextRange.Font.Name      = Convert.ToString(dt.Rows[0]["FontName"]);
                Activeshape.TextFrame.TextRange.Font.Bold      = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Bold"]));                                        //MsoTriState.msoCTrue;                        // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Italic    = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Italics"]));                                     //MsoTriState.msoFalse;                       // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Underline = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Underline"]));                                   //MsoTriState.msoFalse;                    // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Size      = Convert.ToInt32(dt.Rows[0]["FontSize"]);
                Activeshape.TextFrame.TextRange.Font.Color.RGB = System.Drawing.Color.FromArgb(rgbVal[0], rgbVal[1], rgbVal[2]).ToArgb();                                 // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Shadow    = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Shadow"]));                                      //MsoTriState.msoFalse;                       // Apply a msoValue Condition

                Activeshape.TextFrame.TextRange.Paragraphs(1).ParagraphFormat.Bullet.Type = pptMsoObject.getPpBulletType(Convert.ToInt32(dt.Rows[0]["ParagraphBullet"])); // Apply a msoValue Condition(Need to Check)

                // ---- Set the ParagraphFormat --
                Activeshape.TextFrame.TextRange.ParagraphFormat.Alignment          = pptMsoObject.ParagraphFormatAlignment(Convert.ToInt32(dt.Rows[0]["ParagraphAlignment"])); //PowerPoint.PpParagraphAlignment.ppAlignRight;               // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.ParagraphFormat.HangingPunctuation = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["ParagraphHangingPunctuation"]));  // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceBefore        = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceBefore"]));
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceAfter         = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceAfter"]));
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceWithin        = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceWithin"]));
                //Activeshape.TextFrame.Ruler.TabStops.DefaultSpacing = 45;


                Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = (float)Convert.ToDouble((dt.Rows[0]["RulerLevel1FirstMargin"]));
                Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = (float)Convert.ToDouble((dt.Rows[0]["RulerLevel1LeftMargin"]));

                // -'------------------- Specific Adjustments -----------------
                Activeshape.Left   = (float)Convert.ToDouble((dt.Rows[0]["ShapeLeft"]));
                Activeshape.Top    = (float)Convert.ToDouble((dt.Rows[0]["ShapeTop"]));
                Activeshape.Width  = (float)Convert.ToDouble((dt.Rows[0]["ShapeWidth"]));
                Activeshape.Height = (float)Convert.ToDouble((dt.Rows[0]["ShapeHeight"]));


                if (Activeshape.TextFrame.TextRange.Text.PadLeft(1) == " ")
                {
                    Activeshape.TextFrame.TextRange.Text = Activeshape.TextFrame.TextRange.Text.Trim();
                }

                var txtRange  = Activeshape.TextFrame.TextRange;
                int txtLength = Activeshape.TextFrame.TextRange.Count;

                //- - IF Road Map

                if (Convert.ToString(dt.Rows[0]["Name"]) == "Road Map")
                {
                    txtRange.ChangeCase(pptMsoObject.txtChangeCase(Convert.ToInt32(dt.Rows[0]["Case"])));
                }                                                                                                                                                    // Apply a msoValue Condition
                if (Convert.ToString(dt.Rows[0]["Name"]) == "Source Box")
                {
                    Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = 0;
                    Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = 0;
                    for (int x = 1; x <= txtRange.Paragraphs().Count; x++)
                    {
                        txtRange.Paragraphs(x).ParagraphFormat.HangingPunctuation = MsoTriState.msoFalse;
                    }
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "FormatShape");
            }
        }
Esempio n. 2
0
        public string CheckFormat_SBox(int sldNum, string tshpName, DataTable dt, bool sCheck = false)
        {
            string sErr = null;

            try
            {
                CMsoTriState     msoObj   = new CMsoTriState();
                string           shpName  = Convert.ToString(dt.Rows[0]["Name"]);
                PowerPoint.Shape curShape = ActivePPT.Slides[sldNum].Shapes[tshpName];
                if (curShape.Line.Visible != msoObj.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LineVisible"])))
                {
                    sErr = sErr + "Line Border" + '\n';
                }
                if (curShape.Fill.Visible != msoObj.getMsoTriState(Convert.ToInt32(dt.Rows[0]["FillVisible"])))
                //curShape.Fill.Transparency != Convert.ToInt32(dt.Rows[0]["FillTransparency"]))
                {
                    sErr = sErr + "Shape Fill" + '\n';
                }

                // -'-------------- Shape Size and Position ---------------

                float tempBottom = curShape.Top + curShape.Height;
                float shpLeft    = (float)Convert.ToDouble(dt.Rows[0]["ShapeLeft"]);
                float shpTop     = (float)Convert.ToDouble(dt.Rows[0]["ShapeTop"]);
                if (Convert.ToInt32(curShape.Left) != Convert.ToInt32(shpLeft) || Convert.ToInt32(curShape.Top) != Convert.ToInt32(shpTop))
                {
                    sErr = sErr + "Position Error" + '\n';
                }

                //float shpWidth = (float)Convert.ToDouble(dt.Rows[0]["ShapeWidth"]);
                //float shpHeight = (float)Convert.ToDouble(dt.Rows[0]["ShapeHeight"]);
                //-    Get the Margin from mapping -
                float leftMargin   = (float)Convert.ToDouble(dt.Rows[0]["MarginLeft"]);
                float RightMargin  = (float)Convert.ToDouble(dt.Rows[0]["MarginRight"]);
                float TopMargin    = (float)Convert.ToDouble(dt.Rows[0]["MarginTop"]);
                float BottomMargin = (float)Convert.ToDouble(dt.Rows[0]["MarginBottom"]);
                if (curShape.TextFrame.MarginLeft != leftMargin || curShape.TextFrame.MarginRight != RightMargin || curShape.TextFrame.MarginTop != TopMargin ||
                    curShape.TextFrame.MarginBottom != BottomMargin)
                {
                    sErr = sErr + "Margin Error" + '\n';
                }
                // '--------------------- Check the Font Error -------------------
                string     fontName  = dt.Rows[0]["FontName"].ToString();
                int        Bold      = Convert.ToInt32(dt.Rows[0]["Bold"]);
                int        Italics   = Convert.ToInt32(dt.Rows[0]["Italics"]);
                int        Underline = Convert.ToInt32(dt.Rows[0]["Underline"]);
                int        FontSize  = Convert.ToInt32(dt.Rows[0]["FontSize"]);
                List <int> rgbVal1   = msoObj.get_RGBValue(Convert.ToString(dt.Rows[0]["FontColor"]));                  // Set the Object


                PowerPoint.Font txtRangefont = curShape.TextFrame.TextRange.Font;

                int rgbCode = txtRangefont.Color.RGB;
                //int B = rgbCode/65536;
                //int G = (rgbCode - B * 65536) / 256;
                //int R = rgbCode - B * 65536 - G * 256;

                int r = rgbCode & 255;
                int g = rgbCode / 256 & 255;
                int b = rgbCode / 65536;//((rgbCode / 256) ^ 2) & 255;
                if (tshpName == "Text Box" || tshpName == "Quote Box")
                {
                    if (txtRangefont.Name != fontName)
                    {
                        sErr = sErr + "Font Error" + '\n';
                    }
                }
                else
                {
                    if (txtRangefont.Name != fontName || txtRangefont.Bold != msoObj.getMsoTriState(Bold) || txtRangefont.Italic != msoObj.getMsoTriState(Italics) ||
                        txtRangefont.Underline != msoObj.getMsoTriState(Underline) || txtRangefont.Size != FontSize ||
                        (rgbVal1[0] != b || rgbVal1[1] != g || rgbVal1[2] != r))              // Font Color is Fix --
                    {
                        sErr = sErr + "Font Error" + '\n';
                    }
                }
                //----- Check  Paragraph Error
                //--- Get a specification from mapping excel file
                int   prgBullet    = Convert.ToInt32(dt.Rows[0]["ParagraphBullet"]);
                int   prgAlignment = Convert.ToInt32(dt.Rows[0]["ParagraphAlignment"]);
                int   prghpun      = Convert.ToInt32(dt.Rows[0]["ParagraphHangingPunctuation"]);
                float prgbspace    = (float)Convert.ToDouble(dt.Rows[0]["ParagraphSpaceBefore"]);
                float prgaspace    = (float)Convert.ToDouble(dt.Rows[0]["ParagraphSpaceAfter"]);
                float prgwspace    = (float)Convert.ToDouble(dt.Rows[0]["ParagraphSpaceWithin"]);
                float prgflmargin  = (float)Convert.ToDouble(dt.Rows[0]["RulerLevel1FirstMargin"]);                   // It's not part of Paragraph format
                float prgllmargin  = (float)Convert.ToDouble(dt.Rows[0]["RulerLevel1LeftMargin"]);                    // It's not part of Paragraph format
                PowerPoint.ParagraphFormat prgformat = curShape.TextFrame.TextRange.ParagraphFormat;
                if (prgformat.Bullet.Type != msoObj.getPpBulletType(prgBullet) || prgformat.Alignment != msoObj.ParagraphFormatAlignment(prgAlignment) ||
                    prgformat.SpaceBefore != prgbspace || prgformat.SpaceAfter != prgaspace || prgformat.SpaceWithin != prgwspace)

                {
                    sErr = sErr + "Paragraph Error" + '\n';
                }
                // ---    Size and rotation type error
                int Rotaion     = Convert.ToInt32(dt.Rows[0]["Rotaion"]);
                int LARatio     = Convert.ToInt32(dt.Rows[0]["LockAspectRatio"]);
                int Orientation = Convert.ToInt32(dt.Rows[0]["Orientation"]);
                if (curShape.Rotation != Rotaion || curShape.TextFrame.Orientation != msoObj.getOrientation(Orientation) || curShape.LockAspectRatio != msoObj.getMsoTriState(LARatio))
                {
                    sErr = sErr + "Size and rotation" + '\n';
                }
                //getVerticalAnchor
                int shpAnchor = Convert.ToInt32(dt.Rows[0]["VerticalAnchor"]);//VerticalAnchor
                if (curShape.TextFrame.VerticalAnchor != msoObj.getVerticalAnchor(shpAnchor))
                {
                    sErr = sErr + "Vertical alengment error" + '\n';
                }
                //ppAutoSizeShapeToFitText  TxtAutoSize
                int autosize = Convert.ToInt32(dt.Rows[0]["AutoSize"]);//TxtAutoSize
                if (curShape.TextFrame.AutoSize != msoObj.TxtAutoSize(shpAnchor))
                {
                    sErr = sErr + "Shape tex fit error" + '\n';
                }
                //RulerLevel1LeftMargin
                //Activeshape.TextFrame.Ruler.Levels[1].LeftMargin
                int inlmargin = Convert.ToInt32(dt.Rows[0]["RulerLevel1LeftMargin"]);//LeftMargin
                if (curShape.TextFrame.Ruler.Levels[1].LeftMargin != inlmargin)
                {
                    sErr = sErr + "Paragraph indentation eror" + '\n';
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "CheckFormat_SBox");
            }
            return(sErr);
        }
Esempio n. 3
0
        public void FormatShape(int sldNum, string shpNum, DataTable dt, bool textAdjust = true, bool sizeAdjust = true)
        {
            CMsoTriState pptMsoObject = new CMsoTriState();

            try
            {
                PowerPoint.Shape Activeshape = ActivePPT.Slides[sldNum].Shapes[shpNum];
                List <int>       rgbVal      = new List <int>();
                List <int>       rgbVal1     = new List <int>();
                //if (textAdjust == false) { textAdjust = true; }
                //if (sizeAdjust == false) { sizeAdjust = true; }
                if (Convert.ToString(dt.Rows[0]["Name"]) != "Cagr Box")
                {
                    Activeshape.Name = Convert.ToString(dt.Rows[0]["Name"]);
                }
                //-- Selected object is line --
                Activeshape.Line.Visible = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LineVisible"])); //MsoTriState.msoTrue;                               // Apply a msoValue Condition
                Activeshape.Fill.Visible = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["FillVisible"])); //MsoTriState.msoFalse;
                if (Convert.ToInt32(dt.Rows[0]["LineVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineForeColor"]));
                    Activeshape.Line.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();              // Apply a msoValue Condition
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineBackColor"]));
                    Activeshape.Line.BackColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();              // Apply a msoValue Condition
                    Activeshape.Line.Weight        = (float)Convert.ToDouble(dt.Rows[0]["LineWeight"]);
                    Activeshape.Line.Style         = MsoLineStyle.msoLineSingle;
                    // Apply a msoValue Condition
                    //Activeshape.Line.Visible = MsoTriState.msoTrue;
                }// Apply a msoValue Condition
                 //'Shape Fill
                 //Activeshape.Fill.Visible = MsoTriState.msoCTrue;

                if (Convert.ToInt32(dt.Rows[0]["FillVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["FillColor"]));
                    Activeshape.Fill.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();               // Apply a msoValue Condition
                    Activeshape.Fill.Transparency  = Convert.ToInt32(dt.Rows[0]["FillTransparency"]);
                }

                //Shape Shadow
                Activeshape.Shadow.Visible = MsoTriState.msoFalse;                                // Apply a msoValue Condition
                if (Convert.ToInt32(dt.Rows[0]["ShadowVisible"]) == -1)
                {
                    rgbVal1 = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["LineForeColor"]));
                    Activeshape.TextFrame.TextRange.Font.Name = Convert.ToString(dt.Rows[0]["FontName"]);
                    //LineForeColor
                    Activeshape.Shadow.ForeColor.RGB = System.Drawing.Color.FromArgb(rgbVal1[0], rgbVal1[1], rgbVal1[2]).ToArgb();            // Apply a msoValue Condition
                    Activeshape.Shadow.Blur          = Convert.ToInt32(dt.Rows[0]["ShadowBlur"]);
                    Activeshape.Shadow.Size          = Convert.ToInt32(dt.Rows[0]["ShadowSize"]);
                    Activeshape.Shadow.Transparency  = Convert.ToInt32(dt.Rows[0]["ShadowTransparency"]);
                    Activeshape.Shadow.OffsetX       = Convert.ToInt32(dt.Rows[0]["ShadowOffsetX"]);
                    Activeshape.Shadow.OffsetY       = Convert.ToInt32(dt.Rows[0]["ShadowOffsetY"]);
                }
                Activeshape.Rotation = Convert.ToInt32(dt.Rows[0]["Rotaion"]);

                Activeshape.LockAspectRatio = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["LockAspectRatio"]));

                //Shape Position


                // -- Set a Text Frame -
                Activeshape.TextFrame.Orientation    = pptMsoObject.getOrientation(Convert.ToInt32(dt.Rows[0]["Orientation"]));
                Activeshape.TextFrame.VerticalAnchor = pptMsoObject.getVerticalAnchor(Convert.ToInt32(dt.Rows[0]["VerticalAnchor"]));
                Activeshape.TextFrame.AutoSize       = pptMsoObject.TxtAutoSize(0);                                       // Only for test -
                Activeshape.TextFrame.AutoSize       = pptMsoObject.TxtAutoSize(Convert.ToInt32(dt.Rows[0]["AutoSize"])); // Apply a msoValue Condition
                Activeshape.TextFrame.MarginLeft     = (float)Convert.ToDouble((dt.Rows[0]["MarginLeft"]));
                Activeshape.TextFrame.MarginRight    = (float)Convert.ToDouble((dt.Rows[0]["MarginRight"]));
                Activeshape.TextFrame.MarginTop      = (float)Convert.ToDouble((dt.Rows[0]["MarginTop"]));
                Activeshape.TextFrame.MarginBottom   = (float)Convert.ToDouble((dt.Rows[0]["MarginBottom"]));
                Activeshape.TextFrame.WordWrap       = MsoTriState.msoCTrue;
                if (Activeshape.Name == "Road Map")
                {
                    Activeshape.TextFrame2.TextRange.Font.Spacing = 1;
                }
                //----- Set shape text range format --
                if (textAdjust == true)
                {
                    if (Activeshape.Name == "Note Box" || Activeshape.Name == "Text Box")
                    {
                        string   defaultText = Convert.ToString(dt.Rows[0]["DefaultText"]).Replace("\n", "");
                        string[] text        = defaultText.Split(splitChar).ToArray();
                        if (Activeshape.Name == "Note Box")
                        {
                            Activeshape.TextFrame.TextRange.Text = text[0] + '\n' + text[1];
                        }
                        else if (Activeshape.Name == "Text Box")
                        {
                            Activeshape.TextFrame2.TextRange.Text = text[0] + "\r\n" + text[1] + "\r\n" + text[2] + "\r\n" + text[3];
                            //Activeshape.TextFrame.TextRange.Text = text[0] + '\n' + text[1] + '\n' + text[2] + '\n' + text[3];
                        }
                    }
                    else
                    {
                        Activeshape.TextFrame.TextRange.Text = Convert.ToString(dt.Rows[0]["DefaultText"]);
                    }
                }
                //List<int> rgbVal = new List<int>();
                rgbVal = pptMsoObject.get_RGBValue(Convert.ToString(dt.Rows[0]["FontColor"]));
                Activeshape.TextFrame.TextRange.Font.Name      = Convert.ToString(dt.Rows[0]["FontName"]);
                Activeshape.TextFrame.TextRange.Font.Bold      = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Bold"]));        //MsoTriState.msoCTrue;                        // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Italic    = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Italics"]));     //MsoTriState.msoFalse;                       // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Underline = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Underline"]));   //MsoTriState.msoFalse;                    // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Size      = Convert.ToInt32(dt.Rows[0]["FontSize"]);
                Activeshape.TextFrame.TextRange.Font.Color.RGB = System.Drawing.Color.FromArgb(rgbVal[0], rgbVal[1], rgbVal[2]).ToArgb(); // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.Font.Shadow    = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["Shadow"]));      //MsoTriState.msoFalse;                       // Apply a msoValue Condition

                //Activeshape.TextFrame.TextRange.Paragraphs(1).ParagraphFormat.Bullet.Type = pptMsoObject.getPpBulletType(Convert.ToInt32(dt.Rows[0]["ParagraphBullet"]));  // Apply a msoValue Condition(Need to Check)

                // ---- Set the ParagraphFormat --
                Activeshape.TextFrame.TextRange.ParagraphFormat.Alignment          = pptMsoObject.ParagraphFormatAlignment(Convert.ToInt32(dt.Rows[0]["ParagraphAlignment"])); //PowerPoint.PpParagraphAlignment.ppAlignRight;               // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.ParagraphFormat.HangingPunctuation = pptMsoObject.getMsoTriState(Convert.ToInt32(dt.Rows[0]["ParagraphHangingPunctuation"]));  // Apply a msoValue Condition
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceBefore        = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceBefore"]));
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceAfter         = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceAfter"]));
                Activeshape.TextFrame.TextRange.ParagraphFormat.SpaceWithin        = (float)Convert.ToDouble((dt.Rows[0]["ParagraphSpaceWithin"]));
                //Activeshape.TextFrame.Ruler.TabStops.DefaultSpacing = 45;


                Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = (float)Convert.ToDouble((dt.Rows[0]["RulerLevel1FirstMargin"]));
                Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = (float)Convert.ToDouble((dt.Rows[0]["RulerLevel1LeftMargin"]));

                // -'------------------- Specific Adjustments -----------------
                if (sizeAdjust == true)
                {
                    Activeshape.Left   = (float)Convert.ToDouble((dt.Rows[0]["ShapeLeft"]));
                    Activeshape.Top    = (float)Convert.ToDouble((dt.Rows[0]["ShapeTop"]));
                    Activeshape.Width  = (float)Convert.ToDouble((dt.Rows[0]["ShapeWidth"]));
                    Activeshape.Height = (float)Convert.ToDouble((dt.Rows[0]["ShapeHeight"]));
                }



                if (Activeshape.TextFrame.TextRange.Text.PadLeft(1) == " ")
                {
                    Activeshape.TextFrame.TextRange.Text = Activeshape.TextFrame.TextRange.Text.Trim();
                }

                var txtRange  = Activeshape.TextFrame.TextRange;
                int txtLength = Activeshape.TextFrame.TextRange.Count;
                //                                                      Check it why we do the comment -
                //byte result = Convert.ToByte(txtRange.Characters(1,1));
                //if(result==9 || result==10||result==11 || result==13|| result == 32) { txtRange.Text = txtRange.Text.PadRight(txtRange.Text.Length - 1); }
                //- - IF note box

                if (Convert.ToString(dt.Rows[0]["Name"]) == "Note Box")
                {
                    Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = 0;
                    Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = 0;
                    for (int x = 1; x <= txtRange.Paragraphs().Count; x++)
                    {
                        txtRange.Paragraphs(x).ParagraphFormat.HangingPunctuation = MsoTriState.msoFalse;
                    }
                    //int txtLen = Convert.ToString(dt.Rows[0]["DefaultText"]).Length;
                    //if (txtRange.Text.PadLeft(txtLen) != Convert.ToString(dt.Rows[0]["DefaultText"]))
                    //{
                    //    if (txtRange.Text.PadLeft(6) == "Notes:") { txtRange.Text = txtRange.Text.Substring(7, txtRange.Text.Length); }
                    //    else if (txtRange.Text.PadLeft(5) == "Notes:") { txtRange.Text = txtRange.Text.Substring(6, txtRange.Text.Length); }
                    //    txtRange.Text = Convert.ToString(dt.Rows[0]["DefaultText"]) + txtRange.Text;
                    //}
                }
                //- - IF Source Box
                if (Convert.ToString(dt.Rows[0]["Name"]) == "Source Box")
                {
                    Activeshape.TextFrame.Ruler.Levels[1].FirstMargin = 0;
                    Activeshape.TextFrame.Ruler.Levels[1].LeftMargin  = 0;
                    for (int x = 1; x <= txtRange.Paragraphs().Count; x++)
                    {
                        txtRange.Paragraphs(x).ParagraphFormat.HangingPunctuation = MsoTriState.msoFalse;
                    }
                    //int txtLen = Convert.ToString(dt.Rows[0]["DefaultText"]).Length;
                    //if (txtRange.Text.PadLeft(txtLen) != Convert.ToString(dt.Rows[0]["DefaultText"]))
                    //{
                    //    if (txtRange.Text.Substring(0,8) == "Sources:") { txtRange.Text = txtRange.Text.Substring(9, txtRange.Text.Length); }
                    //    else if (txtRange.Text.PadLeft(5) == "Sources:") { txtRange.Text = txtRange.Text.Substring(8, txtRange.Text.Length); }
                    //    txtRange.Text = Convert.ToString(dt.Rows[0]["DefaultText"]) + txtRange.Text;
                    //}
                }
                //- - IF Road Map

                if (Convert.ToString(dt.Rows[0]["Name"]) == "Road Map")
                {
                    txtRange.ChangeCase(pptMsoObject.txtChangeCase(Convert.ToInt32(dt.Rows[0]["Case"])));
                }                                                                                                                                                    // Apply a msoValue Condition


                // --"Quote Box"
                int sn = 0, en = 0;
                if (Convert.ToString(dt.Rows[0]["Name"]) == "Quote Box")
                {
                    var rngs = txtRange.Find("–", 0, MsoTriState.msoCTrue, MsoTriState.msoFalse);
                    var rngE = txtRange.Find(")", 0, MsoTriState.msoCTrue, MsoTriState.msoFalse);
                    if (rngs != null)
                    {
                        sn = rngs.Start;
                    }
                    if (rngE != null)
                    {
                        en = rngE.Start + 3;
                    }
                    if (rngE != null && rngs != null)
                    {
                        txtRange.Characters(sn, en).Font.Italic = MsoTriState.msoCTrue;
                        txtRange.Characters(sn, en).Font.Italic = MsoTriState.msoFalse;
                        txtRange.Characters(sn, en).Font.Bold   = MsoTriState.msoCTrue;
                    }
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "FormatShape");
            }
        }