OSDN Git Service

ProxyPanelに対する設定値の設定・取得を LoadConfing/SaveConfig メソッドに移動
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 27 Jul 2014 16:46:20 +0000 (01:46 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Thu, 31 Jul 2014 16:17:05 +0000 (01:17 +0900)
OpenTween/AppendSettingDialog.cs
OpenTween/Setting/Panel/ProxyPanel.cs
OpenTween/Tween.cs

index f549c7a..dd80975 100644 (file)
@@ -47,7 +47,6 @@ namespace OpenTween
     {
         private static AppendSettingDialog _instance = new AppendSettingDialog();
         private Twitter tw;
-        private ProxyType _MyProxyType;
 
         private bool _ValidationError = false;
         private MyCommon.EVENTTYPE _MyEventNotifyFlag;
@@ -82,6 +81,7 @@ namespace OpenTween
             this.PreviewPanel.LoadConfig(settingCommon);
             this.GetCountPanel.LoadConfig(settingCommon);
             this.ShortUrlPanel.LoadConfig(settingCommon);
+            this.ProxyPanel.LoadConfig(settingLocal);
         }
 
         public void SaveConfig(SettingCommon settingCommon, SettingLocal settingLocal)
@@ -96,6 +96,7 @@ namespace OpenTween
             this.PreviewPanel.SaveConfig(settingCommon);
             this.GetCountPanel.SaveConfig(settingCommon);
             this.ShortUrlPanel.SaveConfig(settingCommon);
+            this.ProxyPanel.SaveConfig(settingLocal);
         }
 
         private void TreeViewSetting_BeforeSelect(object sender, TreeViewCancelEventArgs e)
@@ -221,23 +222,6 @@ namespace OpenTween
 #endif
             try
             {
-                if (this.ProxyPanel.RadioProxyNone.Checked)
-                {
-                    _MyProxyType = ProxyType.None;
-                }
-                else if (this.ProxyPanel.RadioProxyIE.Checked)
-                {
-                    _MyProxyType = ProxyType.IE;
-                }
-                else
-                {
-                    _MyProxyType = ProxyType.Specified;
-                }
-                ProxyAddress = this.ProxyPanel.TextProxyAddress.Text.Trim();
-                ProxyPort = int.Parse(this.ProxyPanel.TextProxyPort.Text.Trim());
-                ProxyUser = this.ProxyPanel.TextProxyUser.Text.Trim();
-                ProxyPassword = this.ProxyPanel.TextProxyPassword.Text.Trim();
-
                 Nicoms = this.CooperatePanel.CheckNicoms.Checked;
                 DefaultTimeOut = int.Parse(this.ConnectionPanel.ConnectionTimeOut.Text);
                 EventNotifyEnabled = this.NotifyPanel.CheckEventNotify.Checked;
@@ -361,33 +345,6 @@ namespace OpenTween
                 }
             }
 
-            switch (_MyProxyType)
-            {
-                case ProxyType.None:
-                    this.ProxyPanel.RadioProxyNone.Checked = true;
-                    break;
-                case ProxyType.IE:
-                    this.ProxyPanel.RadioProxyIE.Checked = true;
-                    break;
-                default:
-                    this.ProxyPanel.RadioProxySpecified.Checked = true;
-                    break;
-            }
-            bool chk = this.ProxyPanel.RadioProxySpecified.Checked;
-            this.ProxyPanel.LabelProxyAddress.Enabled = chk;
-            this.ProxyPanel.TextProxyAddress.Enabled = chk;
-            this.ProxyPanel.LabelProxyPort.Enabled = chk;
-            this.ProxyPanel.TextProxyPort.Enabled = chk;
-            this.ProxyPanel.LabelProxyUser.Enabled = chk;
-            this.ProxyPanel.TextProxyUser.Enabled = chk;
-            this.ProxyPanel.LabelProxyPassword.Enabled = chk;
-            this.ProxyPanel.TextProxyPassword.Enabled = chk;
-
-            this.ProxyPanel.TextProxyAddress.Text = ProxyAddress;
-            this.ProxyPanel.TextProxyPort.Text = ProxyPort.ToString();
-            this.ProxyPanel.TextProxyUser.Text = ProxyUser;
-            this.ProxyPanel.TextProxyPassword.Text = ProxyPassword;
-
             this.CooperatePanel.CheckNicoms.Checked = Nicoms;
             this.ConnectionPanel.ConnectionTimeOut.Text = DefaultTimeOut.ToString();
 
@@ -616,20 +573,6 @@ namespace OpenTween
 
         public string RecommendStatusText { get; set; }
 
-        public ProxyType SelectedProxyType
-        {
-            get {
-                return _MyProxyType;
-            }
-            set {
-                _MyProxyType = value;
-            }
-        }
-
-        public string ProxyAddress { get; set; }
-        public int ProxyPort { get; set; }
-        public string ProxyUser { get; set; }
-        public string ProxyPassword { get; set; }
         public bool Nicoms { get; set; }
         public int DefaultTimeOut { get; set; }
         public string TwitterApiUrl { get; set; }
index bdd0b0d..479e7d9 100644 (file)
@@ -32,6 +32,7 @@ using System.Data;
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using OpenTween.Connection;
 
 namespace OpenTween.Setting.Panel
 {
@@ -42,6 +43,58 @@ namespace OpenTween.Setting.Panel
             InitializeComponent();
         }
 
