Пример #1
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public SettingsManagerImpl(IThemesManager themesManager)
        {
            _ThemesManager = themesManager;

            _SettingData = new Options(_ThemesManager);
            _SessionData = new Profile();
        }
Пример #2
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public SettingsManager(IThemesManager themesManager)
        {
            this.mThemesManager = themesManager;

            this.SettingData = new Options(this.mThemesManager);
            this.SessionData = new Profile();
        }
Пример #3
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public SettingsManagerImpl(IThemesManager themesManager, IAppCore appHelpers)
            : this()
        {
            _ThemesManager = themesManager;
            _AppHelpers    = appHelpers;

            _SettingData = new Options(_ThemesManager);
        }
Пример #4
0
 public Admin(ISessionHelper sessionHelper, IAppUsersManager usersManager, IThemesCrudService themesCrudService, IResourcesManager resourcesManager, IThemesManager themesManager, IMapper mapper)
 {
     this.sessionHelper     = sessionHelper;
     this.usersManager      = usersManager;
     this.themesCrudService = themesCrudService;
     this.themesManager     = themesManager;
     this.resourcesManager  = resourcesManager;
     this.mapper            = mapper;
 }
Пример #5
0
        public Bootstapper(App app,
                           StartupEventArgs eventArgs,
                           Options programSettings,
                           IThemesManager themesManager)
        {
            this.mThemes = themesManager;
            this.mProgramSettingsManager = new SettingsManager(this.mThemes);

            this.mEventArgs = eventArgs;
            this.mApp       = app;
            this.mOptions   = programSettings;
        }
Пример #6
0
        public Bootstapper(App app,
                           StartupEventArgs eventArgs,
                           Options programSettings,
                           IThemesManager themesManager)
            : this()
        {
            mThemes = themesManager;
            mProgramSettingsManager = new SettingsManager(mThemes);

            mEventArgs = eventArgs;
            mApp       = app;
            mOptions   = programSettings;
        }
Пример #7
0
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="app"></param>
        /// <param name="eventArgs"></param>
        /// <param name="programSettings"></param>
        /// <param name="themesManager"></param>
        /// <param name="settingsManager"></param>
        public Bootstapper(App app,
                           StartupEventArgs eventArgs,
                           IOptions programSettings,
                           IThemesManager themesManager,
                           ISettingsManager settingsManager)
            : this()
        {
            _Themes = themesManager;
            _ProgramSettingsManager = settingsManager;

            _EventArgs = eventArgs;
            _App       = app;
            _Options   = programSettings;
        }
Пример #8
0
        /// <summary>
        /// Load program options from persistence.
        /// See <seealso cref="SaveOptions"/> to save program options on program end.
        /// </summary>
        /// <param name="settingsFileName"></param>
        /// <param name="themesManager"></param>
        /// <returns></returns>
        private IOptions LoadOptions(string settingsFileName,
                                     IThemesManager themesManager,
                                     IOptions programSettings = null)
        {
            if (programSettings != null)
            {
                _SettingData = programSettings;
            }
            else                                     // Get a fresh copy from persistence
            {
                _SettingData = LoadOptionsImpl(settingsFileName, themesManager);
            }

            return(_SettingData);
        }
