Umbau angefangen auf ICommand
This commit is contained in:
@@ -23,6 +23,11 @@ namespace KanSan.UI
|
||||
public event EventHandler<SelectBaustelleEventArgs> BaustelleSelected;
|
||||
public event EventHandler<SelectBaustelleEventArgs> BaustelleAdded;
|
||||
public event EventHandler<SelectBaustelleEventArgs> BaustelleEdited;
|
||||
|
||||
public UCBaustelleList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public UCBaustelleList(Projekt projekt)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</DataGrid>
|
||||
<Button Grid.Row="1" Name="SelectKunde" Content="Kunde Auswählen" Click="SelectKunde_Click" />
|
||||
<Button Grid.Row="2" Name="EditKunde" Content="Kunde Editieren" Click="EditKunde_Click" />
|
||||
<Button Grid.Row="3" Name="NeueKunde" Content="Neue Kunde anlegen" Click="NeueKunde_Click" />
|
||||
<Button Grid.Row="3" Name="NeueKunde" Content="Neue Kunde anlegen" Command="{Binding AddNewClientCommand}" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -19,7 +19,14 @@
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition Height="50" />
|
||||
</Grid.RowDefinitions>
|
||||
<TreeView Name="trvItems" ItemsSource="{Binding KanalObjekte}" MouseDoubleClick="trvItems_MouseDoubleClick">
|
||||
<TreeView Name="trvItems" ItemsSource="{Binding KanalObjekte}" >
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="local:MouseLeftButtonUp.Command" Value="{Binding DataContext.ObjektSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeView}}}" />
|
||||
<Setter Property="local:MouseLeftButtonUp.CommandParamter"
|
||||
Value="{Binding ElementName=trvItems, Path=SelectedItem}"/>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type self:ObjekteTransfer}" ItemsSource="{Binding Objekte}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
@@ -16,6 +16,52 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace KanSan.UI
|
||||
{
|
||||
public class MouseLeftButtonUp
|
||||
{
|
||||
public static DependencyProperty CommandProperty = DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(MouseLeftButtonUp), new UIPropertyMetadata(CommandChanged));
|
||||
public static DependencyProperty CommandParameterProperty =
|
||||
DependencyProperty.RegisterAttached("CommandParamter",
|
||||
typeof(object),
|
||||
typeof(MouseLeftButtonUp),
|
||||
new UIPropertyMetadata(null));
|
||||
|
||||
public static void SetCommand(DependencyObject target, ICommand value)
|
||||
{
|
||||
target.SetValue(CommandProperty, value);
|
||||
}
|
||||
public static object GetCommand(DependencyObject target, ICommand value)
|
||||
{
|
||||
return target.GetValue(CommandProperty);
|
||||
}
|
||||
public static void SetCommandParamter(DependencyObject target, object value)
|
||||
{
|
||||
target.SetValue(CommandProperty, value);
|
||||
}
|
||||
public static object GetCommandParamter(DependencyObject target)
|
||||
{
|
||||
return target.GetValue(CommandParameterProperty);
|
||||
}
|
||||
private static void CommandChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
Control control = target as Control;
|
||||
if (control == null) return;
|
||||
if ((e.NewValue != null) && (e.OldValue == null))
|
||||
control.MouseLeftButtonUp += OnMouseLeftButtonUp;
|
||||
else if ((e.NewValue == null) && (e.OldValue != null))
|
||||
control.MouseLeftButtonUp -= OnMouseLeftButtonUp;
|
||||
|
||||
}
|
||||
private static void OnMouseLeftButtonUp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
Control control = sender as Control;
|
||||
ICommand command = (ICommand)control.GetValue(CommandProperty);
|
||||
object commandParameter = control.GetValue(CommandParameterProperty);
|
||||
command.Execute(commandParameter);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Interaktionslogik für UCObjekteList.xaml
|
||||
/// </summary>
|
||||
@@ -23,6 +69,10 @@ namespace KanSan.UI
|
||||
{
|
||||
public event EventHandler<ObjektSelectEventArgs> ObjektSelected;
|
||||
Baustelle baustelle;
|
||||
public UCObjekteList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public UCObjekteList(Baustelle baustelle)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -23,7 +23,11 @@ namespace KanSan.UI
|
||||
public event EventHandler<SelectProjektEventArgs> ProjektAdded;
|
||||
public event EventHandler<SelectProjektEventArgs> ProjektEdited;
|
||||
public event EventHandler<SelectProjektEventArgs> ProjektSelected;
|
||||
|
||||
public UCProjektList()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
public UCProjektList(Kunde selectedKunde)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
19
KanSan/UI/SanMaßnahmen/UCSanierungOverview.xaml
Normal file
19
KanSan/UI/SanMaßnahmen/UCSanierungOverview.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<UserControl x:Class="KanSan.UI.UCSanierungOverview"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="./../../my_controls.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<ContentControl Name="Sanierungsmaßnahmen" Content="{Binding Path=Sanierungsmaßnahmen}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
26
KanSan/UI/SanMaßnahmen/UCSanierungOverview.xaml.cs
Normal file
26
KanSan/UI/SanMaßnahmen/UCSanierungOverview.xaml.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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 UCSanierungOverview.xaml
|
||||
/// </summary>
|
||||
public partial class UCSanierungOverview : UserControl
|
||||
{
|
||||
public UCSanierungOverview()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
KanSan/UI/SewerMainWindow.xaml
Normal file
12
KanSan/UI/SewerMainWindow.xaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<Window x:Class="KanSan.UI.SewerMainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
mc:Ignorable="d"
|
||||
Title="SewerMainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
32
KanSan/UI/SewerMainWindow.xaml.cs
Normal file
32
KanSan/UI/SewerMainWindow.xaml.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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.Shapes;
|
||||
|
||||
namespace KanSan.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für SewerMainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class SewerMainWindow : Window
|
||||
{
|
||||
public SewerMainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public SewerMainWindow(Sewer model)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new SewerMainWindowViewModel(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace KanSan.UI
|
||||
public UCSewerMainMenu(Sewer objekt)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new SewerMainMenuViewModel(objekt);
|
||||
this.DataContext = new SewerMainWindowViewModel(objekt);
|
||||
UI.UCObjektEdit uCObjektEdit = new UCObjektEdit(objekt);
|
||||
ObjektContentcontroller.Content = uCObjektEdit;
|
||||
rbStammdaten.IsChecked = true;
|
||||
@@ -47,11 +47,11 @@ namespace KanSan.UI
|
||||
switch(btn.Name)
|
||||
{
|
||||
case "rbStammdaten":
|
||||
UI.UCObjektEdit uCObjektEdit = new UCObjektEdit((DataContext as SewerMainMenuViewModel).Objekt);
|
||||
UI.UCObjektEdit uCObjektEdit = new UCObjektEdit((DataContext as SewerMainWindowViewModel).Objekt);
|
||||
ObjektContentcontroller.Content = uCObjektEdit;
|
||||
break;
|
||||
case "rbSchaeden":
|
||||
UI.UCSchaedenList uCSchaedenList = new UCSchaedenList((DataContext as SewerMainMenuViewModel).Objekt);
|
||||
UI.UCSchaedenList uCSchaedenList = new UCSchaedenList((DataContext as SewerMainWindowViewModel).Objekt);
|
||||
uCSchaedenList.SchaedenSelected += UCSchaedenList_SchaedenSelected;
|
||||
uCSchaedenList.SanierungsmaßnahmenSelected += UCSchaedenList_SanierungsmaßnahmenSelected;
|
||||
ObjektContentcontroller.Content = uCSchaedenList;
|
||||
@@ -65,7 +65,7 @@ namespace KanSan.UI
|
||||
{
|
||||
aktuellSchadenSelected = e.schaeden;
|
||||
UI.UCSanMaßnahmenList uCSanMaßnahmenList = new UCSanMaßnahmenList(e.schaeden);
|
||||
(DataContext as SewerMainMenuViewModel).Schaden = e.schaeden;
|
||||
(DataContext as SewerMainWindowViewModel).Schaden = e.schaeden;
|
||||
|
||||
uCSanMaßnahmenList.TaetigkeitenSelected += UCSanMaßnahmenList_TaetigkeitenSelected;
|
||||
rbSchaeden.IsChecked = false;
|
||||
@@ -103,7 +103,7 @@ namespace KanSan.UI
|
||||
|
||||
private void UCSchaedenEdit_SpeichernClicked(object sender, EventArgs e)
|
||||
{
|
||||
UI.UCSchaedenList uCSchaedenList = new UCSchaedenList((DataContext as SewerMainMenuViewModel).Objekt);
|
||||
UI.UCSchaedenList uCSchaedenList = new UCSchaedenList((DataContext as SewerMainWindowViewModel).Objekt);
|
||||
uCSchaedenList.SchaedenSelected += UCSchaedenList_SchaedenSelected;
|
||||
ObjektContentcontroller.Content = uCSchaedenList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user