OSDN Git Service

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