Пример #9
0
        /// <summary>
        /// Load program options from persistence.
        /// See <seealso cref="SaveOptions"/> to save program options on program end.
        /// </summary>
        /// <param name="settingsFileName"></param>
        /// <param name="themesManager"></param>
        /// <returns></returns>
        private IOptions LoadOptionsImpl(string settingsFileName
                                         , IThemesManager themesManager)
        {
            Options loadedModel = null;

            try
            {
                if (System.IO.File.Exists(settingsFileName))
                {
                    // Create a new file stream for reading the XML file
                    using (FileStream readFileStream = new System.IO.FileStream(settingsFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        try
                        {
                            // Create a new XmlSerializer instance with the type of the test class
                            XmlSerializer serializerObj = new XmlSerializer(typeof(Options));

                            // Load the object saved above by using the Deserialize function
                            loadedModel = (Options)serializerObj.Deserialize(readFileStream);
                        }
                        catch (Exception e)
                        {
                            logger.Error(e);
                        }

                        // Cleanup
                        readFileStream.Close();
                    }
                }
            }
            catch (Exception exp)
            {
                logger.Error(exp);
            }
            finally
            {
                // Just get the defaults if serilization wasn't working here...
                if (loadedModel == null)
                {
                    loadedModel = new Options(themesManager);
                }
            }

            // Data has just been loaded from persistence (or default) so its not dirty for sure
            loadedModel.SetDirtyFlag(false);

            return(loadedModel);
        }
Пример #10
0
        /// <summary>
        /// Load configuration from persistence on startup of application
        /// </summary>
        /// <param name="programSettings"></param>
        /// <param name="settings"></param>
        /// <param name="themes"></param>
        public void LoadConfigOnAppStartup(Options programSettings,
                                           ISettingsManager settings,
                                           IThemesManager themes)
        {
            // Re/Load program options and user profile session data to control global behaviour of program
            settings.LoadOptions(this.mAppCore.DirFileAppSettingsData, themes, programSettings);
            settings.LoadSessionData(this.mAppCore.DirFileAppSessionData);

            settings.CheckSettingsOnLoad(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop);

            // Initialize skinning engine with this current skin
            // standard skins defined in class enum
            // plus configured skins with highlighting
            themes.SetSelectedTheme(settings.SettingData.CurrentTheme);
            this.ResetTheme();                                   // Initialize theme in process
        }
Пример #11
0
        /// <summary>
        /// Save program options into persistence.
        /// See <seealso cref="SaveOptions"/> to save program options on program end.
        /// </summary>
        /// <param name="settingsFileName"></param>
        /// <param name="themesManager"></param>
        /// <returns></returns>
        public void LoadOptions(string settingsFileName,
                                IThemesManager themesManager,
                                Options programSettings = null)
        {
            Options loadedModel = null;

            if (programSettings != null)
            {
                loadedModel = programSettings;
            }
            else                                                 // Get a fresh copy from persistence
            {
                loadedModel = SettingsManager.LoadOptions(settingsFileName, themesManager);
            }

            loadedModel.SetDirtyFlag(false);              // Data has just been loaded from persistence (or default) so its not dirty for sure
            this.SettingData = loadedModel;
        }
Пример #12
0
        /// <summary>
        /// Load configuration from persistence on startup of application
        /// </summary>
        /// <param name="programSettings"></param>
        /// <param name="settings"></param>
        /// <param name="themes"></param>
        public void LoadConfigOnAppStartup(Options programSettings,
                                           ISettingsManager settings,
                                           IThemesManager themes)
        {
            // Re/Load program options and user profile session data to control global behaviour of program
            settings.LoadOptions(this.mAppCore.DirFileAppSettingsData, themes, programSettings);
            settings.LoadSessionData(this.mAppCore.DirFileAppSessionData);

            settings.CheckSettingsOnLoad(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop);

            // Convert Session model into viewmodel instance
            var mruVM = ServiceLocator.Current.GetInstance <IMRUListViewModel>();

            MRUEntrySerializer.ConvertToViewModel(settings.SessionData.MruList, mruVM);

            // Initialize skinning engine with this current skin
            // standard skins defined in class enum
            // plus configured skins with highlighting
            themes.SetSelectedTheme(settings.SettingData.CurrentTheme);
            this.ResetTheme();                       // Initialize theme in process
        }
Пример #13
0
        /// <summary>
        /// Load configuration from persistence on startup of application
        /// </summary>
        /// <param name="programSettings"></param>
        /// <param name="settings"></param>
        /// <param name="themes"></param>
        public async Task <IOptions> LoadConfigOnAppStartupAsync(IOptions programSettings,
                                                                 ISettingsManager settings,
                                                                 IThemesManager themes)
        {
            // Re/Load program options and user profile session data to control global behaviour of program
            await settings.LoadOptionsAsync(_AppCore.DirFileAppSettingsData, themes, programSettings);

            settings.LoadSessionData(_AppCore.DirFileAppSessionData);

            settings.CheckSettingsOnLoad(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop);

            // Initialize skinning engine with this current skin
            // standard skins defined in class enum PLUS
            // configured skins with highlighting
            themes.SetSelectedTheme(settings.SettingData.CurrentTheme);
            ResetTheme();                       // Initialize theme in process

            // Convert Session model into viewmodel instance
            MRUEntrySerializer.ConvertToViewModel(settings.SessionData.MruList, _MruVM);

            return(programSettings);
        }
Пример #14
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="copyThis"></param>
        public Options(Options copyThis)
            : this()
        {
            if (copyThis == null)
            {
                return;
            }

            this._ThemesManager    = copyThis._ThemesManager;
            this.EditorTextOptions = copyThis.EditorTextOptions;
            this._WordWarpText     = copyThis._WordWarpText;

            this._DocumentZoomUnit = copyThis._DocumentZoomUnit;     // Zoom View in Percent
            this._DocumentZoomView = copyThis._DocumentZoomView;     // Font Size 12 is 100 %

            this._ReloadOpenFilesOnAppStart = copyThis._ReloadOpenFilesOnAppStart;
            this._RunSingleInstance         = copyThis._RunSingleInstance;
            this._CurrentTheme     = copyThis._CurrentTheme;
            this._LanguageSelected = copyThis._LanguageSelected;

            this._IsDirty = copyThis._IsDirty;
        }
Пример #15
0
        /// <summary>
        /// Hidden class Constructor
        /// </summary>
        protected Options()
        {
            this._ThemesManager = null;

            this.EditorTextOptions = new TextEditorOptions();
            this._WordWarpText     = false;

            this._DocumentZoomUnit = ZoomUnit.Percentage;     // Zoom View in Percent
            this._DocumentZoomView = 100;                     // Font Size 12 is 100 %

            this._ReloadOpenFilesOnAppStart = true;
            this._RunSingleInstance         = true;
            this._CurrentTheme     = Edi.Themes.Factory.DefaultThemeName;
            this._LanguageSelected = SettingsFactory.DefaultLocal;

            this.HighlightOnFileNew          = true;
            this.FileNewDefaultFileName      = Edi.Util.Local.Strings.STR_FILE_DEFAULTNAME;
            this.FileNewDefaultFileExtension = ".txt";

            this.ExplorerSettings = new ExplorerSettingsModel(true);

            this._IsDirty = false;
        }
Пример #16
0
        /// <summary>
        /// Hidden class Constructor
        /// </summary>
        protected Options()
        {
            this.mThemesManager = null;

            this.EditorTextOptions = new TextEditorOptions();
            this.mWordWarpText     = false;

            this.mDocumentZoomUnit = ZoomUnit.Percentage;     // Zoom View in Percent
            this.mDocumentZoomView = 100;                     // Font Size 12 is 100 %

            this.mReloadOpenFilesOnAppStart = true;
            this.mRunSingleInstance         = true;
            this.mCurrentTheme     = ThemesManager.DefaultThemeName;
            this.mMRU_SortMethod   = MRUSortMethod.PinnedEntriesFirst;
            this.mLanguageSelected = Options.DefaultLocal;

            this.HighlightOnFileNew          = true;
            this.FileNewDefaultFileName      = Util.Local.Strings.STR_FILE_DEFAULTNAME;
            this.FileNewDefaultFileExtension = ".txt";

            this.ExplorerSettings = new ExplorerSettingsModel(true);

            this.mIsDirty = false;
        }
Пример #17
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)
 {
     return(new SettingsManagerImpl(themesManager));
 }
