コード例 #1
0
        private void FillRowHeaders(string[] rowHeaders, AUGrid c1fgrid)
        {
            bool isrowheaderchecked = true;// rowheaderscheck.IsChecked == true ? true : false;
            //creating row headers
            string[,] rowheadersdata = new string[rowHeaders.Length, 1];
            ////creating data
            for (int r = 0; r < rowheadersdata.GetLength(0); r++)
            {
                for (int c = 0; c < rowheadersdata.GetLength(1); c++)
                {
                    rowheadersdata[r, c] = rowHeaders[r];
                }
            }
            //create & fill row headers
            bool fillrowheaders = isrowheaderchecked;
            if (fillrowheaders)
            {
                var FGrowheaders = c1fgrid.RowHeaders;
                FGrowheaders.Columns[0].AllowMerging = true;
                FGrowheaders.Columns[0].VerticalAlignment = VerticalAlignment.Top;
                FGrowheaders.Columns[0].Width = new GridLength(70);

                for (int i = FGrowheaders.Columns.Count; i < rowheadersdata.GetLength(1); i++)
                {
                    C1.WPF.FlexGrid.Column col = new C1.WPF.FlexGrid.Column();
                    col.AllowMerging = true;
                    col.VerticalAlignment = VerticalAlignment.Top;
                    col.Width = new GridLength(70);
                    FGrowheaders.Columns.Add(col);
                }

                for (int i = FGrowheaders.Rows.Count; i < rowheadersdata.GetLength(0); i++)
                {
                    C1.WPF.FlexGrid.Row row = new C1.WPF.FlexGrid.Row();
                    row.AllowMerging = true;
                    FGrowheaders.Rows.Add(row);
                }

                //fill row headers
                for (int i = 0; i < rowheadersdata.GetLength(0); i++)
                    for (int j = 0; j < rowheadersdata.GetLength(1); j++)
                    {
                        if (rowheadersdata[i, j] != null && rowheadersdata[i, j].Trim().Equals(".-."))
                            FGrowheaders[i, j] = "";//14Jul2014 filling empty header
                        else
                            FGrowheaders[i, j] = rowheadersdata[i, j];
                    }
            }
        }
コード例 #2
0
        private void FillColHeaders(string[] colHeaders, AUGrid c1fgrid)
        {
            bool iscolheaderchecked = true;// rowheaderscheck.IsChecked == true ? true : false;
            //creating row headers
            string[,] colheadersdata = new string[1, colHeaders.Length];
            ////creating data
            for (int r = 0; r < colheadersdata.GetLength(0); r++)
            {
                for (int c = 0; c < colheadersdata.GetLength(1); c++)
                {
                    colheadersdata[r, c] = colHeaders[c];
                }
            }

            //create & fill row headers
            bool fillcolheaders = iscolheaderchecked;
            if (fillcolheaders)
            {
                var FGcolheaders = c1fgrid.ColumnHeaders; 
                FGcolheaders.Rows[0].AllowMerging = true;
                FGcolheaders.Rows[0].HorizontalAlignment = HorizontalAlignment.Center;

                for (int i = FGcolheaders.Columns.Count; i < colheadersdata.GetLength(1); i++)
                {
                    C1.WPF.FlexGrid.Column col = new C1.WPF.FlexGrid.Column();
                    col.AllowMerging = true;
                    col.VerticalAlignment = VerticalAlignment.Top;
                    FGcolheaders.Columns.Add(col);
                }

                for (int i = FGcolheaders.Rows.Count; i < colheadersdata.GetLength(0); i++)
                {
                    C1.WPF.FlexGrid.Row row = new C1.WPF.FlexGrid.Row();
                    FGcolheaders.Rows.Add(row);
                    row.AllowMerging = true;
                }

                //fill row headers
                for (int i = 0; i < colheadersdata.GetLength(0); i++)
                    for (int j = 0; j < colheadersdata.GetLength(1); j++)
                    {
                        if (colheadersdata[i, j] != null && colheadersdata[i, j].Trim().Equals(".-."))
                            FGcolheaders[i, j] = "";//14Jul2014 filling empty header
                        else
                            FGcolheaders[i, j] = colheadersdata[i, j];
                    }
            }
        }
