Exemple #1
0
        public BSkyNotes createBSkyNotes(XmlNode xd, string selectNode, string controType)//06Nov2012
        {
            BSkyNotes bsn = new BSkyNotes();
            //09Jul2013 bsn.ControlType = controType;
            /// read xml info and populate bsn ///
            XmlNode xn = null;                       /// showrow  spliposi   notesheading notesrow  notescol

            xn = xd.SelectSingleNode("controltype"); //(selectNode + "/controltype");//09Jul2013
            if (xn == null)
            {
                return(null);
            }
            bsn.ControlType = (xn != null) ? xn.InnerText.Trim() : "-";

            xn = xd.SelectSingleNode("collapsetext");
            bsn.CollapsedText = (xn != null) ? xn.InnerText.Trim() : "";

            xn = xd.SelectSingleNode("showrow");
            bsn.ShowRow_Index = int.Parse((xn != null) ? xn.InnerText.Trim() : "1");

            xn = xd.SelectSingleNode("splitposi");
            bsn.NotesSplitPosition = uint.Parse((xn != null) ? xn.InnerText.Trim() : "1"); bsn.RightPart = 6; bsn.LeftPart = 1;

            xn = xd.SelectSingleNode("notesheading");
            bsn.HearderText = (xn != null) ? xn.InnerText.Trim() : "";

            XmlNodeList xnlrow = xd.SelectNodes("notesrow");
            XmlNodeList xnlcol = xd.SelectNodes("notesrow[1]/notescol");

            if (xnlrow == null || xnlcol == null || xnlcol.Count < 1 || xnlrow.Count < 1)
            {
                return(null);
            }
            int rowcount = xnlrow.Count;
            int colcount = xnlcol.Count;

            string[,] notesdata = new string[rowcount, colcount];
            for (int i = 0; i < rowcount; i++)
            {
                for (int j = 0; j < colcount; j++)
                {
                    xn = xd.SelectSingleNode("notesrow[" + (i + 1) + "]/notescol[" + (j + 1) + "]");
                    notesdata[i, j] = (xn != null) ? xn.InnerText.Trim() : "";
                }
            }
            bsn.NotesData = notesdata;

            bsn.FillData();
            return(bsn);
        }
