コード例 #1
0
        public static Bitmap DisplayImage(Shape formatShape)
        {
            System.Drawing.Font font = SyncFormatConstants.DisplayImageFont;
            Microsoft.Office.Interop.PowerPoint.Font formatFont = formatShape.TextFrame.TextRange.Font;
            FontStyle style = 0;

            if (formatFont.Underline == Microsoft.Office.Core.MsoTriState.msoTrue)
            {
                style |= FontStyle.Underline;
            }
            if (formatFont.Bold == Microsoft.Office.Core.MsoTriState.msoTrue)
            {
                style |= FontStyle.Bold;
            }
            if (formatFont.Italic == Microsoft.Office.Core.MsoTriState.msoTrue)
            {
                style |= FontStyle.Italic;
            }
            font = new System.Drawing.Font(font.FontFamily, font.Size, style);
            return(SyncFormatUtil.GetTextDisplay(SyncFormatConstants.DisplayFontString, font,
                                                 SyncFormatConstants.DisplayImageSize));
        }
コード例 #2
0
ファイル: tscformat.cs プロジェクト: tdev131287/techandmate
        public void Format_XSeries(PowerPoint.Chart myChart, bool hasYAxis)
        {
            //if (myChart.Axes(XlAxisType.xlValue).HasTitle == true)
            try
            {
                if (myChart.HasAxis[XlAxisType.xlSeriesAxis] == true)
                {
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.LineStyle = PowerPoint.XlLineStyle.xlContinuous;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.Color     = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.Weight    = PowerPoint.XlBorderWeight.xlHairline;

                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.MajorTickMark     = PowerPoint.XlTickMark.xlTickMarkOutside;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.MinorTickMark     = PowerPoint.XlTickMark.xlTickMarkNone;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.TickLabelPosition = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;;
                    myChart.HasAxis(XlAxisType.xlSeriesAxis).Border.AutoScaleFont     = false;

                    PowerPoint.Font TickLabelsFont = myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font;
                    TickLabelsFont.Name = "Calibri";
                    TickLabelsFont.Bold = MsoTriState.msoFalse;
                    TickLabelsFont.Size = 11;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Strikethrough = MsoTriState.msoFalse;
                    TickLabelsFont.Superscript = MsoTriState.msoFalse;
                    TickLabelsFont.Subscript   = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.OutlineFont = MsoTriState.msoFalse;
                    TickLabelsFont.Shadow = MsoTriState.msoFalse;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                    myChart.Axes(XlAxisType.xlSeriesAxis).TickLabels.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
                }
            }
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "Format_XSeries");
            }
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: tscformat.cs プロジェクト: tdev131287/techandmate
 public void Format_XAxis(PowerPoint.Chart myChart, bool hasXAxis, string chType)
 {
     try
     {
         if (chType == "Pie" || chType == "Doughnut")
         {
             return;
         }
         if (chType == "Radar")
         {
             PowerPoint.Font RALFont = myChart.ChartGroups(1).RadarAxisLabels.Font;
             RALFont.Name = "Calibri";
             RALFont.Bold = MsoTriState.msoFalse;
             RALFont.Size = 11;
             myChart.ChartGroups(1).RadarAxisLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
             myChart.ChartGroups(1).RadarAxisLabels.Font.Strikethrough = MsoTriState.msoFalse;
             RALFont.Superscript = MsoTriState.msoFalse;
             RALFont.Subscript   = MsoTriState.msoFalse;
             myChart.ChartGroups(1).RadarAxisLabels.Font.OutlineFont = MsoTriState.msoFalse;
             RALFont.Shadow = MsoTriState.msoFalse;
             myChart.ChartGroups(1).RadarAxisLabels.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
             myChart.ChartGroups(1).RadarAxisLabels.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
             //System.Environment.Exit(0);
         }
         if (hasXAxis == true)
         {
             if (myChart.Axes(XlAxisType.xlCategory).HasTitle == true)
             {
                 PowerPoint.Font AxTitleFont = myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font;
                 AxTitleFont.Name = "Calibri";
                 AxTitleFont.Bold = MsoTriState.msoFalse;
                 AxTitleFont.Size = 11;
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                 AxTitleFont.Superscript = MsoTriState.msoFalse;
                 AxTitleFont.Subscript   = MsoTriState.msoFalse;
                 myChart.ChartGroups(1).RadarAxisLabels.Font.OutlineFont = MsoTriState.msoFalse;
                 AxTitleFont.Shadow = MsoTriState.msoFalse;
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                 myChart.Axes(XlAxisType.xlCategory).AxisTitle.Font.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
             }
             myChart.Axes(XlAxisType.xlCategory).Border.LineStyle         = PowerPoint.XlLineStyle.xlContinuous;
             myChart.Axes(XlAxisType.xlCategory).Border.Color             = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
             myChart.Axes(XlAxisType.xlCategory).Border.Weight            = PowerPoint.XlBorderWeight.xlHairline;
             myChart.Axes(XlAxisType.xlCategory).MajorTickMark            = PowerPoint.XlTickMark.xlTickMarkOutside;
             myChart.Axes(XlAxisType.xlCategory).TickLabelPosition        = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.AutoScaleFont = false;
             //---
             //PowerPoint.Font TickLabelsFont = myChart.Axes(XlAxisType.xlCategory).TickLabels.Font;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Name          = "Calibri";
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Bold          = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Size          = 11;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Strikethrough = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Superscript   = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Subscript     = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.OutlineFont   = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Shadow        = MsoTriState.msoFalse;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Underline     = XlUnderlineStyle.xlUnderlineStyleNone;
             myChart.Axes(XlAxisType.xlCategory).TickLabels.Font.Background    = PowerPoint.XlBackground.xlBackgroundAutomatic;
         }
         else if (hasXAxis == false)
         {
             myChart.HasAxis[XlAxisType.xlCategory] = false;
         }
     }
     catch (Exception err)
     {
         string errtext = err.Message;
         PPTAttribute.ErrorLog(errtext, "Format_XAxis");
     }
 }