コード例 #3
0
        //AUGrid c1fg = null;
        /// Read .bso file and create all the displayable objects in allanalysis
        public List <SessionOutput> html2xml(string fullpathfilename)
        {
            #region read html and
            if (!File.Exists(fullpathfilename))
            {
                MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyOutFileNotFound);
                return(null);
            }
            string fulltext = File.ReadAllText(fullpathfilename);
            string s        = Regex.Replace(fulltext, @"\0", "");
            //////////////Put <BSKYOUTPUT> check here //////////////
            if (Regex.Matches(s, "<bskyoutput>").Count < 1 || Regex.Matches(s, "</bskyoutput>").Count < 1)
            {
                MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyOutFileBadFormat);
                return(null);
            }

            string r = Regex.Replace(s, @"<head>", "");
            string t = r;

            /// fixing class attribute with quotes
            string patternh = @"\bclass=h[0-9]+";
            string u        = Regex.Replace(t, patternh, " class='h'");
            string patternc = @"\bclass=c[0-9]+";
            string v        = Regex.Replace(u, patternc, " class='c'");

            List <SessionOutput> allSessions = new List <SessionOutput>();
            XmlDocument          sessXd      = new XmlDocument();
            //New Session tag which is parent of bskyanalysis tag
            ////// No of sessions/// ana is abbrivation for analysis
            MatchCollection sessmc  = Regex.Matches(v, "<sessoutput");
            MatchCollection sessmc2 = Regex.Matches(v, "</sessoutput>");
            for (int ss = 0; ss < sessmc.Count; ss++) ///loop on number of sessions
            {                                         ///
                int    sessStart  = sessmc[ss].Index;
                int    sessEnd    = sessmc2[ss].Index;
                string onesession = v.Substring(sessStart, sessEnd - sessStart + 14);
                ////// No of Analysis/// ana is abbrivation for analysis
                MatchCollection anamc  = Regex.Matches(onesession, "<bskyanalysis>");
                MatchCollection anamc2 = Regex.Matches(onesession, "</bskyanalysis>");

                sessXd.LoadXml(onesession);
                string sessionheader = sessXd.SelectSingleNode("sessoutput").Attributes["Header"] != null?sessXd.SelectSingleNode("sessoutput").Attributes["Header"].Value : string.Empty;

                string isRsession = sessXd.SelectSingleNode("sessoutput").Attributes["isRsession"] != null?sessXd.SelectSingleNode("sessoutput").Attributes["isRsession"].Value : "false";

                bool isrsessionoutput = false;
                if (isRsession.ToLower().Trim().Equals("true"))
                {
                    isrsessionoutput = true;
                }
                int           anaStart = 0; int anaEnd = 0;
                XmlDocument   anaXd       = new XmlDocument();
                CommandOutput lst         = null;
                SessionOutput allanalysis = new SessionOutput();
                allanalysis.NameOfSession    = sessionheader;
                allanalysis.isRSessionOutput = isrsessionoutput;

                AUParagraph AUP;                      //09Jul2013
                for (int j = 0; j < anamc.Count; j++) ///loop on number of analysis
                {
                    lst      = new CommandOutput();   ///for treeview. New analysis
                    anaStart = anamc[j].Index;
                    anaEnd   = anamc2[j].Index;
                    string oneAnalysis = onesession.Substring(anaStart, anaEnd - anaStart + 15);
                    anaXd.LoadXml(oneAnalysis);

                    lst.NameOfAnalysis = anaXd.SelectSingleNode("bskyanalysis/analysisname").InnerText.Trim(); //For Parent Node name 02Aug2012

                    int      noofaup   = anaXd.SelectNodes("bskyanalysis/aup").Count;                          // should be 2
                    int      leafcount = anaXd.ChildNodes.Item(0).ChildNodes.Count;                            //29Oct2013 no. of leaves in an analysis
                    string[] contTyp   = { "Header", "Dataset" };                                              // should be 2
                    int      noofnotes = anaXd.SelectNodes("bskyanalysis/bskynotes").Count;                    //06nov2012

                    foreach (XmlNode ln in anaXd.ChildNodes.Item(0).ChildNodes)
                    {
                        if (ln.Name.Trim().Equals("analysisname"))
                        {
                            continue;
                        }
                        XmlNode xn = null;
                        switch (ln.Name.Trim())
                        {
                        case "aup":
                            #region AUPara
                            AUP = createAUPara(ln, "", "");
                            if (AUP != null)
                            {
                                lst.Add(AUP);
                            }

                            #endregion
                            break;

                        case "bskynotes":
                            #region BSkyNotes
                            if (noofnotes >= 1)
                            {
                                BSkyNotes bsnotes = createBSkyNotes(ln, "", "Notes");
                                if (bsnotes != null)
                                {
                                    lst.Add(bsnotes);
                                }
                            }
                            #endregion
                            break;

                        case "graphic":
                            #region Graphic
                            string  tempDir             = System.IO.Path.GetDirectoryName(fullpathfilename);
                            string  fullpathimgfilename = string.Empty;
                            XmlNode imgxn           = ln;//anaXd.SelectSingleNode("bskyanalysis/graphic");
                            string  pathimgfilename = (imgxn != null) ? imgxn.InnerText.Trim() : "";

                            string imgfileNamewithExt = System.IO.Path.GetFileName(pathimgfilename);
                            string outputDir          = tempDir + "\\";// @"\temp2\";
                            fullpathimgfilename = System.IO.Path.Combine(outputDir + imgfileNamewithExt);

                            if (fullpathimgfilename.Trim().Length > 0)
                            {
                                lst.Add(CreateBSkyGraphicControl(fullpathimgfilename));
                            }
                            #endregion
                            break;

                        case "auxgrid":
                            #region FlexGrid

                            oneAnalysis = ln.OuterXml;
                            ////// No. of Grids in one analysis: for C1FlexGrid header/footer err/warning generation //////
                            MatchCollection aux1    = Regex.Matches(oneAnalysis, "<auxgrid>");
                            MatchCollection aux2    = Regex.Matches(oneAnalysis, "</auxgrid>");
                            XmlDocument     anagrid = new XmlDocument();//this will be used to get contents of auxgrid(excluding flexgrid)

                            ////// No. of FlexGrids in one analysis: for C1FlexGrid generation //////
                            MatchCollection mc = Regex.Matches(oneAnalysis, "<html>");
                            MatchCollection mc2 = Regex.Matches(oneAnalysis, "</html>");
                            int             start = 0; int end = 0;
                            XmlDocument     xd = new XmlDocument();
                            for (int k = 0; k < mc.Count; k++) /// loop till all C1FlexGrid in current Analysis get generated
                            {
                                AUXGrid xgrid = new AUXGrid();
                                AUGrid  c1fg  = xgrid.Grid;// new C1flexgrid.

                                anagrid.LoadXml(oneAnalysis.Substring(aux1[k].Index, aux2[k].Index - aux1[k].Index + 10));
                                //flexgrid header
                                xn = anagrid.SelectSingleNode("auxgrid/fgheader[1]");
                                xgrid.Header.Text = (xn != null) ? xn.InnerText : "";
                                ///AUXGrid  error/warning
                                Dictionary <char, string> Metadata = new Dictionary <char, string>();
                                char   ch = ' '; int erri = 2;
                                string mesg = "", fullmsg = "";
                                xn = anagrid.SelectSingleNode("auxgrid/errm[1]");
                                while (xn != null)
                                {
                                    /// err msg is like :-   "a:. Warning: ....
                                    fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim();
                                    ch      = fullmsg.Substring(0, xn.InnerText.ToString().IndexOf(':')).ToCharArray()[0];///extract key char.
                                    mesg    = fullmsg.Substring(fullmsg.IndexOf(':') + 1);
                                    Metadata.Add(ch, mesg);
                                    xn = anagrid.SelectSingleNode("auxgrid/errm[" + erri + "]");
                                    erri++; //error index. next line.
                                }
                                xgrid.Metadata = Metadata;
                                /////// AUXGrid Footer /////

                                bool templatedDialog = false;
                                if (templatedDialog)
                                {
                                    Dictionary <char, string> Footer = new Dictionary <char, string>();

                                    erri = 2;
                                    xn   = anagrid.SelectSingleNode("auxgrid/footermsg[1]");
                                    while (xn != null)
                                    {
                                        /// err msg is like :-   "a:. Warning: ....
                                        fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim();
                                        ch      = fullmsg.Substring(0, xn.InnerText.ToString().IndexOf(':')).ToCharArray()[0];///extract key char.
                                        mesg    = fullmsg.Substring(fullmsg.IndexOf(':') + 1);
                                        Footer.Add(ch, mesg);
                                        xn = anagrid.SelectSingleNode("auxgrid/errm[" + erri + "]");
                                        erri++;     //error index. next line.
                                    }
                                    xgrid.FootNotes = Footer;
                                }
                                else
                                {
                                    //This works for non-templated dialogs
                                    xn = anagrid.SelectSingleNode("auxgrid/footermsg[1]");
                                    if (xn != null)
                                    {
                                        fullmsg             = xn.InnerText.ToString().Replace('"', ' ').Trim();
                                        xgrid.StarFootNotes = fullmsg;
                                    }
                                }



                                ////////////get index of <html> and </html> //////
                                start = mc[k].Index;
                                end   = mc2[k].Index;

                                //// create xmldoc loaind string from <html> to </html> ////
                                xd.LoadXml(oneAnalysis.Substring(start, end - start + 7));

                                html2flex(xd, c1fg);//create rows/cols/headers and populate
                                ///////////// find C1Flexgrid Generate it //////E/////
                                xgrid.Margin = new Thickness(10);
                                lst.Add(xgrid);
                            }
                            #endregion
                            break;
                        } //switch
                    }     //for each leave

                    allanalysis.Add(lst);
                }
                allSessions.Add(allanalysis);
            }//for session
            #endregion

            return(allSessions);
        }
