MainviewModel erstellt

This commit is contained in:
Husky
2020-02-23 11:27:10 +01:00
parent ba431a8fba
commit 24ae7b517c
8 changed files with 159 additions and 55 deletions

View File

@@ -6,16 +6,6 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Remove="version.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="version.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ilmerge" Version="3.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">

View File

@@ -24,7 +24,7 @@
</StackPanel>
<ContentControl Grid.Column="1" Name="ContentController" Content="KanSan"/>
<StatusBar Grid.ColumnSpan="2" Margin="0,1,0,0" Grid.Row="1">
<StatusBarItem Content="Kunde" />
<StatusBarItem Content="{Binding SelectedKunde.Vorname}" />
<StatusBarItem Content="Projekt" />
<StatusBarItem Content="Baustelle" />
</StatusBar>

View File

@@ -25,24 +25,33 @@ namespace KanSan
/// </summary>
public partial class MainWindow : Window
{
UI.UCKundeEdit UCKundeEdit;
UI.UCKundeList UCKundeList;
public MainWindow()
{
InitializeComponent();
this.DataContext = new MainWindowViewModel();
//this.Title = ProgrammHashVersion.GIT_HASH;
UCKundeList = new UI.UCKundeList();
UCKundeList.KundeAdded += UCKundeList_KundeAdded;
UCKundeList.KundeSelect += UCKundeList_KundeSelect;
}
private void UCKundeList_KundeSelect(object sender, UI.KundeAddedKlickEventArgs e)
{
(DataContext as MainWindowViewModel).SelectedKunde = e.kunde;
}
private void UCKundeList_KundeAdded(object sender, UI.KundeAddedKlickEventArgs e)
{
UI.UCKundeEdit uCKundeEdit = new UI.UCKundeEdit(e.kunde);
ContentController.Content = uCKundeEdit;
UCKundeEdit = new UI.UCKundeEdit(e.kunde);
ContentController.Content = UCKundeEdit;
}
private void btnKunden_Click(object sender, RoutedEventArgs e)
{
UI.UCKundeList uCKundeList = new UI.UCKundeList();
uCKundeList.KundeAdded += UCKundeList_KundeAdded;
ContentController.Content = uCKundeList;
ContentController.Content = UCKundeList;
}
}

View File

@@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
namespace KanSan
{
public static class ProgrammHashVersion
{
public static string GIT_HASH
{
get
{
string gitVersion;
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("KanSan.version.txt"))
using (StreamReader reader = new StreamReader(stream))
{
gitVersion = reader.ReadToEnd();
}
return gitVersion;
}
}
}
}

View File

@@ -9,6 +9,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50" />
<RowDefinition Height="50"/>
<RowDefinition Height="50" />
</Grid.RowDefinitions>
@@ -19,8 +20,9 @@
<DataGridTextColumn Header="Ort" Binding="{Binding Ort}" />
</DataGrid.Columns>
</DataGrid>
<Button Grid.Row="1" Name="EditKunde" Content="Kunde Editieren" Click="EditKunde_Click" />
<Button Grid.Row="2" Name="NeueKunde" Content="Neue Kunde anlegen" Click="NeueKunde_Click" />
<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" />
</Grid>
</UserControl>

View File

@@ -21,7 +21,8 @@ namespace KanSan.UI
/// </summary>
public partial class UCKundeList : UserControl
{
public event EventHandler<KundeAddedKlickEventArgs> KundeAdded;
public event EventHandler<KundeAddedKlickEventArgs> KundeSelect;
public UCKundeList()
{
InitializeComponent();
@@ -32,23 +33,37 @@ namespace KanSan.UI
{
KundeAddedKlickEventArgs args = new KundeAddedKlickEventArgs();
args.kunde = (DataContext as KundenListViewModel).NeueKunde();
OnKlickedKunde(args);
OnClickKundeAdded(args);
}
protected virtual void OnKlickedKunde(KundeAddedKlickEventArgs e)
protected virtual void OnClickKundeAdded(KundeAddedKlickEventArgs e)
{
EventHandler<KundeAddedKlickEventArgs> handler = KundeAdded;
if (handler != null)
handler(this, e);
}
public event EventHandler<KundeAddedKlickEventArgs> KundeAdded;
protected virtual void OnClickSelectedKunde(KundeAddedKlickEventArgs e)
{
EventHandler<KundeAddedKlickEventArgs> handler = KundeSelect;
if (handler != null)
handler(this, e);
}
private void EditKunde_Click(object sender, RoutedEventArgs e)
{
Kunde selectedKunde = (dgKundenList.SelectedItem as Kunde);
if (selectedKunde == null) return;
OnKlickedKunde(new KundeAddedKlickEventArgs() { kunde = selectedKunde });
OnClickKundeAdded(new KundeAddedKlickEventArgs() { kunde = selectedKunde });
}
private void SelectKunde_Click(object sender, RoutedEventArgs e)
{
Kunde selectedKunde = (dgKundenList.SelectedItem as Kunde);
if (selectedKunde == null) return;
OnClickSelectedKunde(new KundeAddedKlickEventArgs() { kunde = selectedKunde });
}
}