Esempio n. 1
0
        private void LoadSettings()
        {
            if (!File.Exists(FilesProvider.SystemSettingsFileName))
            {
                MessageBox.Show("System settings file doesn't exists at path " + FilesProvider.SystemSettingsFileName);
                throw new FileLoadException("System settings file doesn't exists at path " + FilesProvider.SystemSettingsFileName);
            }

            if (File.Exists(FilesProvider.UserSettingsFileName))
            {
                this._settings = SettingsLoader.LoadFromXml(
                    FilesProvider.UserSettingsFileName,
                    FilesProvider.SystemSettingsFileName
                    );
            }
            else
            {
                this._settings = SettingsLoader.LoadFromXml(
                    FilesProvider.UserSettingDefaultFileName,
                    FilesProvider.SystemSettingsFileName
                    );

                SettingsLoader.SaveToXml(
                    FilesProvider.UserSettingsFileName,
                    this._settings
                    );
            }

            if (File.Exists(FilesProvider.UserLayoutSettingsFileName))
            {
                this._layoutSettings = SettingsLoader.LoadAsBaseFromXml <LayoutSettings>(
                    FilesProvider.UserLayoutSettingsFileName
                    );
            }
            else
            {
                this._layoutSettings = new LayoutSettings();

                SettingsLoader.SaveToXml(
                    FilesProvider.UserLayoutSettingsFileName,
                    this._layoutSettings
                    );
            }

            if (File.Exists(FilesProvider.UserTemplateSettingsFileName))
            {
                // this._templateSettings = SettingsLoader.LoadAsTemplateFromXml<ActivityLayoutSetting>(FilesProvider.UserTemplateSettingsFileName);
                // ActivityLayoutSetting loader = new ActivityLayoutSetting();
                this._templateSettings = new ActivityLayoutSetting();

                this._templateSettings.UserSettings = SettingsLoader.LoadAsTemplateFromXml <List <InstanceTemplate> >(
                    FilesProvider.UserTemplateSettingsFileName
                    );
            }
            else
            {
                this._templateSettings = new ActivityLayoutSetting();

                SettingsLoader.SaveTemplateToXml(
                    FilesProvider.UserTemplateSettingsFileName,
                    this._templateSettings
                    );
            }
        }