Exemple #2
0
        private void mypanel_ContextMenuClosing(object sender, ContextMenuEventArgs e)
        {
            bool             deleteControl = false;
            FrameworkElement fe            = e.Source as FrameworkElement;

            #region find control type
            AUParagraph aup = fe as AUParagraph;
            if (aup != null)
            {
                deleteControl = aup.DeleteControl;
            }

            BSkyNotes bsn = fe as BSkyNotes;
            if (bsn != null)
            {
                deleteControl = bsn.DeleteControl;
            }
            BSkyGraphicControl bsgc = fe as BSkyGraphicControl;
            if (bsgc != null)
            {
                deleteControl = bsgc.DeleteControl;
            }

            AUXGrid auxg = fe as AUXGrid;
            if (auxg != null)
            {
                deleteControl = auxg.DeleteControl;
            }

            #endregion

            if (deleteControl)
            {
                MessageBox.Show("Delete is not allowed in the Output Viewer");
            }
        }
        //25Feb2015 exact copy of PopulateTree from OutputWindow.xaml. Not Sure if in future they will differ
        private void PopulateTree(CommandOutput output, bool synedtsession = false)
        {
            string treenocharscount = confService.GetConfigValueForKey("nooftreechars");//16Dec2013
            int    openbracketindex, max;
            string analysisName = string.Empty;

            if (output.NameOfAnalysis != null && output.NameOfAnalysis.Trim().Length > 0) // For shortening left tree parent node name.
            {
                openbracketindex = output.NameOfAnalysis.Contains("(") ? output.NameOfAnalysis.IndexOf('(') : output.NameOfAnalysis.Length;

                analysisName = output.NameOfAnalysis.Substring(0, openbracketindex); //18Nov2013 (0, max);
                if (output.NameOfAnalysis.Contains("BSkyFormat("))                   //it is output
                {
                    analysisName = "BSkyFormat-Output";
                }
            }
            else
            {
                analysisName = "Output";
            }


            //// Main logic to populate tree ////
            TreeViewItem MainItem = new TreeViewItem();

            MainItem.Header     = analysisName;
            MainItem.IsExpanded = true;
            List <string> Headers = new List <string>();

            if (MainItem.Header.ToString().Contains("Execution Started"))
            {
                MainItem.Background = Brushes.LawnGreen;
            }
            if (MainItem.Header.ToString().Contains("Execution Ended"))
            {
                MainItem.Background = Brushes.SkyBlue;
            }
            //bool setFocus = true;

            foreach (DependencyObject obj in output)
            {
                IAUControl control = obj as IAUControl;
                if (control == null)
                {
                    continue;                 //for non IAUControl
                }
                Headers.Add(control.ControlType);
                TreeViewItem tvi = new TreeViewItem();

                ////Setting common Excel sheet/////
                AUParagraph _aup = obj as AUParagraph;
                if (_aup != null)
                {
                    _aup.MSExcelObj = _MSExcelObj;
                }
                BSkyNotes _note = obj as BSkyNotes;
                if (_note != null)
                {
                    _note.MSExcelObj = _MSExcelObj;
                }
                AUXGrid _aux = obj as AUXGrid;
                if (_aux != null)
                {
                    _aux.MSExcelObj = _MSExcelObj;
                }


                ////23Oct2013. for show hide leaf nodes based on checkbox //
                StackPanel treenodesp = new StackPanel();
                treenodesp.Orientation = Orientation.Horizontal;

                int  treenodecharlen;
                bool result = Int32.TryParse(treenocharscount, out treenodecharlen);
                if (!result)
                {
                    treenodecharlen = 15;
                }

                TextBlock nodetb = new TextBlock();
                nodetb.Tag = control;
                int    maxlen = control.ControlType.Length < treenodecharlen ? control.ControlType.Length : (treenodecharlen);
                string dots   = maxlen <= treenodecharlen ? "..." : "...";
                nodetb.Text       = control.ControlType.Substring(0, maxlen) + dots;
                nodetb.Margin     = new Thickness(1);
                nodetb.GotFocus  += new RoutedEventHandler(nodetb_GotFocus);
                nodetb.LostFocus += new RoutedEventHandler(nodetb_LostFocus);
                nodetb.ToolTip    = "Click to bring the item in the view";

                CheckBox cbleaf = new CheckBox();
                cbleaf.Content = "";// control.ControlType;
                cbleaf.Tag     = control;

                cbleaf.Checked   += new RoutedEventHandler(cbleaf_Checked);
                cbleaf.Unchecked += new RoutedEventHandler(cbleaf_Checked);

                cbleaf.Visibility = System.Windows.Visibility.Visible;///unhide to see it on output window.
                cbleaf.ToolTip    = "Select/Unselect this node to show/hide in right pane";
                if (!(control is BSkyNotes))
                {
                    cbleaf.IsChecked = true;
                }

                treenodesp.Children.Add(cbleaf);
                treenodesp.Children.Add(nodetb);

                tvi.Header = treenodesp;// cbleaf;//.Substring(0,openbracketindex);/// Leaf Node Text
                tvi.Tag    = control;

                tvi.Selected   += new RoutedEventHandler(tvi_Selected);
                tvi.Unselected += new RoutedEventHandler(tvi_Unselected);//29Jan2013
                MainItem.Items.Add(tvi);
            }
            if (synedtsession)
            {
                SessionItem.Items.Add(MainItem);
            }
            else
            {
                NavTree.Items.Add(MainItem);
            }
        }
Exemple #4
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);
        }
