/// <summary>
        /// 設定からUIを初期化します。
        /// </summary>
        public void FromConfiguration( Configuration.ConfigurationData config )
        {
            //[通信]
            Connection_Port.Value = config.Connection.Port;
            Connection_SaveReceivedData.Checked = config.Connection.SaveReceivedData;
            Connection_SaveDataPath.Text = config.Connection.SaveDataPath;
            Connection_SaveRequest.Checked = config.Connection.SaveRequest;
            Connection_SaveResponse.Checked = config.Connection.SaveResponse;
            Connection_SaveSWF.Checked = config.Connection.SaveSWF;
            Connection_SaveOtherFile.Checked = config.Connection.SaveOtherFile;
            Connection_ApplyVersion.Checked = config.Connection.ApplyVersion;
            Connection_RegisterAsSystemProxy.Checked = config.Connection.RegisterAsSystemProxy;
            Connection_UseUpstreamProxy.Checked = config.Connection.UseUpstreamProxy;
            Connection_UpstreamProxyPort.Value = config.Connection.UpstreamProxyPort;
            Connection_UpstreamProxyAddress.Text = config.Connection.UpstreamProxyAddress;
            Connection_UseSystemProxy.Checked = config.Connection.UseSystemProxy;
            Connection_DownstreamProxy.Text = config.Connection.DownstreamProxy;

            //[UI]
            UI_MainFont.Font = config.UI.MainFont.FontData;
            UI_MainFont.Text = config.UI.MainFont.SerializeFontAttribute;
            UI_SubFont.Font = config.UI.SubFont.FontData;
            UI_SubFont.Text = config.UI.SubFont.SerializeFontAttribute;
            UI_BarColorMorphing.Checked = config.UI.BarColorMorphing;

            //[ログ]
            Log_LogLevel.Value = config.Log.LogLevel;
            Log_SaveLogFlag.Checked = config.Log.SaveLogFlag;
            Log_SaveErrorReport.Checked = config.Log.SaveErrorReport;
            Log_FileEncodingID.SelectedIndex = config.Log.FileEncodingID;
            Log_ShowSpoiler.Checked = config.Log.ShowSpoiler;

            //[動作]
            Control_ConditionBorder.Value = config.Control.ConditionBorder;
            Control_RecordAutoSaving.SelectedIndex = config.Control.RecordAutoSaving;
            Control_UseSystemVolume.Checked = config.Control.UseSystemVolume;
            Control_PowerEngagementForm.SelectedIndex = config.Control.PowerEngagementForm - 1;

            //[デバッグ]
            Debug_EnableDebugMenu.Checked = config.Debug.EnableDebugMenu;
            Debug_LoadAPIListOnLoad.Checked = config.Debug.LoadAPIListOnLoad;
            Debug_APIListPath.Text = config.Debug.APIListPath;
            Debug_AlertOnError.Checked = config.Debug.AlertOnError;

            //[起動と終了]
            Life_ConfirmOnClosing.Checked = config.Life.ConfirmOnClosing;
            Life_TopMost.Checked = this.TopMost = config.Life.TopMost;		//メインウィンドウに隠れないように
            Life_LayoutFilePath.Text = config.Life.LayoutFilePath;
            Life_CheckUpdateInformation.Checked = config.Life.CheckUpdateInformation;
            Life_ShowStatusBar.Checked = config.Life.ShowStatusBar;
            Life_ClockFormat.SelectedIndex = config.Life.ClockFormat;
            Life_LockLayout.Checked = config.Life.LockLayout;
            Life_CanCloseFloatWindowInLock.Checked = config.Life.CanCloseFloatWindowInLock;

            //[サブウィンドウ]
            FormArsenal_ShowShipName.Checked = config.FormArsenal.ShowShipName;
            FormArsenal_BlinkAtCompletion.Checked = config.FormArsenal.BlinkAtCompletion;

            FormDock_BlinkAtCompletion.Checked = config.FormDock.BlinkAtCompletion;

            FormFleet_ShowAircraft.Checked = config.FormFleet.ShowAircraft;
            FormFleet_SearchingAbilityMethod.SelectedIndex = config.FormFleet.SearchingAbilityMethod;
            FormFleet_IsScrollable.Checked = config.FormFleet.IsScrollable;
            FormFleet_FixShipNameWidth.Checked = config.FormFleet.FixShipNameWidth;
            FormFleet_ShortenHPBar.Checked = config.FormFleet.ShortenHPBar;
            FormFleet_ShowNextExp.Checked = config.FormFleet.ShowNextExp;
            FormFleet_EquipmentLevelVisibility.SelectedIndex = (int)config.FormFleet.EquipmentLevelVisibility;
            FormFleet_AirSuperiorityMethod.SelectedIndex = config.FormFleet.AirSuperiorityMethod;
            FormFleet_ShowAnchorageRepairingTimer.Checked = config.FormFleet.ShowAnchorageRepairingTimer;
            FormFleet_BlinkAtCompletion.Checked = config.FormFleet.BlinkAtCompletion;

            FormHeadquarters_BlinkAtMaximum.Checked = config.FormHeadquarters.BlinkAtMaximum;
            FormHeadquarters_Visibility.Items.Clear();
            FormHeadquarters_Visibility.Items.AddRange( FormHeadquarters.GetItemNames().ToArray() );
            FormHeadquarters.CheckVisibilityConfiguration();
            for ( int i = 0; i < FormHeadquarters_Visibility.Items.Count; i++ ) {
                FormHeadquarters_Visibility.SetItemChecked( i, config.FormHeadquarters.Visibility.List[i] );
            }

            FormQuest_ShowRunningOnly.Checked = config.FormQuest.ShowRunningOnly;
            FormQuest_ShowOnce.Checked = config.FormQuest.ShowOnce;
            FormQuest_ShowDaily.Checked = config.FormQuest.ShowDaily;
            FormQuest_ShowWeekly.Checked = config.FormQuest.ShowWeekly;
            FormQuest_ShowMonthly.Checked = config.FormQuest.ShowMonthly;
            FormQuest_ProgressAutoSaving.SelectedIndex = config.FormQuest.ProgressAutoSaving;
            FormQuest_AllowUserToSortRows.Checked = config.FormQuest.AllowUserToSortRows;

            FormShipGroup_AutoUpdate.Checked = config.FormShipGroup.AutoUpdate;
            FormShipGroup_ShowStatusBar.Checked = config.FormShipGroup.ShowStatusBar;
            FormShipGroup_ShipNameSortMethod.SelectedIndex = config.FormShipGroup.ShipNameSortMethod;

            FormBrowser_IsEnabled.Checked = config.FormBrowser.IsEnabled;
            FormBrowser_ZoomRate.Value = config.FormBrowser.ZoomRate;
            FormBrowser_ZoomFit.Checked = config.FormBrowser.ZoomFit;
            FormBrowser_LogInPageURL.Text = config.FormBrowser.LogInPageURL;
            FormBrowser_ScreenShotFormat_JPEG.Checked = config.FormBrowser.ScreenShotFormat == 1;
            FormBrowser_ScreenShotFormat_PNG.Checked = config.FormBrowser.ScreenShotFormat == 2;
            FormBrowser_ScreenShotPath.Text = config.FormBrowser.ScreenShotPath;
            FormBrowser_ConfirmAtRefresh.Checked = config.FormBrowser.ConfirmAtRefresh;
            FormBrowser_AppliesStyleSheet.Checked = config.FormBrowser.AppliesStyleSheet;
            {
                Microsoft.Win32.RegistryKey reg = null;
                try {

                    reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( RegistryPathMaster + RegistryPathBrowserVersion );
                    if ( reg == null ) {
                        FormBrowser_BrowserVersion.Text = DefaultBrowserVersion.ToString();

                    } else {
                        FormBrowser_BrowserVersion.Text = ( reg.GetValue( FormBrowserHost.BrowserExeName ) ?? DefaultBrowserVersion ).ToString();
                    }
                    if ( reg != null )
                        reg.Close();

                    reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( RegistryPathMaster + RegistryPathGPURendering );
                    if ( reg == null ) {
                        FormBrowser_GPURendering.Checked = DefaultGPURendering;

                    } else {
                        int? gpu = reg.GetValue( FormBrowserHost.BrowserExeName ) as int?;
                        FormBrowser_GPURendering.Checked = gpu != null ? gpu != 0 : DefaultGPURendering;
                    }

                } catch ( Exception ex ) {

                    FormBrowser_BrowserVersion.Text = DefaultBrowserVersion.ToString();
                    FormBrowser_GPURendering.Checked = DefaultGPURendering;

                    Utility.Logger.Add( 3, "レジストリからの読み込みに失敗しました。" + ex.Message );

                } finally {
                    if ( reg != null )
                        reg.Close();

                }
            }
            FormBrowser_FlashQuality.Text = config.FormBrowser.FlashQuality;
            FormBrowser_FlashWMode.Text = config.FormBrowser.FlashWMode;

            FormCompass_CandidateDisplayCount.Value = config.FormCompass.CandidateDisplayCount;

            //[データベース]
            Database_SendDataToKancolleDB.Checked = config.Connection.SendDataToKancolleDB;
            Database_SendKancolleOAuth.Text = config.Connection.SendKancolleOAuth;

            //[BGM]
            BGMPlayer_Enabled.Checked = config.BGMPlayer.Enabled;
            BGMHandles = config.BGMPlayer.Handles.ToDictionary( h => h.HandleID );
            BGMPlayer_SyncBrowserMute.Checked = config.BGMPlayer.SyncBrowserMute;
            UpdateBGMPlayerUI();

            //finalize
            UpdateParameter();
        }
 public DialogConfiguration( Configuration.ConfigurationData config )
     : this()
 {
     FromConfiguration( config );
 }
        /// <summary>
        /// UIをもとに設定を適用します。
        /// </summary>
        public void ToConfiguration( Configuration.ConfigurationData config )
        {
            //[通信]
            {
                bool changed = false;

                changed |= config.Connection.Port != (ushort)Connection_Port.Value;
                config.Connection.Port = (ushort)Connection_Port.Value;

                config.Connection.SaveReceivedData = Connection_SaveReceivedData.Checked;
                config.Connection.SaveDataPath = Connection_SaveDataPath.Text.Trim( @"\ """.ToCharArray() );
                config.Connection.SaveRequest = Connection_SaveRequest.Checked;
                config.Connection.SaveResponse = Connection_SaveResponse.Checked;
                config.Connection.SaveSWF = Connection_SaveSWF.Checked;
                config.Connection.SaveOtherFile = Connection_SaveOtherFile.Checked;
                config.Connection.ApplyVersion = Connection_ApplyVersion.Checked;

                changed |= config.Connection.RegisterAsSystemProxy != Connection_RegisterAsSystemProxy.Checked;
                config.Connection.RegisterAsSystemProxy = Connection_RegisterAsSystemProxy.Checked;

                changed |= config.Connection.UseUpstreamProxy != Connection_UseUpstreamProxy.Checked;
                config.Connection.UseUpstreamProxy = Connection_UseUpstreamProxy.Checked;
                changed |= config.Connection.UpstreamProxyPort != (ushort)Connection_UpstreamProxyPort.Value;
                config.Connection.UpstreamProxyPort = (ushort)Connection_UpstreamProxyPort.Value;
                changed |= config.Connection.UpstreamProxyAddress != Connection_UpstreamProxyAddress.Text;
                config.Connection.UpstreamProxyAddress = Connection_UpstreamProxyAddress.Text;

                changed |= config.Connection.UseSystemProxy != Connection_UseSystemProxy.Checked;
                config.Connection.UseSystemProxy = Connection_UseSystemProxy.Checked;

                changed |= config.Connection.DownstreamProxy != Connection_DownstreamProxy.Text;
                config.Connection.DownstreamProxy = Connection_DownstreamProxy.Text;

                if ( changed ) {
                    APIObserver.Instance.Start( config.Connection.Port, _UIControl );
                }

            }

            //[UI]
            config.UI.MainFont = UI_MainFont.Font;
            config.UI.SubFont = UI_SubFont.Font;
            config.UI.BarColorMorphing = UI_BarColorMorphing.Checked;

            //[ログ]
            config.Log.LogLevel = (int)Log_LogLevel.Value;
            config.Log.SaveLogFlag = Log_SaveLogFlag.Checked;
            config.Log.SaveErrorReport = Log_SaveErrorReport.Checked;
            config.Log.FileEncodingID = Log_FileEncodingID.SelectedIndex;
            config.Log.ShowSpoiler = Log_ShowSpoiler.Checked;

            //[動作]
            config.Control.ConditionBorder = (int)Control_ConditionBorder.Value;
            config.Control.RecordAutoSaving = Control_RecordAutoSaving.SelectedIndex;
            config.Control.UseSystemVolume = Control_UseSystemVolume.Checked;
            config.Control.PowerEngagementForm = Control_PowerEngagementForm.SelectedIndex + 1;

            //[デバッグ]
            config.Debug.EnableDebugMenu = Debug_EnableDebugMenu.Checked;
            config.Debug.LoadAPIListOnLoad = Debug_LoadAPIListOnLoad.Checked;
            config.Debug.APIListPath = Debug_APIListPath.Text;
            config.Debug.AlertOnError = Debug_AlertOnError.Checked;

            //[起動と終了]
            config.Life.ConfirmOnClosing = Life_ConfirmOnClosing.Checked;
            config.Life.TopMost = Life_TopMost.Checked;
            config.Life.LayoutFilePath = Life_LayoutFilePath.Text;
            config.Life.CheckUpdateInformation = Life_CheckUpdateInformation.Checked;
            config.Life.ShowStatusBar = Life_ShowStatusBar.Checked;
            config.Life.ClockFormat = Life_ClockFormat.SelectedIndex;
            config.Life.LockLayout = Life_LockLayout.Checked;
            config.Life.CanCloseFloatWindowInLock = Life_CanCloseFloatWindowInLock.Checked;

            //[サブウィンドウ]
            config.FormArsenal.ShowShipName = FormArsenal_ShowShipName.Checked;
            config.FormArsenal.BlinkAtCompletion = FormArsenal_BlinkAtCompletion.Checked;

            config.FormDock.BlinkAtCompletion = FormDock_BlinkAtCompletion.Checked;

            config.FormFleet.ShowAircraft = FormFleet_ShowAircraft.Checked;
            config.FormFleet.SearchingAbilityMethod = FormFleet_SearchingAbilityMethod.SelectedIndex;
            config.FormFleet.IsScrollable = FormFleet_IsScrollable.Checked;
            config.FormFleet.FixShipNameWidth = FormFleet_FixShipNameWidth.Checked;
            config.FormFleet.ShortenHPBar = FormFleet_ShortenHPBar.Checked;
            config.FormFleet.ShowNextExp = FormFleet_ShowNextExp.Checked;
            config.FormFleet.EquipmentLevelVisibility = (Window.Control.ShipStatusEquipment.LevelVisibilityFlag)FormFleet_EquipmentLevelVisibility.SelectedIndex;
            config.FormFleet.AirSuperiorityMethod = FormFleet_AirSuperiorityMethod.SelectedIndex;
            config.FormFleet.ShowAnchorageRepairingTimer = FormFleet_ShowAnchorageRepairingTimer.Checked;
            config.FormFleet.BlinkAtCompletion = FormFleet_BlinkAtCompletion.Checked;

            config.FormHeadquarters.BlinkAtMaximum = FormHeadquarters_BlinkAtMaximum.Checked;
            {
                var list = new List<bool>();
                for ( int i = 0; i < FormHeadquarters_Visibility.Items.Count; i++ )
                    list.Add( FormHeadquarters_Visibility.GetItemChecked( i ) );
                config.FormHeadquarters.Visibility.List = list;
            }

            config.FormQuest.ShowRunningOnly = FormQuest_ShowRunningOnly.Checked;
            config.FormQuest.ShowOnce = FormQuest_ShowOnce.Checked;
            config.FormQuest.ShowDaily = FormQuest_ShowDaily.Checked;
            config.FormQuest.ShowWeekly = FormQuest_ShowWeekly.Checked;
            config.FormQuest.ShowMonthly = FormQuest_ShowMonthly.Checked;
            config.FormQuest.ProgressAutoSaving = FormQuest_ProgressAutoSaving.SelectedIndex;
            config.FormQuest.AllowUserToSortRows = FormQuest_AllowUserToSortRows.Checked;

            config.FormShipGroup.AutoUpdate = FormShipGroup_AutoUpdate.Checked;
            config.FormShipGroup.ShowStatusBar = FormShipGroup_ShowStatusBar.Checked;
            config.FormShipGroup.ShipNameSortMethod = FormShipGroup_ShipNameSortMethod.SelectedIndex;

            config.FormBrowser.IsEnabled = FormBrowser_IsEnabled.Checked;
            config.FormBrowser.ZoomRate = (int)FormBrowser_ZoomRate.Value;
            config.FormBrowser.ZoomFit = FormBrowser_ZoomFit.Checked;
            config.FormBrowser.LogInPageURL = FormBrowser_LogInPageURL.Text;
            if ( FormBrowser_ScreenShotFormat_JPEG.Checked )
                config.FormBrowser.ScreenShotFormat = 1;
            else
                config.FormBrowser.ScreenShotFormat = 2;
            config.FormBrowser.ScreenShotPath = FormBrowser_ScreenShotPath.Text;
            config.FormBrowser.ConfirmAtRefresh = FormBrowser_ConfirmAtRefresh.Checked;
            config.FormBrowser.AppliesStyleSheet = FormBrowser_AppliesStyleSheet.Checked;
            config.FormBrowser.FlashQuality = FormBrowser_FlashQuality.Text;
            config.FormBrowser.FlashWMode = FormBrowser_FlashWMode.Text;

            config.FormCompass.CandidateDisplayCount = (int)FormCompass_CandidateDisplayCount.Value;

            //[データベース]
            config.Connection.SendDataToKancolleDB = Database_SendDataToKancolleDB.Checked;
            config.Connection.SendKancolleOAuth = Database_SendKancolleOAuth.Text;

            //[BGM]
            config.BGMPlayer.Enabled = BGMPlayer_Enabled.Checked;
            for ( int i = 0; i < BGMPlayer_ControlGrid.Rows.Count; i++ ) {
                BGMHandles[(SyncBGMPlayer.SoundHandleID)BGMPlayer_ControlGrid[BGMPlayer_ColumnContent.Index, i].Value].Enabled = (bool)BGMPlayer_ControlGrid[BGMPlayer_ColumnEnabled.Index, i].Value;
            }
            config.BGMPlayer.Handles = new List<SyncBGMPlayer.SoundHandle>( BGMHandles.Values.ToList() );
            config.BGMPlayer.SyncBrowserMute = BGMPlayer_SyncBrowserMute.Checked;
        }
        /// <summary>
        /// 設定からUIを初期化します。
        /// </summary>
        public void FromConfiguration( Configuration.ConfigurationData config )
        {
            //[通信]
            Connection_Port.Value = config.Connection.Port;
            Connection_SaveReceivedData.Checked = config.Connection.SaveReceivedData;
            Connection_SaveDataFilter.Text = config.Connection.SaveDataFilter;
            Connection_SaveDataPath.Text = config.Connection.SaveDataPath;
            Connection_SaveRequest.Checked = config.Connection.SaveRequest;
            Connection_SaveResponse.Checked = config.Connection.SaveResponse;
            Connection_SaveSWF.Checked = config.Connection.SaveSWF;
            Connection_SaveOtherFile.Checked = config.Connection.SaveOtherFile;
            Connection_ApplyVersion.Checked = config.Connection.ApplyVersion;
            Connection_RegisterAsSystemProxy.Checked = config.Connection.RegisterAsSystemProxy;
            Connection_UseUpstreamProxy.Checked = config.Connection.UseUpstreamProxy;
            Connection_UpstreamProxyPort.Value = config.Connection.UpstreamProxyPort;

            //[UI]
            UI_MainFont.Font = config.UI.MainFont.FontData;
            UI_MainFont.Text = config.UI.MainFont.SerializeFontAttribute;
            UI_SubFont.Font = config.UI.SubFont.FontData;
            UI_SubFont.Text = config.UI.SubFont.SerializeFontAttribute;

            //[ログ]
            Log_LogLevel.Value = config.Log.LogLevel;
            Log_SaveLogFlag.Checked = config.Log.SaveLogFlag;
            Log_SaveErrorReport.Checked = config.Log.SaveErrorReport;
            Log_FileEncodingID.SelectedIndex = config.Log.FileEncodingID;
            Log_ShowSpoiler.Checked = config.Log.ShowSpoiler;

            //[動作]
            Control_ConditionBorder.Value = config.Control.ConditionBorder;

            //[デバッグ]
            Debug_EnableDebugMenu.Checked = config.Debug.EnableDebugMenu;
            Debug_LoadAPIListOnLoad.Checked = config.Debug.LoadAPIListOnLoad;
            Debug_APIListPath.Text = config.Debug.APIListPath;

            //[起動と終了]
            Life_ConfirmOnClosing.Checked = config.Life.ConfirmOnClosing;
            Life_TopMost.Checked = this.TopMost = config.Life.TopMost;		//メインウィンドウに隠れないように
            Life_LayoutFilePath.Text = config.Life.LayoutFilePath;
            Life_CheckUpdateInformation.Checked = config.Life.CheckUpdateInformation;
            Life_ShowStatusBar.Checked = config.Life.ShowStatusBar;

            //[サブウィンドウ]
            FormArsenal_ShowShipName.Checked = config.FormArsenal.ShowShipName;

            FormFleet_ShowAircraft.Checked = config.FormFleet.ShowAircraft;
            FormFleet_SearchingAbilityMethod.SelectedIndex = config.FormFleet.SearchingAbilityMethod;
            FormFleet_IsScrollable.Checked = config.FormFleet.IsScrollable;
            FormFleet_FixShipNameWidth.Checked = config.FormFleet.FixShipNameWidth;
            FormFleet_ShortenHPBar.Checked = config.FormFleet.ShortenHPBar;
            FormFleet_ShowNextExp.Checked = config.FormFleet.ShowNextExp;
            FormFleet_ShowEquipmentLevel.Checked = config.FormFleet.ShowEquipmentLevel;
            FormFleet_AirSuperiorityMethod.SelectedIndex = config.FormFleet.AirSuperiorityMethod;

            FormHeadquarters_BlinkAtMaximum.Checked = config.FormHeadquarters.BlinkAtMaximum;

            FormQuest_ShowRunningOnly.Checked = config.FormQuest.ShowRunningOnly;
            FormQuest_ShowOnce.Checked = config.FormQuest.ShowOnce;
            FormQuest_ShowDaily.Checked = config.FormQuest.ShowDaily;
            FormQuest_ShowWeekly.Checked = config.FormQuest.ShowWeekly;
            FormQuest_ShowMonthly.Checked = config.FormQuest.ShowMonthly;

            FormShipGroup_AutoUpdate.Checked = config.FormShipGroup.AutoUpdate;
            FormShipGroup_ShowStatusBar.Checked = config.FormShipGroup.ShowStatusBar;

            FormBrowser_IsEnabled.Checked = config.FormBrowser.IsEnabled;
            FormBrowser_ZoomRate.Value = config.FormBrowser.ZoomRate;
            FormBrowser_ZoomFit.Checked = config.FormBrowser.ZoomFit;
            FormBrowser_LogInPageURL.Text = config.FormBrowser.LogInPageURL;
            FormBrowser_ScreenShotFormat_JPEG.Checked = config.FormBrowser.ScreenShotFormat == 1;
            FormBrowser_ScreenShotFormat_PNG.Checked = config.FormBrowser.ScreenShotFormat == 2;
            FormBrowser_ScreenShotPath.Text = config.FormBrowser.ScreenShotPath;
            FormBrowser_ConfirmAtRefresh.Checked = config.FormBrowser.ConfirmAtRefresh;
            FormBrowser_AppliesStyleSheet.Checked = config.FormBrowser.AppliesStyleSheet;
            {
                Microsoft.Win32.RegistryKey reg = null;
                try {

                    reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( RegistryPathMaster + RegistryPathBrowserVersion );
                    if ( reg == null ) {
                        FormBrowser_BrowserVersion.Text = DefaultBrowserVersion.ToString();

                    } else {
                        FormBrowser_BrowserVersion.Text = ( reg.GetValue( FormBrowserHost.BrowserExeName ) ?? DefaultBrowserVersion ).ToString();
                    }
                    reg.Close();

                    reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( RegistryPathMaster + RegistryPathGPURendering );
                    if ( reg == null ) {
                        FormBrowser_GPURendering.Checked = DefaultGPURendering;

                    } else {
                        int? gpu = reg.GetValue( FormBrowserHost.BrowserExeName ) as int?;
                        FormBrowser_GPURendering.Checked = gpu != null ? gpu != 0 : DefaultGPURendering;
                    }

                } catch ( Exception ex ) {

                    FormBrowser_BrowserVersion.Text = DefaultBrowserVersion.ToString();
                    FormBrowser_GPURendering.Checked = DefaultGPURendering;

                    Utility.Logger.Add( 3, "レジストリからの読み込みに失敗しました。" + ex.Message );

                } finally {
                    if ( reg != null )
                        reg.Close();

                }
            }
            FormBrowser_FlashQuality.Text = config.FormBrowser.FlashQuality;
            FormBrowser_FlashWMode.Text = config.FormBrowser.FlashWMode;

            //[データベース]
            Database_SendDataToKancolleDB.Checked = config.Connection.SendDataToKancolleDB;
            Database_SendKancolleOAuth.Text = config.Connection.SendKancolleOAuth;

            //finalize
            UpdateParameter();
        }
        /// <summary>
        /// UIをもとに設定を適用します。
        /// </summary>
        public void ToConfiguration( Configuration.ConfigurationData config )
        {
            //[通信]
            {
                bool changed = false;

                changed |= config.Connection.Port != (ushort)Connection_Port.Value;
                config.Connection.Port = (ushort)Connection_Port.Value;

                config.Connection.SaveReceivedData = Connection_SaveReceivedData.Checked;
                config.Connection.SaveDataFilter = Connection_SaveDataFilter.Text;
                config.Connection.SaveDataPath = Connection_SaveDataPath.Text.Trim( @"\ """.ToCharArray() );
                config.Connection.SaveRequest = Connection_SaveRequest.Checked;
                config.Connection.SaveResponse = Connection_SaveResponse.Checked;
                config.Connection.SaveSWF = Connection_SaveSWF.Checked;
                config.Connection.SaveOtherFile = Connection_SaveOtherFile.Checked;
                config.Connection.ApplyVersion = Connection_ApplyVersion.Checked;

                changed |= config.Connection.RegisterAsSystemProxy != Connection_RegisterAsSystemProxy.Checked;
                config.Connection.RegisterAsSystemProxy = Connection_RegisterAsSystemProxy.Checked;

                config.Connection.UseUpstreamProxy = Connection_UseUpstreamProxy.Checked;
                config.Connection.UpstreamProxyPort = (ushort)Connection_UpstreamProxyPort.Value;

                if ( changed ) {
                    APIObserver.Instance.Stop();
                    APIObserver.Instance.Start( config.Connection.Port, this );
                }

            }

            //[UI]
            config.UI.MainFont = UI_MainFont.Font;
            config.UI.SubFont = UI_SubFont.Font;

            //[ログ]
            config.Log.LogLevel = (int)Log_LogLevel.Value;
            config.Log.SaveLogFlag = Log_SaveLogFlag.Checked;
            config.Log.SaveErrorReport = Log_SaveErrorReport.Checked;
            config.Log.FileEncodingID = Log_FileEncodingID.SelectedIndex;
            config.Log.ShowSpoiler = Log_ShowSpoiler.Checked;

            //[動作]
            config.Control.ConditionBorder = (int)Control_ConditionBorder.Value;

            //[デバッグ]
            config.Debug.EnableDebugMenu = Debug_EnableDebugMenu.Checked;
            config.Debug.LoadAPIListOnLoad = Debug_LoadAPIListOnLoad.Checked;
            config.Debug.APIListPath = Debug_APIListPath.Text;

            //[起動と終了]
            config.Life.ConfirmOnClosing = Life_ConfirmOnClosing.Checked;
            config.Life.TopMost = Life_TopMost.Checked;
            config.Life.LayoutFilePath = Life_LayoutFilePath.Text;
            config.Life.CheckUpdateInformation = Life_CheckUpdateInformation.Checked;
            config.Life.ShowStatusBar = Life_ShowStatusBar.Checked;

            //[サブウィンドウ]
            config.FormArsenal.ShowShipName = FormArsenal_ShowShipName.Checked;

            config.FormFleet.ShowAircraft = FormFleet_ShowAircraft.Checked;
            config.FormFleet.SearchingAbilityMethod = FormFleet_SearchingAbilityMethod.SelectedIndex;
            config.FormFleet.IsScrollable = FormFleet_IsScrollable.Checked;
            config.FormFleet.FixShipNameWidth = FormFleet_FixShipNameWidth.Checked;
            config.FormFleet.ShortenHPBar = FormFleet_ShortenHPBar.Checked;
            config.FormFleet.ShowNextExp = FormFleet_ShowNextExp.Checked;
            config.FormFleet.ShowEquipmentLevel = FormFleet_ShowEquipmentLevel.Checked;
            config.FormFleet.AirSuperiorityMethod = FormFleet_AirSuperiorityMethod.SelectedIndex;

            config.FormHeadquarters.BlinkAtMaximum = FormHeadquarters_BlinkAtMaximum.Checked;

            config.FormQuest.ShowRunningOnly = FormQuest_ShowRunningOnly.Checked;
            config.FormQuest.ShowOnce = FormQuest_ShowOnce.Checked;
            config.FormQuest.ShowDaily = FormQuest_ShowDaily.Checked;
            config.FormQuest.ShowWeekly = FormQuest_ShowWeekly.Checked;
            config.FormQuest.ShowMonthly = FormQuest_ShowMonthly.Checked;

            config.FormShipGroup.AutoUpdate = FormShipGroup_AutoUpdate.Checked;
            config.FormShipGroup.ShowStatusBar = FormShipGroup_ShowStatusBar.Checked;

            config.FormBrowser.IsEnabled = FormBrowser_IsEnabled.Checked;
            config.FormBrowser.ZoomRate = (int)FormBrowser_ZoomRate.Value;
            config.FormBrowser.ZoomFit = FormBrowser_ZoomFit.Checked;
            config.FormBrowser.LogInPageURL = FormBrowser_LogInPageURL.Text;
            if ( FormBrowser_ScreenShotFormat_JPEG.Checked )
                config.FormBrowser.ScreenShotFormat = 1;
            else
                config.FormBrowser.ScreenShotFormat = 2;
            config.FormBrowser.ScreenShotPath = FormBrowser_ScreenShotPath.Text;
            config.FormBrowser.ConfirmAtRefresh = FormBrowser_ConfirmAtRefresh.Checked;
            config.FormBrowser.AppliesStyleSheet = FormBrowser_AppliesStyleSheet.Checked;
            config.FormBrowser.FlashQuality = FormBrowser_FlashQuality.Text;
            config.FormBrowser.FlashWMode = FormBrowser_FlashWMode.Text;

            //[データベース]
            config.Connection.SendDataToKancolleDB = Database_SendDataToKancolleDB.Checked;
            config.Connection.SendKancolleOAuth = Database_SendKancolleOAuth.Text;
        }
        /// <summary>
        /// 設定からUIを初期化します。
        /// </summary>
        public void FromConfiguration( Configuration.ConfigurationData config )
        {
            //[通信]
            Connection_Port.Value = config.Connection.Port;
            Connection_SaveReceivedData.Checked = config.Connection.SaveReceivedData;
            Connection_SaveDataPath.Text = config.Connection.SaveDataPath;
            Connection_SaveRequest.Checked = config.Connection.SaveRequest;
            Connection_SaveResponse.Checked = config.Connection.SaveResponse;
            Connection_SaveSWF.Checked = config.Connection.SaveSWF;
            Connection_SaveOtherFile.Checked = config.Connection.SaveOtherFile;
            Connection_ApplyVersion.Checked = config.Connection.ApplyVersion;
            Connection_RegisterAsSystemProxy.Checked = config.Connection.RegisterAsSystemProxy;
            Connection_UseUpstreamProxy.Checked = config.Connection.UseUpstreamProxy;
            Connection_UpstreamProxyPort.Value = config.Connection.UpstreamProxyPort;
            Connection_UpstreamProxyAddress.Text = config.Connection.UpstreamProxyAddress;
            Connection_UseSystemProxy.Checked = config.Connection.UseSystemProxy;
            Connection_DownstreamProxy.Text = config.Connection.DownstreamProxy;

            //[UI]
            UI_MainFont.Font = config.UI.MainFont.FontData;
            UI_MainFont.Text = config.UI.MainFont.SerializeFontAttribute;
            UI_SubFont.Font = config.UI.SubFont.FontData;
            UI_SubFont.Text = config.UI.SubFont.SerializeFontAttribute;
            UI_BarColorMorphing.Checked = config.UI.BarColorMorphing;

            //[ログ]
            Log_LogLevel.Value = config.Log.LogLevel;
            Log_SaveLogFlag.Checked = config.Log.SaveLogFlag;
            Log_SaveErrorReport.Checked = config.Log.SaveErrorReport;
            Log_FileEncodingID.SelectedIndex = config.Log.FileEncodingID;
            Log_ShowSpoiler.Checked = config.Log.ShowSpoiler;

            //[動作]
            Control_ConditionBorder.Value = config.Control.ConditionBorder;
            Control_RecordAutoSaving.SelectedIndex = config.Control.RecordAutoSaving;
            Control_UseSystemVolume.Checked = config.Control.UseSystemVolume;
            Control_ConditionTimeLag.Value = config.Control.ConditionTimeLag;
            Control_PowerEngagementForm.SelectedIndex = config.Control.PowerEngagementForm - 1;

            //[デバッグ]
            Debug_EnableDebugMenu.Checked = config.Debug.EnableDebugMenu;
            Debug_LoadAPIListOnLoad.Checked = config.Debug.LoadAPIListOnLoad;
            Debug_APIListPath.Text = config.Debug.APIListPath;
            Debug_AlertOnError.Checked = config.Debug.AlertOnError;

            //[起動と終了]
            Life_ConfirmOnClosing.Checked = config.Life.ConfirmOnClosing;
            Life_TopMost.Checked = this.TopMost = config.Life.TopMost;		//メインウィンドウに隠れないように
            Life_LayoutFilePath.Text = config.Life.LayoutFilePath;
            Life_CheckUpdateInformation.Checked = config.Life.CheckUpdateInformation;
            Life_ShowStatusBar.Checked = config.Life.ShowStatusBar;
            Life_ClockFormat.SelectedIndex = config.Life.ClockFormat;
            Life_LockLayout.Checked = config.Life.LockLayout;
            Life_CanCloseFloatWindowInLock.Checked = config.Life.CanCloseFloatWindowInLock;

            //[サブウィンドウ]
            FormArsenal_ShowShipName.Checked = config.FormArsenal.ShowShipName;
            FormArsenal_BlinkAtCompletion.Checked = config.FormArsenal.BlinkAtCompletion;

            FormDock_BlinkAtCompletion.Checked = config.FormDock.BlinkAtCompletion;

            FormFleet_ShowAircraft.Checked = config.FormFleet.ShowAircraft;
            FormFleet_SearchingAbilityMethod.SelectedIndex = config.FormFleet.SearchingAbilityMethod;
            FormFleet_IsScrollable.Checked = config.FormFleet.IsScrollable;
            FormFleet_FixShipNameWidth.Checked = config.FormFleet.FixShipNameWidth;
            FormFleet_ShortenHPBar.Checked = config.FormFleet.ShortenHPBar;
            FormFleet_ShowNextExp.Checked = config.FormFleet.ShowNextExp;
            FormFleet_EquipmentLevelVisibility.SelectedIndex = (int)config.FormFleet.EquipmentLevelVisibility;
            FormFleet_AirSuperiorityMethod.SelectedIndex = config.FormFleet.AirSuperiorityMethod;
            FormFleet_ShowAnchorageRepairingTimer.Checked = config.FormFleet.ShowAnchorageRepairingTimer;
            FormFleet_BlinkAtCompletion.Checked = config.FormFleet.BlinkAtCompletion;

            FormHeadquarters_BlinkAtMaximum.Checked = config.FormHeadquarters.BlinkAtMaximum;
            FormHeadquarters_Visibility.Items.Clear();
            FormHeadquarters_Visibility.Items.AddRange( FormHeadquarters.GetItemNames().ToArray() );
            FormHeadquarters.CheckVisibilityConfiguration();
            for ( int i = 0; i < FormHeadquarters_Visibility.Items.Count; i++ ) {
                FormHeadquarters_Visibility.SetItemChecked( i, config.FormHeadquarters.Visibility.List[i] );
            }

            FormQuest_ShowRunningOnly.Checked = config.FormQuest.ShowRunningOnly;
            FormQuest_ShowOnce.Checked = config.FormQuest.ShowOnce;
            FormQuest_ShowDaily.Checked = config.FormQuest.ShowDaily;
            FormQuest_ShowWeekly.Checked = config.FormQuest.ShowWeekly;
            FormQuest_ShowMonthly.Checked = config.FormQuest.ShowMonthly;
            FormQuest_ShowOther.Checked = config.FormQuest.ShowOther;
            FormQuest_ProgressAutoSaving.SelectedIndex = config.FormQuest.ProgressAutoSaving;
            FormQuest_AllowUserToSortRows.Checked = config.FormQuest.AllowUserToSortRows;

            FormShipGroup_AutoUpdate.Checked = config.FormShipGroup.AutoUpdate;
            FormShipGroup_ShowStatusBar.Checked = config.FormShipGroup.ShowStatusBar;
            FormShipGroup_ShipNameSortMethod.SelectedIndex = config.FormShipGroup.ShipNameSortMethod;

            FormBrowser_IsEnabled.Checked = config.FormBrowser.IsEnabled;
            FormBrowser_ZoomRate.Value = config.FormBrowser.ZoomRate;
            FormBrowser_ZoomFit.Checked = config.FormBrowser.ZoomFit;
            FormBrowser_LogInPageURL.Text = config.FormBrowser.LogInPageURL;
            FormBrowser_ScreenShotFormat_JPEG.Checked = config.FormBrowser.ScreenShotFormat == 1;
            FormBrowser_ScreenShotFormat_PNG.Checked = config.FormBrowser.ScreenShotFormat == 2;
            FormBrowser_ScreenShotPath.Text = config.FormBrowser.ScreenShotPath;
            FormBrowser_ConfirmAtRefresh.Checked = config.FormBrowser.ConfirmAtRefresh;
            FormBrowser_AppliesStyleSheet.Checked = config.FormBrowser.AppliesStyleSheet;
            {
                Microsoft.Win32.RegistryKey reg = null;
                try {

                    reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( RegistryPathMaster + RegistryPathBrowserVersion );
                    if ( reg == null ) {
                        FormBrowser_BrowserVersion.Text = DefaultBrowserVersion.ToString();

                    } else {
                        FormBrowser_BrowserVersion.Text = ( reg.GetValue( FormBrowserHost.BrowserExeName ) ?? DefaultBrowserVersion ).ToString();
                    }
                    if ( reg != null )
                        reg.Close();

                    reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( RegistryPathMaster + RegistryPathGPURendering );
                    if ( reg == null ) {
                        FormBrowser_GPURendering.Checked = DefaultGPURendering;

                    } else {
                        int? gpu = reg.GetValue( FormBrowserHost.BrowserExeName ) as int?;
                        FormBrowser_GPURendering.Checked = gpu != null ? gpu != 0 : DefaultGPURendering;
                    }

                } catch ( Exception ex ) {

                    FormBrowser_BrowserVersion.Text = DefaultBrowserVersion.ToString();
                    FormBrowser_GPURendering.Checked = DefaultGPURendering;

                    Utility.Logger.Add( 3, "レジストリからの読み込みに失敗しました。" + ex.Message );

                } finally {
                    if ( reg != null )
                        reg.Close();

                }
            }
            FormBrowser_FlashQuality.Text = config.FormBrowser.FlashQuality;
            FormBrowser_FlashWMode.Text = config.FormBrowser.FlashWMode;
            if ( !config.FormBrowser.IsToolMenuVisible )
                FormBrowser_ToolMenuDockStyle.SelectedIndex = 4;
            else
                FormBrowser_ToolMenuDockStyle.SelectedIndex = (int)config.FormBrowser.ToolMenuDockStyle - 1;

            FormCompass_CandidateDisplayCount.Value = config.FormCompass.CandidateDisplayCount;

            // [サブウィンドウ]内の[艦隊+]
            var fleetIconList = new Dictionary<ResourceManager.IconContent, string>() {
                { ResourceManager.IconContent.FleetDocking, "入渠中" },
                { ResourceManager.IconContent.FleetSortie, "出撃中" },
                { ResourceManager.IconContent.FleetExpedition, "遠征中" },
                { ResourceManager.IconContent.FleetDamaged, "大破艦あり" },
                { ResourceManager.IconContent.FleetAnchorageRepairing, "泊地修理中" },
                { ResourceManager.IconContent.FleetNotReplenished, "未補給" },
                { ResourceManager.IconContent.ConditionTired, "疲労" },
                { ResourceManager.IconContent.ConditionSparkle, "戦意高揚" },
            };
            var IconOrder = config.FormFleetPlus.FleetIconOrder.List;
            IconOrder.AddRange(fleetIconList.Keys.Except(IconOrder)); // 今後の更新で↑のリストに追加があった場合に備えての処理
            foreach ( var key in IconOrder ) {
                var index = FleetIconPriorityView.Rows.Add();
                var row = FleetIconPriorityView.Rows[index];

                var imageIndexCell = row.Cells[ColumnImageIndex.Index];
                imageIndexCell.Value = (int)key;
                var imageCell = row.Cells[ColumnImage.Index];
                imageCell.Value = ResourceManager.Instance.Icons.Images[(int)key];
                var captionCell = row.Cells[ColumnCaption.Index];
                captionCell.Value = fleetIconList[key];
            }
            var fleetInfoIconList = new List<Tuple<ImageList, int, string>>() {
                Tuple.Create(
                    ResourceManager.Instance.Equipments,
                    (int)ResourceManager.EquipmentContent.CarrierBasedFighter,
                    "制空値"),
                Tuple.Create(
                    ResourceManager.Instance.Equipments,
                    (int)ResourceManager.EquipmentContent.CarrierBasedRecon,
                    "索敵値"),
                Tuple.Create(
                    ResourceManager.Instance.Equipments,
                    (int)ResourceManager.EquipmentContent.DrumCanister,
                    "ドラム缶"),
                Tuple.Create(
                    ResourceManager.Instance.Equipments,
                    (int)ResourceManager.EquipmentContent.LandingCraft,
                    "大発動艇"),
                Tuple.Create(
                    ResourceManager.Instance.Icons,
                    (int)ResourceManager.IconContent.ConditionSparkle,
                    "キラ隻数"),
            };
            foreach ( var tuple in fleetInfoIconList ) {
                var index = FleetInfoIconView.Rows.Add();
                var row = FleetInfoIconView.Rows[index];
                var imageList = tuple.Item1;
                var key = tuple.Item2;
                var text = tuple.Item3;

                row.Cells[FleetInfoIconImageColumn.Index].Value = imageList.Images[key];
                row.Cells[FleetInfoIconCaptionColumn.Index].Value = text;
                row.Cells[Fleet1InfoIconVisibleColumn.Index].Value = config.FormFleetPlus.Fleet1InfoIcon?[index] ?? false;
                row.Cells[Fleet2InfoIconVisibleColumn.Index].Value = config.FormFleetPlus.Fleet2InfoIcon?[index] ?? false;
                row.Cells[Fleet3InfoIconVisibleColumn.Index].Value = config.FormFleetPlus.Fleet3InfoIcon?[index] ?? false;
                row.Cells[Fleet4InfoIconVisibleColumn.Index].Value = config.FormFleetPlus.Fleet4InfoIcon?[index] ?? false;
            }

            //[データベース]
            Database_SendDataToKancolleDB.Checked = config.Connection.SendDataToKancolleDB;
            Database_SendKancolleOAuth.Text = config.Connection.SendKancolleOAuth;

            //[BGM]
            BGMPlayer_Enabled.Checked = config.BGMPlayer.Enabled;
            BGMHandles = config.BGMPlayer.Handles.ToDictionary( h => h.HandleID );
            BGMPlayer_SyncBrowserMute.Checked = config.BGMPlayer.SyncBrowserMute;
            UpdateBGMPlayerUI();

            //finalize
            UpdateParameter();
        }