OSDN Git Service

StartupPanelに対する設定値の設定・取得を LoadConfing/SaveConfig メソッドに移動
[opentween/open-tween.git] / OpenTween / AppendSettingDialog.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 //           (c) 2008-2011 Moz (@syo68k)
4 //           (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 //           (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 //           (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 //           (c) 2011      kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
8 // All rights reserved.
9 // 
10 // This file is part of OpenTween.
11 // 
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
15 // any later version.
16 // 
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 // for more details. 
21 // 
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
26
27 using System;
28 using System.Collections.Generic;
29 using System.ComponentModel;
30 using System.Data;
31 using System.Drawing;
32 using System.Linq;
33 using System.Text;
34 using System.Windows.Forms;
35 using System.Threading;
36 using System.IO;
37 using System.Resources;
38 using OpenTween.Api;
39 using OpenTween.Connection;
40 using OpenTween.Thumbnail;
41 using System.Threading.Tasks;
42 using OpenTween.Setting.Panel;
43
44 namespace OpenTween
45 {
46     public partial class AppendSettingDialog : OTBaseForm
47     {
48         private static AppendSettingDialog _instance = new AppendSettingDialog();
49         private Twitter tw;
50         private ProxyType _MyProxyType;
51
52         private bool _ValidationError = false;
53         private MyCommon.EVENTTYPE _MyEventNotifyFlag;
54         private MyCommon.EVENTTYPE _isMyEventNotifyFlag;
55         private string _MyTranslateLanguage;
56
57         public bool HideDuplicatedRetweets;
58
59         public bool EnableImgAzyobuziNet { get; set; }
60         public bool ImgAzyobuziNetDisabledInDM { get; set; }
61         public MapProvider MapThumbnailProvider;
62         public int MapThumbnailHeight;
63         public int MapThumbnailWidth;
64         public int MapThumbnailZoom;
65         public bool IsListStatusesIncludeRts;
66         public List<UserAccount> UserAccounts;
67         private long? InitialUserId;
68         public bool TabMouseLock;
69         public bool IsRemoveSameEvent;
70         public bool IsNotifyUseGrowl;
71
72         public TwitterConfiguration TwitterConfiguration = TwitterConfiguration.DefaultConfiguration();
73
74         private string _pin;
75
76         public event EventHandler<IntervalChangedEventArgs> IntervalChanged;
77
78         public void LoadConfig(SettingCommon settingCommon, SettingLocal settingLocal)
79         {
80             this.GetPeriodPanel.LoadConfig(settingCommon);
81             this.StartupPanel.LoadConfig(settingCommon);
82         }
83
84         public void SaveConfig(SettingCommon settingCommon, SettingLocal settingLocal)
85         {
86             this.GetPeriodPanel.SaveConfig(settingCommon);
87             this.StartupPanel.SaveConfig(settingCommon);
88         }
89
90         private void TreeViewSetting_BeforeSelect(object sender, TreeViewCancelEventArgs e)
91         {
92             if (this.TreeViewSetting.SelectedNode == null) return;
93             var pnl = (SettingPanelBase)this.TreeViewSetting.SelectedNode.Tag;
94             if (pnl == null) return;
95             pnl.Enabled = false;
96             pnl.Visible = false;
97         }
98
99         private void TreeViewSetting_AfterSelect(object sender, TreeViewEventArgs e)
100         {
101             if (e.Node == null) return;
102             var pnl = (SettingPanelBase)e.Node.Tag;
103             if (pnl == null) return;
104             pnl.Enabled = true;
105             pnl.Visible = true;
106
107             if (pnl.Name == "PreviewPanel")
108             {
109                 if (GrowlHelper.IsDllExists)
110                 {
111                     this.PreviewPanel.IsNotifyUseGrowlCheckBox.Enabled = true;
112                 }
113                 else
114                 {
115                     this.PreviewPanel.IsNotifyUseGrowlCheckBox.Enabled = false;
116                 }
117             }
118         }
119
120         private void Save_Click(object sender, EventArgs e)
121         {
122             if (MyCommon.IsNetworkAvailable() &&
123                 (this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Bitly || this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex == (int)MyCommon.UrlConverter.Jmp))
124             {
125                 // bit.ly 短縮機能実装のプライバシー問題の暫定対応
126                 // bit.ly 使用時はログインIDとAPIキーの指定を必須とする
127                 // 参照: http://sourceforge.jp/projects/opentween/lists/archive/dev/2012-January/000020.html
128                 if (string.IsNullOrEmpty(this.ShortUrlPanel.TextBitlyId.Text) || string.IsNullOrEmpty(this.ShortUrlPanel.TextBitlyPw.Text))
129                 {
130                     MessageBox.Show("bit.ly のログイン名とAPIキーの指定は必須項目です。", Application.ProductName);
131                     _ValidationError = true;
132                     TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択
133                     TreeViewSetting.Select();
134                     this.ShortUrlPanel.TextBitlyId.Focus();
135                     return;
136                 }
137
138                 if (!BitlyValidation(this.ShortUrlPanel.TextBitlyId.Text, this.ShortUrlPanel.TextBitlyPw.Text))
139                 {
140                     MessageBox.Show(Properties.Resources.SettingSave_ClickText1);
141                     _ValidationError = true;
142                     TreeViewSetting.SelectedNode = TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"]; // 動作タブを選択
143                     TreeViewSetting.Select();
144                     this.ShortUrlPanel.TextBitlyId.Focus();
145                     return;
146                 }
147                 else
148                 {
149                     _ValidationError = false;
150                 }
151             }
152             else
153             {
154                 _ValidationError = false;
155             }
156
157             this.UserAccounts.Clear();
158             foreach (object u in this.BasedPanel.AuthUserCombo.Items)
159             {
160                 this.UserAccounts.Add((UserAccount)u);
161             }
162             if (this.BasedPanel.AuthUserCombo.SelectedIndex > -1)
163             {
164                 foreach (UserAccount u in this.UserAccounts)
165                 {
166                     if (u.Username.ToLower() == ((UserAccount)this.BasedPanel.AuthUserCombo.SelectedItem).Username.ToLower())
167                     {
168                         tw.Initialize(u.Token, u.TokenSecret, u.Username, u.UserId);
169                         if (u.UserId == 0)
170                         {
171                             tw.VerifyCredentials();
172                             u.UserId = tw.UserId;
173                         }
174                         break;
175                     }
176                 }
177             }
178             else
179             {
180                 tw.ClearAuthInfo();
181                 tw.Initialize("", "", "", 0);
182             }
183
184 #if UA
185             //フォロー
186             if (this.FollowCheckBox.Checked)
187             {
188                 //現在の設定内容で通信
189                 HttpConnection.ProxyType ptype;
190                 if (RadioProxyNone.Checked)
191                 {
192                     ptype = HttpConnection.ProxyType.None;
193                 }
194                 else if (RadioProxyIE.Checked)
195                 {
196                     ptype = HttpConnection.ProxyType.IE;
197                 }
198                 else
199                 {
200                     ptype = HttpConnection.ProxyType.Specified;
201                 }
202                 string padr = TextProxyAddress.Text.Trim();
203                 int pport = int.Parse(TextProxyPort.Text.Trim());
204                 string pusr = TextProxyUser.Text.Trim();
205                 string ppw = TextProxyPassword.Text.Trim();
206                 HttpConnection.InitializeConnection(20, ptype, padr, pport, pusr, ppw);
207
208                 string ret = tw.PostFollowCommand(ApplicationSettings.FeedbackTwitterName);
209             }
210 #endif
211             try
212             {
213                 switch (this.TweetPrvPanel.IconSize.SelectedIndex)
214                 {
215                     case 0:
216                         IconSz = MyCommon.IconSizes.IconNone;
217                         break;
218                     case 1:
219                         IconSz = MyCommon.IconSizes.Icon16;
220                         break;
221                     case 2:
222                         IconSz = MyCommon.IconSizes.Icon24;
223                         break;
224                     case 3:
225                         IconSz = MyCommon.IconSizes.Icon48;
226                         break;
227                     case 4:
228                         IconSz = MyCommon.IconSizes.Icon48_2;
229                         break;
230                 }
231                 Status = this.TweetActPanel.StatusText.Text;
232                 PlaySound = this.ActionPanel.PlaySnd.Checked;
233                 UnreadManage = this.ActionPanel.UReadMng.Checked;
234                 OneWayLove = this.TweetPrvPanel.OneWayLv.Checked;
235
236                 FontUnread = this.FontPanel.lblUnread.Font;     //未使用
237                 ColorUnread = this.FontPanel.lblUnread.ForeColor;
238                 FontReaded = this.FontPanel.lblListFont.Font;     //リストフォントとして使用
239                 ColorReaded = this.FontPanel.lblListFont.ForeColor;
240                 ColorFav = this.FontPanel.lblFav.ForeColor;
241                 ColorOWL = this.FontPanel.lblOWL.ForeColor;
242                 ColorRetweet = this.FontPanel.lblRetweet.ForeColor;
243                 FontDetail = this.FontPanel.lblDetail.Font;
244                 ColorSelf = this.FontPanel2.lblSelf.BackColor;
245                 ColorAtSelf = this.FontPanel2.lblAtSelf.BackColor;
246                 ColorTarget = this.FontPanel2.lblTarget.BackColor;
247                 ColorAtTarget = this.FontPanel2.lblAtTarget.BackColor;
248                 ColorAtFromTarget = this.FontPanel2.lblAtFromTarget.BackColor;
249                 ColorAtTo = this.FontPanel2.lblAtTo.BackColor;
250                 ColorInputBackcolor = this.FontPanel2.lblInputBackcolor.BackColor;
251                 ColorInputFont = this.FontPanel2.lblInputFont.ForeColor;
252                 ColorListBackcolor = this.FontPanel2.lblListBackcolor.BackColor;
253                 ColorDetailBackcolor = this.FontPanel.lblDetailBackcolor.BackColor;
254                 ColorDetail = this.FontPanel.lblDetail.ForeColor;
255                 ColorDetailLink = this.FontPanel.lblDetailLink.ForeColor;
256                 FontInputFont = this.FontPanel2.lblInputFont.Font;
257                 switch (this.PreviewPanel.cmbNameBalloon.SelectedIndex)
258                 {
259                     case 0:
260                         NameBalloon = MyCommon.NameBalloonEnum.None;
261                         break;
262                     case 1:
263                         NameBalloon = MyCommon.NameBalloonEnum.UserID;
264                         break;
265                     case 2:
266                         NameBalloon = MyCommon.NameBalloonEnum.NickName;
267                         break;
268                 }
269
270                 switch (this.TweetActPanel.ComboBoxPostKeySelect.SelectedIndex)
271                 {
272                     case 2:
273                         PostShiftEnter = true;
274                         PostCtrlEnter = false;
275                         break;
276                     case 1:
277                         PostCtrlEnter = true;
278                         PostShiftEnter = false;
279                         break;
280                     case 0:
281                         PostCtrlEnter = false;
282                         PostShiftEnter = false;
283                         break;
284                 }
285                 CountApi = int.Parse(this.GetCountPanel.TextCountApi.Text);
286                 CountApiReply = int.Parse(this.GetCountPanel.TextCountApiReply.Text);
287                 BrowserPath = this.ActionPanel.BrowserPathText.Text.Trim();
288                 UseRecommendStatus = this.TweetActPanel.CheckUseRecommendStatus.Checked;
289                 DispUsername = this.PreviewPanel.CheckDispUsername.Checked;
290                 CloseToExit = this.ActionPanel.CheckCloseToExit.Checked;
291                 MinimizeToTray = this.ActionPanel.CheckMinimizeToTray.Checked;
292                 switch (this.PreviewPanel.ComboDispTitle.SelectedIndex)
293                 {
294                     case 0:  //None
295                         DispLatestPost = MyCommon.DispTitleEnum.None;
296                         break;
297                     case 1:  //Ver
298                         DispLatestPost = MyCommon.DispTitleEnum.Ver;
299                         break;
300                     case 2:  //Post
301                         DispLatestPost = MyCommon.DispTitleEnum.Post;
302                         break;
303                     case 3:  //RepCount
304                         DispLatestPost = MyCommon.DispTitleEnum.UnreadRepCount;
305                         break;
306                     case 4:  //AllCount
307                         DispLatestPost = MyCommon.DispTitleEnum.UnreadAllCount;
308                         break;
309                     case 5:  //Rep+All
310                         DispLatestPost = MyCommon.DispTitleEnum.UnreadAllRepCount;
311                         break;
312                     case 6:  //Unread/All
313                         DispLatestPost = MyCommon.DispTitleEnum.UnreadCountAllCount;
314                         break;
315                     case 7: //Count of Status/Follow/Follower
316                         DispLatestPost = MyCommon.DispTitleEnum.OwnStatus;
317                         break;
318                 }
319                 SortOrderLock = this.TweetPrvPanel.CheckSortOrderLock.Checked;
320                 ViewTabBottom = this.TweetPrvPanel.CheckViewTabBottom.Checked;
321                 TinyUrlResolve = this.ShortUrlPanel.CheckTinyURL.Checked;
322                 ShortUrl.Instance.DisableExpanding = !TinyUrlResolve;
323                 if (this.ProxyPanel.RadioProxyNone.Checked)
324                 {
325                     _MyProxyType = ProxyType.None;
326                 }
327                 else if (this.ProxyPanel.RadioProxyIE.Checked)
328                 {
329                     _MyProxyType = ProxyType.IE;
330                 }
331                 else
332                 {
333                     _MyProxyType = ProxyType.Specified;
334                 }
335                 ProxyAddress = this.ProxyPanel.TextProxyAddress.Text.Trim();
336                 ProxyPort = int.Parse(this.ProxyPanel.TextProxyPort.Text.Trim());
337                 ProxyUser = this.ProxyPanel.TextProxyUser.Text.Trim();
338                 ProxyPassword = this.ProxyPanel.TextProxyPassword.Text.Trim();
339                 RestrictFavCheck = this.ActionPanel.CheckFavRestrict.Checked;
340                 AlwaysTop = this.PreviewPanel.CheckAlwaysTop.Checked;
341                 UrlConvertAuto = this.ShortUrlPanel.CheckAutoConvertUrl.Checked;
342                 ShortenTco = this.ShortUrlPanel.ShortenTcoCheck.Checked;
343
344                 Nicoms = this.CooperatePanel.CheckNicoms.Checked;
345                 UseUnreadStyle = this.TweetPrvPanel.chkUnreadStyle.Checked;
346                 DateTimeFormat = this.TweetPrvPanel.CmbDateTimeFormat.Text;
347                 DefaultTimeOut = int.Parse(this.ConnectionPanel.ConnectionTimeOut.Text);
348                 RetweetNoConfirm = this.TweetActPanel.CheckRetweetNoConfirm.Checked;
349                 LimitBalloon = this.PreviewPanel.CheckBalloonLimit.Checked;
350                 EventNotifyEnabled = this.NotifyPanel.CheckEventNotify.Checked;
351                 GetEventNotifyFlag(ref _MyEventNotifyFlag, ref _isMyEventNotifyFlag);
352                 ForceEventNotify = this.NotifyPanel.CheckForceEventNotify.Checked;
353                 FavEventUnread = this.NotifyPanel.CheckFavEventUnread.Checked;
354                 TranslateLanguage = Bing.GetLanguageEnumFromIndex(this.CooperatePanel.ComboBoxTranslateLanguage.SelectedIndex);
355                 EventSoundFile = (string)this.NotifyPanel.ComboBoxEventNotifySound.SelectedItem;
356                 AutoShortUrlFirst = (MyCommon.UrlConverter)this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex;
357                 TabIconDisp = this.PreviewPanel.chkTabIconDisp.Checked;
358                 ReadOwnPost = this.ActionPanel.chkReadOwnPost.Checked;
359                 IsMonospace = this.PreviewPanel.CheckMonospace.Checked;
360                 ReadOldPosts = this.ActionPanel.CheckReadOldPosts.Checked;
361                 BitlyUser = this.ShortUrlPanel.TextBitlyId.Text;
362                 BitlyPwd = this.ShortUrlPanel.TextBitlyPw.Text;
363                 ShowGrid = this.TweetPrvPanel.CheckShowGrid.Checked;
364                 UseAtIdSupplement = this.TweetActPanel.CheckAtIdSupple.Checked;
365                 UseHashSupplement = this.TweetActPanel.CheckHashSupple.Checked;
366                 PreviewEnable = this.PreviewPanel.CheckPreviewEnable.Checked;
367                 StatusAreaAtBottom = this.PreviewPanel.CheckStatusAreaAtBottom.Checked;
368                 TwitterApiUrl = this.ConnectionPanel.TwitterAPIText.Text.Trim();
369                 switch (this.PreviewPanel.ReplyIconStateCombo.SelectedIndex)
370                 {
371                     case 0:
372                         ReplyIconState = MyCommon.REPLY_ICONSTATE.None;
373                         break;
374                     case 1:
375                         ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon;
376                         break;
377                     case 2:
378                         ReplyIconState = MyCommon.REPLY_ICONSTATE.BlinkIcon;
379                         break;
380                 }
381                 switch (this.PreviewPanel.LanguageCombo.SelectedIndex)
382                 {
383                     case 0:
384                         Language = "OS";
385                         break;
386                     case 1:
387                         Language = "ja";
388                         break;
389                     case 2:
390                         Language = "en";
391                         break;
392                     case 3:
393                         Language = "zh-CN";
394                         break;
395                     default:
396                         Language = "en";
397                         break;
398                 }
399                 HotkeyEnabled = this.ActionPanel.HotkeyCheck.Checked;
400                 HotkeyMod = Keys.None;
401                 if (this.ActionPanel.HotkeyAlt.Checked) HotkeyMod = HotkeyMod | Keys.Alt;
402                 if (this.ActionPanel.HotkeyShift.Checked) HotkeyMod = HotkeyMod | Keys.Shift;
403                 if (this.ActionPanel.HotkeyCtrl.Checked) HotkeyMod = HotkeyMod | Keys.Control;
404                 if (this.ActionPanel.HotkeyWin.Checked) HotkeyMod = HotkeyMod | Keys.LWin;
405                 int.TryParse(this.ActionPanel.HotkeyCode.Text, out HotkeyValue);
406                 HotkeyKey = (Keys)this.ActionPanel.HotkeyText.Tag;
407                 BlinkNewMentions = this.PreviewPanel.ChkNewMentionsBlink.Checked;
408                 UseAdditionalCount = this.GetCountPanel.UseChangeGetCount.Checked;
409                 MoreCountApi = int.Parse(this.GetCountPanel.GetMoreTextCountApi.Text);
410                 FirstCountApi = int.Parse(this.GetCountPanel.FirstTextCountApi.Text);
411                 SearchCountApi = int.Parse(this.GetCountPanel.SearchTextCountApi.Text);
412                 FavoritesCountApi = int.Parse(this.GetCountPanel.FavoritesTextCountApi.Text);
413                 UserTimelineCountApi = int.Parse(this.GetCountPanel.UserTimelineTextCountApi.Text);
414                 ListCountApi = int.Parse(this.GetCountPanel.ListTextCountApi.Text);
415                 OpenUserTimeline = this.ActionPanel.CheckOpenUserTimeline.Checked;
416                 ListDoubleClickAction = this.ActionPanel.ListDoubleClickActionComboBox.SelectedIndex;
417                 UserAppointUrl = this.CooperatePanel.UserAppointUrlText.Text;
418                 this.HideDuplicatedRetweets = this.TweetPrvPanel.HideDuplicatedRetweetsCheck.Checked;
419                 this.EnableImgAzyobuziNet = this.CooperatePanel.EnableImgAzyobuziNetCheckBox.Checked;
420                 this.ImgAzyobuziNetDisabledInDM = this.CooperatePanel.ImgAzyobuziNetDisabledInDMCheckBox.Checked;
421                 this.MapThumbnailProvider = (MapProvider)this.CooperatePanel.MapThumbnailProviderComboBox.SelectedIndex;
422                 this.MapThumbnailHeight = int.Parse(this.CooperatePanel.MapThumbnailHeightTextBox.Text);
423                 this.MapThumbnailWidth = int.Parse(this.CooperatePanel.MapThumbnailWidthTextBox.Text);
424                 this.MapThumbnailZoom = int.Parse(this.CooperatePanel.MapThumbnailZoomTextBox.Text);
425                 this.IsListStatusesIncludeRts = this.TweetPrvPanel.IsListsIncludeRtsCheckBox.Checked;
426                 this.TabMouseLock = this.ActionPanel.TabMouseLockCheck.Checked;
427                 this.IsRemoveSameEvent = this.NotifyPanel.IsRemoveSameFavEventCheckBox.Checked;
428                 this.IsNotifyUseGrowl = this.PreviewPanel.IsNotifyUseGrowlCheckBox.Checked;
429             }
430             catch(Exception)
431             {
432                 MessageBox.Show(Properties.Resources.Save_ClickText3);
433                 this.DialogResult = DialogResult.Cancel;
434                 return;
435             }
436         }
437
438         private void Setting_FormClosing(object sender, FormClosingEventArgs e)
439         {
440             if (MyCommon._endingFlag) return;
441
442             if (this.DialogResult == DialogResult.Cancel)
443             {
444                 //キャンセル時は画面表示時のアカウントに戻す
445                 //キャンセル時でも認証済みアカウント情報は保存する
446                 this.UserAccounts.Clear();
447                 foreach (object u in this.BasedPanel.AuthUserCombo.Items)
448                 {
449                     this.UserAccounts.Add((UserAccount)u);
450                 }
451                 //アクティブユーザーを起動時のアカウントに戻す(起動時アカウントなければ何もしない)
452                 bool userSet = false;
453                 if (this.InitialUserId != null)
454                 {
455                     foreach (UserAccount u in this.UserAccounts)
456                     {
457                         if (u.UserId == this.InitialUserId)
458                         {
459                             tw.Initialize(u.Token, u.TokenSecret, u.Username, u.UserId);
460                             userSet = true;
461                             break;
462                         }
463                     }
464                 }
465                 //認証済みアカウントが削除されていた場合、もしくは起動時アカウントがなかった場合は、
466                 //アクティブユーザーなしとして初期化
467                 if (!userSet)
468                 {
469                     tw.ClearAuthInfo();
470                     tw.Initialize("", "", "", 0);
471                 }
472             }
473
474             if (tw != null && string.IsNullOrEmpty(tw.Username) && e.CloseReason == CloseReason.None)
475             {
476                 if (MessageBox.Show(Properties.Resources.Setting_FormClosing1, "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
477                 {
478                     e.Cancel = true;
479                 }
480             }
481             if (_ValidationError)
482             {
483                 e.Cancel = true;
484             }
485             if (e.Cancel == false && TreeViewSetting.SelectedNode != null)
486             {
487                 var curPanel = (SettingPanelBase)TreeViewSetting.SelectedNode.Tag;
488                 curPanel.Visible = false;
489                 curPanel.Enabled = false;
490             }
491         }
492
493         private void Setting_Load(object sender, EventArgs e)
494         {
495             tw = ((TweenMain)this.Owner).TwitterInstance;
496             //this.AuthStateLabel.Enabled = true;
497             //this.AuthUserLabel.Enabled = true;
498             this.BasedPanel.AuthClearButton.Enabled = true;
499
500             //if (tw.Username == "")
501             //{
502             //    //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click4
503             //    //this.AuthUserLabel.Text = ""
504             //    //this.Save.Enabled = false
505             //}
506             //else
507             //{
508             //    //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click3;
509             //    //if (TwitterApiInfo.AccessLevel == ApiAccessLevel.ReadWrite)
510             //    //{
511             //    //    this.AuthStateLabel.Text += "(xAuth)";
512             //    //}
513             //    //else if (TwitterApiInfo.AccessLevel == ApiAccessLevel.ReadWriteAndDirectMessage)
514             //    //{
515             //    //    this.AuthStateLabel.Text += "(OAuth)";
516             //    //}
517             //    //this.AuthUserLabel.Text = tw.Username;
518             //}
519
520             this.BasedPanel.AuthUserCombo.Items.Clear();
521             if (this.UserAccounts.Count > 0)
522             {
523                 this.BasedPanel.AuthUserCombo.Items.AddRange(this.UserAccounts.ToArray());
524                 foreach (UserAccount u in this.UserAccounts)
525                 {
526                     if (u.UserId == tw.UserId)
527                     {
528                         this.BasedPanel.AuthUserCombo.SelectedItem = u;
529                         this.InitialUserId = u.UserId;
530                         break;
531                     }
532                 }
533             }
534
535             switch (IconSz)
536             {
537                 case MyCommon.IconSizes.IconNone:
538                     this.TweetPrvPanel.IconSize.SelectedIndex = 0;
539                     break;
540                 case MyCommon.IconSizes.Icon16:
541                     this.TweetPrvPanel.IconSize.SelectedIndex = 1;
542                     break;
543                 case MyCommon.IconSizes.Icon24:
544                     this.TweetPrvPanel.IconSize.SelectedIndex = 2;
545                     break;
546                 case MyCommon.IconSizes.Icon48:
547                     this.TweetPrvPanel.IconSize.SelectedIndex = 3;
548                     break;
549                 case MyCommon.IconSizes.Icon48_2:
550                     this.TweetPrvPanel.IconSize.SelectedIndex = 4;
551                     break;
552             }
553             this.TweetActPanel.StatusText.Text = Status;
554             this.ActionPanel.UReadMng.Checked = UnreadManage;
555             this.ActionPanel.PlaySnd.Checked = PlaySound;
556             this.TweetPrvPanel.OneWayLv.Checked = OneWayLove;
557
558             this.FontPanel.lblListFont.Font = FontReaded;
559             this.FontPanel.lblUnread.Font = FontUnread;
560             this.FontPanel.lblUnread.ForeColor = ColorUnread;
561             this.FontPanel.lblListFont.ForeColor = ColorReaded;
562             this.FontPanel.lblFav.ForeColor = ColorFav;
563             this.FontPanel.lblOWL.ForeColor = ColorOWL;
564             this.FontPanel.lblRetweet.ForeColor = ColorRetweet;
565             this.FontPanel.lblDetail.Font = FontDetail;
566             this.FontPanel2.lblSelf.BackColor = ColorSelf;
567             this.FontPanel2.lblAtSelf.BackColor = ColorAtSelf;
568             this.FontPanel2.lblTarget.BackColor = ColorTarget;
569             this.FontPanel2.lblAtTarget.BackColor = ColorAtTarget;
570             this.FontPanel2.lblAtFromTarget.BackColor = ColorAtFromTarget;
571             this.FontPanel2.lblAtTo.BackColor = ColorAtTo;
572             this.FontPanel2.lblInputBackcolor.BackColor = ColorInputBackcolor;
573             this.FontPanel2.lblInputFont.ForeColor = ColorInputFont;
574             this.FontPanel2.lblInputFont.Font = FontInputFont;
575             this.FontPanel2.lblListBackcolor.BackColor = ColorListBackcolor;
576             this.FontPanel.lblDetailBackcolor.BackColor = ColorDetailBackcolor;
577             this.FontPanel.lblDetail.ForeColor = ColorDetail;
578             this.FontPanel.lblDetailLink.ForeColor = ColorDetailLink;
579
580             switch (NameBalloon)
581             {
582                 case MyCommon.NameBalloonEnum.None:
583                     this.PreviewPanel.cmbNameBalloon.SelectedIndex = 0;
584                     break;
585                 case MyCommon.NameBalloonEnum.UserID:
586                     this.PreviewPanel.cmbNameBalloon.SelectedIndex = 1;
587                     break;
588                 case MyCommon.NameBalloonEnum.NickName:
589                     this.PreviewPanel.cmbNameBalloon.SelectedIndex = 2;
590                     break;
591             }
592
593             if (PostCtrlEnter)
594             {
595                 this.TweetActPanel.ComboBoxPostKeySelect.SelectedIndex = 1;
596             }
597             else if (PostShiftEnter)
598             {
599                 this.TweetActPanel.ComboBoxPostKeySelect.SelectedIndex = 2;
600             }
601             else
602             {
603                 this.TweetActPanel.ComboBoxPostKeySelect.SelectedIndex = 0;
604             }
605
606             this.GetCountPanel.TextCountApi.Text = CountApi.ToString();
607             this.GetCountPanel.TextCountApiReply.Text = CountApiReply.ToString();
608             this.ActionPanel.BrowserPathText.Text = BrowserPath;
609             this.TweetActPanel.CheckUseRecommendStatus.Checked = UseRecommendStatus;
610             this.PreviewPanel.CheckDispUsername.Checked = DispUsername;
611             this.ActionPanel.CheckCloseToExit.Checked = CloseToExit;
612             this.ActionPanel.CheckMinimizeToTray.Checked = MinimizeToTray;
613             switch (DispLatestPost)
614             {
615                 case MyCommon.DispTitleEnum.None:
616                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 0;
617                     break;
618                 case MyCommon.DispTitleEnum.Ver:
619                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 1;
620                     break;
621                 case MyCommon.DispTitleEnum.Post:
622                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 2;
623                     break;
624                 case MyCommon.DispTitleEnum.UnreadRepCount:
625                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 3;
626                     break;
627                 case MyCommon.DispTitleEnum.UnreadAllCount:
628                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 4;
629                     break;
630                 case MyCommon.DispTitleEnum.UnreadAllRepCount:
631                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 5;
632                     break;
633                 case MyCommon.DispTitleEnum.UnreadCountAllCount:
634                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 6;
635                     break;
636                 case MyCommon.DispTitleEnum.OwnStatus:
637                     this.PreviewPanel.ComboDispTitle.SelectedIndex = 7;
638                     break;
639             }
640             this.TweetPrvPanel.CheckSortOrderLock.Checked = SortOrderLock;
641             this.TweetPrvPanel.CheckViewTabBottom.Checked = ViewTabBottom;
642             this.ShortUrlPanel.CheckTinyURL.Checked = TinyUrlResolve;
643             switch (_MyProxyType)
644             {
645                 case ProxyType.None:
646                     this.ProxyPanel.RadioProxyNone.Checked = true;
647                     break;
648                 case ProxyType.IE:
649                     this.ProxyPanel.RadioProxyIE.Checked = true;
650                     break;
651                 default:
652                     this.ProxyPanel.RadioProxySpecified.Checked = true;
653                     break;
654             }
655             bool chk = this.ProxyPanel.RadioProxySpecified.Checked;
656             this.ProxyPanel.LabelProxyAddress.Enabled = chk;
657             this.ProxyPanel.TextProxyAddress.Enabled = chk;
658             this.ProxyPanel.LabelProxyPort.Enabled = chk;
659             this.ProxyPanel.TextProxyPort.Enabled = chk;
660             this.ProxyPanel.LabelProxyUser.Enabled = chk;
661             this.ProxyPanel.TextProxyUser.Enabled = chk;
662             this.ProxyPanel.LabelProxyPassword.Enabled = chk;
663             this.ProxyPanel.TextProxyPassword.Enabled = chk;
664
665             this.ProxyPanel.TextProxyAddress.Text = ProxyAddress;
666             this.ProxyPanel.TextProxyPort.Text = ProxyPort.ToString();
667             this.ProxyPanel.TextProxyUser.Text = ProxyUser;
668             this.ProxyPanel.TextProxyPassword.Text = ProxyPassword;
669
670             this.ActionPanel.CheckFavRestrict.Checked = RestrictFavCheck;
671             this.PreviewPanel.CheckAlwaysTop.Checked = AlwaysTop;
672             this.ShortUrlPanel.CheckAutoConvertUrl.Checked = UrlConvertAuto;
673             this.ShortUrlPanel.ShortenTcoCheck.Checked = ShortenTco;
674             this.ShortUrlPanel.ShortenTcoCheck.Enabled = this.ShortUrlPanel.CheckAutoConvertUrl.Checked;
675
676             this.CooperatePanel.CheckNicoms.Checked = Nicoms;
677             this.TweetPrvPanel.chkUnreadStyle.Checked = UseUnreadStyle;
678             this.TweetPrvPanel.CmbDateTimeFormat.Text = DateTimeFormat;
679             this.ConnectionPanel.ConnectionTimeOut.Text = DefaultTimeOut.ToString();
680             this.TweetActPanel.CheckRetweetNoConfirm.Checked = RetweetNoConfirm;
681             this.PreviewPanel.CheckBalloonLimit.Checked = LimitBalloon;
682
683             ApplyEventNotifyFlag(EventNotifyEnabled, EventNotifyFlag, IsMyEventNotifyFlag);
684             this.NotifyPanel.CheckForceEventNotify.Checked = ForceEventNotify;
685             this.NotifyPanel.CheckFavEventUnread.Checked = FavEventUnread;
686             this.CooperatePanel.ComboBoxTranslateLanguage.SelectedIndex = Bing.GetIndexFromLanguageEnum(TranslateLanguage);
687             SoundFileListup();
688             this.ShortUrlPanel.ComboBoxAutoShortUrlFirst.SelectedIndex = (int)AutoShortUrlFirst;
689             this.PreviewPanel.chkTabIconDisp.Checked = TabIconDisp;
690             this.ActionPanel.chkReadOwnPost.Checked = ReadOwnPost;
691             this.PreviewPanel.CheckMonospace.Checked = IsMonospace;
692             this.ActionPanel.CheckReadOldPosts.Checked = ReadOldPosts;
693             this.ShortUrlPanel.TextBitlyId.Text = BitlyUser;
694             this.ShortUrlPanel.TextBitlyPw.Text = BitlyPwd;
695             this.ShortUrlPanel.TextBitlyId.Modified = false;
696             this.ShortUrlPanel.TextBitlyPw.Modified = false;
697             this.TweetPrvPanel.CheckShowGrid.Checked = ShowGrid;
698             this.TweetActPanel.CheckAtIdSupple.Checked = UseAtIdSupplement;
699             this.TweetActPanel.CheckHashSupple.Checked = UseHashSupplement;
700             this.PreviewPanel.CheckPreviewEnable.Checked = PreviewEnable;
701             this.PreviewPanel.CheckStatusAreaAtBottom.Checked = StatusAreaAtBottom;
702             this.ConnectionPanel.TwitterAPIText.Text = TwitterApiUrl;
703             switch (ReplyIconState)
704             {
705                 case MyCommon.REPLY_ICONSTATE.None:
706                     this.PreviewPanel.ReplyIconStateCombo.SelectedIndex = 0;
707                     break;
708                 case MyCommon.REPLY_ICONSTATE.StaticIcon:
709                     this.PreviewPanel.ReplyIconStateCombo.SelectedIndex = 1;
710                     break;
711                 case MyCommon.REPLY_ICONSTATE.BlinkIcon:
712                     this.PreviewPanel.ReplyIconStateCombo.SelectedIndex = 2;
713                     break;
714             }
715             switch (Language)
716             {
717                 case "OS":
718                     this.PreviewPanel.LanguageCombo.SelectedIndex = 0;
719                     break;
720                 case "ja":
721                     this.PreviewPanel.LanguageCombo.SelectedIndex = 1;
722                     break;
723                 case "en":
724                     this.PreviewPanel.LanguageCombo.SelectedIndex = 2;
725                     break;
726                 case "zh-CN":
727                     this.PreviewPanel.LanguageCombo.SelectedIndex = 3;
728                     break;
729                 default:
730                     this.PreviewPanel.LanguageCombo.SelectedIndex = 0;
731                     break;
732             }
733             this.ActionPanel.HotkeyCheck.Checked = HotkeyEnabled;
734             this.ActionPanel.HotkeyAlt.Checked = ((HotkeyMod & Keys.Alt) == Keys.Alt);
735             this.ActionPanel.HotkeyCtrl.Checked = ((HotkeyMod & Keys.Control) == Keys.Control);
736             this.ActionPanel.HotkeyShift.Checked = ((HotkeyMod & Keys.Shift) == Keys.Shift);
737             this.ActionPanel.HotkeyWin.Checked = ((HotkeyMod & Keys.LWin) == Keys.LWin);
738             this.ActionPanel.HotkeyCode.Text = HotkeyValue.ToString();
739             this.ActionPanel.HotkeyText.Text = HotkeyKey.ToString();
740             this.ActionPanel.HotkeyText.Tag = HotkeyKey;
741             this.ActionPanel.HotkeyAlt.Enabled = HotkeyEnabled;
742             this.ActionPanel.HotkeyShift.Enabled = HotkeyEnabled;
743             this.ActionPanel.HotkeyCtrl.Enabled = HotkeyEnabled;
744             this.ActionPanel.HotkeyWin.Enabled = HotkeyEnabled;
745             this.ActionPanel.HotkeyText.Enabled = HotkeyEnabled;
746             this.ActionPanel.HotkeyCode.Enabled = HotkeyEnabled;
747             this.PreviewPanel.ChkNewMentionsBlink.Checked = BlinkNewMentions;
748
749             this.GetCountPanel.GetMoreTextCountApi.Text = MoreCountApi.ToString();
750             this.GetCountPanel.FirstTextCountApi.Text = FirstCountApi.ToString();
751             this.GetCountPanel.SearchTextCountApi.Text = SearchCountApi.ToString();
752             this.GetCountPanel.FavoritesTextCountApi.Text = FavoritesCountApi.ToString();
753             this.GetCountPanel.UserTimelineTextCountApi.Text = UserTimelineCountApi.ToString();
754             this.GetCountPanel.ListTextCountApi.Text = ListCountApi.ToString();
755             this.GetCountPanel.UseChangeGetCount.Checked = UseAdditionalCount;
756             this.GetCountPanel.Label28.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
757             this.GetCountPanel.Label30.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
758             this.GetCountPanel.Label53.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
759             this.GetCountPanel.Label66.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
760             this.GetCountPanel.Label17.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
761             this.GetCountPanel.Label25.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
762             this.GetCountPanel.GetMoreTextCountApi.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
763             this.GetCountPanel.FirstTextCountApi.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
764             this.GetCountPanel.SearchTextCountApi.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
765             this.GetCountPanel.FavoritesTextCountApi.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
766             this.GetCountPanel.UserTimelineTextCountApi.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
767             this.GetCountPanel.ListTextCountApi.Enabled = this.GetCountPanel.UseChangeGetCount.Checked;
768             this.ActionPanel.CheckOpenUserTimeline.Checked = OpenUserTimeline;
769             this.ActionPanel.ListDoubleClickActionComboBox.SelectedIndex = ListDoubleClickAction;
770             this.CooperatePanel.UserAppointUrlText.Text = UserAppointUrl;
771             this.TweetPrvPanel.HideDuplicatedRetweetsCheck.Checked = this.HideDuplicatedRetweets;
772             this.CooperatePanel.EnableImgAzyobuziNetCheckBox.Checked = this.EnableImgAzyobuziNet;
773             this.CooperatePanel.ImgAzyobuziNetDisabledInDMCheckBox.Checked = this.ImgAzyobuziNetDisabledInDM;
774             this.CooperatePanel.MapThumbnailProviderComboBox.SelectedIndex = (int)this.MapThumbnailProvider;
775             this.CooperatePanel.MapThumbnailHeightTextBox.Text = this.MapThumbnailHeight.ToString();
776             this.CooperatePanel.MapThumbnailWidthTextBox.Text = this.MapThumbnailWidth.ToString();
777             this.CooperatePanel.MapThumbnailZoomTextBox.Text = this.MapThumbnailZoom.ToString();
778             this.TweetPrvPanel.IsListsIncludeRtsCheckBox.Checked = this.IsListStatusesIncludeRts;
779             this.ActionPanel.TabMouseLockCheck.Checked = this.TabMouseLock;
780             this.NotifyPanel.IsRemoveSameFavEventCheckBox.Checked = this.IsRemoveSameEvent;
781             this.PreviewPanel.IsNotifyUseGrowlCheckBox.Checked = this.IsNotifyUseGrowl;
782
783             if (GrowlHelper.IsDllExists)
784             {
785                 this.PreviewPanel.IsNotifyUseGrowlCheckBox.Enabled = true;
786             }
787             else
788             {
789                 this.PreviewPanel.IsNotifyUseGrowlCheckBox.Enabled = false;
790             }
791
792             this.TreeViewSetting.Nodes["BasedNode"].Tag = BasedPanel;
793             this.TreeViewSetting.Nodes["BasedNode"].Nodes["PeriodNode"].Tag = GetPeriodPanel;
794             this.TreeViewSetting.Nodes["BasedNode"].Nodes["StartUpNode"].Tag = StartupPanel;
795             this.TreeViewSetting.Nodes["BasedNode"].Nodes["GetCountNode"].Tag = GetCountPanel;
796             //this.TreeViewSetting.Nodes["BasedNode"].Nodes["UserStreamNode"].Tag = UserStreamPanel;
797             this.TreeViewSetting.Nodes["ActionNode"].Tag = ActionPanel;
798             this.TreeViewSetting.Nodes["ActionNode"].Nodes["TweetActNode"].Tag = TweetActPanel;
799             this.TreeViewSetting.Nodes["PreviewNode"].Tag = PreviewPanel;
800             this.TreeViewSetting.Nodes["PreviewNode"].Nodes["TweetPrvNode"].Tag = TweetPrvPanel;
801             this.TreeViewSetting.Nodes["PreviewNode"].Nodes["NotifyNode"].Tag = NotifyPanel;
802             this.TreeViewSetting.Nodes["FontNode"].Tag = FontPanel;
803             this.TreeViewSetting.Nodes["FontNode"].Nodes["FontNode2"].Tag = FontPanel2;
804             this.TreeViewSetting.Nodes["ConnectionNode"].Tag = ConnectionPanel;
805             this.TreeViewSetting.Nodes["ConnectionNode"].Nodes["ProxyNode"].Tag = ProxyPanel;
806             this.TreeViewSetting.Nodes["ConnectionNode"].Nodes["CooperateNode"].Tag = CooperatePanel;
807             this.TreeViewSetting.Nodes["ConnectionNode"].Nodes["ShortUrlNode"].Tag = ShortUrlPanel;
808
809             this.TreeViewSetting.SelectedNode = this.TreeViewSetting.Nodes[0];
810             this.TreeViewSetting.ExpandAll();
811
812             //TreeViewSetting.SelectedNode = TreeViewSetting.TopNode;
813             ActiveControl = BasedPanel.StartAuthButton;
814         }
815
816         private void UReadMng_CheckedChanged(object sender, EventArgs e)
817         {
818             if (this.ActionPanel.UReadMng.Checked == true)
819             {
820                 this.StartupPanel.StartupReaded.Enabled = true;
821             }
822             else
823             {
824                 this.StartupPanel.StartupReaded.Enabled = false;
825             }
826         }
827
828         private void btnFontAndColor_Click(object sender, EventArgs e) // Handles btnUnread.Click, btnDetail.Click, btnListFont.Click, btnInputFont.Click
829         {
830             Button Btn = (Button) sender;
831             DialogResult rtn;
832
833             FontDialog1.AllowVerticalFonts = false;
834             FontDialog1.AllowScriptChange = true;
835             FontDialog1.AllowSimulations = true;
836             FontDialog1.AllowVectorFonts = true;
837             FontDialog1.FixedPitchOnly = false;
838             FontDialog1.FontMustExist = true;
839             FontDialog1.ScriptsOnly = false;
840             FontDialog1.ShowApply = false;
841             FontDialog1.ShowEffects = true;
842             FontDialog1.ShowColor = true;
843
844             switch (Btn.Name)
845             {
846                 case "btnUnread":
847                     FontDialog1.Color = this.FontPanel.lblUnread.ForeColor;
848                     FontDialog1.Font = this.FontPanel.lblUnread.Font;
849                     break;
850                 case "btnDetail":
851                     FontDialog1.Color = this.FontPanel.lblDetail.ForeColor;
852                     FontDialog1.Font = this.FontPanel.lblDetail.Font;
853                     break;
854                 case "btnListFont":
855                     FontDialog1.Color = this.FontPanel.lblListFont.ForeColor;
856                     FontDialog1.Font = this.FontPanel.lblListFont.Font;
857                     break;
858                 case "btnInputFont":
859                     FontDialog1.Color = this.FontPanel2.lblInputFont.ForeColor;
860                     FontDialog1.Font = this.FontPanel2.lblInputFont.Font;
861                     break;
862             }
863
864             try
865             {
866                 rtn = FontDialog1.ShowDialog();
867             }
868             catch(ArgumentException ex)
869             {
870                 MessageBox.Show(ex.Message);
871                 return;
872             }
873
874             if (rtn == DialogResult.Cancel) return;
875
876             switch (Btn.Name)
877             {
878                 case "btnUnread":
879                     this.FontPanel.lblUnread.ForeColor = FontDialog1.Color;
880                     this.FontPanel.lblUnread.Font = FontDialog1.Font;
881                     break;
882                 case "btnDetail":
883                     this.FontPanel.lblDetail.ForeColor = FontDialog1.Color;
884                     this.FontPanel.lblDetail.Font = FontDialog1.Font;
885                     break;
886                 case "btnListFont":
887                     this.FontPanel.lblListFont.ForeColor = FontDialog1.Color;
888                     this.FontPanel.lblListFont.Font = FontDialog1.Font;
889                     break;
890                 case "btnInputFont":
891                     this.FontPanel2.lblInputFont.ForeColor = FontDialog1.Color;
892                     this.FontPanel2.lblInputFont.Font = FontDialog1.Font;
893                     break;
894             }
895
896         }
897
898         private void btnColor_Click(object sender, EventArgs e) //Handles btnSelf.Click, btnAtSelf.Click, btnTarget.Click, btnAtTarget.Click, btnAtFromTarget.Click, btnFav.Click, btnOWL.Click, btnInputBackcolor.Click, btnAtTo.Click, btnListBack.Click, btnDetailBack.Click, btnDetailLink.Click, btnRetweet.Click
899         {
900             Button Btn = (Button)sender;
901             DialogResult rtn;
902
903             ColorDialog1.AllowFullOpen = true;
904             ColorDialog1.AnyColor = true;
905             ColorDialog1.FullOpen = false;
906             ColorDialog1.SolidColorOnly = false;
907
908             switch (Btn.Name)
909             {
910                 case "btnSelf":
911                     ColorDialog1.Color = this.FontPanel2.lblSelf.BackColor;
912                     break;
913                 case "btnAtSelf":
914                     ColorDialog1.Color = this.FontPanel2.lblAtSelf.BackColor;
915                     break;
916                 case "btnTarget":
917                     ColorDialog1.Color = this.FontPanel2.lblTarget.BackColor;
918                     break;
919                 case "btnAtTarget":
920                     ColorDialog1.Color = this.FontPanel2.lblAtTarget.BackColor;
921                     break;
922                 case "btnAtFromTarget":
923                     ColorDialog1.Color = this.FontPanel2.lblAtFromTarget.BackColor;
924                     break;
925                 case "btnFav":
926                     ColorDialog1.Color = this.FontPanel.lblFav.ForeColor;
927                     break;
928                 case "btnOWL":
929                     ColorDialog1.Color = this.FontPanel.lblOWL.ForeColor;
930                     break;
931                 case "btnRetweet":
932                     ColorDialog1.Color = this.FontPanel.lblRetweet.ForeColor;
933                     break;
934                 case "btnInputBackcolor":
935                     ColorDialog1.Color = this.FontPanel2.lblInputBackcolor.BackColor;
936                     break;
937                 case "btnAtTo":
938                     ColorDialog1.Color = this.FontPanel2.lblAtTo.BackColor;
939                     break;
940                 case "btnListBack":
941                     ColorDialog1.Color = this.FontPanel2.lblListBackcolor.BackColor;
942                     break;
943                 case "btnDetailBack":
944                     ColorDialog1.Color = this.FontPanel.lblDetailBackcolor.BackColor;
945                     break;
946                 case "btnDetailLink":
947                     ColorDialog1.Color = this.FontPanel.lblDetailLink.ForeColor;
948                     break;
949             }
950
951             rtn = ColorDialog1.ShowDialog();
952
953             if (rtn == DialogResult.Cancel) return;
954
955             switch (Btn.Name)
956             {
957                 case "btnSelf":
958                     this.FontPanel2.lblSelf.BackColor = ColorDialog1.Color;
959                     break;
960                 case "btnAtSelf":
961                     this.FontPanel2.lblAtSelf.BackColor = ColorDialog1.Color;
962                     break;
963                 case "btnTarget":
964                     this.FontPanel2.lblTarget.BackColor = ColorDialog1.Color;
965                     break;
966                 case "btnAtTarget":
967                     this.FontPanel2.lblAtTarget.BackColor = ColorDialog1.Color;
968                     break;
969                 case "btnAtFromTarget":
970                     this.FontPanel2.lblAtFromTarget.BackColor = ColorDialog1.Color;
971                     break;
972                 case "btnFav":
973                     this.FontPanel.lblFav.ForeColor = ColorDialog1.Color;
974                     break;
975                 case "btnOWL":
976                     this.FontPanel.lblOWL.ForeColor = ColorDialog1.Color;
977                     break;
978                 case "btnRetweet":
979                     this.FontPanel.lblRetweet.ForeColor = ColorDialog1.Color;
980                     break;
981                 case "btnInputBackcolor":
982                     this.FontPanel2.lblInputBackcolor.BackColor = ColorDialog1.Color;
983                     break;
984                 case "btnAtTo":
985                     this.FontPanel2.lblAtTo.BackColor = ColorDialog1.Color;
986                     break;
987                 case "btnListBack":
988                     this.FontPanel2.lblListBackcolor.BackColor = ColorDialog1.Color;
989                     break;
990                 case "btnDetailBack":
991                     this.FontPanel.lblDetailBackcolor.BackColor = ColorDialog1.Color;
992                     break;
993                 case "btnDetailLink":
994                     this.FontPanel.lblDetailLink.ForeColor = ColorDialog1.Color;
995                     break;
996             }
997         }
998
999         public MyCommon.IconSizes IconSz { get; set; }
1000         public string Status { get; set; }
1001         public bool UnreadManage { get; set; }
1002         public bool PlaySound { get; set; }
1003         public bool OneWayLove { get; set; }
1004         public Font FontUnread { get; set; } /////未使用
1005         public Color ColorUnread { get; set; }
1006         public Font FontReaded { get; set; } /////リストフォントとして使用
1007         public Color ColorReaded { get; set; }
1008         public Color ColorFav { get; set; }
1009         public Color ColorOWL { get; set; }
1010         public Color ColorRetweet { get; set; }
1011         public Font FontDetail { get; set; }
1012         public Color ColorDetail { get; set; }
1013         public Color ColorDetailLink { get; set; }
1014         public Color ColorSelf { get; set; }
1015         public Color ColorAtSelf { get; set; }
1016         public Color ColorTarget { get; set; }
1017         public Color ColorAtTarget { get; set; }
1018         public Color ColorAtFromTarget { get; set; }
1019         public Color ColorAtTo { get; set; }
1020         public Color ColorInputBackcolor { get; set; }
1021         public Color ColorInputFont { get; set; }
1022         public Font FontInputFont { get; set; }
1023         public Color ColorListBackcolor { get; set; }
1024         public Color ColorDetailBackcolor { get; set; }
1025         public MyCommon.NameBalloonEnum NameBalloon { get; set; }
1026         public bool PostCtrlEnter { get; set; }
1027         public bool PostShiftEnter { get; set; }
1028         public int CountApi { get; set; }
1029         public int CountApiReply { get; set; }
1030         public int MoreCountApi { get; set; }
1031         public int FirstCountApi { get; set; }
1032         public int SearchCountApi { get; set; }
1033         public int FavoritesCountApi { get; set; }
1034         public int UserTimelineCountApi { get; set; }
1035         public int ListCountApi { get; set; }
1036         public bool UseRecommendStatus { get; set; }
1037         public string RecommendStatusText { get; set; }
1038         public bool DispUsername { get; set; }
1039         public bool CloseToExit { get; set; }
1040         public bool MinimizeToTray { get; set; }
1041         public MyCommon.DispTitleEnum DispLatestPost { get; set; }
1042         public string BrowserPath { get; set; }
1043         public bool TinyUrlResolve { get; set; }
1044
1045         public bool SortOrderLock { get; set; }
1046         public ProxyType SelectedProxyType
1047         {
1048             get {
1049                 return _MyProxyType;
1050             }
1051             set {
1052                 _MyProxyType = value;
1053             }
1054         }
1055         /// <summary>
1056         /// タブを下部に表示するかどうかを取得または設定する
1057         /// </summary>
1058         public bool ViewTabBottom { get; set; }
1059
1060         public string ProxyAddress { get; set; }
1061         public int ProxyPort { get; set; }
1062         public string ProxyUser { get; set; }
1063         public string ProxyPassword { get; set; }
1064         public bool RestrictFavCheck { get; set; }
1065         public bool AlwaysTop { get; set; }
1066         public bool UrlConvertAuto { get; set; }
1067         public bool ShortenTco { get; set; }
1068         public bool Nicoms { get; set; }
1069         public MyCommon.UrlConverter AutoShortUrlFirst { get; set; }
1070         public bool UseUnreadStyle { get; set; }
1071         public string DateTimeFormat { get; set; }
1072         public int DefaultTimeOut { get; set; }
1073         public bool RetweetNoConfirm { get; set; }
1074         public bool TabIconDisp { get; set; }
1075         public MyCommon.REPLY_ICONSTATE ReplyIconState { get; set; }
1076         public bool ReadOwnPost { get; set; }
1077         public bool IsMonospace { get; set; }
1078         public bool ReadOldPosts { get; set; }
1079         public string BitlyUser { get; set; }
1080         public string BitlyPwd { get; set; }
1081         public bool ShowGrid { get; set; }
1082         public bool UseAtIdSupplement { get; set; }
1083         public bool UseHashSupplement { get; set; }
1084         public bool PreviewEnable { get; set; }
1085         public bool StatusAreaAtBottom { get; set; }
1086         public bool UseAdditionalCount { get; set; }
1087         public bool OpenUserTimeline { get; set; }
1088         public string TwitterApiUrl { get; set; }
1089         public string Language { get; set; }
1090
1091         public bool LimitBalloon { get; set; }
1092         public bool EventNotifyEnabled { get; set; }
1093
1094         public MyCommon.EVENTTYPE EventNotifyFlag
1095         {
1096             get
1097             {
1098                 return _MyEventNotifyFlag;
1099             }
1100             set
1101             {
1102                 _MyEventNotifyFlag = value;
1103             }
1104         }
1105
1106         public MyCommon.EVENTTYPE IsMyEventNotifyFlag
1107         {
1108             get
1109             {
1110                 return _isMyEventNotifyFlag;
1111             }
1112             set
1113             {
1114                 _isMyEventNotifyFlag = value;
1115             }
1116         }
1117
1118         public bool ForceEventNotify { get; set; }
1119         public bool FavEventUnread { get; set; }
1120
1121         public string TranslateLanguage
1122         {
1123             get
1124             {
1125                 return _MyTranslateLanguage;
1126             }
1127             set
1128             {
1129                 _MyTranslateLanguage = value;
1130                 this.CooperatePanel.ComboBoxTranslateLanguage.SelectedIndex = Bing.GetIndexFromLanguageEnum(value);
1131             }
1132         }
1133
1134         public string EventSoundFile { get; set; }
1135         public int ListDoubleClickAction { get; set; }
1136         public string UserAppointUrl { get; set; }
1137
1138         private bool StartAuth()
1139         {
1140             //現在の設定内容で通信
1141             ProxyType ptype;
1142             if (this.ProxyPanel.RadioProxyNone.Checked)
1143             {
1144                 ptype = ProxyType.None;
1145             }
1146             else if (this.ProxyPanel.RadioProxyIE.Checked)
1147             {
1148                 ptype = ProxyType.IE;
1149             }
1150             else
1151             {
1152                 ptype = ProxyType.Specified;
1153             }
1154             string padr = this.ProxyPanel.TextProxyAddress.Text.Trim();
1155             int pport = int.Parse(this.ProxyPanel.TextProxyPort.Text.Trim());
1156             string pusr = this.ProxyPanel.TextProxyUser.Text.Trim();
1157             string ppw = this.ProxyPanel.TextProxyPassword.Text.Trim();
1158
1159             //通信基底クラス初期化
1160             Networking.DefaultTimeout = TimeSpan.FromSeconds(20);
1161             Networking.SetWebProxy(ptype, padr, pport, pusr, ppw);
1162             HttpTwitter.TwitterUrl = this.ConnectionPanel.TwitterAPIText.Text.Trim();
1163             tw.Initialize("", "", "", 0);
1164             //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click4;
1165             //this.AuthUserLabel.Text = "";
1166             string pinPageUrl = "";
1167             string rslt = tw.StartAuthentication(ref pinPageUrl);
1168             if (string.IsNullOrEmpty(rslt))
1169             {
1170                 string pin = AuthDialog.DoAuth(this, pinPageUrl);
1171                 if (!string.IsNullOrEmpty(pin))
1172                 {
1173                     this._pin = pin;
1174                     return true;
1175                 }
1176                 else
1177                 {
1178                     return false;
1179                 }
1180             }
1181             else
1182             {
1183                 MessageBox.Show(Properties.Resources.AuthorizeButton_Click2 + Environment.NewLine + rslt, "Authenticate", MessageBoxButtons.OK);
1184                 return false;
1185             }
1186         }
1187
1188         private bool PinAuth()
1189         {
1190             string pin = this._pin;   //PIN Code
1191
1192             string rslt = tw.Authenticate(pin);
1193             if (string.IsNullOrEmpty(rslt))
1194             {
1195                 MessageBox.Show(Properties.Resources.AuthorizeButton_Click1, "Authenticate", MessageBoxButtons.OK);
1196                 //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click3;
1197                 //this.AuthUserLabel.Text = tw.Username;
1198                 int idx = -1;
1199                 UserAccount user = new UserAccount();
1200                 user.Username = tw.Username;
1201                 user.UserId = tw.UserId;
1202                 user.Token = tw.AccessToken;
1203                 user.TokenSecret = tw.AccessTokenSecret;
1204
1205                 foreach (object u in this.BasedPanel.AuthUserCombo.Items)
1206                 {
1207                     if (((UserAccount)u).Username.ToLower() == tw.Username.ToLower())
1208                     {
1209                         idx = this.BasedPanel.AuthUserCombo.Items.IndexOf(u);
1210                         break;
1211                     }
1212                 }
1213                 if (idx > -1)
1214                 {
1215                     this.BasedPanel.AuthUserCombo.Items.RemoveAt(idx);
1216                     this.BasedPanel.AuthUserCombo.Items.Insert(idx, user);
1217                     this.BasedPanel.AuthUserCombo.SelectedIndex = idx;
1218                 }
1219                 else
1220                 {
1221                     this.BasedPanel.AuthUserCombo.SelectedIndex = this.BasedPanel.AuthUserCombo.Items.Add(user);
1222                 }
1223                 //if (TwitterApiInfo.AccessLevel = ApiAccessLevel.ReadWrite)
1224                 //{
1225                 //    this.AuthStateLabel.Text += "(xAuth)";
1226                 //}
1227                 //else if (TwitterApiInfo.AccessLevel == ApiAccessLevel.ReadWriteAndDirectMessage)
1228                 //{
1229                 //    this.AuthStateLabel.Text += "(OAuth)";
1230                 //}
1231                 return true;
1232             }
1233             else
1234             {
1235                 MessageBox.Show(Properties.Resources.AuthorizeButton_Click2 + Environment.NewLine + rslt, "Authenticate", MessageBoxButtons.OK);
1236                 //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click4;
1237                 //this.AuthUserLabel.Text = "";
1238                 return false;
1239             }
1240         }
1241
1242         private void StartAuthButton_Click(object sender, EventArgs e)
1243         {
1244             //this.Save.Enabled = false;
1245             if (StartAuth())
1246             {
1247                 if (PinAuth())
1248                 {
1249                     //this.Save.Enabled = true;
1250                 }
1251             }
1252         }
1253
1254         private void CheckPostAndGet_CheckedChanged(object sender, EventArgs e)
1255         {
1256             this.GetPeriodPanel.LabelPostAndGet.Visible = this.GetPeriodPanel.CheckPostAndGet.Checked && !tw.UserStreamEnabled;
1257         }
1258
1259         private void Setting_Shown(object sender, EventArgs e)
1260         {
1261             do
1262             {
1263                 Thread.Sleep(10);
1264                 if (this.Disposing || this.IsDisposed) return;
1265             } while (!this.IsHandleCreated);
1266             this.TopMost = this.AlwaysTop;
1267
1268             this.GetPeriodPanel.LabelPostAndGet.Visible = this.GetPeriodPanel.CheckPostAndGet.Checked && !tw.UserStreamEnabled;
1269             this.GetPeriodPanel.LabelUserStreamActive.Visible = tw.UserStreamEnabled;
1270         }
1271
1272         public static AppendSettingDialog Instance
1273         {
1274             get { return _instance; }
1275         }
1276
1277         private bool BitlyValidation(string id, string apikey)
1278         {
1279             if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(apikey))
1280             {
1281                 return false;
1282             }
1283
1284             string req = "http://api.bit.ly/v3/validate";
1285             string content = "";
1286             Dictionary<string, string> param = new Dictionary<string, string>();
1287
1288             param.Add("login", ApplicationSettings.BitlyLoginId);
1289             param.Add("apiKey", ApplicationSettings.BitlyApiKey);
1290             param.Add("x_login", id);
1291             param.Add("x_apiKey", apikey);
1292             param.Add("format", "txt");
1293
1294             if (!(new HttpVarious()).PostData(req, param, out content))
1295             {
1296                 return true;             // 通信エラーの場合はとりあえずチェックを通ったことにする
1297             }
1298             else if (content.Trim() == "1")
1299             {
1300                 return true;             // 検証成功
1301             }
1302             else if (content.Trim() == "0")
1303             {
1304                 return false;            // 検証失敗 APIキーとIDの組み合わせが違う
1305             }
1306             else
1307             {
1308                 return true;             // 規定外応答:通信エラーの可能性があるためとりあえずチェックを通ったことにする
1309             }
1310         }
1311
1312         private void Cancel_Click(object sender, EventArgs e)
1313         {
1314             _ValidationError = false;
1315         }
1316
1317         public bool HotkeyEnabled;
1318         public Keys HotkeyKey;
1319         public int HotkeyValue;
1320         public Keys HotkeyMod;
1321
1322         public bool BlinkNewMentions;
1323
1324         //private void CheckEventNotify_CheckedChanged(object sender, EventArgs e)
1325         //                Handles CheckEventNotify.CheckedChanged, CheckFavoritesEvent.CheckStateChanged,
1326         //                        CheckUnfavoritesEvent.CheckStateChanged, CheckFollowEvent.CheckStateChanged,
1327         //                        CheckListMemberAddedEvent.CheckStateChanged, CheckListMemberRemovedEvent.CheckStateChanged,
1328         //                        CheckListCreatedEvent.CheckStateChanged, CheckUserUpdateEvent.CheckStateChanged
1329         //{
1330         //    EventNotifyEnabled = CheckEventNotify.Checked;
1331         //    GetEventNotifyFlag(EventNotifyFlag, IsMyEventNotifyFlag);
1332         //    ApplyEventNotifyFlag(EventNotifyEnabled, EventNotifyFlag, IsMyEventNotifyFlag);
1333         //}
1334
1335         private class EventCheckboxTblElement
1336         {
1337             public CheckBox CheckBox;
1338             public MyCommon.EVENTTYPE Type;
1339         }
1340
1341         private EventCheckboxTblElement[] GetEventCheckboxTable()
1342         {
1343             EventCheckboxTblElement[] _eventCheckboxTable = new EventCheckboxTblElement[8];
1344
1345             _eventCheckboxTable[0] = new EventCheckboxTblElement();
1346             _eventCheckboxTable[0].CheckBox = this.NotifyPanel.CheckFavoritesEvent;
1347             _eventCheckboxTable[0].Type = MyCommon.EVENTTYPE.Favorite;
1348
1349             _eventCheckboxTable[1] = new EventCheckboxTblElement();
1350             _eventCheckboxTable[1].CheckBox = this.NotifyPanel.CheckUnfavoritesEvent;
1351             _eventCheckboxTable[1].Type = MyCommon.EVENTTYPE.Unfavorite;
1352
1353             _eventCheckboxTable[2] = new EventCheckboxTblElement();
1354             _eventCheckboxTable[2].CheckBox = this.NotifyPanel.CheckFollowEvent;
1355             _eventCheckboxTable[2].Type = MyCommon.EVENTTYPE.Follow;
1356
1357             _eventCheckboxTable[3] = new EventCheckboxTblElement();
1358             _eventCheckboxTable[3].CheckBox = this.NotifyPanel.CheckListMemberAddedEvent;
1359             _eventCheckboxTable[3].Type = MyCommon.EVENTTYPE.ListMemberAdded;
1360
1361             _eventCheckboxTable[4] = new EventCheckboxTblElement();
1362             _eventCheckboxTable[4].CheckBox = this.NotifyPanel.CheckListMemberRemovedEvent;
1363             _eventCheckboxTable[4].Type = MyCommon.EVENTTYPE.ListMemberRemoved;
1364
1365             _eventCheckboxTable[5] = new EventCheckboxTblElement();
1366             _eventCheckboxTable[5].CheckBox = this.NotifyPanel.CheckBlockEvent;
1367             _eventCheckboxTable[5].Type = MyCommon.EVENTTYPE.Block;
1368
1369             _eventCheckboxTable[6] = new EventCheckboxTblElement();
1370             _eventCheckboxTable[6].CheckBox = this.NotifyPanel.CheckUserUpdateEvent;
1371             _eventCheckboxTable[6].Type = MyCommon.EVENTTYPE.UserUpdate;
1372
1373             _eventCheckboxTable[7] = new EventCheckboxTblElement();
1374             _eventCheckboxTable[7].CheckBox = this.NotifyPanel.CheckListCreatedEvent;
1375             _eventCheckboxTable[7].Type = MyCommon.EVENTTYPE.ListCreated;
1376
1377             return _eventCheckboxTable;
1378         }
1379
1380         private void GetEventNotifyFlag(ref MyCommon.EVENTTYPE eventnotifyflag, ref MyCommon.EVENTTYPE isMyeventnotifyflag)
1381         {
1382             MyCommon.EVENTTYPE evt = MyCommon.EVENTTYPE.None;
1383             MyCommon.EVENTTYPE myevt = MyCommon.EVENTTYPE.None;
1384
1385             foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable())
1386             {
1387                 switch (tbl.CheckBox.CheckState)
1388                 {
1389                     case CheckState.Checked:
1390                         evt = evt | tbl.Type;
1391                         myevt = myevt | tbl.Type;
1392                         break;
1393                     case CheckState.Indeterminate:
1394                         evt = evt | tbl.Type;
1395                         break;
1396                     case CheckState.Unchecked:
1397                         break;
1398                 }
1399             }
1400             eventnotifyflag = evt;
1401             isMyeventnotifyflag = myevt;
1402         }
1403
1404         private void ApplyEventNotifyFlag(bool rootEnabled, MyCommon.EVENTTYPE eventnotifyflag, MyCommon.EVENTTYPE isMyeventnotifyflag)
1405         {
1406             MyCommon.EVENTTYPE evt = eventnotifyflag;
1407             MyCommon.EVENTTYPE myevt = isMyeventnotifyflag;
1408
1409             this.NotifyPanel.CheckEventNotify.Checked = rootEnabled;
1410
1411             foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable())
1412             {
1413                 if ((evt & tbl.Type) != 0)
1414                 {
1415                     if ((myevt & tbl.Type) != 0)
1416                     {
1417                         tbl.CheckBox.CheckState = CheckState.Checked;
1418                     }
1419                     else
1420                     {
1421                         tbl.CheckBox.CheckState = CheckState.Indeterminate;
1422                     }
1423                 }
1424                 else
1425                 {
1426                     tbl.CheckBox.CheckState = CheckState.Unchecked;
1427                 }
1428                 tbl.CheckBox.Enabled = rootEnabled;
1429             }
1430
1431         }
1432
1433         private void CheckEventNotify_CheckedChanged(object sender, EventArgs e)
1434         {
1435             foreach (EventCheckboxTblElement tbl in GetEventCheckboxTable())
1436             {
1437                 tbl.CheckBox.Enabled = this.NotifyPanel.CheckEventNotify.Checked;
1438             }
1439         }
1440
1441         //private void CheckForceEventNotify_CheckedChanged(object sender, EventArgs e)
1442         //{
1443         //    _MyForceEventNotify = CheckEventNotify.Checked;
1444         //}
1445
1446         //private void CheckFavEventUnread_CheckedChanged(object sender, EventArgs e)
1447         //{
1448         //    _MyFavEventUnread = CheckFavEventUnread.Checked;
1449         //}
1450
1451         //private void ComboBoxTranslateLanguage_SelectedIndexChanged(object sender, EventArgs e)
1452         //{
1453         //    _MyTranslateLanguage = (new Google()).GetLanguageEnumFromIndex(ComboBoxTranslateLanguage.SelectedIndex);
1454         //}
1455
1456         private void SoundFileListup()
1457         {
1458             if (EventSoundFile == null) EventSoundFile = "";
1459             this.NotifyPanel.ComboBoxEventNotifySound.Items.Clear();
1460             this.NotifyPanel.ComboBoxEventNotifySound.Items.Add("");
1461             DirectoryInfo oDir = new DirectoryInfo(Application.StartupPath + Path.DirectorySeparatorChar);
1462             if (Directory.Exists(Path.Combine(Application.StartupPath, "Sounds")))
1463             {
1464                 oDir = oDir.GetDirectories("Sounds")[0];
1465             }
1466             foreach (FileInfo oFile in oDir.GetFiles("*.wav"))
1467             {
1468                 this.NotifyPanel.ComboBoxEventNotifySound.Items.Add(oFile.Name);
1469             }
1470             int idx = this.NotifyPanel.ComboBoxEventNotifySound.Items.IndexOf(EventSoundFile);
1471             if (idx == -1) idx = 0;
1472             this.NotifyPanel.ComboBoxEventNotifySound.SelectedIndex = idx;
1473         }
1474
1475         //private void ComboBoxEventNotifySound_VisibleChanged(object sender, EventArgs e)
1476         //{
1477         //    SoundFileListup();
1478         //}
1479
1480         //private void ComboBoxEventNotifySound_SelectedIndexChanged(object sender, EventArgs e)
1481         //{
1482         //   if (_soundfileListup) return;
1483
1484         //    _MyEventSoundFile = (string)ComboBoxEventNotifySound.SelectedItem;
1485         //}
1486
1487         private void OpenUrl(string url)
1488         {
1489             string myPath = url;
1490             string path = this.ActionPanel.BrowserPathText.Text;
1491             try
1492             {
1493                 if (!string.IsNullOrEmpty(BrowserPath))
1494                 {
1495                     if (path.StartsWith("\"") && path.Length > 2 && path.IndexOf("\"", 2) > -1)
1496                     {
1497                         int sep = path.IndexOf("\"", 2);
1498                         string browserPath = path.Substring(1, sep - 1);
1499                         string arg = "";
1500                         if (sep < path.Length - 1)
1501                         {
1502                             arg = path.Substring(sep + 1);
1503                         }
1504                         myPath = arg + " " + myPath;
1505                         System.Diagnostics.Process.Start(browserPath, myPath);
1506                     }
1507                     else
1508                     {
1509                         System.Diagnostics.Process.Start(path, myPath);
1510                     }
1511                 }
1512                 else
1513                 {
1514                     System.Diagnostics.Process.Start(myPath);
1515                 }
1516             }
1517             catch(Exception)
1518             {
1519 //              MessageBox.Show("ブラウザの起動に失敗、またはタイムアウトしました。" + ex.ToString());
1520             }
1521         }
1522
1523         private void CreateAccountButton_Click(object sender, EventArgs e)
1524         {
1525             this.OpenUrl("https://twitter.com/signup");
1526         }
1527
1528         public AppendSettingDialog()
1529         {
1530             InitializeComponent();
1531
1532             this.BasedPanel.StartAuthButton.Click += this.StartAuthButton_Click;
1533             this.BasedPanel.CreateAccountButton.Click += this.CreateAccountButton_Click;
1534             this.NotifyPanel.CheckEventNotify.CheckedChanged += this.CheckEventNotify_CheckedChanged;
1535             this.GetPeriodPanel.CheckPostAndGet.CheckedChanged += this.CheckPostAndGet_CheckedChanged;
1536             this.ActionPanel.UReadMng.CheckedChanged += this.UReadMng_CheckedChanged;
1537             this.FontPanel.btnUnread.Click += this.btnFontAndColor_Click;
1538             this.FontPanel.btnDetail.Click += this.btnFontAndColor_Click;
1539             this.FontPanel.btnListFont.Click += this.btnFontAndColor_Click;
1540             this.FontPanel.btnFav.Click += this.btnColor_Click;
1541             this.FontPanel.btnOWL.Click += this.btnColor_Click;
1542             this.FontPanel.btnRetweet.Click += this.btnColor_Click;
1543             this.FontPanel.btnDetailBack.Click += this.btnColor_Click;
1544             this.FontPanel.btnDetailLink.Click += this.btnColor_Click;
1545             this.FontPanel2.btnInputFont.Click += this.btnFontAndColor_Click;
1546             this.FontPanel2.btnSelf.Click += this.btnColor_Click;
1547             this.FontPanel2.btnAtSelf.Click += this.btnColor_Click;
1548             this.FontPanel2.btnTarget.Click += this.btnColor_Click;
1549             this.FontPanel2.btnAtTarget.Click += this.btnColor_Click;
1550             this.FontPanel2.btnAtFromTarget.Click += this.btnColor_Click;
1551             this.FontPanel2.btnInputBackcolor.Click += this.btnColor_Click;
1552             this.FontPanel2.btnAtTo.Click += this.btnColor_Click;
1553             this.FontPanel2.btnListBack.Click += this.btnColor_Click;
1554
1555             this.Icon = Properties.Resources.MIcon;
1556         }
1557
1558         private void GetPeriodPanel_IntervalChanged(object sender, IntervalChangedEventArgs e)
1559         {
1560             if (this.IntervalChanged != null)
1561                 this.IntervalChanged(sender, e);
1562         }
1563     }
1564
1565     public class IntervalChangedEventArgs : EventArgs
1566     {
1567         public bool UserStream;
1568         public bool Timeline;
1569         public bool Reply;
1570         public bool DirectMessage;
1571         public bool PublicSearch;
1572         public bool Lists;
1573         public bool UserTimeline;
1574     }
1575 }