// (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
// (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
// All rights reserved.
-//
+//
// This file is part of OpenTween.
-//
+//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option)
// any later version.
-//
+//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-// for more details.
-//
+// for more details.
+//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.
+#nullable enable
+
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using OpenTween.Models;
namespace OpenTween
{
public partial class ListAvailable : OTBaseForm
{
- private ListElement _selectedList = null;
- public ListElement SelectedList
- {
- get
- {
- return _selectedList;
- }
- }
+ public ListElement? SelectedList { get; private set; }
public ListAvailable()
- {
- InitializeComponent();
- }
+ => this.InitializeComponent();
private void OK_Button_Click(object sender, EventArgs e)
{
- if (this.ListsList.SelectedIndex > -1) {
- _selectedList = (ListElement)this.ListsList.SelectedItem;
+ if (this.ListsList.SelectedIndex > -1)
+ {
+ this.SelectedList = (ListElement)this.ListsList.SelectedItem;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
private void Cancel_Button_Click(object sender, EventArgs e)
{
- _selectedList = null;
+ this.SelectedList = null;
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
}
private void ListsList_SelectedIndexChanged(object sender, EventArgs e)
{
- ListElement lst;
+ ListElement? lst;
if (this.ListsList.SelectedIndex > -1)
{
lst = (ListElement)this.ListsList.SelectedItem;
var lists = await this.FetchListsAsync();
this.UpdateListsListBox(lists);
}
- catch (OperationCanceledException) { }
- catch (WebApiException) { }
+ catch (OperationCanceledException)
+ {
+ }
+ catch (WebApiException ex)
+ {
+ MessageBox.Show("Failed to get lists. (" + ex.Message + ")");
+ }
}
}
private async Task<IReadOnlyList<ListElement>> FetchListsAsync()
{
- using (var dialog = new WaitingDialog("Getting Lists..."))
- {
- var cancellationToken = dialog.EnableCancellation();
+ using var dialog = new WaitingDialog("Getting Lists...");
+ var cancellationToken = dialog.EnableCancellation();
- var tw = ((TweenMain)this.Owner).TwitterInstance;
- var task = Task.Run(() => tw.GetListsApi());
- var err = await dialog.WaitForAsync(this, task);
+ var tw = ((TweenMain)this.Owner).TwitterInstance;
+ var task = tw.GetListsApi();
+ await dialog.WaitForAsync(this, task);
- cancellationToken.ThrowIfCancellationRequested();
-
- if (!string.IsNullOrEmpty(err))
- {
- MessageBox.Show("Failed to get lists. (" + err + ")");
- throw new WebApiException(err);
- }
- }
+ cancellationToken.ThrowIfCancellationRequested();
return TabInformations.GetInstance().SubscribableLists;
}