public void LoadConnections() { dt = new ObservableCollection <Connection>(); foreach (Connection connection in StoredConnections.getConnections()) { dt.Add(connection); } }
private void InitComboBox() { foreach (Connection con in StoredConnections.getConnections()) { comboBox_connection.Items.Add(con); } //comboBox_connection.SelectedIndex = 0; }
private void Button_Click(object sender, RoutedEventArgs e) { //add new connection string name = textBoxName.Text; string ip = textBoxIP.Text; Connection connection = new Connection(name, ip); if (name == "" || ip == "") { label_succesfull.Content = "Empty input"; } else if (StoredConnections.getConnections().Contains(connection)) { label_succesfull.Content = "Duplicate Connection"; } else if (StoredConnections.GetConnection(name) != null) { //connection exists, we ask the user if he wants to change it if (MessageBox.Show("Connection already exists, change it?", "Connection", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { StoredConnections.GetConnection(name).IP = ip; label_succesfull.Content = "Connection modified"; } } else { label_succesfull.Content = "Connection added succesfully"; StoredConnections.AddConnection(name, ip); } clearInput(); AddTimerEraseLabel(); }