OSDN Git Service

77b779ccef6a667b336c5a49a73f880478755fae
[opentween/open-tween.git] / OpenTween / Setting / Panel / PreviewPanel.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) 2014      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.Drawing;
31 using System.Data;
32 using System.Linq;
33 using System.Text;
34 using System.Windows.Forms;
35
36 namespace OpenTween.Setting.Panel
37 {
38     public partial class PreviewPanel : SettingPanelBase
39     {
40         public PreviewPanel()
41             => this.InitializeComponent();
42
43         public void LoadConfig(SettingCommon settingCommon)
44         {
45             switch (settingCommon.NameBalloon)
46             {
47                 case MyCommon.NameBalloonEnum.None:
48                     this.cmbNameBalloon.SelectedIndex = 0;
49                     break;
50                 case MyCommon.NameBalloonEnum.UserID:
51                     this.cmbNameBalloon.SelectedIndex = 1;
52                     break;
53                 case MyCommon.NameBalloonEnum.NickName:
54                     this.cmbNameBalloon.SelectedIndex = 2;
55                     break;
56             }
57
58             this.CheckDispUsername.Checked = settingCommon.DispUsername;
59
60             switch (settingCommon.DispLatestPost)
61             {
62                 case MyCommon.DispTitleEnum.None:
63                     this.ComboDispTitle.SelectedIndex = 0;
64                     break;
65                 case MyCommon.DispTitleEnum.Ver:
66                     this.ComboDispTitle.SelectedIndex = 1;
67                     break;
68                 case MyCommon.DispTitleEnum.Post:
69                     this.ComboDispTitle.SelectedIndex = 2;
70                     break;
71                 case MyCommon.DispTitleEnum.UnreadRepCount:
72                     this.ComboDispTitle.SelectedIndex = 3;
73                     break;
74                 case MyCommon.DispTitleEnum.UnreadAllCount:
75                     this.ComboDispTitle.SelectedIndex = 4;
76                     break;
77                 case MyCommon.DispTitleEnum.UnreadAllRepCount:
78                     this.ComboDispTitle.SelectedIndex = 5;
79                     break;
80                 case MyCommon.DispTitleEnum.UnreadCountAllCount:
81                     this.ComboDispTitle.SelectedIndex = 6;
82                     break;
83                 case MyCommon.DispTitleEnum.OwnStatus:
84                     this.ComboDispTitle.SelectedIndex = 7;
85                     break;
86             }
87
88             this.CheckAlwaysTop.Checked = settingCommon.AlwaysTop;
89             this.CheckBalloonLimit.Checked = settingCommon.LimitBalloon;
90             this.chkTabIconDisp.Checked = settingCommon.TabIconDisp;
91             this.CheckMonospace.Checked = settingCommon.IsMonospace;
92             this.CheckPreviewEnable.Checked = settingCommon.PreviewEnable;
93             this.CheckStatusAreaAtBottom.Checked = settingCommon.StatusAreaAtBottom;
94
95             switch (settingCommon.ReplyIconState)
96             {
97                 case MyCommon.REPLY_ICONSTATE.None:
98                     this.ReplyIconStateCombo.SelectedIndex = 0;
99                     break;
100                 case MyCommon.REPLY_ICONSTATE.StaticIcon:
101                     this.ReplyIconStateCombo.SelectedIndex = 1;
102                     break;
103                 case MyCommon.REPLY_ICONSTATE.BlinkIcon:
104                     this.ReplyIconStateCombo.SelectedIndex = 2;
105                     break;
106             }
107
108             switch (settingCommon.Language)
109             {
110                 case "OS":
111                     this.LanguageCombo.SelectedIndex = 0;
112                     break;
113                 case "ja":
114                     this.LanguageCombo.SelectedIndex = 1;
115                     break;
116                 case "en":
117                     this.LanguageCombo.SelectedIndex = 2;
118                     break;
119                 default:
120                     this.LanguageCombo.SelectedIndex = 0;
121                     break;
122             }
123
124             this.ChkNewMentionsBlink.Checked = settingCommon.BlinkNewMentions;
125             this.IsNotifyUseGrowlCheckBox.Checked = settingCommon.IsUseNotifyGrowl;
126             this.IsNotifyUseGrowlCheckBox.Enabled = GrowlHelper.IsDllExists;
127         }
128
129         public void SaveConfig(SettingCommon settingCommon)
130         {
131             switch (this.cmbNameBalloon.SelectedIndex)
132             {
133                 case 0:
134                     settingCommon.NameBalloon = MyCommon.NameBalloonEnum.None;
135                     break;
136                 case 1:
137                     settingCommon.NameBalloon = MyCommon.NameBalloonEnum.UserID;
138                     break;
139                 case 2:
140                     settingCommon.NameBalloon = MyCommon.NameBalloonEnum.NickName;
141                     break;
142             }
143
144             settingCommon.DispUsername = this.CheckDispUsername.Checked;
145
146             switch (this.ComboDispTitle.SelectedIndex)
147             {
148                 case 0: // None
149                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.None;
150                     break;
151                 case 1: // Ver
152                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.Ver;
153                     break;
154                 case 2: // Post
155                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.Post;
156                     break;
157                 case 3: // RepCount
158                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadRepCount;
159                     break;
160                 case 4: // AllCount
161                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadAllCount;
162                     break;
163                 case 5: // Rep+All
164                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadAllRepCount;
165                     break;
166                 case 6: // Unread/All
167                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.UnreadCountAllCount;
168                     break;
169                 case 7: // Count of Status/Follow/Follower
170                     settingCommon.DispLatestPost = MyCommon.DispTitleEnum.OwnStatus;
171                     break;
172             }
173
174             settingCommon.AlwaysTop = this.CheckAlwaysTop.Checked;
175             settingCommon.LimitBalloon = this.CheckBalloonLimit.Checked;
176             settingCommon.TabIconDisp = this.chkTabIconDisp.Checked;
177             settingCommon.IsMonospace = this.CheckMonospace.Checked;
178             settingCommon.PreviewEnable = this.CheckPreviewEnable.Checked;
179             settingCommon.StatusAreaAtBottom = this.CheckStatusAreaAtBottom.Checked;
180
181             switch (this.ReplyIconStateCombo.SelectedIndex)
182             {
183                 case 0:
184                     settingCommon.ReplyIconState = MyCommon.REPLY_ICONSTATE.None;
185                     break;
186                 case 1:
187                     settingCommon.ReplyIconState = MyCommon.REPLY_ICONSTATE.StaticIcon;
188                     break;
189                 case 2:
190                     settingCommon.ReplyIconState = MyCommon.REPLY_ICONSTATE.BlinkIcon;
191                     break;
192             }
193
194             switch (this.LanguageCombo.SelectedIndex)
195             {
196                 case 0:
197                     settingCommon.Language = "OS";
198                     break;
199                 case 1:
200                     settingCommon.Language = "ja";
201                     break;
202                 case 2:
203                     settingCommon.Language = "en";
204                     break;
205                 default:
206                     settingCommon.Language = "en";
207                     break;
208             }
209
210             settingCommon.BlinkNewMentions = this.ChkNewMentionsBlink.Checked;
211             settingCommon.IsUseNotifyGrowl = this.IsNotifyUseGrowlCheckBox.Checked;
212         }
213     }
214 }