Пример #18
0
 /// <summary>
 /// Class constructor from <paramref name="themesManager"/> parameter.
 /// </summary>
 /// <param name="themesManager"></param>
 public Options(IThemesManager themesManager)
     : this()
 {
     this._ThemesManager = themesManager;
     this._CurrentTheme  = themesManager.DefaultThemeName;
 }
Пример #19
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));
 }
Пример #20
0
 /// <summary>
 /// Class constructor from <paramref name="themesManager"/> parameter.
 /// </summary>
 /// <param name="themesManager"></param>
 public Options(IThemesManager themesManager)
     : this()
 {
     this.mThemesManager = themesManager;
 }
Пример #21
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();
        }
Пример #22
0
        /// <summary>
        /// This is the first bit of code being executed when the application is invoked (main entry point).
        ///
        /// Use the <paramref name="e"/> parameter to evaluate command line options.
        /// Invoking a program with an associated file type extension (eg.: *.txt) in Explorer
        /// results, for example, in executing this function with the path and filename being
        /// supplied in <paramref name="e"/>.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Application_Startup(object sender, StartupEventArgs 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
            {
            }

            Options        options       = null;
            IThemesManager themesManager = Factory.CreateThemeManager();

            try
            {
                options = SettingsManager.LoadOptions(AppHelpers.DirFileAppSettingsData, themesManager);

                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("");
            }

            try
            {
                mBoot = new Bootstapper(this, e, options, themesManager);
                mBoot.Run();
            }
            catch (Exception exp)
            {
                Logger.Error(exp);
                Console.WriteLine("");
                Console.WriteLine("Unexpected Error 2 in App.Application_Startup()");
                Console.WriteLine("   Message:{0}", exp.Message);
                Console.WriteLine("StackTrace:{0}", exp.StackTrace);
                Console.WriteLine("");

                // Typically thrown by MEF when module binding does not work
                if (exp is System.Reflection.ReflectionTypeLoadException)
                {
                    var loaderExcept = (exp as System.Reflection.ReflectionTypeLoadException).LoaderExceptions;

                    Console.WriteLine("Loader Exception(s):");
                    Logger.Error("Loader Exception(s):");

                    foreach (var item in loaderExcept)
                    {
                        Console.WriteLine("Message {0}:", item.Message);
                        Console.WriteLine("StackTrace {0}:", item.StackTrace);
                    }
                }

                // 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;
                    }
                }

//                var msgBox = ServiceLocator.Current.GetInstance<IMessageBoxService>();
//                msgBox.Show(exp, Strings.STR_MSG_ERROR_FINDING_RESOURCE, MsgBoxButtons.OKCopy, MsgBoxImage.Error);

                if (AppIsShuttingDown == false)
                {
                    Shutdown();
                }
            }
        }
Пример #23
0
 /// <summary>
 /// Async method to load program options from persistence (without blocking UI thread).
 /// See <seealso cref="SaveOptions"/> to load program options on program start.
 /// </summary>
 /// <param name="settingsFileName"></param>
 /// <param name="themesManager"></param>
 /// <returns></returns>
 public Task <IOptions> LoadOptionsAsync(string settingsFileName,
                                         IThemesManager themesManager,
                                         IOptions programSettings = null)
 {
     return(Task.Run(() => { return LoadOptions(settingsFileName, themesManager, programSettings); }));
 }