コード例 #5
0
ファイル: tscformat.cs プロジェクト: tdev131287/techandmate
        public void Format_YAxis2(PowerPoint.Chart myChart, bool hasYAxis, string chType)
        {
            try
            {
                bool secAxis = false;
                PowerPoint.SeriesCollection sc = myChart.SeriesCollection();
                if (chType == "Pie" || chType == "Doughnut" || chType == "Surface")
                {
                    return;
                }
                if (chType == "Radar" || chType == "Stock")
                {
                    hasYAxis = true;
                }

                for (int i = 1; i <= sc.Count; i++)
                {
                    if (myChart.SeriesCollection(i).AxisGroup == 2)
                    {
                        secAxis = true; break;
                    }                                                                                    //XlAxisGroup.xlSecondary
                }
                if (secAxis == true)
                {
                    if (hasYAxis == true)
                    {
                        myChart.HasAxis[XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary] = true;
                        if (myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).HasTitle == true)
                        {
                            PowerPoint.Font fontObj = myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font;
                            fontObj.Name = "Calibri";
                            fontObj.Bold = MsoTriState.msoTrue;
                            fontObj.Size = 11;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                            fontObj.Superscript = MsoTriState.msoFalse;
                            fontObj.Subscript   = MsoTriState.msoFalse;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.OutlineFont = MsoTriState.msoFalse;
                            fontObj.Shadow = MsoTriState.msoFalse;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                            myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
                        }
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).Border.LineStyle         = PowerPoint.XlLineStyle.xlContinuous;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).Border.Color             = System.Drawing.Color.FromArgb(127, 127, 127).ToArgb();
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).Border.Weight            = PowerPoint.XlBorderWeight.xlHairline;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).MajorTickMark            = PowerPoint.XlTickMark.xlTickMarkOutside;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).TickLabelPosition        = PowerPoint.XlTickLabelPosition.xlTickLabelPositionNextToAxis;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).TickLabels.AutoScaleFont = false;
                        // ------

                        PowerPoint.Font fontObjTB = myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).TickLabels.Font;
                        fontObjTB.Name = "Calibri";
                        fontObjTB.Bold = MsoTriState.msoTrue;
                        fontObjTB.Size = 11;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Color         = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Strikethrough = MsoTriState.msoFalse;
                        fontObjTB.Superscript = MsoTriState.msoFalse;
                        fontObjTB.Subscript   = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.OutlineFont = MsoTriState.msoFalse;
                        fontObjTB.Shadow = MsoTriState.msoFalse;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Underline  = XlUnderlineStyle.xlUnderlineStyleNone;
                        myChart.Axes(XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary).AxisTitle.Font.Background = PowerPoint.XlBackground.xlBackgroundAutomatic;
                    }     // Check hasAxis is true
                    else if (hasYAxis == false)
                    {
                        myChart.HasAxis[XlAxisType.xlValue, PowerPoint.XlAxisGroup.xlSecondary] = false;
                    }
                }
            } // Close Main if Check the chart type
            catch (Exception err)
            {
                string errtext = err.Message;
                PPTAttribute.ErrorLog(errtext, "Format_YAxis2");
            }
        }