76 lines
2.1 KiB
C#
76 lines
2.1 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für ProfileEditView.xaml
|
|
/// </summary>
|
|
public partial class ProfileEditView : UserControl
|
|
{
|
|
private ObservableCollection<ConnectionProfile> _Profiles;
|
|
|
|
public ObservableCollection<ConnectionProfile> 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<ConnectionProfile>();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|