コード例 #4
0
        /// using the xml doc xd [ <html>...</html> ] create row/col headers and datamatrix
        /// for the referenced flexgrid and then populate the grid
        public void html2flex(XmlDocument xd, AUGrid c1FlexGrid1)
        {
            RefreshAPAConfig();
            //AUXGrid xgrid = (AUXGrid)c1FlexGrid1.Tag;
            #region create Row, Col header and data matrix
            string[,] colheadermatrix = null;
            string[,] rowheadermatrix = null;
            string[,] datamatrix      = null;
            {
                /////////generate col header////////
                #region
                XmlNode thead = xd.SelectSingleNode("/html/body/table/thead");
                if (thead == null)
                {
                }
                int colheaderrows = thead.ChildNodes.Count; //no. of rows in colheader
                int colheadercols = 0;                      //no.cols in each row of colheader
                //////No of Cols in Colheader///////////
                XmlNode tr = xd.SelectSingleNode("/html/body/table/thead/tr");
                foreach (XmlNode th in tr.ChildNodes)
                {
                    //if (th.InnerText.Trim().Length > 0) colheadercols++;
                    colheadercols++;
                }
                if (colheadercols > 0 && colheaderrows > 0)
                {
                    ///////Colheader Matrix//////////
                    colheadermatrix = new string[colheaderrows, colheadercols];
                    ////fill Matrix////////
                    int row = 0, col;
                    foreach (XmlNode trr in thead.ChildNodes)// <tr>
                    {
                        col = 0;
                        foreach (XmlNode th in trr.ChildNodes)
                        {
                            if (th.InnerText.Trim().Length > 0)
                            {
                                colheadermatrix[row, col++] = th.InnerText.Trim();
                            }
                        }
                        row++;
                    }
                }
                #endregion
                /////////generate col header and data////////
                #region
                XmlNode tbody = xd.SelectSingleNode("/html/body/table/tbody");
                if (tbody == null)
                {
                }
                int rowheaderrows = tbody.ChildNodes.Count; //no. of rows in rowheader. Also, No of data rows
                int rowheadercols = 0;                      //no.cols in each row of rowheader
                int datacols      = 0;                      //no. of data columns
                //////No of Cols in Rowheader and data////////
                XmlNode tr2 = xd.SelectSingleNode("/html/body/table/tbody/tr");
                if (tr2 != null)
                {
                    foreach (XmlNode td in tr2.ChildNodes)//<td>
                    {
                        XmlAttributeCollection xac = td.Attributes;
                        foreach (XmlAttribute xa in xac)
                        {
                            if (xa.Name.Equals("class") && xa.Value.Equals("h")) //row header cols
                            {
                                rowheadercols++;
                            }
                            else if (xa.Name.Equals("class") && xa.Value.Equals("c"))// data col
                            {
                                datacols++;
                            }
                            else
                            {
                            }
                        }
                    }
                }

                if (rowheadercols > 0 && rowheaderrows > 0)
                {
                    /////// Rowheader/Data Matrix//////////
                    rowheadermatrix = new string[rowheaderrows, rowheadercols];
                    datamatrix      = new string[rowheaderrows, datacols];
                    ////fill Row header Matrix and Data Matrix////////
                    int row2 = 0, rhcol, dtcol;
                    foreach (XmlNode trr in tbody.ChildNodes)// <tr>
                    {
                        rhcol = 0; dtcol = 0;
                        foreach (XmlNode td in trr.ChildNodes)
                        {
                            if (rhcol < rowheadercols) // row header col of a row
                            {
                                rowheadermatrix[row2, rhcol++] = td.InnerText.Trim();
                            }
                            else
                            {
                                datamatrix[row2, dtcol++] = td.InnerText.Trim();
                            }
                        }
                        row2++;
                    }
                }
                #endregion
            }
            #endregion

            #region populating C1flexGrid
            ////// Populate Row/Col Headers and Data //////

            //// creating hreaders ////

            ///////////// merge and sizing /////
            c1FlexGrid1.AllowMerging = AllowMerging.ColumnHeaders | AllowMerging.RowHeaders;
            c1FlexGrid1.AllowSorting = true;

            //trying to fix the size of the grid so that rendering does not take much time calculating these
            c1FlexGrid1.MaxHeight = 800;// NoOfRows* EachRowHeight;
            c1FlexGrid1.MaxWidth  = 1000;

            var rowheaders = c1FlexGrid1.RowHeaders;
            var colheaders = c1FlexGrid1.ColumnHeaders;

            colheaders.Rows[0].AllowMerging        = true;
            colheaders.Rows[0].HorizontalAlignment = HorizontalAlignment.Center;

            rowheaders.Columns[0].AllowMerging      = true;
            rowheaders.Columns[0].VerticalAlignment = VerticalAlignment.Top;


            if (APA)
            {
                c1FlexGrid1.GridLinesVisibility    = GridLinesVisibility.None;
                c1FlexGrid1.HeaderGridLinesBrush   = Brushes.White;
                c1FlexGrid1.ColumnHeaderBackground = Brushes.White;
                c1FlexGrid1.RowHeaderBackground    = Brushes.White;
                c1FlexGrid1.TopLeftCellBackground  = Brushes.White;
                c1FlexGrid1.BorderBrush            = Brushes.WhiteSmoke;
                c1FlexGrid1.Background             = Brushes.White;
                c1FlexGrid1.RowBackground          = Brushes.White;
                c1FlexGrid1.BorderThickness        = new Thickness(0, 3, 0, 0);
                //find border of flexgrid and set it to APA style
                DependencyObject border = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(c1FlexGrid1));
                (border as Border).BorderThickness = new Thickness(0, 1, 0, 1);
            }
            else
            {
                c1FlexGrid1.ColumnHeaderBackground = Brushes.LightBlue;
                c1FlexGrid1.RowHeaderBackground    = Brushes.LightBlue;
                c1FlexGrid1.TopLeftCellBackground  = Brushes.LightBlue;

                c1FlexGrid1.BorderThickness = new Thickness(1);
            }

            /////////////Col Headers//////////
            if (colheadermatrix != null)
            {
                for (int i = colheaders.Rows.Count; i < colheadermatrix.GetLength(0); i++)
                {
                    C1.WPF.FlexGrid.Row row = new C1.WPF.FlexGrid.Row();
                    colheaders.Rows.Add(row);
                    row.AllowMerging        = true;
                    row.HorizontalAlignment = HorizontalAlignment.Center;
                }
                for (int i = colheaders.Columns.Count; i < colheadermatrix.GetLength(1); i++) // creating col headers
                {
                    C1.WPF.FlexGrid.Column col = new C1.WPF.FlexGrid.Column();
                    colheaders.Columns.Add(col);
                    col.AllowMerging = true;

                    //for APA Style table
                    if (APA)
                    {
                    }
                }

                //fill col headers
                for (int i = 0; i < colheadermatrix.GetLength(0); i++)
                {
                    for (int j = 0; j < colheadermatrix.GetLength(1); j++)
                    {
                        if (colheadermatrix[i, j] != null && colheadermatrix[i, j].Trim().Equals(".-."))
                        {
                            colheaders[i, j] = "";//14Jul2014 filling empty header
                        }
                        else
                        {
                            colheaders[i, j] = colheadermatrix[i, j];
                        }
                    }
                }
            }
            /////////////Row Headers///////////
            if (rowheadermatrix != null)
            {
                for (int i = rowheaders.Columns.Count; i < rowheadermatrix.GetLength(1); i++)
                {
                    C1.WPF.FlexGrid.Column col = new C1.WPF.FlexGrid.Column();
                    col.AllowMerging      = true;
                    col.VerticalAlignment = VerticalAlignment.Top;
                    rowheaders.Columns.Add(col);
                }

                for (int i = rowheaders.Rows.Count; i < rowheadermatrix.GetLength(0); i++)
                {
                    C1.WPF.FlexGrid.Row row = new C1.WPF.FlexGrid.Row();
                    rowheaders.Rows.Add(row);
                    row.AllowMerging = true;

                    //for APA Style table
                    if (APA)
                    {
                    }
                }
            }
            //fill row headers
            if (IsEmptyOrNullArray(rowheadermatrix))//rowheader are empty or null
            {
                c1FlexGrid1.HeadersVisibility = HeadersVisibility.Column;
            }
            else
            {
                for (int i = 0; i < rowheadermatrix.GetLength(0); i++)
                {
                    for (int j = 0; j < rowheadermatrix.GetLength(1); j++)
                    {
                        if (rowheadermatrix[i, j] != null && rowheadermatrix[i, j].Trim().Equals(".-."))
                        {
                            rowheaders[i, j] = "";//14Jul2014 filling empty header
                        }
                        else
                        {
                            rowheaders[i, j] = rowheadermatrix[i, j];
                        }
                    }
                }
            }
            //Filling Data
            if (datamatrix != null)
            {
                bool isemptyrow;
                for (int rw = 0; rw < datamatrix.GetLength(0); rw++)
                {
                    isemptyrow = true;//assuming row is empty
                    for (int c = 0; c < datamatrix.GetLength(1); c++)
                    {
                        if (datamatrix[rw, c].Trim().Length > 0)
                        {
                            if (c1FlexGrid1.Columns.Count > c && c1FlexGrid1.Rows.Count > rw)
                            {
                                c1FlexGrid1[rw, c] = datamatrix[rw, c];
                            }
                            isemptyrow = false;// if it has atleast one column filled then row is not empty
                        }
                    }
                    //// hide or remove empty row////
                    if (isemptyrow)
                    {
                        c1FlexGrid1.Rows[rw].Visible = false;
                    }
                }
            }
            #endregion
        }
