1 // OpenTween - Client of Twitter
2 // Copyright (c) 2012 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3 // All rights reserved.
5 // This file is part of OpenTween.
7 // This program is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 3 of the License, or (at your option)
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 // You should have received a copy of the GNU General Public License along
18 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 // Boston, MA 02110-1301, USA.
25 using System.Collections.Generic;
26 using System.ComponentModel;
31 using System.Windows.Forms;
32 using OpenTween.Models;
36 public partial class TabsDialog : OTBaseForm
38 private readonly TabInformations tabInfo;
40 private bool multiSelect = false;
42 public bool MultiSelect
44 get => this.multiSelect;
47 this.multiSelect = value;
52 protected internal record TabListItem(
57 public override string ToString()
61 public TabsDialog(TabInformations tabinformation)
63 this.InitializeComponent();
65 this.tabInfo = tabinformation;
69 protected void UpdateTabList()
71 this.TabList.Items.Clear();
75 this.TabList.SelectionMode = SelectionMode.MultiExtended;
79 this.TabList.SelectionMode = SelectionMode.One;
81 this.TabList.Items.Add(new TabListItem(
82 Label: Properties.Resources.AddNewTabText1,
87 var tabs = this.tabInfo.Tabs.Append(this.tabInfo.MuteTab);
89 foreach (var tab in tabs.OfType<FilterTabModel>())
91 this.TabList.Items.Add(new TabListItem(
98 private void TabList_DoubleClick(object sender, EventArgs e)
100 if (this.TabList.SelectedIndex == -1) return;
102 this.DialogResult = DialogResult.OK;
106 private void TabList_SelectedValueChanged(object sender, EventArgs e)
108 if (this.TabList.SelectedIndex == -1)
109 this.OK_Button.Enabled = false;
111 this.OK_Button.Enabled = true;
114 public FilterTabModel? SelectedTab
115 => this.TabList.SelectedItem is TabListItem item ? item.Tab : null;
117 public FilterTabModel[] SelectedTabs
118 => this.TabList.SelectedItems
121 .OfType<FilterTabModel>()