Beispiel #1
0
 /// <summary>
 /// Class constructor
 /// </summary>
 public AppLifeCycleViewModel(IAppCore appCore,
                              ISettingsManager settingsManager)
     : this()
 {
     Core             = appCore;
     _SettingsManager = settingsManager;
 }
Beispiel #2
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public SettingsManagerImpl(IThemesManager themesManager, IAppCore appHelpers)
            : this()
        {
            _ThemesManager = themesManager;
            _AppHelpers    = appHelpers;

            _SettingData = new Options(_ThemesManager);
        }
        public MainViewModel(IAppCore appCore, ILazyProxyClient lazyProxyClient, INavigationService navigationService,
                             IDialogsService dialogsService, IAppSettings appSettings)
            : base(navigationService)
        {
            this.appCore         = appCore;
            this.dialogsService  = dialogsService;
            this.lazyProxyClient = lazyProxyClient;
            this.appSettings     = appSettings;

            SetDisconnectedStatus();
        }
Beispiel #4
0
        public MainViewModel(ILoggerService loggingService, IAppCore appCore, IDialogsService dialogsService, IPermsService permissionsService, INavigationService navigationService)
            : base(navigationService)
        {
            Title = "Main Page";

            this.appCore            = appCore;
            this.dialogsService     = dialogsService;
            this.permissionsService = permissionsService;
            this.loggingService     = loggingService;

            DeviceId = "DeviceID: " + appCore.DeviceId;
            LogPath  = "Log path: " + appCore.LogPath;
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new Settings Manager instance
 /// given a themes manager instance is available.
 /// </summary>
 /// <param name="themesManager"></param>
 /// <returns></returns>
 public static ISettingsManager CreateSettingsManager(IThemesManager themesManager, IAppCore appHelpers)
 {
     return(new SettingsManagerImpl(themesManager, appHelpers));
 }
Beispiel #6
0
        /// <summary>
        /// Method executes as application entry point - that is -
        /// this bit of code executes before anything else in this
        /// class and application.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            try
            {
                // Set shutdown mode here (and reset further below) to enable showing custom dialogs (messageboxes)
                // durring start-up without shutting down application when the custom dialogs (messagebox) closes
                ShutdownMode = ShutdownMode.OnExplicitShutdown;
            }
            catch
            {
            }

            IOptions         options         = null;
            ISettingsManager settingsManager = null;
            IThemesManager   themesManager   = null;

            try
            {
                _Container = new WindsorContainer();

                // This allows castle to look at the current assembly and look for implementations
                // of the IWindsorInstaller interface
                _Container.Install(FromAssembly.This());                         // Register

                // Resolve SettingsManager to retrieve app settings/session data
                // and start with correct parameters from last session (theme, window pos etc...)
                settingsManager = _Container.Resolve <ISettingsManager>();
                themesManager   = _Container.Resolve <IThemesManager>();
                _AppCore        = _Container.Resolve <IAppCore>();

                var task = Task.Run(async() =>  // Off Loading Load Programm Settings to non-UI thread
                {
                    options = await settingsManager.LoadOptionsAsync(_AppCore.DirFileAppSettingsData, themesManager);
                });
                task.Wait(); // Block this to ensure that results are usable in next steps of sequence

                Thread.CurrentThread.CurrentCulture   = new CultureInfo(options.LanguageSelected);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(options.LanguageSelected);

                if (options.RunSingleInstance == true)
                {
                    if (enforcer.ShouldApplicationExit() == true)
                    {
                        if (AppIsShuttingDown == false)
                        {
                            AppIsShuttingDown = true;
                            Shutdown();
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                Logger.Error(exp);
                Console.WriteLine("");
                Console.WriteLine("Unexpected Error 1 in App.Application_Startup()");
                Console.WriteLine("   Message:{0}", exp.Message);
                Console.WriteLine("StackTrace:{0}", exp.StackTrace);
                Console.WriteLine("");
            }

            var AppViewModel = _Container.Resolve <IApplicationViewModel>();
            var task1        = Task.Run(async() => // Off Loading Load Programm Settings to non-UI thread
            {
                await AppViewModel.LoadConfigOnAppStartupAsync(options, settingsManager, themesManager);
            });

            task1.Wait();                                            // Block this to ensure that results are usable in next steps of sequence

            var start = _Container.Resolve <IShell <MainWindow> >(); // Resolve

            //resolve our shell to start the application.
            if (start != null)
            {
                start.ConfigureSession(AppViewModel, settingsManager);
                AppViewModel.EnableMainWindowActivated(true);

/////                var toolWindowRegistry = _Container.Resolve<IToolWindowRegistry>();
/////                toolWindowRegistry.PublishTools();

                if (this.AppIsShuttingDown == false)
                {
                    this.ShutdownMode = ShutdownMode.OnLastWindowClose;
                }
            }
            else
            {
                throw new Exception("Main Window construction failed in application boot strapper class.");
            }

            // Show the startpage if application starts for the very first time
            // (This requires that command binding was succesfully done before this line)
            if (string.IsNullOrEmpty(settingsManager.SessionData.LastActiveFile))
            {
                AppViewModel.ShowStartPage();
            }

            start.Run();                                              // Show the mainWindow

            var msgBox = _Container.Resolve <IMessageBoxService>();

            // discover via Plugin folder instead
            MiniUML.Model.MiniUmlPluginLoader.LoadPlugins(
                _AppCore.AssemblyEntryLocation + @".\Plugins\MiniUML.Plugins.UmlClassDiagram\",
                AppViewModel, msgBox);


            if (e != null)
            {
                ProcessCmdLine(e.Args, AppViewModel);
            }

            // Modules (and everything else) have been initialized if we got here
            var output = _Container.Resolve <IMessageManager>();

            output.Output.AppendLine("Get involved at: https://github.com/Dirkster99/Edi");

            _AppCore.CreateAppDataFolder();

            // Cannot set shutdown mode when application is already shuttong down
//            try
//            {
//                if (AppIsShuttingDown == false)
//                    ShutdownMode = ShutdownMode.OnExplicitShutdown;
//            }
//            catch
//            {
//            }

            // 1) Application hangs when this is set to null while MainWindow is visible
            // 2) Application throws exception when this is set as owner of window when it
            //    was never visible.
            //
            if (Current.MainWindow != null)
            {
                if (Current.MainWindow.IsVisible == false)
                {
                    Current.MainWindow = null;
                }
            }

/////            if (AppIsShuttingDown == false)
/////                Shutdown();
        }