using BeWoLauncher.Logic; using BeWoLauncher.Models; 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 = value; } } public ProfileEditView() { InitializeComponent(); Profiles = new ObservableCollection(); } private void ProfileAddClick(object sender, RoutedEventArgs e) { var bp = new ConnectionProfile("", string.Empty, string.Empty); if (Profiles.Contains(bp)) return; Profiles.Add(bp); } 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; } if(profileControl.SelectedItem is null) { MessageBox.Show("Wählen Sie ein Profil aus", "Löschen nicht möglich", MessageBoxButton.OK); return; } Profiles.Remove(profileControl.SelectedItem as ConnectionProfile); } private void ProfileControl_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { } } }