using BS.SharedLauncher; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace BeWoLauncher.Components { /// /// Interaktionslogik für ProfileEditView.xaml /// public partial class ProfileEditView : UserControl { private ObservableCollection _Profiles; public ObservableCollection Profiles { get { return _Profiles; } set { _Profiles = value; profileControl.ItemsSource = _Profiles; } } public string NewName { get => profileNameTextBox.Text; set => profileNameTextBox.Text = value; } public string NewServer { get => profileServerTextBox.Text; set => profileServerTextBox.Text = value; } public string NewTenant { get => profileTenantBox.Text; set => profileTenantBox.Text = value; } public ProfileEditView() { InitializeComponent(); Profiles = new ObservableCollection(); } private void ProfileAddClick(object sender, RoutedEventArgs e) { var bp = new ConnectionProfile(NewName, NewServer, NewTenant); if (Profiles.Contains(bp)) return; Profiles.Add(bp); NewName = string.Empty; NewServer = string.Empty; NewTenant = string.Empty; } private void ProfileDeleteClick(object sender, RoutedEventArgs e) { if (Profiles.Count == 1) { MessageBox.Show("Es muss mindestens ein Profil vorhanden sein.\nLöschen nicht möglich", "Löschen nicht möglich", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Profiles.Remove(profileControl.SelectedItem as ConnectionProfile); } } }