Winify – Diff between revs 14 and 15
?pathlinks?
Rev 14 | Rev 15 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using System; |
1 | using System; |
|
2 | using System.Linq; |
2 | using System.Linq; |
|
3 | using System.Windows.Forms; |
3 | using System.Windows.Forms; |
|
- | 4 | using Announcements; |
||
4 | using Servers; |
5 | using Servers; |
|
5 | using Winify.Properties; |
6 | using Winify.Properties; |
|
6 | using Winify.Utilities; |
7 | using Winify.Utilities; |
|
Line 7... | Line 8... | |||
7 | |
8 | |
|
8 | namespace Winify |
9 | namespace Winify |
|
9 | { |
10 | { |
|
10 | public partial class SettingsForm : Form |
11 | public partial class SettingsForm : Form |
|
11 | { |
12 | { |
|
Line -... | Line 13... | |||
- | 13 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
- | 14 | |
||
12 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
15 | private readonly Announcements.Announcements _notifications; |
|
Line 13... | Line 16... | |||
13 | |
16 | |
|
Line 14... | Line 17... | |||
14 | private readonly global::Servers.Servers _servers; |
17 | private readonly global::Servers.Servers _servers; |
|
Line 20... | Line 23... | |||
20 | private SettingsForm() |
23 | private SettingsForm() |
|
21 | { |
24 | { |
|
22 | InitializeComponent(); |
25 | InitializeComponent(); |
|
23 | } |
26 | } |
|
Line 24... | Line 27... | |||
24 | |
27 | |
|
25 | public SettingsForm(global::Servers.Servers servers) : this() |
28 | public SettingsForm(global::Servers.Servers servers, Announcements.Announcements notifications) : this() |
|
26 | { |
29 | { |
|
Line 27... | Line 30... | |||
27 | _servers = servers; |
30 | _servers = servers; |
|
28 | |
31 | |
|
29 | listBox1.DataSource = _servers.Server; |
32 | listBox1.DataSource = _servers.Server; |
|
30 | listBox1.DisplayMember = "Name"; |
33 | listBox1.DisplayMember = "Name"; |
|
- | 34 | listBox1.DataBindings.Add(new Binding("Text", _servers.Server, "Name", true, |
||
- | 35 | DataSourceUpdateMode.OnPropertyChanged)); |
||
- | 36 | |
||
- | 37 | _notifications = notifications; |
||
- | 38 | listBox2.DataSource = _notifications.Announcement; |
||
- | 39 | listBox2.DisplayMember = "Id"; |
||
31 | listBox1.DataBindings.Add(new Binding("Text", _servers.Server, "Name", true, |
40 | listBox2.DataBindings.Add(new Binding("Text", _notifications.Announcement, "Id", true, |
|
Line 32... | Line 41... | |||
32 | DataSourceUpdateMode.OnPropertyChanged)); |
41 | DataSourceUpdateMode.OnPropertyChanged)); |
|
Line 33... | Line 42... | |||
33 | } |
42 | } |
|
Line 106... | Line 115... | |||
106 | serverUrlTextBox.Text = server.Url; |
115 | serverUrlTextBox.Text = server.Url; |
|
107 | serverUsernameTextBox.Text = server.Username; |
116 | serverUsernameTextBox.Text = server.Username; |
|
108 | serverPasswordTextBox.Text = server.Password; |
117 | serverPasswordTextBox.Text = server.Password; |
|
109 | } |
118 | } |
|
Line -... | Line 119... | |||
- | 119 | |
||
- | 120 | private void Button3_Click(object sender, EventArgs e) |
||
- | 121 | { |
||
- | 122 | listBox2.InvokeIfRequired(listbox => |
||
- | 123 | { |
||
- | 124 | var item = listbox.SelectedItem; |
||
- | 125 | |
||
- | 126 | _notifications.Announcement.Remove((Announcement) item); |
||
- | 127 | }); |
||
- | 128 | } |
||
- | 129 | |
||
- | 130 | private void Button4_Click(object sender, EventArgs e) |
||
- | 131 | { |
||
- | 132 | var appId = appIdTextBox.Text; |
||
- | 133 | var lingerTime = lingerTimeTextBox.Text; |
||
- | 134 | var speak = speakTextBox.Text; |
||
- | 135 | |
||
- | 136 | if (string.IsNullOrEmpty(appId) || |
||
- | 137 | !int.TryParse(appId, out var numAppId) || |
||
- | 138 | string.IsNullOrEmpty(lingerTime) || |
||
- | 139 | !int.TryParse(lingerTime, out var numLingerTime) || |
||
- | 140 | string.IsNullOrEmpty(speak)) |
||
- | 141 | { |
||
- | 142 | return; |
||
- | 143 | } |
||
- | 144 | |
||
- | 145 | var notification = new Announcement(numAppId, numLingerTime, speak); |
||
- | 146 | |
||
- | 147 | var update = _notifications.Announcement.FirstOrDefault(select => select.Id == notification.Id); |
||
- | 148 | switch (update) |
||
- | 149 | { |
||
- | 150 | default: |
||
- | 151 | _notifications.Announcement.Remove(update); |
||
- | 152 | update.AppId = numAppId; |
||
- | 153 | update.LingerTime = numLingerTime; |
||
- | 154 | update.Speak = speak; |
||
- | 155 | _notifications.Announcement.Add(update); |
||
- | 156 | break; |
||
- | 157 | case null: |
||
- | 158 | _notifications.Announcement.Add(notification); |
||
- | 159 | break; |
||
- | 160 | } |
||
- | 161 | } |
||
- | 162 | |
||
- | 163 | private void ListBox2_SelectedIndexChanged(object sender, EventArgs e) |
||
- | 164 | { |
||
- | 165 | var listBox = (ListBox) sender; |
||
- | 166 | |
||
- | 167 | if (listBox.SelectedIndex == -1) |
||
- | 168 | { |
||
- | 169 | appIdTextBox.Text = string.Empty; |
||
- | 170 | lingerTimeTextBox.Text = string.Empty; |
||
- | 171 | speakTextBox.Text = string.Empty; |
||
- | 172 | |
||
- | 173 | return; |
||
- | 174 | } |
||
- | 175 | |
||
- | 176 | var notification = (Announcement) listBox.SelectedItem; |
||
- | 177 | |
||
- | 178 | appIdTextBox.Text = notification.AppId.ToString(); |
||
- | 179 | lingerTimeTextBox.Text = notification.LingerTime.ToString(); |
||
- | 180 | speakTextBox.Text = notification.Speak; |
||
- | 181 | } |
||
110 | |
182 | |
|
111 | #endregion |
183 | #endregion |
|
112 | } |
184 | } |
|
113 | } |
185 | } |