OSDN Git Service

メソッドに式本体を使用する (IDE0021, IDE0022, IDE0025, IDE0027)
[opentween/open-tween.git] / OpenTween / Setting / Panel / CooperatePanel.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 using OpenTween.Thumbnail;
36
37 namespace OpenTween.Setting.Panel
38 {
39     public partial class CooperatePanel : SettingPanelBase
40     {
41         public CooperatePanel()
42             => this.InitializeComponent();
43
44         public void LoadConfig(SettingCommon settingCommon)
45         {
46             this.CheckNicoms.Checked = settingCommon.Nicoms;
47             this.ComboBoxTranslateLanguage.SelectedIndex = Bing.GetIndexFromLanguageEnum(settingCommon.TranslateLanguage);
48             this.UserAppointUrlText.Text = settingCommon.UserAppointUrl;
49             this.EnableImgAzyobuziNetCheckBox.Checked = settingCommon.EnableImgAzyobuziNet;
50             this.ImgAzyobuziNetDisabledInDMCheckBox.Checked = settingCommon.ImgAzyobuziNetDisabledInDM;
51             this.MapThumbnailProviderComboBox.SelectedIndex = (int)settingCommon.MapThumbnailProvider;
52             this.MapThumbnailHeightTextBox.Text = settingCommon.MapThumbnailHeight.ToString();
53             this.MapThumbnailWidthTextBox.Text = settingCommon.MapThumbnailWidth.ToString();
54             this.MapThumbnailZoomTextBox.Text = settingCommon.MapThumbnailZoom.ToString();
55         }
56
57         public void SaveConfig(SettingCommon settingCommon)
58         {
59             settingCommon.Nicoms = this.CheckNicoms.Checked;
60             settingCommon.TranslateLanguage = Bing.GetLanguageEnumFromIndex(this.ComboBoxTranslateLanguage.SelectedIndex);
61             settingCommon.UserAppointUrl = this.UserAppointUrlText.Text;
62             settingCommon.EnableImgAzyobuziNet = this.EnableImgAzyobuziNetCheckBox.Checked;
63             settingCommon.ImgAzyobuziNetDisabledInDM = this.ImgAzyobuziNetDisabledInDMCheckBox.Checked;
64             settingCommon.MapThumbnailProvider = (MapProvider)this.MapThumbnailProviderComboBox.SelectedIndex;
65             settingCommon.MapThumbnailHeight = int.Parse(this.MapThumbnailHeightTextBox.Text);
66             settingCommon.MapThumbnailWidth = int.Parse(this.MapThumbnailWidthTextBox.Text);
67             settingCommon.MapThumbnailZoom = int.Parse(this.MapThumbnailZoomTextBox.Text);
68         }
69
70         private void UserAppointUrlText_Validating(object sender, CancelEventArgs e)
71         {
72             if (!UserAppointUrlText.Text.StartsWith("http", StringComparison.Ordinal) && !string.IsNullOrEmpty(UserAppointUrlText.Text))
73             {
74                 MessageBox.Show("Text Error:正しいURLではありません");
75             }
76         }
77
78         private void EnableImgAzyobuziNetCheckBox_CheckedChanged(object sender, EventArgs e)
79             => this.ImgAzyobuziNetDisabledInDMCheckBox.Enabled = this.EnableImgAzyobuziNetCheckBox.Checked;
80     }
81 }