Beispiel #1
0
        /// <summary>
        /// 設定をファイルに書き出す
        /// </summary>
        /// <param name="file_name">書きだしたい設定</param>
        /// <param name="file_name">設定ファイルパス</param>
        public static void SaveToFile( ProgramSetting setting, String file_name )
        {
            var serializer = new System.Xml.Serialization.XmlSerializer( typeof(ProgramSetting) );

            using( var fs = new System.IO.FileStream( file_name, System.IO.FileMode.Create ) ) {
                serializer.Serialize( fs, setting );
            }
        }
Beispiel #2
0
        /// <summary>
        /// 設定ファイルを読み込んでプログラムをセットアップする
        /// </summary>
        private void SettingSetup()
        {
            try {
                if( System.IO.File.Exists( Program.SettingFileName ) ) {
                    this.setting_ = WP7_2012ULV.Setting.ProgramSetting.LoadFromFile( Program.SettingFileName );
                } else {
                    this.setting_ = WP7_2012ULV.Setting.ProgramSetting.DefaultSetting;
                }
            } catch {
                MessageBox.Show( "設定の読み込みに失敗しました", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                this.setting_ = WP7_2012ULV.Setting.ProgramSetting.DefaultSetting;
            }

            try {
                var file_name = String.Format( "{0}\\{1}", this.ExtenstionsDir, Program.EXTENSIONS_SETTING_FILE_NAME );

                if( System.IO.File.Exists( file_name ) ) {
                    this.extension_setting_ = WP7_2012ULV.Setting.ExtensionSetting.Setting.LoadFromFile( file_name );
                } else {
                    this.extension_setting_ = WP7_2012ULV.Setting.ExtensionSetting.Setting.DefaultExtensionSetting;
                }
            } catch {
                MessageBox.Show( "拡張機能設定の読み込みに失敗しました", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                this.extension_setting_ = WP7_2012ULV.Setting.ExtensionSetting.Setting.DefaultExtensionSetting;
            }

            try {
                if( !System.IO.File.Exists( Program.VersionSettingFileName ) ) {
                    MessageBox.Show( "バージョン情報設定ファイルがありません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
                    this.version_setting_ = WP7_2012ULV.Setting.WPVersionConfig.DefaultExtensionSetting;
                } else {
                    this.version_setting_ = WP7_2012ULV.Setting.WPVersionConfig.LoadFromFile( Program.VersionSettingFileName );
                }
            }  catch {
                MessageBox.Show( "バージョン設定の読み込みに失敗しました", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error );
            }

            this.FromSetting( this.setting_.MainFormSetting );
        }