private void PrintDialogTitle(string title) { CommandOutput batch = new CommandOutput(); batch.NameOfAnalysis = "Open R package dataset"; batch.IsFromSyntaxEditor = false; batch.Insert(0, new BSkyOutputOptionsToolbar()); string rcommcol = confService.GetConfigValueForKey("dctitlecol");//23nov2012 //before was syntitlecol byte red = byte.Parse(rcommcol.Substring(3, 2), NumberStyles.HexNumber); byte green = byte.Parse(rcommcol.Substring(5, 2), NumberStyles.HexNumber); byte blue = byte.Parse(rcommcol.Substring(7, 2), NumberStyles.HexNumber); Color c = Color.FromArgb(255, red, green, blue); AUParagraph aup = new AUParagraph(); aup.Text = title; // dialogTitle; aup.FontSize = BSkyStyler.BSkyConstants.HEADER_FONTSIZE; //16;// before it was 16 aup.FontWeight = FontWeights.DemiBold; aup.textcolor = new SolidColorBrush(c); //Colors.Blue);//SlateBlue //DogerBlue aup.ControlType = "Title"; batch.Add(aup); SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); sewindow.AddToSession(batch); }
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"); } }
//18Dec2013 Sending command to output to make them appear different than command-output private void SendCommandToOutput(string command, string NameOfAnalysis) { string rcommcol = confService.GetConfigValueForKey("rcommcol");//23nov2012 byte red = byte.Parse(rcommcol.Substring(3, 2), NumberStyles.HexNumber); byte green = byte.Parse(rcommcol.Substring(5, 2), NumberStyles.HexNumber); byte blue = byte.Parse(rcommcol.Substring(7, 2), NumberStyles.HexNumber); Color c = Color.FromArgb(255, red, green, blue); CommandOutput lst = new CommandOutput(); lst.NameOfAnalysis = NameOfAnalysis; // left tree Parent AUParagraph Title = new AUParagraph(); Title.Text = command; //right side contents Title.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//10Nov2014 //12; //right side content size Title.textcolor = new SolidColorBrush(c);//new SolidColorBrush(Colors.DeepSkyBlue); Title.ControlType = "Command"; // left tree child lst.Add(Title); AddToSession(lst); }
//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); } }
//For commands : Dialog may or may not be shown but surely XML template is not present. public void ExeuteSingleCommandWithtoutXML(string command = "") { if (command != null && command.Length > 0) { cmd = new CommandRequest(); cmd.CommandSyntax = command; } if (cmd.CommandSyntax == null || cmd.CommandSyntax.Length < 1) { cmd = new CommandRequest(); cmd.CommandSyntax = "print('No command to execute')"; } if (cmd.CommandSyntax.Contains("BSkyReloadDataset("))// if its relaod dataset commmand then prepare some parameter before executing the command { DataSource tempds = UIController.GetActiveDocument(); string filename = tempds.FileName.Replace("\\", "/"); string filetype = tempds.FileType; string temp = new string(cmd.CommandSyntax.ToCharArray()); cmd.CommandSyntax = temp.Replace("fullpathfilename", "fullpathfilename='" + filename + "'").Replace("filetype", "filetype='" + filetype + "'"); ; //Restting split if all data and attributes are loaded int idx = temp.IndexOf("=", temp.IndexOf("loaddataonly")); // index of '=' after 'loaddataonly' int idxcomma = temp.IndexOf(",", temp.IndexOf("loaddataonly")); // index of ',' after 'loaddataonly' string boolvalue = temp.Substring(idx + 1, idxcomma - idx - 1).Trim(); if (boolvalue.Equals("FALSE"))//loaddataonly = false then we need to reset SPLIT in C# also { OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name)); } } //retval = analytics.Execute(cmd); if (bdt != null) if (!bdt.IsBatchCommand && bdt.IsCommandOnly && !bdt.IsXMLDefined && !cmd.CommandSyntax.Contains("BSkySetDataFrameSplit(")) { SendToOutputWindow(dialogTitle, cmd.CommandSyntax); ExecuteInSyntaxEditor(true, dialogTitle);//GenerateOutputTablesForNonXAML(null);// ExecuteXMLDefinedDialog(); } if (cmd.CommandSyntax.Contains("BSkySortDataframe(") || cmd.CommandSyntax.Contains("BSkyComputeExpression(") || cmd.CommandSyntax.Contains("BSkyRecode(")) { retval = analytics.Execute(cmd); OutputHelper.AnalyticsData.Result = retval;//putting latest DOM string[,] ew = OutputHelper.GetBSkyErrorsWarning(1, "normal");//08Nov2014 if (cmd.CommandSyntax.Contains("BSkySortDataframe")) //11Apr2014 putting sort icon { //single column logic //int startidx = cmd.CommandSyntax.IndexOf("'"); //int endidx= cmd.CommandSyntax.IndexOf("'", startidx+1); //int leng = endidx - startidx-1; //string colname = cmd.CommandSyntax.Substring(startidx+1, leng); //sort order 14Apr2014 string srtodr = string.Empty; // descending=TRUE in command. There is just 1 boolean in sort so this 'if' will work if (cmd.CommandSyntax.Contains("TRUE")) srtodr = "desc"; else srtodr = "asc"; //mulitiple col logic List<string> collst = new List<string>(); int startidx = cmd.CommandSyntax.IndexOf("c("); if (startidx == -1) //no items in target listbox. No need of this if sort dialog has OK disabled when no items in target { return; } int endidx = cmd.CommandSyntax.IndexOf(")", startidx + 1); int leng = endidx - startidx - 1; string selcols = cmd.CommandSyntax.Substring(startidx + 2, leng - 1).Replace("'", "");// +2 is the length of "c(", -1 for ) string[] cols = selcols.Split(','); for (int j = 0; j < cols.Length; j++) //string s in cols) { collst.Add(cols[j]); } RefreshGrids(collst, srtodr); } else { //testing something. If success, we dont need this. RefreshGrids(); } //16Apr2014 //must be excuted at the end after data is reloaded otherwise split is not refresh in statusbar. if (cmd.CommandSyntax.Contains("BSkyReloadDataset(")) { Refresh_Statusbar(); } ////Finally show messages in output //SendToOutputWindow(dialogTitle, cmd.CommandSyntax); //Show errors if any 08Nov2014 if (ew != null && ew[0, 0] != null) { //SendToOutputWindow("", ew[0, 2]); CommandOutput ewmsg = new CommandOutput(); ewmsg.NameOfAnalysis = "Errors/Warnings"; ewmsg.IsFromSyntaxEditor = false; AUParagraph ewtypeaup = new AUParagraph(); ewtypeaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE; ewtypeaup.Text = (ew[0, 0] != null)?ew[0, 0]:"no type info"; ewtypeaup.ControlType = "Type:"; ewmsg.Add(ewtypeaup); AUParagraph usrmsgaup = new AUParagraph(); usrmsgaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE; usrmsgaup.Text = (ew[0, 1] != null) ? ew[0, 1] : "no user message info"; usrmsgaup.ControlType = "User Message:"; ewmsg.Add(usrmsgaup); AUParagraph rmsgaup = new AUParagraph(); rmsgaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE; rmsgaup.Text = (ew[0, 2] != null) ? ew[0, 2] : "no R message info"; rmsgaup.ControlType = "R Message:"; ewmsg.Add(rmsgaup); AddToSyntaxSession(ewmsg); } } }
public AUParagraph createAUPara(XmlNode xd, string selectNode, string controType) { XmlNode xn = null; AUParagraph AUP = new AUParagraph(); xn = selectNode.Length > 0 ? xd.SelectSingleNode(selectNode) : xd; if (xn == null) { return(null); //09Jul2013 } AUP.Text = (xn != null) ? xn.InnerText.Trim(' ') : ""; AUP.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE; //10Nov2014//12;//04Nov2014 //Controltype if ((controType == null || controType.Trim().Length < 1)) //03Aug2012 { if (xn.Attributes["controltype"] != null && xn.Attributes["controltype"].Value.Length > 0) //29Oct2013 { controType = xn.Attributes["controltype"].Value; } else if (AUP.Text.Trim().Length > 0 && controType.Length < 1) { int len = AUP.Text.IndexOf('\n', 1);//if \n not found if (len < 1) { len = AUP.Text.Length; } controType = AUP.Text.Substring(0, len).Replace("\n", string.Empty); } else { controType = "-"; } } //textcolor if (xn.Attributes["textcolor"] != null && xn.Attributes["textcolor"].Value.Length > 0) //29Oct2013 { string hexstr = xn.Attributes["textcolor"].Value; //"#AARRGGBB" if (hexstr == null || hexstr.Length < 1) { hexstr = "#FF000000"; // black color } var color = (Color)ColorConverter.ConvertFromString(hexstr); AUP.textcolor = new SolidColorBrush(color); } //fontsize if (xn.Attributes["fontsize"] != null && xn.Attributes["fontsize"].Value.Length > 0)//29Oct2013 { double fsize; if (double.TryParse(xn.Attributes["fontsize"].Value, out fsize)) { AUP.FontSize = fsize; } else { AUP.FontSize = 14;//set default in case something goes wrong } } //fontweight if (xn.Attributes["fontweight"] != null && xn.Attributes["fontweight"].Value.Length > 0) //29Oct2013 { string fWt = xn.Attributes["fontweight"].Value; // remove curly braces eg.. "{Bold}" FontWeight fw = (FontWeight) new FontWeightConverter().ConvertFromString(fWt); AUP.FontWeight = fw; } //fontsize added above so this is no needed //if (controType.Equals("Header")) AUP.FontSize = 16; AUP.ControlType = controType; //// Leaf node name in treeview return(AUP); }
public void ExecuteSplit(string command = null, FrameworkElement fe = null) { CommandRequest cr = new CommandRequest(); cr.CommandSyntax = command; string stmt = command; //cmd.CommandSyntax; if (stmt.Contains("BSkySetDataFrameSplit("))///executes when SPLIT is fired from menu { bool setsplit = false; int startind = 0; int endind = 0; if (stmt.Contains("col.names")) { startind = stmt.IndexOf("c(", stmt.IndexOf("col.names"));// index of c( } else { startind = stmt.IndexOf("c(");// index of c( } if (startind > 0) endind = stmt.IndexOf(")", startind); if (startind > 0 && endind > startind) { int len = endind - startind + 1; // finding the length of c(......) string str = stmt.Substring(startind, len); // this will contain c('tg0','tg1') or just c() string ch = null; if (str.Contains("'")) ch = "'"; if (str.Contains('"')) ch = "\""; if (ch != null && ch.Length > 0) { int i = str.IndexOf(ch); int j = -1; if (i >= 0) j = str.IndexOf(ch, i + 1); if (j < 0) j = i + 1; string sub = str.Substring(i + 1, (j - i - 1)).Trim(); if (i < 0) i = str.IndexOf("'"); if (i >= 0) { if (sub.Length > 0) setsplit = true; } } } //Executing the command in R/// analytics.ExecuteR(cr,false,false); ////Creating a command output////11Jul2014 CommandOutput splitCo = new CommandOutput(); splitCo.NameOfAnalysis = "Split:#" + setsplit; splitCo.IsFromSyntaxEditor = false; AUParagraph aup = new AUParagraph(); aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.HEADER_FONTSIZE; aup.Text = stmt; aup.ControlType = "Header";// treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen); splitCo.Add(aup); ////////// Setting/Unsetting Macro for SPLIT ////////// if (setsplit) { OutputHelper.AddGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name), fe); //window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window. AddToSyntaxSession(splitCo);//11Jul2014 SendToOutputWindow(dialogTitle, stmt); Refresh_Statusbar();// RefreshGrids(); return;// no need to do any thing further } else // unset split { OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name)); //if (window != null && window.Template != null) // window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window. AddToSyntaxSession(splitCo);//11Jul2014 SendToOutputWindow(dialogTitle, stmt); Refresh_Statusbar();// RefreshGrids(); return;// no need to do any thing further } } }
protected void ExecuteBatch(string[] commands) { commands = RemoveSplitCommandFromBatch(commands); bool IsSplitCommand= false; string allcommands = string.Join(";", commands); if(allcommands.Contains("BSkySetDataFrameSplit")) { IsSplitCommand = true;//current command is split/unsplit command and so we dont run split/unsplit in split loop. } string datasetname = UIController.GetActiveDocument().Name;//'Dataset1' string modifiedCommand = string.Empty; int splititrationcount = 1; try { if(AdvancedLogging)logService.WriteToLogLevel("ExtraLogs: BatchCommand begins.", LogLevelEnum.Info); #region R Batch Command invoker //11Jul2014 need dialog title for commands those are single lined. if (CommandCountInBatch > 1) { //BSkyFunctionInit() // Execute in R cmd.CommandSyntax = "BSkyBatchCommand(1)"; // starting batch command analytics.ExecuteR(cmd, false, false); cmd.CommandSyntax = "BSkySetCurrentDatasetName('" + datasetname + "', setDatasetIndex = \"y\")"; analytics.ExecuteR(cmd, false, false); cmd.CommandSyntax = "New.version.BSkyComputeSplitdataset('" + datasetname + "')"; object ocnt = analytics.ExecuteR(cmd, true, false); if (ocnt != null)// && (ocnt is int)) { splititrationcount = Convert.ToInt32(ocnt); } ///ADDing right side Title for batch commands and associate it with left side leaf node//// PrintDialogTitle(dialogTitle); } #endregion bool islastslice = false; bool isemptyslice = false; object slicename; string curslice; string treenocharscount = confService.GetConfigValueForKey("nooftreechars");//16Dec2013 int treenodecharlen; bool result = Int32.TryParse(treenocharscount, out treenodecharlen); if (!result) treenodecharlen = 15; if (splititrationcount > 1 && !IsSplitCommand) //dlgprop.HandleSplits) { #region Split itrations for (int i = 1; i <= splititrationcount; i++) { CommandOutput sliceco = null;//21Nov2013 Slicename, if any isemptyslice = false; slicename = null; curslice = null; //int uaGlobalDataSliceIndexToWorkOn = 1; if (true)//04Jul2014 all dialogs get executed in Syntax // !commands[0].Contains("bsky") && !commands[0].Contains("BSky")) // FOR NON-BSKY COMMANDS { cmd.CommandSyntax = "uaDatasetSliceIndex = New.version.BSkyGetNextDatasetSplitSlice('" + datasetname + "')"; analytics.ExecuteR(cmd, false, false); //Current Slice cmd.CommandSyntax = "paste(BSkyComputeCurrentVarNamesAndFactorValues('" + datasetname + "'))"; slicename = analytics.ExecuteR(cmd, true, false).ToString(); curslice = slicename.ToString(); //21Nov2013 SendToOutputWindow("<<-- " + curslice +" -->>", "Slice:" + i.ToString()); //following block in place of above commented line // Set slicename for syn edt session list if (!curslice.Contains("Split = N")) { int startindex = curslice.IndexOf(','); startindex = curslice.IndexOf(',', startindex + 1) + 2; string treenodename = curslice.Substring(startindex).Trim(); sliceco = new CommandOutput(); sliceco.NameOfAnalysis = "Split:" + i.ToString(); sliceco.IsFromSyntaxEditor = false; AUParagraph aup = new AUParagraph(); aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//10Nov2014 aup.Text = "<<-- " + curslice + " -->>"; aup.ControlType = treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen); sliceco.Add(aup); } } #region /////// Checking if slice is empty or not /////// Do not process empty slice ////// //check uadatasets$lst[[index]] exists or not cmd.CommandSyntax = "eval(parse(text=paste('nrow(bskyCurrentDatasetSplitSliceObj)', sep='')))"; object rcont = analytics.ExecuteR(cmd, true, false); int rowcount = rcont != null ? Int32.Parse(rcont.ToString()) : -1; if (rowcount < 2)//empty slice. There should be empty slice. If no slice error "subscript out of bounds" will occur { isemptyslice = true; } //} #endregion if (!isemptyslice) { cmd.CommandSyntax = GetSliceSubstitutedCommands(commands, splititrationcount); } else { if (sliceco != null) // There is no slice when slice==null.(No Split dataset) { cmd.CommandSyntax = null; // no command is to be executed for empty slice. //adding one more AUPara to sliceco for empty slice string treenodename = "Empty Slice : " + i.ToString(); AUParagraph aup = new AUParagraph(); aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//10Nov2014 aup.Text = "!!!!!!! Empty Slice !!!!!!!"; aup.ControlType = treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen); sliceco.Add(aup); } } if (i == splititrationcount)//last slice under execution islastslice = true; ExecuteInSyntaxEditor(true, dialogTitle, sliceco, islastslice); //Execute command batch in syntax editor in one session. }//split itration on command batch #endregion } else//No Split { cmd.CommandSyntax = GetSliceSubstitutedCommands(commands, splititrationcount); ExecuteInSyntaxEditor(true, dialogTitle); } //till this point command has already been executed. So now we store this command for "History" }//Try finally { //////// THIS MUST EXECUTE AT THE END OTHERWISE THIS WILL IMPACT BADLY ON R SIDE ////////// //if (CommandCountInBatch > 1) { if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: BatchCommand ends.", LogLevelEnum.Info); cmd.CommandSyntax = "BSkyBatchCommand(0)"; // ending batch command analytics.ExecuteR(cmd, false, false); } } }
//30Apr2015 Output Dialog Title private void PrintDialogTitle(string title) { CommandOutput batch = new CommandOutput(); batch.NameOfAnalysis = "Batch Command"; batch.IsFromSyntaxEditor = false; string rcommcol = confService.GetConfigValueForKey("dctitlecol");//23nov2012 //before was syntitlecol byte red = byte.Parse(rcommcol.Substring(3, 2), NumberStyles.HexNumber); byte green = byte.Parse(rcommcol.Substring(5, 2), NumberStyles.HexNumber); byte blue = byte.Parse(rcommcol.Substring(7, 2), NumberStyles.HexNumber); Color c = Color.FromArgb(255, red, green, blue); AUParagraph aup = new AUParagraph(); aup.Text = title; // dialogTitle; aup.FontSize = BSkyStyler.BSkyConstants.HEADER_FONTSIZE;//16;// before it was 16 aup.FontWeight = FontWeights.DemiBold; aup.textcolor = new SolidColorBrush(c); //Colors.Blue);//SlateBlue //DogerBlue aup.ControlType = "Header"; batch.Add(aup); SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve<SyntaxEditorWindow>(); sewindow.AddToSession(batch); }
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()); } } }
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 }
//For commands : Dialog may or may not be shown but surely XML template is not present. public void ExeuteSingleCommandWithtoutXML(string command = "") { if (command != null && command.Length > 0) { cmd = new CommandRequest(); cmd.CommandSyntax = command; } if (cmd.CommandSyntax == null || cmd.CommandSyntax.Length < 1) { cmd = new CommandRequest(); cmd.CommandSyntax = "print('No command to execute')"; } if (cmd.CommandSyntax.Contains("BSkyReloadDataset("))// if its relaod dataset commmand then prepare some parameter before executing the command { DataSource tempds = UIController.GetActiveDocument(); string filename = tempds.FileName.Replace("\\", "/"); string filetype = tempds.FileType; string temp = new string(cmd.CommandSyntax.ToCharArray()); cmd.CommandSyntax = temp.Replace("fullpathfilename", "fullpathfilename='" + filename + "'").Replace("filetype", "filetype='" + filetype + "'");; //Restting split if all data and attributes are loaded int idx = temp.IndexOf("=", temp.IndexOf("loaddataonly")); // index of '=' after 'loaddataonly' int idxcomma = temp.IndexOf(",", temp.IndexOf("loaddataonly")); // index of ',' after 'loaddataonly' string boolvalue = temp.Substring(idx + 1, idxcomma - idx - 1).Trim(); if (boolvalue.Equals("FALSE")) //loaddataonly = false then we need to reset SPLIT in C# also { OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name)); } } //retval = analytics.Execute(cmd); if (bdt != null) { if (!bdt.IsBatchCommand && bdt.IsCommandOnly && !bdt.IsXMLDefined && !cmd.CommandSyntax.Contains("BSkySetDataFrameSplit(")) { SendToOutputWindow(dialogTitle, cmd.CommandSyntax); ExecuteInSyntaxEditor(true, dialogTitle);//GenerateOutputTablesForNonXAML(null);// ExecuteXMLDefinedDialog(); } } if (cmd.CommandSyntax.Contains("BSkySortDataframe(") || cmd.CommandSyntax.Contains("BSkyComputeExpression(") || cmd.CommandSyntax.Contains("BSkyRecode(")) { retval = analytics.Execute(cmd); OutputHelper.AnalyticsData.Result = retval; //putting latest DOM string[,] ew = OutputHelper.GetBSkyErrorsWarning(1, "normal"); //08Nov2014 if (cmd.CommandSyntax.Contains("BSkySortDataframe")) //11Apr2014 putting sort icon { //single column logic //int startidx = cmd.CommandSyntax.IndexOf("'"); //int endidx= cmd.CommandSyntax.IndexOf("'", startidx+1); //int leng = endidx - startidx-1; //string colname = cmd.CommandSyntax.Substring(startidx+1, leng); //sort order 14Apr2014 string srtodr = string.Empty; // descending=TRUE in command. There is just 1 boolean in sort so this 'if' will work if (cmd.CommandSyntax.Contains("TRUE")) { srtodr = "desc"; } else { srtodr = "asc"; } //mulitiple col logic List <string> collst = new List <string>(); int startidx = cmd.CommandSyntax.IndexOf("c("); if (startidx == -1) //no items in target listbox. No need of this if sort dialog has OK disabled when no items in target { return; } int endidx = cmd.CommandSyntax.IndexOf(")", startidx + 1); int leng = endidx - startidx - 1; string selcols = cmd.CommandSyntax.Substring(startidx + 2, leng - 1).Replace("'", ""); // +2 is the length of "c(", -1 for ) string[] cols = selcols.Split(','); for (int j = 0; j < cols.Length; j++) //string s in cols) { collst.Add(cols[j]); } RefreshGrids(collst, srtodr); } else { //testing something. If success, we dont need this. RefreshGrids(); } //16Apr2014 //must be excuted at the end after data is reloaded otherwise split is not refresh in statusbar. if (cmd.CommandSyntax.Contains("BSkyReloadDataset(")) { Refresh_Statusbar(); } ////Finally show messages in output //SendToOutputWindow(dialogTitle, cmd.CommandSyntax); //Show errors if any 08Nov2014 if (ew != null && ew[0, 0] != null) { //SendToOutputWindow("", ew[0, 2]); CommandOutput ewmsg = new CommandOutput(); ewmsg.NameOfAnalysis = "Errors/Warnings"; ewmsg.IsFromSyntaxEditor = false; AUParagraph ewtypeaup = new AUParagraph(); ewtypeaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE; ewtypeaup.Text = (ew[0, 0] != null)?ew[0, 0]:"no type info"; ewtypeaup.ControlType = "Type:"; ewmsg.Add(ewtypeaup); AUParagraph usrmsgaup = new AUParagraph(); usrmsgaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE; usrmsgaup.Text = (ew[0, 1] != null) ? ew[0, 1] : "no user message info"; usrmsgaup.ControlType = "User Message:"; ewmsg.Add(usrmsgaup); AUParagraph rmsgaup = new AUParagraph(); rmsgaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE; rmsgaup.Text = (ew[0, 2] != null) ? ew[0, 2] : "no R message info"; rmsgaup.ControlType = "R Message:"; ewmsg.Add(rmsgaup); AddToSyntaxSession(ewmsg); } } }
public void ExecuteSplit(string command = null, FrameworkElement fe = null) { CommandRequest cr = new CommandRequest(); cr.CommandSyntax = command; string stmt = command; //cmd.CommandSyntax; if (stmt.Contains("BSkySetDataFrameSplit(")) ///executes when SPLIT is fired from menu { bool setsplit = false; int startind = 0; int endind = 0; if (stmt.Contains("col.names")) { startind = stmt.IndexOf("c(", stmt.IndexOf("col.names"));// index of c( } else { startind = stmt.IndexOf("c(");// index of c( } if (startind > 0) { endind = stmt.IndexOf(")", startind); } if (startind > 0 && endind > startind) { int len = endind - startind + 1; // finding the length of c(......) string str = stmt.Substring(startind, len); // this will contain c('tg0','tg1') or just c() string ch = null; if (str.Contains("'")) { ch = "'"; } if (str.Contains('"')) { ch = "\""; } if (ch != null && ch.Length > 0) { int i = str.IndexOf(ch); int j = -1; if (i >= 0) { j = str.IndexOf(ch, i + 1); } if (j < 0) { j = i + 1; } string sub = str.Substring(i + 1, (j - i - 1)).Trim(); if (i < 0) { i = str.IndexOf("'"); } if (i >= 0) { if (sub.Length > 0) { setsplit = true; } } } } //Executing the command in R/// analytics.ExecuteR(cr, false, false); ////Creating a command output////11Jul2014 CommandOutput splitCo = new CommandOutput(); splitCo.NameOfAnalysis = "Split:#" + setsplit; splitCo.IsFromSyntaxEditor = false; AUParagraph aup = new AUParagraph(); aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE; //App.HEADER_FONTSIZE; aup.Text = stmt; aup.ControlType = "Header"; // treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen); splitCo.Add(aup); ////////// Setting/Unsetting Macro for SPLIT ////////// if (setsplit) { OutputHelper.AddGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name), fe); //window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window. AddToSyntaxSession(splitCo); //11Jul2014 SendToOutputWindow(dialogTitle, stmt); Refresh_Statusbar(); // RefreshGrids(); return; // no need to do any thing further } else // unset split { OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name)); //if (window != null && window.Template != null) // window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window. AddToSyntaxSession(splitCo); //11Jul2014 SendToOutputWindow(dialogTitle, stmt); Refresh_Statusbar(); // RefreshGrids(); return; // no need to do any thing further } } }
//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(); //} }