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
{
///
/// Interaktionslogik für UCBaustelleList.xaml
///
public partial class UCBaustelleList : UserControl
{
public event EventHandler BaustelleSelected;
public event EventHandler BaustelleAdded;
public event EventHandler 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 handler = BaustelleSelected;
if (handler != null)
handler(this, e);
}
protected virtual void OnClickBaustelleAdd(SelectBaustelleEventArgs e)
{
EventHandler handler = BaustelleAdded;
if (handler != null)
handler(this, e);
}
protected virtual void OnClickBaustelleEdit(SelectBaustelleEventArgs e)
{
EventHandler handler = BaustelleEdited;
if (handler != null)
handler(this, e);
}
}
public class SelectBaustelleEventArgs : EventArgs
{
public Baustelle baustelle { get; set; }
}
}