Exemple #5
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
        }
        //05Sept2019 exact copy from OutputWindow.xaml. Not Sure if in future they will differ
        private void PopulateTree(CommandOutput output, bool synedtsession = false)
        {
            string treenocharscount = confService.GetConfigValueForKey("nooftreechars");//16Dec2013
            int    openbracketindex, max;
            string analysisName = string.Empty;


            if (output.NameOfAnalysis != null && output.NameOfAnalysis.Trim().Length > 0) // For shortening left tree parent node name.
            {
                openbracketindex = output.NameOfAnalysis.Contains("(") ? output.NameOfAnalysis.IndexOf('(') : output.NameOfAnalysis.Length;
                //if (output.NameOfAnalysis.Trim().Length > 15)
                //    max = 15;
                //else
                //    max = output.NameOfAnalysis.Trim().Length;
                analysisName = output.NameOfAnalysis.Substring(0, openbracketindex); //18Nov2013 (0, max);
                if (output.NameOfAnalysis.Contains("BSkyFormat("))                   //it is output
                {
                    analysisName = "BSkyFormat-Output";
                }
            }
            else
            {
                analysisName = "Output";
            }

            List <string> Headers  = new List <string>();
            TreeViewItem  MainItem = new TreeViewItem();

            if (!synedtsession)         ///\if (MainItem.Header.ToString().Contains("Execution Started"))
            {
                ///\MainItem.Background = Brushes.LawnGreen;
                MainItem.Header     = analysisName;
                MainItem.IsExpanded = true;

                if (MainItem.Header.ToString().Contains("Execution Started"))
                {
                    MainItem.Background = Brushes.LawnGreen;
                }
                if (MainItem.Header.ToString().Contains("Execution Ended"))
                {
                    MainItem.Background = Brushes.SkyBlue;
                }
                //bool setFocus = true;
            }
            ///\if (MainItem.Header.ToString().Contains("Execution Ended"))
            ///\MainItem.Background = Brushes.SkyBlue;
            //bool setFocus = true;

            foreach (DependencyObject obj in output)
            {
                IAUControl control = obj as IAUControl;
                if (control == null)
                {
                    continue;                 //for non IAUControl
                }
                Headers.Add(control.ControlType);
                TreeViewItem tvi = new TreeViewItem();

                ////Setting common Excel sheet/////
                AUParagraph _aup = obj as AUParagraph;
                if (_aup != null)
                {
                    _aup.MSExcelObj = _MSExcelObj;
                }
                BSkyNotes _note = obj as BSkyNotes;
                if (_note != null)
                {
                    _note.MSExcelObj = _MSExcelObj;
                }
                AUXGrid _aux = obj as AUXGrid;
                if (_aux != null)
                {
                    _aux.MSExcelObj = _MSExcelObj;
                }

                ///Toolbar delete icon saves reference of the analysis output controls ///
                BSkyOutputOptionsToolbar toolbar = obj as BSkyOutputOptionsToolbar;
                if (toolbar != null)
                {
                    toolbar.AnalysisOutput = output;
                }
                ////23Oct2013. for show hide leaf nodes based on checkbox //
                StackPanel treenodesp = new StackPanel();
                treenodesp.Orientation = Orientation.Horizontal;

                int  treenodecharlen;//for config char count
                bool result = Int32.TryParse(treenocharscount, out treenodecharlen);
                if (!result)
                {
                    treenodecharlen = 20;
                }

                TextBlock nodetb = new TextBlock();
                nodetb.Tag = control;

                string nodetext = control.ControlType;; // string.Empty;
                if (_aup != null && _aup.ControlType.Equals("Command"))
                {
                    nodetext = _aup.Text;
                }
                else
                {
                    nodetext = control.ControlType;
                }

                //maxlen is need to avoid indexoutofbounds when finding Substring()
                int maxlen = nodetext.Length < treenodecharlen ? nodetext.Length : (treenodecharlen);
                //if (maxlen > 20) maxlen = 20; //this could be used for putting restriction for max. length

                string dots = maxlen < nodetext.Length ? " ..." : "";//add dots only if text are getting trimmed.

                //Show node text with or without dots based on condition.
                if (maxlen >= nodetext.Length) //show full length
                {
                    nodetb.Text = nodetext.Replace("\n", " ").Replace("\r", " ");
                }
                else
                {
                    nodetb.Text = nodetext.Substring(0, maxlen).Replace("\n", " ").Replace("\r", " ") + dots;
                }

                nodetb.Margin     = new Thickness(1, 0, 0, 2);
                nodetb.GotFocus  += new RoutedEventHandler(nodetb_GotFocus);
                nodetb.LostFocus += new RoutedEventHandler(nodetb_LostFocus);
                nodetb.ToolTip    = BSky.GlobalResources.Properties.UICtrlResources.NavTreeNodeTBTooltip;

                CheckBox cbleaf = new CheckBox();
                cbleaf.Content = "";// control.ControlType;
                cbleaf.Tag     = control;
                //cbleaf.Click += new RoutedEventHandler(cbleaf_Checked);
                cbleaf.Checked   += new RoutedEventHandler(cbleaf_Checked);
                cbleaf.Unchecked += new RoutedEventHandler(cbleaf_Checked);
                //cbleaf.LostFocus +=new RoutedEventHandler(cbleaf_LostFocus);
                //cbleaf.GotFocus +=new RoutedEventHandler(cbleaf_GotFocus);
                cbleaf.Visibility = System.Windows.Visibility.Visible;///unhide to see it on output window.
                cbleaf.ToolTip    = BSky.GlobalResources.Properties.UICtrlResources.NavTreeCheckboxTooltip;

                ///if (!(control is BSkyNotes) && !((control is AUParagraph) && (control.ControlType.Equals("Header"))))
                if (isRunFromSyntaxEditor)
                {
                    //show/hide BSkyNote in the output if templated dialog syntax is run from the command editor
                    if (_note != null)
                    {
                        control.BSkyControlVisibility = Visibility.Collapsed;
                    }
                    else
                    {
                        control.BSkyControlVisibility = Visibility.Visible;
                    }
                }
                cbleaf.IsChecked = (control.BSkyControlVisibility == Visibility.Visible) ? true : false;

                #region putting icon in the tree
                Image img = GetImage(control);
                img.Margin = new Thickness(0, 0, 2, 2);
                #endregion

                treenodesp.Children.Add(cbleaf);
                treenodesp.Children.Add(img);
                treenodesp.Children.Add(nodetb);

                tvi.Header = treenodesp;// cbleaf;//.Substring(0,openbracketindex);/// Leaf Node Text
                tvi.Tag    = control;
                (control as FrameworkElement).Tag = tvi;

                ////following lines does not show any effect ///
                //FrameworkElement fe = obj as FrameworkElement;
                //fe.GotFocus += new RoutedEventHandler(delegate(object sender, RoutedEventArgs e) { tvi.IsSelected = true; /*Bold or background */ });

                tvi.Selected   += new RoutedEventHandler(tvi_Selected);
                tvi.Unselected += new RoutedEventHandler(tvi_Unselected);//29Jan2013

                ///\MainItem.Items.Add(tvi);
                if (synedtsession)                                                                   //analysis run
                {
                    if (control.ControlType.Equals("Title") || control.ControlType.Equals("Header")) // 'Header' for backward compatibilty
                    {
                        SessionItem.Tag = control;                                                   //SessionItem.Header= R-Session and SessionItem.Count==0
                        AddEventsAndContextMenu(SessionItem);
                    }
                    SessionItem.Items.Add(tvi);
                }
                else //dataset opened
                {
                    if (control.ControlType.Equals("Title") || control.ControlType.Equals("Header"))// 'Header' for backward compatibilty
                    {
                        MainItem.Tag = control;
                        AddEventsAndContextMenu(MainItem);
                    }
                    MainItem.Items.Add(tvi);
                }

                //if (setFocus) { fe.Focus();tvi.IsSelected = true; setFocus = false; }//setting focus to start time for each RUN
            }

            /*
             * if (synedtsession)
             *  SessionItem.Items.Add(MainItem);
             * else
             *  NavTree.Items.Add(MainItem);
             */
            if (!synedtsession)
            {
                NavTree.Items.Add(MainItem);
            }

            //follwing 'if' block could be commented because BringLastLeaf is doing its job. Test, if not scrolling to latest output then uncomment.
            //if (MainItem.Items.Count > 0)//if analysis has something //17Jan2013
            //{
            //    ((MainItem.Items.GetItemAt(0) as TreeViewItem).Tag as FrameworkElement).BringIntoView(); //bring to focus, the latest output.
            //}

            //if (NavTree!=null && NavTree.Items.Count > 0)//11Dec2014 scroll to bottom if there are items present
            //{
            //    int itcount = NavTree.Items.Count;
            //    (NavTree.Items.GetItemAt(itcount - 1) as TreeViewItem).BringIntoView();
            //}
        }