OSDN Git Service

C# 8.0 のnull許容参照型を有効化
[opentween/open-tween.git] / OpenTween / Setting / Panel / BasedPanel.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.Drawing;
33 using System.Data;
34 using System.Linq;
35 using System.Text;
36 using System.Windows.Forms;
37
38 namespace OpenTween.Setting.Panel
39 {
40     public partial class BasedPanel : SettingPanelBase
41     {
42         public BasedPanel()
43             => this.InitializeComponent();
44
45         public void LoadConfig(SettingCommon settingCommon)
46         {
47             using (ControlTransaction.Update(this.AuthUserCombo))
48             {
49                 this.AuthUserCombo.Items.Clear();
50                 this.AuthUserCombo.Items.AddRange(settingCommon.UserAccounts.ToArray());
51             }
52         }
53
54         public void SaveConfig(SettingCommon settingCommon)
55             => settingCommon.UserAccounts = this.AuthUserCombo.Items.Cast<UserAccount>().ToList();
56
57         private void AuthClearButton_Click(object sender, EventArgs e)
58         {
59             //tw.ClearAuthInfo();
60             //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click4;
61             //this.AuthUserLabel.Text = "";
62             if (this.AuthUserCombo.SelectedIndex > -1)
63             {
64                 this.AuthUserCombo.Items.RemoveAt(this.AuthUserCombo.SelectedIndex);
65                 if (this.AuthUserCombo.Items.Count > 0)
66                 {
67                     this.AuthUserCombo.SelectedIndex = 0;
68                 }
69                 else
70                 {
71                     this.AuthUserCombo.SelectedIndex = -1;
72                 }
73             }
74             //this.Save.Enabled = false;
75         }
76     }
77 }