public App() { //25Aug2017 To see how Date fomatting changes in the Datagrid Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");//US English 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) { 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 + s1 + s2 + s3 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop); #region R Home Dir edit prompt 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; 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.InstallReqRPkgFrmCRAN + "\n" + BSky.GlobalResources.Properties.Resources.RegPkgsMenuPath;// + 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); } } }