+        public void LoadConfig(SettingLocal settingLocal)
+        {
+            switch (settingLocal.ProxyType)
+            {
+                case ProxyType.None:
+                    this.RadioProxyNone.Checked = true;
+                    break;
+                case ProxyType.IE:
+                    this.RadioProxyIE.Checked = true;
+                    break;
+                default:
+                    this.RadioProxySpecified.Checked = true;
+                    break;
+            }
+
+            var chk = this.RadioProxySpecified.Checked;
+            this.LabelProxyAddress.Enabled = chk;
+            this.TextProxyAddress.Enabled = chk;
+            this.LabelProxyPort.Enabled = chk;
+            this.TextProxyPort.Enabled = chk;
+            this.LabelProxyUser.Enabled = chk;
+            this.TextProxyUser.Enabled = chk;
+            this.LabelProxyPassword.Enabled = chk;
+            this.TextProxyPassword.Enabled = chk;
+
+            this.TextProxyAddress.Text = settingLocal.ProxyAddress;
+            this.TextProxyPort.Text = settingLocal.ProxyPort.ToString();
+            this.TextProxyUser.Text = settingLocal.ProxyUser;
+            this.TextProxyPassword.Text = settingLocal.ProxyPassword;
+        }
+
+        public void SaveConfig(SettingLocal settingLocal)
+        {
+            if (this.RadioProxyNone.Checked)
+            {
+                settingLocal.ProxyType = ProxyType.None;
+            }
+            else if (this.RadioProxyIE.Checked)
+            {
+                settingLocal.ProxyType = ProxyType.IE;
+            }
+            else
+            {
+                settingLocal.ProxyType = ProxyType.Specified;
+            }
+
+            settingLocal.ProxyAddress = this.TextProxyAddress.Text.Trim();
+            settingLocal.ProxyPort = int.Parse(this.TextProxyPort.Text.Trim());
+            settingLocal.ProxyUser = this.TextProxyUser.Text.Trim();
+            settingLocal.ProxyPassword = this.TextProxyPassword.Text.Trim();
+        }
+
         private void RadioProxySpecified_CheckedChanged(object sender, EventArgs e)
         {
             bool chk = RadioProxySpecified.Checked;
index 92e39a5..65b82e5 100644 (file)
@@ -775,12 +775,6 @@ namespace OpenTween
             this.PlaySoundMenuItem.Checked = this._cfgCommon.PlaySound;
             this.PlaySoundFileMenuItem.Checked = this._cfgCommon.PlaySound;
 
-            SettingDialog.SelectedProxyType = _cfgLocal.ProxyType;
-            SettingDialog.ProxyAddress = _cfgLocal.ProxyAddress;
-            SettingDialog.ProxyPort = _cfgLocal.ProxyPort;
-            SettingDialog.ProxyUser = _cfgLocal.ProxyUser;
-            SettingDialog.ProxyPassword = _cfgLocal.ProxyPassword;
-
             SettingDialog.DefaultTimeOut = _cfgCommon.DefaultTimeOut;
             SettingDialog.EventNotifyEnabled = _cfgCommon.EventNotifyEnabled;
             SettingDialog.EventNotifyFlag = _cfgCommon.EventNotifyFlag;
@@ -911,9 +905,9 @@ namespace OpenTween
 
             //Twitter用通信クラス初期化
             Networking.DefaultTimeout = TimeSpan.FromSeconds(this.SettingDialog.DefaultTimeOut);
-            Networking.SetWebProxy(this.SettingDialog.SelectedProxyType,
-                this.SettingDialog.ProxyAddress, this.SettingDialog.ProxyPort,
-                this.SettingDialog.ProxyUser, this.SettingDialog.ProxyPassword);
+            Networking.SetWebProxy(this._cfgLocal.ProxyType,
+                this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort,
+                this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
 
             tw.RestrictFavCheck = this._cfgCommon.RestrictFavCheck;
             tw.ReadOwnPost = this._cfgCommon.ReadOwnPost;
@@ -3824,9 +3818,9 @@ namespace OpenTween
                     HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl;
 
                     Networking.DefaultTimeout = TimeSpan.FromSeconds(this.SettingDialog.DefaultTimeOut);
-                    Networking.SetWebProxy(this.SettingDialog.SelectedProxyType,
-                        this.SettingDialog.ProxyAddress, this.SettingDialog.ProxyPort,
-                        this.SettingDialog.ProxyUser, this.SettingDialog.ProxyPassword);
+                    Networking.SetWebProxy(this._cfgLocal.ProxyType,
+                        this._cfgLocal.ProxyAddress, this._cfgLocal.ProxyPort,
+                        this._cfgLocal.ProxyUser, this._cfgLocal.ProxyPassword);
 
                     ImageSelector.Reset(tw, SettingDialog.TwitterConfiguration);
 
@@ -7765,11 +7759,6 @@ namespace OpenTween
                 _cfgLocal.ColorInputFont = _clInputFont;
                 _cfgLocal.FontInputFont = _fntInputFont;
 
-                _cfgLocal.ProxyType = SettingDialog.SelectedProxyType;
-                _cfgLocal.ProxyAddress = SettingDialog.ProxyAddress;
-                _cfgLocal.ProxyPort = SettingDialog.ProxyPort;
-                _cfgLocal.ProxyUser = SettingDialog.ProxyUser;
-                _cfgLocal.ProxyPassword = SettingDialog.ProxyPassword;
                 if (_ignoreConfigSave) return;
                 _cfgLocal.Save();
             }