Files
Kansan/KanSan/UI/Baustelle/UCBaustelleList.xaml.cs
2020-07-12 19:32:14 +02:00

84 lines
2.8 KiB
C#

using KanSan.Base.Models;
using KanSan.ViewModel;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace KanSan.UI
{
/// <summary>
/// Interaktionslogik für UCBaustelleList.xaml
/// </summary>
public partial class UCBaustelleList : UserControl
{
public event EventHandler<SelectBaustelleEventArgs> BaustelleSelected;
public event EventHandler<SelectBaustelleEventArgs> BaustelleAdded;
public event EventHandler<SelectBaustelleEventArgs> BaustelleEdited;
public UCBaustelleList()
{
InitializeComponent();
}
public UCBaustelleList(Projekt projekt)
{
InitializeComponent();
this.DataContext = new BaustellenListViewModel(projekt);
}
private void BaustelleSelect_Click(object sender, RoutedEventArgs e)
{
Baustelle selectedBaustelle = (dgBaustelle.SelectedItem as Baustelle);
if (selectedBaustelle == null) return;
OnClickBaustelleSelect(new SelectBaustelleEventArgs() { baustelle = selectedBaustelle });
}
private void BaustelleEdit_Click(object sender, RoutedEventArgs e)
{
Baustelle selectedBaustelle = (dgBaustelle.SelectedItem as Baustelle);
if (selectedBaustelle == null) return;
OnClickBaustelleEdit(new SelectBaustelleEventArgs() { baustelle = selectedBaustelle });
}
private void BaustelleNew_Click(object sender, RoutedEventArgs e)
{
OnClickBaustelleAdd(
new SelectBaustelleEventArgs()
{
baustelle = (DataContext as BaustellenListViewModel).NeueBaustelle()
});
}
protected virtual void OnClickBaustelleSelect(SelectBaustelleEventArgs e)
{
EventHandler<SelectBaustelleEventArgs> handler = BaustelleSelected;
if (handler != null)
handler(this, e);
}
protected virtual void OnClickBaustelleAdd(SelectBaustelleEventArgs e)
{
EventHandler<SelectBaustelleEventArgs> handler = BaustelleAdded;
if (handler != null)
handler(this, e);
}
protected virtual void OnClickBaustelleEdit(SelectBaustelleEventArgs e)
{
EventHandler<SelectBaustelleEventArgs> handler = BaustelleEdited;
if (handler != null)
handler(this, e);
}
}
public class SelectBaustelleEventArgs : EventArgs
{
public Baustelle baustelle { get; set; }
}
}