OSDN Git Service

usingの順序を揃える (SA1208, SA1210)
[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 #nullable enable
28
29 using System;
30 using System.Collections.Generic;
31 using System.ComponentModel;
32 using System.Data;
33 using System.Drawing;
34 using System.Linq;
35 using System.Text;
36 using System.Windows.Forms;
37
38 namespace OpenTween.Setting.Panel
39 {
40     public partial class PreviewPanel : SettingPanelBase
41     {
42         public PreviewPanel()
43             => this.InitializeComponent();
44
45         public void LoadConfig(SettingCommon settingCommon)
46         {
47             this.CheckDispUsername.Checked = settingCommon.DispUsername;
48             this.ComboDispTitle.SelectedIndex = settingCommon.DispLatestPost switch
49             {
50                 MyCommon.DispTitleEnum.None => 0,
51                 MyCommon.DispTitleEnum.Ver => 1,
52                 MyCommon.DispTitleEnum.Post => 2,
53                 MyCommon.DispTitleEnum.UnreadRepCount => 3,
54                 MyCommon.DispTitleEnum.UnreadAllCount => 4,
55                 MyCommon.DispTitleEnum.UnreadAllRepCount => 5,
56                 MyCommon.DispTitleEnum.UnreadCountAllCount => 6,
57                 MyCommon.DispTitleEnum.OwnStatus => 7,
58                 _ => 2,
59             };
60             this.CheckAlwaysTop.Checked = settingCommon.AlwaysTop;
61             this.CheckBalloonLimit.Checked = settingCommon.LimitBalloon;
62             this.chkTabIconDisp.Checked = settingCommon.TabIconDisp;
63             this.CheckMonospace.Checked = settingCommon.IsMonospace;
64             this.CheckPreviewEnable.Checked = settingCommon.PreviewEnable;
65             this.CheckStatusAreaAtBottom.Checked = settingCommon.StatusAreaAtBottom;
66             this.ReplyIconStateCombo.SelectedIndex = settingCommon.ReplyIconState switch
67             {
68                 MyCommon.REPLY_ICONSTATE.None => 0,
69                 MyCommon.REPLY_ICONSTATE.StaticIcon => 1,
70                 MyCommon.REPLY_ICONSTATE.BlinkIcon => 2,
71                 _ => 1,
72             };
73             this.LanguageCombo.SelectedIndex = settingCommon.Language switch
74             {
75                 "OS" => 0,
76                 "ja" => 1,
77                 "en" => 2,
78                 _ => 0,
79             };
80         }
81
82         public void SaveConfig(SettingCommon settingCommon)
83         {
84             settingCommon.DispUsername = this.CheckDispUsername.Checked;
85             settingCommon.DispLatestPost = this.ComboDispTitle.SelectedIndex switch
86             {
87                 0 => MyCommon.DispTitleEnum.None,
88                 1 => MyCommon.DispTitleEnum.Ver,
89                 2 => MyCommon.DispTitleEnum.Post,
90                 3 => MyCommon.DispTitleEnum.UnreadRepCount,
91                 4 => MyCommon.DispTitleEnum.UnreadAllCount,
92                 5 => MyCommon.DispTitleEnum.UnreadAllRepCount,
93                 6 => MyCommon.DispTitleEnum.UnreadCountAllCount,
94                 7 => MyCommon.DispTitleEnum.OwnStatus,
95                 _ => throw new IndexOutOfRangeException(),
96             };
97             settingCommon.AlwaysTop = this.CheckAlwaysTop.Checked;
98             settingCommon.LimitBalloon = this.CheckBalloonLimit.Checked;
99             settingCommon.TabIconDisp = this.chkTabIconDisp.Checked;
100             settingCommon.IsMonospace = this.CheckMonospace.Checked;
101             settingCommon.PreviewEnable = this.CheckPreviewEnable.Checked;
102             settingCommon.StatusAreaAtBottom = this.CheckStatusAreaAtBottom.Checked;
103             settingCommon.ReplyIconState = this.ReplyIconStateCombo.SelectedIndex switch
104             {
105                 0 => MyCommon.REPLY_ICONSTATE.None,
106                 1 => MyCommon.REPLY_ICONSTATE.StaticIcon,
107                 2 => MyCommon.REPLY_ICONSTATE.BlinkIcon,
108                 _ => throw new IndexOutOfRangeException(),
109             };
110             settingCommon.Language = this.LanguageCombo.SelectedIndex switch
111             {
112                 0 => "OS",
113                 1 => "ja",
114                 2 => "en",
115                 _ => "en",
116             };
117         }
118     }
119 }