private void ButtonAddConnection_OnClick(object sender, RoutedEventArgs e) { var ci = new ConnectionInfo(ConnectionTypes.MSSQL, GetNewConnectionEntryName(), null, false, ""); var cef = new AddConnectionWindow(ci) { Owner = this }; if (cef.ShowDialog() == true) { var item = new ConnectionListItem() { Name = ci.Name, Type = ci.Type.ToString(), Tag = ci }; var source = LvConnections.ItemsSource as ObservableCollection <ConnectionListItem>; if (source != null) { source.Add(item); } App.Connections.Add(ci); LvConnections.SelectedItem = item; } LvConnections.Focus(); Properties.Settings.Default.XmlFiles = App.XmlFiles; Properties.Settings.Default.Connections = App.Connections; Properties.Settings.Default.Save(); }
void RefreshTimer_Tick(object sender, EventArgs e) { try { lock (SocksServer) { this._openConnections = SocksServer.OpenConnections; LvConnections.VirtualListSize = this._openConnections.Length; LvConnections.Refresh(); } } catch { } }
private void ButtonRemoveConnection_OnClick(object sender, RoutedEventArgs e) { var item = (ConnectionListItem)LvConnections.SelectedItem; if (item == null) { return; } var source = LvConnections.ItemsSource as ObservableCollection <ConnectionListItem>; if (source != null) { source.Remove(item); } App.Connections.Remove((ConnectionInfo)item.Tag); LvConnections.Focus(); }
private void ButtonConfigureConnection_OnClick(object sender, RoutedEventArgs e) { if (LvConnections.SelectedItem == null) { return; } var item = (ConnectionListItem)LvConnections.SelectedItem; var ci = (ConnectionInfo)item.Tag; var cef = new AddConnectionWindow(ci); if (cef.ShowDialog() == true) { item.Name = ci.Name; item.Type = ci.Type.ToString(); } LvConnections.Focus(); }