committed

This commit is contained in:
HuskyTeufel
2021-05-05 13:06:56 +02:00
parent 2c4bcde9c8
commit af01e537cf
17 changed files with 234 additions and 38 deletions

17
.vscode/launch.json vendored
View File

@@ -1,6 +1,7 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
@@ -17,6 +18,22 @@
"console": "internalConsole",
"stopAtEntry": false
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (WPF)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/GuiWPF/bin/Debug/net5.0-windows/GuiWPF.exe",
"args": [],
"cwd": "${workspaceFolder}/ConsoleApplication",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",

View File

@@ -16,13 +16,14 @@ namespace ConsoleApplication
{
static void Main(string[] args)
{
Console.WriteLine("Hallo");
var kernel = new StandardKernel();
new KernelInitializer().Initialize(kernel);
var manager = kernel.Get<IAuftraggeberManager>();
var baustellen = kernel.Get<IBaustelleManager>();
/*Auftraggeber auftraggeber = new Auftraggeber();
/*
Auftraggeber auftraggeber = new Auftraggeber();
auftraggeber.Baustellen = new List<Bauvorhaben>();
auftraggeber.Baustellen.Add(new Bauvorhaben()
{
@@ -36,10 +37,11 @@ namespace ConsoleApplication
auftraggeber.Strasse = "Schlachthofstraße 42";
manager.Add(auftraggeber);
*/
var auftragger = manager.GetAllAuftraggeber();
var bau = baustellen.GetAllBauvorhaben();
*/
Debugger.Break();
/*

View File

@@ -24,7 +24,7 @@ namespace DataStoring.EfCore
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseNpgsql("Host = localhost; Database = DP; Username = DP; Password = DP");
optionsBuilder.UseNpgsql("Host = 192.168.1.195; Database = DP; Username = DP; Password = DP");
}
}
}

View File

@@ -30,7 +30,7 @@ namespace DataStoring.EfCore
}
catch(Exception e)
{
throw new Exception("Cant delete entity with id " + id);
throw new Exception(string.Format("Cant delete entity with id {0} # {1} " ,id,e.Message));
}
}

View File

@@ -13,5 +13,6 @@ namespace GuiWPF
/// </summary>
public partial class App : Application
{
}
}

75
GuiWPF/DelegateCommand.cs Normal file
View File

@@ -0,0 +1,75 @@
using System;
using System.Windows.Input;
namespace GuiWPF {
public class DelegateCommand : ICommand {
/// <summary>
/// Action to be performed when this command is executed
/// </summary>
private Action<object> executionAction;
/// <summary>
/// Predicate to determine if the command is valid for execution
/// </summary>
private Predicate<object> canExecutePredicate;
/// <summary>
/// Initializes a new instance of the DelegateCommand class.
/// The command will always be valid for execution.
/// </summary>
/// <param name="execute">The delegate to call on execution</param>
public DelegateCommand(Action<object> execute)
: this(execute, null)
{
}
/// <summary>
/// Initializes a new instance of the DelegateCommand class.
/// </summary>
/// <param name="execute">The delegate to call on execution</param>
/// <param name="canExecute">The predicate to determine if command is valid for execution</param>
public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
{
throw new ArgumentNullException("execute");
}
this.executionAction = execute;
this.canExecutePredicate = canExecute;
}
/// <summary>
/// Raised when CanExecute is changed
/// </summary>
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
/// <summary>
/// Executes the delegate backing this DelegateCommand
/// </summary>
/// <param name="parameter">parameter to pass to predicate</param>
/// <returns>True if command is valid for execution</returns>
public bool CanExecute(object parameter)
{
return this.canExecutePredicate == null ? true : this.canExecutePredicate(parameter);
}
/// <summary>
/// Executes the delegate backing this DelegateCommand
/// </summary>
/// <param name="parameter">parameter to pass to delegate</param>
/// <exception cref="InvalidOperationException">Thrown if CanExecute returns false</exception>
public void Execute(object parameter)
{
if (!this.CanExecute(parameter))
{
throw new InvalidOperationException("The command is not valid for execution, check the CanExecute method before attempting to execute.");
}
this.executionAction(parameter);
}
}
}

5
GuiWPF/HomePage.cs Normal file
View File

@@ -0,0 +1,5 @@
namespace GuiWPF {
public class HomePage {
public string PageTitle {get;set;}
}
}

12
GuiWPF/HomePageView.xaml Normal file
View File

@@ -0,0 +1,12 @@
<UserControl x:Class="GuiWPF.HomePageView"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Button Content="lool"></Button>
<TextBlock FontSize="20" Text="Lala" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace GuiWPF
{
public class HomePageViewModel : ViewModelBase {
//public string PageTitle = "HomePage";
public HomePage Model {get; private set;}
public HomePageViewModel(HomePage model) {
this.Model = model;
}
public string PageTitle {
get {
return Model.PageTitle;
}
set {
Model.PageTitle = value;
OnPropertyChanged();
}
}
}
}

45
GuiWPF/MainViewModel.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Input;
namespace GuiWPF
{
public class MainViewModel : ViewModelBase
{
public string PageTitle { get; set; }
public ICommand LoadHomePageCommand {get; private set;}
public ICommand LoadSettingsPageCommand {get; private set;}
private ViewModelBase _currentViewModel;
public ViewModelBase CurrentViewModel {
get {
Trace.WriteLine("CurrentAbgefragt");
return _currentViewModel;
}
set {
Trace.WriteLine("CurrentView ist geändert worden");
_currentViewModel = value;
OnPropertyChanged();
}
}
public MainViewModel()
{
PageTitle = "Dichtheitsprüfung by Damian";
LoadHomePage();
LoadHomePageCommand = new DelegateCommand(o => this.LoadHomePage());
LoadSettingsPageCommand = new DelegateCommand(o => this.LoadSettingsPage());
//Initialisieren();
}
private void LoadHomePage() {
CurrentViewModel = new HomePageViewModel(new HomePage() { PageTitle = "Home"});
}
private void LoadSettingsPage() {
CurrentViewModel = new SettingsPageViewModel();
}
}
}

View File

@@ -5,14 +5,20 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GuiWPF"
mc:Ignorable="d"
Title="{Binding Titel, StringFormat={} DP - {0}}" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Content="WWWings-Flugbuchung" FontSize="30" Margin="5"/>
<ContentControl Content="{Binding}" Grid.Row="1"/>
</Grid>
Title="{Binding PageTitle, StringFormat={} DP - {0}}" Height="450" Width="800">
<Window.Resources>
<DataTemplate DataType="{x:Type local:HomePageViewModel}">
<local:HomePageView />
</DataTemplate>
<DataTemplate DataType="{x:Type local:SettingsPageViewModel}">
<local:SettingsPageView />
</DataTemplate>
</Window.Resources>
<DockPanel>
<StackPanel DockPanel.Dock="Left">
<Button Content="Home Page" Command="{Binding Path=LoadHomePageCommand}" />
<Button Content="Settings Page" Command="{Binding Path=LoadSettingsPageCommand}"/>
</StackPanel>
<ContentControl Content="{Binding CurrentViewModel}" Name="Contenter"></ContentControl>
</DockPanel>
</Window>

View File

@@ -1,5 +1,4 @@
using GuiWPF_ViewModel;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,8 +22,8 @@ namespace GuiWPF
{
public MainWindow()
{
InitializeComponent();
this.DataContext = new MainViewModel();
//InitializeComponent();
//this.DataContext = new MainViewModel();
}
}
}

View File

@@ -1,8 +1,9 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace GuiWPF_ViewModel
namespace GuiWPF
{
public class NotificationObject : INotifyPropertyChanged
{
@@ -13,6 +14,7 @@ namespace GuiWPF_ViewModel
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
Trace.WriteLine(string.Format("OnPropertyChanged {0}",propertyName));
}
}
}

View File

@@ -0,0 +1,11 @@
<UserControl x:Class="GuiWPF.SettingsPageView"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock FontSize="20" Text="{Binding Path=PageTitle}" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GuiWPF
{
public class SettingsPageViewModel : ViewModelBase {
public string PageTitle = "SettingsPage";
}
}

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace GuiWPF_ViewModel
namespace GuiWPF
{
public class ViewModelBase : NotificationObject
{

View File

@@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GuiWPF_ViewModel
{
public class MainViewModel : NotificationObject
{
public string Titel { get; set; }
public MainViewModel()
{
Titel = "Dichtheitsprüfung by Damian";
//Initialisieren();
}
}
}