private void PasteSyntax() { //copy to clipboard and return for this function // Clipboard.SetText(cmd.CommandSyntax); //Clipboard.SetText("asd dddddw"); //Launch Syntax Editor window with command pasted /// 29Jan2013 MainWindow mwindow = LifetimeService.Instance.Container.Resolve <MainWindow>(); ////// Start Syntax Editor ////// SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); sewindow.Owner = mwindow; //string syncomment = "# Use BSkyFormat(obj) to format the output.\n" + // "# UAloadDataset(\'" + UIController.GetActiveDocument().FileName.Replace('\\', '/') + // "\', filetype=\'SPSS\', worksheetName=NULL, replace_ds=FALSE, csvHeader=TRUE, datasetName=\'" + // UIController.GetActiveDocument().Name + "\' )\n"; // sewindow.PasteSyntax(syncomment + "asd dddddw");//paste command string syncomment = BSky.GlobalResources.Properties.UICtrlResources.syncomment + " " + "\"" + getTitle() + "\""; if (string.IsNullOrEmpty(getCommand())) { syncomment = syncomment = BSky.GlobalResources.Properties.UICtrlResources.syncomment2 + "\"" + getTitle() + "\""; } else { syncomment = syncomment + "\n" + getCommand(); } sewindow.PasteSyntax(syncomment); sewindow.Show(); sewindow.WindowState = WindowState.Normal; sewindow.Activate(); this.Close(); }
protected void ExecuteInSyntaxEditor(bool ExecuteCommand, string sessionTitle = "", CommandOutput sliceco = null, bool islastslice = true) { //Launch Syntax Editor window with command pasted /// 29Jan2013 MainWindow mwindow = LifetimeService.Instance.Container.Resolve <MainWindow>(); ////// Start Syntax Editor ////// SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); sewindow.Owner = mwindow; //21Nov2013. if there is slicename add it first to the syntax editor output session list if (sliceco != null) { sewindow.AddToSession(sliceco); } if (cmd.CommandSyntax != null && cmd.CommandSyntax.Length > 0) { sewindow.RunCommands(cmd.CommandSyntax);//, sessionheader); } //22Nov2013 //if sessionTitle is empty that means there are more (split)slices to execute //when the last slice is ready for execution that time sessionTitle //will have the main title for whole session if (islastslice)//sessionTitle != null && sessionTitle.Length > 0) { sewindow.DisplayAllSessionOutput(sessionTitle); } else { return;//go get another slice. Do not process rest of the code till last slice comes in. } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)///15Jan2013 { try { MainWindow mwindow = LifetimeService.Instance.Container.Resolve <MainWindow>();//28Jan2013 mwindow.Activate(); if (mwindow.OwnedWindows.Count > 1) { System.Windows.Forms.DialogResult dresult = ExitAppMessageBox(); //19feb2013 if (dresult == System.Windows.Forms.DialogResult.Yes) //save & exit { #region CLose Output Windows and then Close Syntax Eiditor //// Close output window and synedtr window /// 05Feb2013 OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve <IOutputWindowContainer>()) as OutputWindowContainer; SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); // First collect window names string[] outwinnames = new string[owc.Count]; int i = 0; foreach (KeyValuePair <String, IOutputWindow> item in owc.AllOutputWindows) { outwinnames[i] = item.Key; i++; } //close each output window one by one. foreach (string winname in outwinnames) { (owc.GetOuputWindow(winname) as Window).Close();//invoke close {Closing then Closed } } //now close Syntax Editor window sewindow.SynEdtForceClose = true; sewindow.Close(); if (owc.Count > 0 || sewindow != null && !sewindow.SynEdtForceClose) // if any of the output window is open { e.Cancel = true; // abort closing. } #endregion } else if (dresult == System.Windows.Forms.DialogResult.No) //Exit without save { } else //cancel exit. Keep the app open. { e.Cancel = true; return; } } } catch (Exception ex) { logService.WriteToLogLevel("Error while closing:" + ex.Message, LogLevelEnum.Error); } }
private void PasteSyntax() { //copy to clipboard and return for this function Clipboard.SetText(cmd.CommandSyntax); //Launch Syntax Editor window with command pasted /// 29Jan2013 MainWindow mwindow = LifetimeService.Instance.Container.Resolve <MainWindow>(); ////// Start Syntax Editor ////// SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); sewindow.Owner = mwindow; //31May2015. No need to paste the R commented '#' commands in syntax //string syncomment = "# Use BSkyFormat(obj) to format the output.\n" + // "# UAloadDataset(\'" + UIController.GetActiveDocument().FileName.Replace('\\', '/') + // "\', filetype=\'SPSS\', worksheetName=NULL, replace_ds=FALSE, csvHeader=TRUE, datasetName=\'" + // UIController.GetActiveDocument().Name + "\' )\n"; string syncomment = "\n"; //31May2015 sewindow.PasteSyntax(syncomment + cmd.CommandSyntax); //paste command :-> sewindow.Show(); sewindow.WindowState = WindowState.Normal; sewindow.Activate(); }
public App() { //25Aug2017 To see how Date fomatting changes in the Datagrid Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");//US English en-US Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); //Calling order found was:: Dispatcher -> Main Window -> XAML Application Dispatcher -> Unhandeled AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException); Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException); MainWindow mwindow = container.Resolve <MainWindow>(); container.RegisterInstance <MainWindow>(mwindow);///new line mwindow.Show(); mwindow.Visibility = Visibility.Hidden; ShowProgressbar(); bool BlueSkyFound = true; string upath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlueSky");;//Per User path string applogpath = BSkyAppData.RoamingUserBSkyLogPath; DirectoryHelper.UserPath = upath; LifetimeService.Instance.Container = container; container.RegisterInstance <ILoggerService>(new LoggerService(applogpath)); //Check if user profies has got old files. If so overwrite all(dialogs, modelclasses and other xmls, txt etc.) bool hasOldUserContent = CheckIfOldInUserProfile(); //Copy folders inside Bin/Config to User profile BlueSky\config. if (hasOldUserContent) { CopyL18nDialogsToUserRoamingConfig(); } //copy config file to user profile. CopyNewAndRetainOldSettings(string.Format(@"{0}BlueSky.exe.config", "./"), string.Format(@"{0}BlueSky.exe.config", BSkyAppData.RoamingUserBSkyConfigPath)); container.RegisterInstance <IConfigService>(new ConfigService()); //For App Config file container.RegisterInstance <IAdvancedLoggingService>(new AdvancedLoggingService()); //For Advanced Logging ////////////// TRY LOADING BSKY R PACKAGES HERE ///////// ILoggerService logService = container.Resolve <ILoggerService>(); logService.SetLogLevelFromConfig(); //loading log level from config file logService.WriteToLogLevel("R.Net,Logger and Config loaded:", LogLevelEnum.Info); /// ////Recent default packages. This code must appear before loading any R package. (including BlueSky R package) XMLitemsProcessor defaultpackages = container.Resolve <XMLitemsProcessor>();//06Feb2014 defaultpackages.MaxRecentItems = 100; if (hasOldUserContent) { CopyIfNotExistsOrOld(string.Format(@"{0}DefaultPackages.xml", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}DefaultPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath)); } defaultpackages.XMLFilename = string.Format(@"{0}DefaultPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 ;BSkyAppData.BSkyDataDirConfigFwdSlash defaultpackages.RefreshXMLItems(); container.RegisterInstance <XMLitemsProcessor>("defaultpackages", defaultpackages); //Recent user packages. This code must appear before loading any R package. (including uadatapackage) RecentItems userpackages = container.Resolve <RecentItems>();//06Feb2014 userpackages.MaxRecentItems = 100; userpackages.XMLFilename = string.Format(@"{0}UserPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 @"./Config/UserPackages.xml"; userpackages.RefreshXMLItems(); container.RegisterInstance <RecentItems>(userpackages); ////User listed model classes. XMLitemsProcessor modelClasses = container.Resolve <XMLitemsProcessor>();// modelClasses.MaxRecentItems = 100; if (hasOldUserContent) { CopyIfNotExistsOrOld(string.Format(@"{0}ModelClasses.xml", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}ModelClasses.xml", BSkyAppData.RoamingUserBSkyConfigPath)); } modelClasses.XMLFilename = string.Format(@"{0}ModelClasses.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 ;BSkyAppData.BSkyDataDirConfigFwdSlash modelClasses.RefreshXMLItems(); container.RegisterInstance <XMLitemsProcessor>("modelClasses", modelClasses); if (hasOldUserContent) { CopyIfNotExistsOrOld(string.Format(@"{0}GraphicCommandList.txt", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}GraphicCommandList.txt", BSkyAppData.RoamingUserBSkyConfigPath)); } try { BridgeSetup.ConfigureContainer(container); } catch (Exception ex) { bool anothersessionrunning = false; if (ex.Message.Contains("used by another process")) { anothersessionrunning = true; } string s1 = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureRInstalled; string s2 = "\n" + BSky.GlobalResources.Properties.Resources.MakeSure32x64Compatibility; string s3 = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureAnotherBSkySession; string s4 = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureRHOME2LatestR; string s5 = "\n" + BSky.GlobalResources.Properties.Resources.PleaseMakeSure; string mboxtitle0 = "\n" + BSky.GlobalResources.Properties.Resources.CantLaunchBSkyApp; //MessageBox.Show(s5 + s3 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop); if (anothersessionrunning) { MessageBox.Show(s5 + s3, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop); } else { MessageBox.Show(s5 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop); } #region R Home Dir edit prompt if (!anothersessionrunning) { //Provide R Home Dir check/modify option to the user so that he can have a chance to fix this issue. //Otherwise app will not launch until reinstalled or manually modify the config file. //So following is much better and easier way to fix the issue. HideMouseBusy(); HideProgressbar(); ChangeConfigForRHome(); } #endregion logService.WriteToLogLevel("Unable to launch the BlueSky Statistics Application." + s1 + s3, LogLevelEnum.Error); logService.WriteToLogLevel("Exception:" + ex.Message, LogLevelEnum.Fatal); Environment.Exit(0); } finally { HideProgressbar(); } container.RegisterInstance <IDashBoardService>(container.Resolve <XmlDashBoardService>()); container.RegisterInstance <IDataService>(container.Resolve <DataService>()); IOutputWindowContainer iowc = container.Resolve <OutputWindowContainer>(); container.RegisterInstance <IOutputWindowContainer>(iowc); SessionDialogContainer sdc = container.Resolve <SessionDialogContainer>(); //13Feb2013 //Recent Files settings RecentDocs rdoc = container.Resolve <RecentDocs>(); //21Feb2013 rdoc.MaxRecentItems = 7; rdoc.XMLFilename = string.Format(@"{0}Recent.xml", BSkyAppData.RoamingUserBSkyConfigPath); //23Apr2015 @"./Config/Recent.xml"; container.RegisterInstance <RecentDocs>(rdoc); Window1 window = container.Resolve <Window1>(); container.RegisterInstance <Window1>(window); ///new line window.Closed += new EventHandler(window_Closed); //28Jan2013 window.Owner = mwindow; //28Jan2013 //17Apr2017 Showing version number on titlebar of main window Version ver = Assembly.GetExecutingAssembly().GetName().Version; string strfullversion = ver.ToString(); //Full version with four parts string shortversion = string.Format("{0}.{1}", ver.Major.ToString(), ver.Minor.ToString()); string titlemsg = string.Empty; titlemsg = string.Format("BlueSky Statistics (Open Source Desktop Edition. Ver- {0})", shortversion); window.Title = titlemsg; window.Show(); window.Activate(); ShowMouseBusy();//02Apr2015 show mouse busy //// one Syntax Editor window for one session ////29Jan2013 SyntaxEditorWindow sewindow = container.Resolve <SyntaxEditorWindow>(); container.RegisterInstance <SyntaxEditorWindow>(sewindow);///new line sewindow.Owner = mwindow; #region Create Column Significance codes List SignificanceCodesHandler.CreateSignifColList(); #endregion //load default packages window.setLMsgInStatusBar(BSky.GlobalResources.Properties.Resources.StatMsgPkgLoad); IAnalyticsService IAService = LifetimeService.Instance.Container.Resolve <IAnalyticsService>(); BridgeSetup.LoadDefaultRPackages(IAService); string PkgLoadStatusMessage = BridgeSetup.PkgLoadStatusMessage; bool BlueSkyPkgErr = PkgLoadStatusMessage.Contains("BlueSky") ? true : false; if (PkgLoadStatusMessage != null && PkgLoadStatusMessage.Trim().Length > 0) { StringBuilder sb = new StringBuilder(); string[] defpacklist = PkgLoadStatusMessage.Split('\n'); foreach (string s in defpacklist) { if (s != null && (s.ToLower().Contains("error")))//|| s.ToLower().Contains("warning"))) { //sb.Append(s.Substring(0, s.IndexOf(". ")) + "\n"); sb.Append(s.Replace("Error loading R package:", "") + "\n"); } } if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1);//removing last comma string defpkgs = sb.ToString(); string firstmsg = BSky.GlobalResources.Properties.Resources.ErrLoadingRPkg + "\n\n"; string msg = "\n\n" + BSky.GlobalResources.Properties.Resources.DisableAntivirus;// + if (BlueSkyPkgErr) { msg = string.Empty; } HideMouseBusy(); string mboxtitle1 = BSky.GlobalResources.Properties.Resources.ErrReqRPkgMissing; MessageBox.Show(firstmsg + defpkgs + msg, mboxtitle1, MessageBoxButton.OK, MessageBoxImage.Error); Window1.DatasetReqPackages = defpkgs; BlueSkyFound = false; } } //deimal default should be set here as now BlueSky is loaded window.SetRDefaults(); IAdvancedLoggingService advlog = container.Resolve <IAdvancedLoggingService>();;//01May2015 advlog.RefreshAdvancedLogging(); window.setInitialAllModels(); //select All_Models in model class dropdown. window.setLMsgInStatusBar(""); HideMouseBusy(); //02Apr2015 hide mouse busy if (BlueSkyFound) { try { FileNewCommand newds = new FileNewCommand(); newds.NewFileOpen(""); } catch (Exception ex) { string so = BSky.GlobalResources.Properties.Resources.ErrLoadingNewDS; string mboxtitle2 = BSky.GlobalResources.Properties.Resources.BSkyPkgMissing; logService.WriteToLogLevel("ERROR: " + ex.Message, LogLevelEnum.Error); MessageBox.Show(so, mboxtitle2, MessageBoxButton.OK, MessageBoxImage.Error); } } }
public App() { //Calling order found was:: Dispatcher -> Main Window -> XAML Application Dispatcher -> Unhandeled AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException); Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException); MainWindow mwindow = container.Resolve <MainWindow>(); container.RegisterInstance <MainWindow>(mwindow);///new line mwindow.Show(); mwindow.Visibility = Visibility.Hidden; ShowProgressbar(); //strat showing progress bar bool BlueSkyFound = true; //Assuming BlueSky R package is present. LifetimeService.Instance.Container = container; container.RegisterInstance <ILoggerService>(new LoggerService()); /// For Application log. Starts with default level "Error" container.RegisterInstance <IConfigService>(new ConfigService()); //For App Config file container.RegisterInstance <IAdvancedLoggingService>(new AdvancedLoggingService()); //For Advanced Logging ////////////// TRY LOADING BSKY R PACKAGES HERE ///////// ILoggerService logService = container.Resolve <ILoggerService>(); logService.SetLogLevelFromConfig(); //loading log level from config file logService.WriteToLogLevel("R.Net,Logger and Config loaded:", LogLevelEnum.Info); /// ////Recent default packages. This code must appear before loading any R package. (including uadatapackage) XMLitemsProcessor defaultpackages = container.Resolve <XMLitemsProcessor>();//06Feb2014 defaultpackages.MaxRecentItems = 50; defaultpackages.XMLFilename = string.Format(@"{0}DefaultPackages.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);//23Apr2015 @"./Config/DefaultPackages.xml"; defaultpackages.RefreshXMLItems(); container.RegisterInstance <XMLitemsProcessor>(defaultpackages); //Recent user packages. This code must appear before loading any R package. (including uadatapackage) RecentItems userpackages = container.Resolve <RecentItems>();//06Feb2014 userpackages.MaxRecentItems = 50; userpackages.XMLFilename = string.Format(@"{0}UserPackages.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);//23Apr2015 @"./Config/UserPackages.xml"; userpackages.RefreshXMLItems(); container.RegisterInstance <RecentItems>(userpackages); try { BridgeSetup.ConfigureContainer(container); } catch (Exception ex) { string s1 = "\n1. R is installed. BlueSky Statistics requires R."; string s2 = "\n2. Binary incompatibility between BlueSky Statistics and R. 64bit BlueSky Statistics requires 64bit R and 32bit BlueSky Statistics required 32bit R. (Go to Help > About in BlueSky Statistics)"; string s3 = "\n3. Another session of the BlueSky application is not already running."; MessageBox.Show("Please make sure:" + s1 + s2 + s3, "Error: Can't Launch BlueSky Application!", MessageBoxButton.OK, MessageBoxImage.Stop); logService.WriteToLogLevel("Unable to launch the BlueSky Application." + s1 + s3, LogLevelEnum.Error); Environment.Exit(0); } finally { HideProgressbar(); } container.RegisterInstance <IDashBoardService>(container.Resolve <XmlDashBoardService>()); container.RegisterInstance <IDataService>(container.Resolve <DataService>()); IOutputWindowContainer iowc = container.Resolve <OutputWindowContainer>(); container.RegisterInstance <IOutputWindowContainer>(iowc); SessionDialogContainer sdc = container.Resolve <SessionDialogContainer>(); //13Feb2013 //Recent Files settings RecentDocs rdoc = container.Resolve <RecentDocs>(); //21Feb2013 rdoc.MaxRecentItems = 7; rdoc.XMLFilename = string.Format(@"{0}Recent.xml", BSkyAppData.BSkyDataDirConfigFwdSlash); container.RegisterInstance <RecentDocs>(rdoc); Window1 window = container.Resolve <Window1>(); container.RegisterInstance <Window1>(window); ///new line window.Closed += new EventHandler(window_Closed); //28Jan2013 window.Owner = mwindow; //28Jan2013 window.Show(); window.Activate(); ShowMouseBusy();//02Apr2015 show mouse busy //// one Syntax Editor window for one session ////29Jan2013 SyntaxEditorWindow sewindow = container.Resolve <SyntaxEditorWindow>(); container.RegisterInstance <SyntaxEditorWindow>(sewindow);///new line sewindow.Owner = mwindow; //load default packages window.setLMsgInStatusBar("Please wait ... Loading required R packages ..."); IAnalyticsService IAService = LifetimeService.Instance.Container.Resolve <IAnalyticsService>(); BridgeSetup.LoadDefaultRPackages(IAService); string PkgLoadStatusMessage = BridgeSetup.PkgLoadStatusMessage; if (PkgLoadStatusMessage != null && PkgLoadStatusMessage.Trim().Length > 0) { StringBuilder sb = new StringBuilder(); string[] defpacklist = PkgLoadStatusMessage.Split('\n'); foreach (string s in defpacklist) { if (s != null && (s.ToLower().Contains("error"))) //|| s.ToLower().Contains("warning"))) { sb.Append(s.Replace("Error loading R package:", "") + "\n"); } } if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1);//removing last comma string defpkgs = sb.ToString(); string firstmsg = "Error loading following R package(s):\n\n"; string msg = "\n\nInstall required R packages from CRAN by clicking:\nTools > Package > Install required package(s) from CRAN.";// + HideMouseBusy(); MessageBox.Show(firstmsg + defpkgs + msg, "Error: Required R Package(s) Missing", MessageBoxButton.OK, MessageBoxImage.Warning); if (defpkgs.Contains("BlueSky")) { BlueSkyFound = false; } } } //deimal default should be set here as now BlueSky is loaded window.SetRDefaults(); IAdvancedLoggingService advlog = container.Resolve <IAdvancedLoggingService>();;//01May2015 advlog.RefreshAdvancedLogging(); HideMouseBusy();//02Apr2015 hide mouse busy if (BlueSkyFound) { try { //Try loading empty dataset(newdataset) just after app finished loading itself and R packages. FileNewCommand newds = new FileNewCommand(); newds.NewFileOpen(""); } catch (Exception ex) { MessageBox.Show("Error Loading new dataset. Make sure you have BlueSky R package installed", "BlueSky pacakge missing", MessageBoxButton.OK, MessageBoxImage.Error); } } window.setLMsgInStatusBar("For additional functionality and for details on the commercial edition, "); }
private void AddToSyntaxSession(CommandOutput co) { SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); sewindow.AddToSession(co); }