コード例 #5
0
        private static void ExportFlexgrid(MigraDoc.DocumentObjectModel.Document Doc, string TblTitle, AUXGrid fgrid)
        {
            if ((fgrid) != null)
            {
                AUXGrid xgrid = fgrid;     //31Aug2012

                ////////// Printing Header //////////  <fgheader> means flexgrid header
                string      header  = xgrid.Header.Text;
                AUParagraph FGTitle = new AUParagraph();
                FGTitle.Text       = header;
                FGTitle.FontWeight = FontWeights.SemiBold;
                if (APAStyle)
                {
                    FGTitle.FontStyle = FontStyles.Italic;
                }

                MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FGTitle.Text, FGTitle.FontWeight, FGTitle.FontSize, FGTitle.textcolor, FGTitle.FontStyle);     //FGTitle.ExportPDFParagraph();
                PDFpara.AddLineBreak();
                Doc.LastSection.Add(PDFpara.Clone());

                //////////////// Printing Errors ///////////
                if (xgrid.Metadata != null)    //// <errhd> means error heading
                {
                    // Error/Warning Title
                    AUParagraph ErrWarnTitle = new AUParagraph();
                    ErrWarnTitle.Text       = "Errors/Warnings: ";;
                    ErrWarnTitle.FontWeight = FontWeights.SemiBold;

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnTitle.Text, ErrWarnTitle.FontWeight, ErrWarnTitle.FontSize, ErrWarnTitle.textcolor, ErrWarnTitle.FontStyle);     //ErrWarnTitle.ExportPDFParagraph();
                    PDFparaErrWarnTitle.AddLineBreak();
                    Doc.LastSection.Add(PDFparaErrWarnTitle.Clone());

                    // Error/Warning Messages
                    AUParagraph ErrWarnMsgPara = null;
                    foreach (KeyValuePair <char, string> keyval in xgrid.Metadata)
                    {
                        ErrWarnMsgPara      = new AUParagraph();
                        ErrWarnMsgPara.Text = keyval.Key.ToString() + ":" + keyval.Value;
                        MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnMsgPara.Text, ErrWarnMsgPara.FontWeight, ErrWarnMsgPara.FontSize, ErrWarnMsgPara.textcolor, ErrWarnMsgPara.FontStyle);     //ErrWarnMsgPara.ExportPDFParagraph();
                        PDFparaErrWarnMsg.AddLineBreak();
                        Doc.LastSection.Add(PDFparaErrWarnMsg.Clone());
                    }
                }

                //////// Printing  Grid ////////////

                AUGrid grid = xgrid.Grid;
                float  remainingpagesize = 0.0f;   //remaining page height
                float  currentTblHt      = 0.0f;
                float  PDFpageHeight     = Doc.DefaultPageSetup.PageHeight;
                BSky.ExportToPDF.ExportAUXGrid.APAStyle = APAStyle;
                List <MigraDoc.DocumentObjectModel.Tables.Table> TablePortions = BSky.ExportToPDF.ExportAUXGrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight, grid, strMaxTblCol, strMaxTblRow, strPDFfontsize);     //xgrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight);
                                                                                                                                                                                                                     // MigraDoc.DocumentObjectModel.Section sec = Doc.AddSection();

                foreach (MigraDoc.DocumentObjectModel.Tables.Table ptbl in TablePortions)
                {
                    if (ptbl == null)
                    {
                        continue;
                    }

                    //Add Partial Table ID (so that printouts can be arranged in proper order)
                    if (ptbl.Tag != null)
                    {
                        Doc.LastSection.AddParagraph(ptbl.Tag.ToString());
                    }

                    //add table part to doc
                    Doc.LastSection.Add(ptbl);     //table.Format.KeepWithNext = true;
                    //sec.AddParagraph();
                    Doc.LastSection.AddParagraph().AddLineBreak();
                }

                /////////////////Printing Footer  ///////////////
                string starfootnotes   = string.Empty;
                bool   templatedDialog = false;
                if (templatedDialog)
                {
                    //I think this works for templated dialogs
                    if (xgrid.FootNotes != null)
                    {
                        // Printing Foonotes Title
                        if (xgrid.FootNotes.Count > 0)
                        {
                            AUParagraph FooterTitle = new AUParagraph();
                            FooterTitle.Text       = "Footnotes: "; //Footnote Title
                            FooterTitle.FontWeight = FontWeights.SemiBold;
                            //FooterTitle.textcolor =
                            MigraDoc.DocumentObjectModel.Paragraph PDFparaFooterTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FooterTitle.Text, FooterTitle.FontWeight, FooterTitle.FontSize, FooterTitle.textcolor, FooterTitle.FontStyle);     //FooterTitle.ExportPDFParagraph();
                            PDFparaFooterTitle.AddLineBreak();
                            Doc.LastSection.Add(PDFparaFooterTitle.Clone());
                        }
                        AUParagraph footnote = null;
                        foreach (KeyValuePair <char, string> keyval in xgrid.FootNotes)
                        {
                            footnote      = new AUParagraph();
                            footnote.Text = keyval.Key.ToString() + ":" + keyval.Value;
                            MigraDoc.DocumentObjectModel.Paragraph PDFparaFootnotesMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(footnote.Text, footnote.FontWeight, footnote.FontSize, footnote.textcolor, footnote.FontStyle);     //footnote.ExportPDFParagraph();
                            PDFparaFootnotesMsg.AddLineBreak();
                            Doc.LastSection.Add(PDFparaFootnotesMsg.Clone());
                        }
                    }
                }
                else     //This works for non-templated dialogs
                {
                    AUParagraph starfootnote = new AUParagraph();
                    starfootnote.Text     = xgrid.StarFootNotes;
                    starfootnote.FontSize = 9;                                                                                                                                                                                                                //table cell text(& R syntax) looks size 12. So I want it to be smaller than other text.

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaStarFooterText = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(starfootnote.Text, starfootnote.FontWeight, starfootnote.FontSize, starfootnote.textcolor, starfootnote.FontStyle); //FooterTitle.ExportPDFParagraph();
                    PDFparaStarFooterText.AddLineBreak();
                    Doc.LastSection.Add(PDFparaStarFooterText.Clone());
                }
            }
        }
