Winify – Diff between revs 1 and 4

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 1 Rev 4
Line 1... Line 1...
1 using System; 1 using System;
-   2 using System.Linq;
2 using System.Windows.Forms; 3 using System.Windows.Forms;
-   4 using Winify.Connections;
3 using Winify.Properties; 5 using Winify.Properties;
4 using Winify.Utilities; 6 using Winify.Utilities;
Line 5... Line 7...
5   7  
6 namespace Winify 8 namespace Winify
7 { 9 {
8 public partial class SettingsForm : Form 10 public partial class SettingsForm : Form
-   11 {
-   12 #region Public Events & Delegates
-   13  
-   14 public event EventHandler<ServersUpdatedEventArgs> ServersUpdated;
-   15  
-   16 #endregion
-   17  
-   18 #region Private Delegates, Events, Enums, Properties, Indexers and Fields
-   19  
-   20 private readonly Servers _servers;
-   21  
-   22 #endregion
9 { 23  
Line 10... Line 24...
10 #region Constructors, Destructors and Finalizers 24 #region Constructors, Destructors and Finalizers
11   25  
12 public SettingsForm() 26 private SettingsForm()
13 { 27 {
Line -... Line 28...
-   28 InitializeComponent();
-   29 }
-   30  
-   31 public SettingsForm(Servers servers) : this()
-   32 {
14 InitializeComponent(); 33 _servers = servers;
Line 15... Line 34...
15 } 34 }
Line 16... Line 35...
16   35  
Line 23... Line 42...
23 Settings.Default.LaunchOnBoot = ((CheckBox) sender).Checked; 42 Settings.Default.LaunchOnBoot = ((CheckBox) sender).Checked;
Line 24... Line 43...
24   43  
25 Miscellaneous.LaunchOnBootSet(Settings.Default.LaunchOnBoot); 44 Miscellaneous.LaunchOnBootSet(Settings.Default.LaunchOnBoot);
Line -... Line 45...
-   45 }
-   46  
-   47 private void Button1_Click(object sender, EventArgs e)
-   48 {
-   49 var name = serverNameTextBox.Text;
-   50 var host = serverHostTextBox.Text;
-   51 var port = serverPortTextBox.Text;
-   52 var username = serverUsernameTextBox.Text;
-   53 var password = serverPasswordTextBox.Text;
-   54  
-   55 if (string.IsNullOrEmpty(name) ||
-   56 string.IsNullOrEmpty(host) ||
-   57 string.IsNullOrEmpty(port) ||
-   58 string.IsNullOrEmpty(username) ||
-   59 string.IsNullOrEmpty(password))
-   60 {
-   61 return;
-   62 }
-   63  
-   64 var server = new Server(name, host, port, username, password);
-   65  
-   66 if (_servers.Server.Any(servers => servers.Name == server.Name))
-   67 {
-   68 return;
-   69 }
-   70  
-   71 listBox1.InvokeIfRequired(listBox => { listBox.Items.Add(server); });
-   72  
-   73 _servers.Server.Add(server);
-   74  
-   75 ServersUpdated?.Invoke(this, new ServersUpdatedEventArgs(_servers));
-   76 }
-   77  
-   78 private void Button2_Click(object sender, EventArgs e)
-   79 {
-   80 listBox1.InvokeIfRequired(listBox =>
-   81 {
-   82 var item = listBox.SelectedItem;
-   83  
-   84 listBox.Items.Remove(item);
-   85  
-   86 _servers.Server.Remove((Server) item);
-   87  
-   88 ServersUpdated?.Invoke(this, new ServersUpdatedEventArgs(_servers));
-   89 });
-   90 }
-   91  
-   92 private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
-   93 {
-   94 var listBox = (ListBox) sender;
-   95  
-   96 if (listBox.SelectedIndex == -1)
-   97 {
-   98 serverNameTextBox.Text = string.Empty;
-   99 serverHostTextBox.Text = string.Empty;
-   100 serverPortTextBox.Text = string.Empty;
-   101 serverUsernameTextBox.Text = string.Empty;
-   102 serverPasswordTextBox.Text = string.Empty;
-   103  
-   104 return;
-   105 }
-   106  
-   107 var server = (Server) listBox.SelectedItem;
-   108  
-   109 serverNameTextBox.Text = server.Name;
-   110 serverHostTextBox.Text = server.Host;
-   111 serverPortTextBox.Text = server.Port;
-   112 serverUsernameTextBox.Text = server.Username;
-   113 serverPasswordTextBox.Text = server.Password;
-   114 }
-   115  
-   116 private void SettingsForm_Shown(object sender, EventArgs e)
-   117 {
-   118 foreach (var server in _servers.Server)
-   119 {
-   120 listBox1.InvokeIfRequired(listBox => { listBox.Items.Add(server); });
-   121 }
26 } 122 }
27   123  
28 #endregion 124 #endregion
29 } 125 }