Example #1
0
        /// <summary>
        /// Save application settings when the application is being closed down
        /// </summary>
        public void SaveConfigOnAppClosed()
        {
            try
            {
                this.mAppCore.CreateAppDataFolder();

                // Save current explorer settings and user profile data
                // Query for an explorer tool window and return it
                // Query for an explorer tool window and return it
                var explorerTW = this.GetToolWindowVM <IExplorer>();

                if (explorerTW != null)
                {
                    FileExplorerViewModel.SaveSettings(this.mSettingsManager, explorerTW);
                }

                // Save program options only if there are un-saved changes that need persistence
                // This can be caused when WPF theme was changed or something else
                // but should normally not occur as often as saving session data
                if (this.mSettingsManager.SettingData.IsDirty == true)
                {
                    this.mSettingsManager.SaveOptions(this.mAppCore.DirFileAppSettingsData, this.mSettingsManager.SettingData);
                }

                // Convert viewmodel data into model for persistance layer...
                var mruVM = ServiceLocator.Current.GetInstance <IMRUListViewModel>();
                MRUEntrySerializer.ConvertToModel(mruVM, this.mSettingsManager.SessionData.MruList);

                this.mSettingsManager.SaveSessionData(this.mAppCore.DirFileAppSessionData, this.mSettingsManager.SessionData);
            }
            catch (Exception exp)
            {
                _MsgBox.Show(exp, "Unhandled Exception", MsgBoxButtons.OK, MsgBoxImage.Error);
            }
        }
Example #2
0
        private void SaveMRU()
        {
            string dirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MSI Viewer");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            string persistPath = Path.Combine(dirPath, "mru.dat");

            MRUEntrySerializer.Save(persistPath, MRUModel);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppModel"/> class.
        /// </summary>
        public AppModel()
        {
            string dirPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MSI Viewer");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            string persistPath = Path.Combine(dirPath, "mru.dat");

            try
            {
                MRUModel = MRUEntrySerializer.Load(persistPath);
            }
            catch (FileNotFoundException)
            {
                MRUModel = MRU_Service.Create_List();
            }
        }
Example #4
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
        }
        /// <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);
        }