76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using DevExpress.Xpf.Grid;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für ProfileEditView.xaml
|
|
/// </summary>
|
|
public partial class ProfileEditView : BeWoView
|
|
{
|
|
private List<BeWoProfile> _Profiles;
|
|
|
|
public List<BeWoProfile> Profiles
|
|
{
|
|
get { return _Profiles; }
|
|
set
|
|
{
|
|
_Profiles = value;
|
|
profileGridControl.ItemsSource = _Profiles;
|
|
}
|
|
}
|
|
|
|
public ProfileEditView()
|
|
{
|
|
InitializeComponent();
|
|
Profiles = new List<BeWoProfile>();
|
|
}
|
|
|
|
private void ProfileAddClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!validating())
|
|
return;
|
|
|
|
//var bp = new BeWoProfile(profileNameTextBox.Text, profileServerTextBox.Text, profileTenantBox.Text);
|
|
var bp = new BeWoProfile("<Neues Profil>", "", "");
|
|
|
|
if (Profiles.Contains(bp))
|
|
return;
|
|
|
|
Profiles.Add(bp);
|
|
//profileNameTextBox.Text = string.Empty;
|
|
//profileTenantBox.Text = string.Empty;
|
|
//profileServerTextBox.Text = string.Empty;
|
|
profileGridControl.RefreshData();
|
|
}
|
|
|
|
private void btn_deleteProfileClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var selectedItem = (BeWoProfile)((((Button)sender).Tag as EditGridCellData).RowData.Row);
|
|
|
|
if (!Profiles.Contains(selectedItem))
|
|
return;
|
|
|
|
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(selectedItem);
|
|
profileGridControl.RefreshData();
|
|
}
|
|
|
|
private bool validating()
|
|
{
|
|
//return !string.IsNullOrWhiteSpace(profileNameTextBox.Text) &&
|
|
// !string.IsNullOrWhiteSpace(profileServerTextBox.Text) &&
|
|
// !string.IsNullOrWhiteSpace(profileTenantBox.Text);
|
|
return true;
|
|
}
|
|
}
|
|
}
|