コード例 #6
0
        private static void ExportOutputPDF(CommandOutput output, MigraDoc.DocumentObjectModel.Document Doc, bool extratags, List <string> filelist, bool issessionout = false)//csv of excel
        {
            if (output.NameOfAnalysis == null)
            {
                output.NameOfAnalysis = string.Empty;
            }

            foreach (DependencyObject obj in output)
            {
                FrameworkElement element = obj as FrameworkElement;
                //31Aug2012 AUXGrid xgrid = element as AUXGrid;
                if ((element as AUParagraph) != null)
                {
                    AUParagraph aup = element as AUParagraph;

                    if (!aup.IsVisible)
                    {
                        continue;
                    }

                    if (aup.Text != null)                                                                                                                                                              ///// <aup> means AUParagraph
                    {
                        MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(aup.Text, aup.FontWeight, aup.FontSize, aup.textcolor, aup.FontStyle); //aup.ExportPDFParagraph();
                        PDFpara.AddLineBreak();
                        Doc.LastSection.Add(PDFpara.Clone());
                    }
                }
                else if ((element as AUXGrid) != null)
                {
                    AUXGrid xgrid = element as AUXGrid; //31Aug2012


                    if (!xgrid.IsVisible)
                    {
                        continue;
                    }
                    ////////// Printing Header //////////  <fgheader> means flexgrid header
                    string      header  = xgrid.Header.Text;
                    AUParagraph FGTitle = new AUParagraph();
                    FGTitle.Text       = header;
                    FGTitle.FontWeight = FontWeights.SemiBold;
                    if (APAStyle)
                    {
                        FGTitle.FontStyle = FontStyles.Italic;
                    }
                    //FGTitle.textcolor =
                    MigraDoc.DocumentObjectModel.Paragraph PDFpara = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FGTitle.Text, FGTitle.FontWeight, FGTitle.FontSize, FGTitle.textcolor, FGTitle.FontStyle); //FGTitle.ExportPDFParagraph();
                    PDFpara.AddLineBreak();
                    Doc.LastSection.Add(PDFpara.Clone());

                    //////////////// Printing Errors ///////////
                    if (xgrid.Metadata != null)//// <errhd> means error heading
                    {
                        // Error/Warning Title
                        AUParagraph ErrWarnTitle = new AUParagraph();
                        ErrWarnTitle.Text       = "Errors/Warnings: ";;
                        ErrWarnTitle.FontWeight = FontWeights.SemiBold;
                        //ErrWarnTitle.FontStyle = FontStyles.Normal;
                        //ErrWarnTitle.textcolor =
                        MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnTitle.Text, ErrWarnTitle.FontWeight, ErrWarnTitle.FontSize, ErrWarnTitle.textcolor, ErrWarnTitle.FontStyle); //ErrWarnTitle.ExportPDFParagraph();
                        PDFparaErrWarnTitle.AddLineBreak();
                        Doc.LastSection.Add(PDFparaErrWarnTitle.Clone());

                        // Error/Warning Messages
                        AUParagraph ErrWarnMsgPara = null;
                        foreach (KeyValuePair <char, string> keyval in xgrid.Metadata)
                        {
                            ErrWarnMsgPara      = new AUParagraph();
                            ErrWarnMsgPara.Text = keyval.Key.ToString() + ":" + keyval.Value;

                            MigraDoc.DocumentObjectModel.Paragraph PDFparaErrWarnMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(ErrWarnMsgPara.Text, ErrWarnMsgPara.FontWeight, ErrWarnMsgPara.FontSize, ErrWarnMsgPara.textcolor, ErrWarnMsgPara.FontStyle); //ErrWarnMsgPara.ExportPDFParagraph();
                            PDFparaErrWarnMsg.AddLineBreak();
                            Doc.LastSection.Add(PDFparaErrWarnMsg.Clone());
                        }
                    }

                    //////// Printing  Grid ////////////
                    AUGrid grid = xgrid.Grid;
                    float  remainingpagesize = 0.0f;//remaining page height
                    float  currentTblHt      = 0.0f;
                    float  PDFpageHeight     = Doc.DefaultPageSetup.PageHeight;

                    BSky.ExportToPDF.ExportAUXGrid.APAStyle = APAStyle;
                    List <MigraDoc.DocumentObjectModel.Tables.Table> TablePortions = BSky.ExportToPDF.ExportAUXGrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight, grid, strMaxTblCol, strMaxTblRow, strPDFfontsize);  //xgrid.ExportMultiHeaderFlexgridToPDF(PDFpageHeight);

                    foreach (MigraDoc.DocumentObjectModel.Tables.Table ptbl in TablePortions)
                    {
                        if (ptbl == null)
                        {
                            continue;
                        }

                        //Add Partial Table ID (so that printouts can be arranged in proper order)
                        if (ptbl.Tag != null)
                        {
                            Doc.LastSection.AddParagraph(ptbl.Tag.ToString());
                        }

                        //add table part to doc
                        Doc.LastSection.Add(ptbl);

                        Doc.LastSection.AddParagraph().AddLineBreak();
                    }

                    /////////////////Printing Footer  ///////////////
                    string starfootnotes   = string.Empty;
                    bool   templatedDialog = false;
                    if (templatedDialog)
                    {
                        //I think this works for templated dialogs
                        if (xgrid.FootNotes != null)
                        {
                            // Printing Foonotes Title
                            if (xgrid.FootNotes.Count > 0)
                            {
                                AUParagraph FooterTitle = new AUParagraph();
                                FooterTitle.Text       = "Footnotes: ";                                                                                                                                                                                           //Footnote Title
                                FooterTitle.FontWeight = FontWeights.SemiBold;
                                MigraDoc.DocumentObjectModel.Paragraph PDFparaFooterTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(FooterTitle.Text, FooterTitle.FontWeight, FooterTitle.FontSize, FooterTitle.textcolor, FooterTitle.FontStyle); //FooterTitle.ExportPDFParagraph();
                                PDFparaFooterTitle.AddLineBreak();
                                Doc.LastSection.Add(PDFparaFooterTitle.Clone());
                            }
                            AUParagraph footnote = null;
                            foreach (KeyValuePair <char, string> keyval in xgrid.FootNotes)
                            {
                                footnote      = new AUParagraph();
                                footnote.Text = keyval.Key.ToString() + ":" + keyval.Value;

                                MigraDoc.DocumentObjectModel.Paragraph PDFparaFootnotesMsg = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(footnote.Text, footnote.FontWeight, footnote.FontSize, footnote.textcolor, footnote.FontStyle); //footnote.ExportPDFParagraph();
                                PDFparaFootnotesMsg.AddLineBreak();
                                Doc.LastSection.Add(PDFparaFootnotesMsg.Clone());
                            }
                        }
                    }
                    else //This works for non-templated dialogs
                    {
                        AUParagraph starfootnote = new AUParagraph();
                        starfootnote.Text     = xgrid.StarFootNotes;
                        starfootnote.FontSize = 9;                                                                                                                                                                                                                //table cell text(& R syntax) looks size 12. So I want it to be smaller than other text.

                        MigraDoc.DocumentObjectModel.Paragraph PDFparaStarFooterText = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(starfootnote.Text, starfootnote.FontWeight, starfootnote.FontSize, starfootnote.textcolor, starfootnote.FontStyle); //FooterTitle.ExportPDFParagraph();
                        PDFparaStarFooterText.AddLineBreak();
                        Doc.LastSection.Add(PDFparaStarFooterText.Clone());
                    }
                }
                else if ((element as BSkyGraphicControl) != null)//Graphics 31Aug2012
                {
                    BSkyGraphicControl bsgc = element as BSkyGraphicControl;

                    //To only Export Graphics those are visible (checked in the left navigation tree, in output window)
                    if (!bsgc.IsVisible)
                    {
                        continue;
                    }
                    //Create image filename
                    string imgfilename = "PDF" + bsgc.ImageName + ".png";

                    string synedtimg = Path.Combine(tempDir, imgfilename);

                    //Saving Image separately
                    BSkyGraphicControlToImageFile(bsgc, synedtimg);                                                          //not imgfilename

                    MigraDoc.DocumentObjectModel.Paragraph imgPara = BSky.ExportToPDF.ExportGraphics.ExportToPDF(synedtimg); //bsgc.ExportToPDF(synedtimg);// not imgfilename

                    //finally add image to the PDF doc.
                    Doc.LastSection.Add(imgPara);
                }
                else if ((element as BSkyNotes) != null) // Notes Control 05Nov2012.
                {
                    BSkyNotes bsn = element as BSkyNotes;
                    //To only Export Notes those are visible (checked in the left navigation tree, in output window)
                    if (!bsn.IsVisible)
                    {
                        continue;
                    }

                    //Put a title
                    AUParagraph NotesTitle = new AUParagraph();
                    NotesTitle.Text       = "Notes"; //Footnote Title
                    NotesTitle.FontWeight = FontWeights.SemiBold;

                    MigraDoc.DocumentObjectModel.Paragraph PDFparaNotesTitle = BSky.ExportToPDF.ExportAUParagraph.ExportFormattedText(NotesTitle.Text, NotesTitle.FontWeight, NotesTitle.FontSize, NotesTitle.textcolor, NotesTitle.FontStyle); //NotesTitle.ExportPDFParagraph();
                    PDFparaNotesTitle.AddLineBreak();
                    Doc.LastSection.Add(PDFparaNotesTitle.Clone());

                    //Now Notes data in PdfPTable
                    MigraDoc.DocumentObjectModel.Tables.Table notestable = BSky.ExportToPDF.ExportNotes.ExportToPDF(bsn.NotesData, strPDFfontsize);// bsn.ExportToPDF();
                    Doc.LastSection.Add(notestable);
                    Doc.LastSection.AddParagraph().AddLineBreak();
                }
            }

            ////for export to excel////E
        }