Refactoring durchgeführt
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using DaSaSo.EntityFramework.Services.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using System;
|
||||
@@ -13,31 +14,22 @@ namespace DaSaSo.EntityFramework.Services
|
||||
public class ClientDataService : IDataService<Client>
|
||||
{
|
||||
private readonly DaSaSoDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<Client> _nonQueryDataService;
|
||||
|
||||
public ClientDataService(DaSaSoDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<Client>(contextFactory);
|
||||
}
|
||||
|
||||
public async Task<Client> Create(Client entity)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
EntityEntry<Client> createdResult = await context.Set<Client>().AddAsync(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return createdResult.Entity;
|
||||
}
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
Client entity = await context.Set<Client>().FirstOrDefaultAsync((e) => e.Id == id);
|
||||
context.Set<Client>().Remove(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
return await _nonQueryDataService.Delete(id);
|
||||
}
|
||||
|
||||
public async Task<Client> Get(int id)
|
||||
@@ -54,7 +46,7 @@ namespace DaSaSo.EntityFramework.Services
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
IEnumerable<Client> entities = await context.Set<Client>().ToListAsync();
|
||||
IEnumerable<Client> entities = await context.Clients.ToListAsync();
|
||||
|
||||
return entities;
|
||||
}
|
||||
@@ -62,13 +54,7 @@ namespace DaSaSo.EntityFramework.Services
|
||||
|
||||
public async Task<Client> Update(int id, Client entity)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
entity.Id = id;
|
||||
context.Set<Client>().Update(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.EntityFramework.Services.Common
|
||||
{
|
||||
class NonQueryDataService<T> where T: DomainObject
|
||||
{
|
||||
private readonly DaSaSoDbContextFactory _contextFactory;
|
||||
|
||||
public NonQueryDataService(DaSaSoDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
public async Task<T> Create(T entity)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return createdEntity.Entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
|
||||
context.Set<T>().Remove(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public async Task<T> Update(int id, T entity)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
entity.Id = id;
|
||||
context.Set<T>().Update(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using DaSaSo.EntityFramework.Services.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using System;
|
||||
@@ -13,31 +14,22 @@ namespace DaSaSo.EntityFramework.Services
|
||||
public class GenericDataService<T> : IDataService<T> where T : DomainObject
|
||||
{
|
||||
private readonly DaSaSoDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<T> _nonQueryDataService;
|
||||
|
||||
public GenericDataService(DaSaSoDbContextFactory contextFactory)
|
||||
{
|
||||
this._contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<T>(contextFactory);
|
||||
}
|
||||
|
||||
public async Task<T> Create(T entity)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return createdEntity.Entity;
|
||||
}
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
|
||||
context.Set<T>().Remove(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
return await _nonQueryDataService.Delete(id);
|
||||
}
|
||||
|
||||
public async Task<T> Get(int id)
|
||||
@@ -62,13 +54,7 @@ namespace DaSaSo.EntityFramework.Services
|
||||
|
||||
public async Task<T> Update(int id, T entity)
|
||||
{
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
entity.Id = id;
|
||||
context.Set<T>().Update(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace DaSaSo.ViewModel
|
||||
_dataService = dataService;
|
||||
|
||||
|
||||
//LoadClient();
|
||||
LoadClient();
|
||||
SelectClientCommand = new RelayCommand(SelectClient, () => SelectedClient != null);
|
||||
EditClientCommand = new RelayCommand(EditClient, () => SelectedClient != null);
|
||||
AddNewClientCommand = new RelayCommand(AddNewClient);
|
||||
|
||||
33
DaSaSo.ViewModel/Commands/UpdateCurrentViewModelCommand.cs
Normal file
33
DaSaSo.ViewModel/Commands/UpdateCurrentViewModelCommand.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using DaSaSo.ViewModel.Enums;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DaSaSo.ViewModel.Commands
|
||||
{
|
||||
class UpdateCurrentViewModelCommand : ICommand
|
||||
{
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
private INavigator _navigator;
|
||||
private readonly IViewModelAbstractFactory _viewModelFactory;
|
||||
|
||||
public UpdateCurrentViewModelCommand(INavigator navigator, IViewModelAbstractFactory viewModelFactory)
|
||||
{
|
||||
_navigator = navigator;
|
||||
_viewModelFactory = viewModelFactory;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object? parameter)
|
||||
{
|
||||
if(parameter is EViewType)
|
||||
{
|
||||
EViewType viewType = (EViewType)parameter;
|
||||
_navigator.CurrentViewModel = _viewModelFactory.CreateViewModel(viewType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
DaSaSo.ViewModel/Enums/EViewType.cs
Normal file
17
DaSaSo.ViewModel/Enums/EViewType.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Enums
|
||||
{
|
||||
public enum EViewType
|
||||
{
|
||||
Home,
|
||||
Clients,
|
||||
Projects,
|
||||
Buildingsites,
|
||||
SewerObjects
|
||||
}
|
||||
}
|
||||
20
DaSaSo.ViewModel/Factories/ClientListViewModelFactory.cs
Normal file
20
DaSaSo.ViewModel/Factories/ClientListViewModelFactory.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.EntityFramework;
|
||||
using DaSaSo.EntityFramework.Services;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Factories
|
||||
{
|
||||
public class ClientListViewModelFactory : IViewModelFactory<ClientListViewModel>
|
||||
{
|
||||
public ClientListViewModel CreateViewModel()
|
||||
{
|
||||
return new ClientListViewModel(new GenericDataService<Client>(new DaSaSoDbContextFactory()));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
DaSaSo.ViewModel/Factories/HomeViewModelFactory.cs
Normal file
17
DaSaSo.ViewModel/Factories/HomeViewModelFactory.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Factories
|
||||
{
|
||||
public class HomeViewModelFactory : IViewModelFactory<HomeViewModel>
|
||||
{
|
||||
public HomeViewModel CreateViewModel()
|
||||
{
|
||||
return new HomeViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
DaSaSo.ViewModel/Factories/ViewModelAbstractFactory.cs
Normal file
46
DaSaSo.ViewModel/Factories/ViewModelAbstractFactory.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.EntityFramework;
|
||||
using DaSaSo.EntityFramework.Services;
|
||||
using DaSaSo.ViewModel.Enums;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Factories
|
||||
{
|
||||
public class ViewModelAbstractFactory : IViewModelAbstractFactory
|
||||
{
|
||||
private IViewModelFactory<HomeViewModel> _homeViewModelFactory;
|
||||
private IViewModelFactory<ClientListViewModel> _clientListViewModel;
|
||||
|
||||
public ViewModelAbstractFactory(IViewModelFactory<HomeViewModel> homeViewModelFactory, IViewModelFactory<ClientListViewModel> clientListViewModel)
|
||||
{
|
||||
_homeViewModelFactory = homeViewModelFactory;
|
||||
_clientListViewModel = clientListViewModel;
|
||||
}
|
||||
|
||||
public BaseViewModel CreateViewModel(EViewType viewType)
|
||||
{
|
||||
|
||||
switch (viewType)
|
||||
{
|
||||
case EViewType.Home:
|
||||
return _homeViewModelFactory.CreateViewModel();
|
||||
case EViewType.Clients:
|
||||
return _clientListViewModel.CreateViewModel();
|
||||
/*case EViewType.Projects:
|
||||
break;
|
||||
case EViewType.Buildingsites:
|
||||
break;
|
||||
case EViewType.SewerObjects:
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
throw new ArgumentException("The Viewtype dos not have a ViewModel.", "viewType");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
DaSaSo.ViewModel/HomeViewModel.cs
Normal file
13
DaSaSo.ViewModel/HomeViewModel.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel
|
||||
{
|
||||
public class HomeViewModel : BaseViewModel
|
||||
{
|
||||
public string Welcome { get => "Herzlich willkommen"; }
|
||||
}
|
||||
}
|
||||
15
DaSaSo.ViewModel/Interface/INavigator.cs
Normal file
15
DaSaSo.ViewModel/Interface/INavigator.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DaSaSo.ViewModel.Interface
|
||||
{
|
||||
public interface INavigator
|
||||
{
|
||||
BaseViewModel CurrentViewModel { get; set; }
|
||||
ICommand UpdateViewModelCommand { get; }
|
||||
}
|
||||
}
|
||||
14
DaSaSo.ViewModel/Interface/IViewModelAbstractFactory.cs
Normal file
14
DaSaSo.ViewModel/Interface/IViewModelAbstractFactory.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using DaSaSo.ViewModel.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Interface
|
||||
{
|
||||
public interface IViewModelAbstractFactory
|
||||
{
|
||||
BaseViewModel CreateViewModel(EViewType viewType);
|
||||
}
|
||||
}
|
||||
13
DaSaSo.ViewModel/Interface/IViewModelFactory.cs
Normal file
13
DaSaSo.ViewModel/Interface/IViewModelFactory.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Interface
|
||||
{
|
||||
public interface IViewModelFactory<T> where T: BaseViewModel
|
||||
{
|
||||
T CreateViewModel();
|
||||
}
|
||||
}
|
||||
35
DaSaSo.ViewModel/State/Navigation/Navigator.cs
Normal file
35
DaSaSo.ViewModel/State/Navigation/Navigator.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using DaSaSo.ViewModel.Commands;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DaSaSo.ViewModel.State.Navigation
|
||||
{
|
||||
public class Navigator : INavigator, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
private BaseViewModel _currentViewModel;
|
||||
public BaseViewModel CurrentViewModel
|
||||
{
|
||||
get => _currentViewModel;
|
||||
set
|
||||
{
|
||||
_currentViewModel = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand UpdateViewModelCommand { get; set; }
|
||||
|
||||
public Navigator(IViewModelAbstractFactory viewModelFactory)
|
||||
{
|
||||
UpdateViewModelCommand = new UpdateCurrentViewModelCommand(this, viewModelFactory);
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName]string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.EntityFramework;
|
||||
using DaSaSo.EntityFramework.Services;
|
||||
using DaSaSo.ViewModel.Enums;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using DaSaSo.ViewModel.State.Navigation;
|
||||
using Microsoft.Toolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -19,6 +22,8 @@ namespace DaSaSo.ViewModel
|
||||
private Project _selectedProject;
|
||||
private Buildingsite _selectedBuildingsite;
|
||||
|
||||
public INavigator Navigator { get; set; }
|
||||
|
||||
public IRelayCommand ListClientsCommand { get; set; }
|
||||
public IRelayCommand ListProjectCommand { get; set; }
|
||||
public IRelayCommand ListBuildingsiteCommand { get; set; }
|
||||
@@ -85,8 +90,10 @@ namespace DaSaSo.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
public MainWindowViewModel()
|
||||
public MainWindowViewModel(INavigator navigator)
|
||||
{
|
||||
this.Navigator = navigator;
|
||||
Navigator.UpdateViewModelCommand.Execute(EViewType.Home);
|
||||
ListClientsCommand = new RelayCommand(showClients);
|
||||
ListProjectCommand = new RelayCommand(listProjecte, () => SelectedClient != null);
|
||||
ListBuildingsiteCommand = new RelayCommand(listBuildingsite, () => SelectedProject != null);
|
||||
|
||||
@@ -4,6 +4,9 @@ using DaSaSo.Domain.Services.ClientServices;
|
||||
using DaSaSo.EntityFramework;
|
||||
using DaSaSo.EntityFramework.Services;
|
||||
using DaSaSo.ViewModel;
|
||||
using DaSaSo.ViewModel.Factories;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using DaSaSo.ViewModel.State.Navigation;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -23,19 +26,27 @@ namespace DaSaSo.Wpf
|
||||
protected override async void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
IServiceProvider serviceProvider = CreateServiceProvider();
|
||||
IDataService<Client> clientService = new ClientDataService(new DaSaSoDbContextFactory());
|
||||
var d = await clientService.GetAll();
|
||||
base.OnStartup(e);
|
||||
MainWindow? window = new MainWindow() { DataContext = new MainWindowViewModel() };
|
||||
|
||||
MainWindow? window = new MainWindow() { DataContext = serviceProvider.GetRequiredService<MainWindowViewModel>() };
|
||||
window.Show();
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
private IServiceProvider CreateServiceProvider()
|
||||
{
|
||||
IServiceCollection services = new ServiceCollection();
|
||||
|
||||
services.AddSingleton<DaSaSoDbContext>();
|
||||
//services.AddSingleton<IDataService<Client>, ClientDataService>();
|
||||
services.AddSingleton<DaSaSoDbContextFactory>();
|
||||
services.AddSingleton<IDataService<Client>, ClientDataService>();
|
||||
|
||||
|
||||
services.AddSingleton<IViewModelAbstractFactory, ViewModelAbstractFactory>();
|
||||
services.AddSingleton<IViewModelFactory<HomeViewModel>, HomeViewModelFactory>();
|
||||
services.AddSingleton<IViewModelFactory<ClientListViewModel>, ClientListViewModelFactory>();
|
||||
services.AddScoped<INavigator, Navigator>();
|
||||
|
||||
services.AddScoped<MainWindowViewModel>();
|
||||
|
||||
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
22
DaSaSo.Wpf/Controls/NavigationBar.xaml
Normal file
22
DaSaSo.Wpf/Controls/NavigationBar.xaml
Normal file
@@ -0,0 +1,22 @@
|
||||
<UserControl x:Class="DaSaSo.Wpf.Controls.NavigationBar"
|
||||
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:DaSaSo.Wpf.Controls"
|
||||
xmlns:nav="clr-namespace:DaSaSo.ViewModel.Enums;assembly=DaSaSo.ViewModel"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<RadioButton Grid.Row="0" Content="Kunden" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.Clients}" />
|
||||
<RadioButton Grid.Row="1" Content="Projekte" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.Projects}" />
|
||||
<RadioButton Grid.Row="2" Content="Baustellen" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.Buildingsites}" />
|
||||
<RadioButton Grid.Row="3" Content="Objekten" Style="{StaticResource ToggleButtonList}" Command="{Binding UpdateViewModelCommand}" CommandParameter="{x:Static nav:EViewType.SewerObjects}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
DaSaSo.Wpf/Controls/NavigationBar.xaml.cs
Normal file
28
DaSaSo.Wpf/Controls/NavigationBar.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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 DaSaSo.Wpf.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for NavigationBar.xaml
|
||||
/// </summary>
|
||||
public partial class NavigationBar : UserControl
|
||||
{
|
||||
public NavigationBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,26 +7,41 @@
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Controls\NavigationBar.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Client\ClientEditView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Client\ClientListView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\HomeView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Project\ProjectListView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Controls\NavigationBar.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="my_controls.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Styles\Navigation_Style.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="View\Client\ClientEditView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="View\Client\ClientListView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="View\HomeView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="View\Project\ProjectListView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
4
DaSaSo.Wpf/Styles/Navigation_Style.xaml
Normal file
4
DaSaSo.Wpf/Styles/Navigation_Style.xaml
Normal file
@@ -0,0 +1,4 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
</ResourceDictionary>
|
||||
12
DaSaSo.Wpf/View/HomeView.xaml
Normal file
12
DaSaSo.Wpf/View/HomeView.xaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="DaSaSo.Wpf.View.HomeView"
|
||||
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:DaSaSo.Wpf.View" xmlns:viewmodel="clr-namespace:DaSaSo.ViewModel;assembly=DaSaSo.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:HomeViewModel}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding Welcome }" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
DaSaSo.Wpf/View/HomeView.xaml.cs
Normal file
28
DaSaSo.Wpf/View/HomeView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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 DaSaSo.Wpf.View
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for HomeView.xaml
|
||||
/// </summary>
|
||||
public partial class HomeView : UserControl
|
||||
{
|
||||
public HomeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ClientViews="clr-namespace:DaSaSo.Wpf.View.Client"
|
||||
xmlns:ProjektViews="clr-namespace:DaSaSo.Wpf.View.Project"
|
||||
xmlns:controls="clr-namespace:DaSaSo.Wpf.Controls"
|
||||
xmlns:View="clr-namespace:DaSaSo.Wpf.View"
|
||||
xmlns:local="clr-namespace:DaSaSo.Wpf" xmlns:viewmodel="clr-namespace:DaSaSo.ViewModel;assembly=DaSaSo.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
@@ -18,6 +20,9 @@
|
||||
<DataTemplate DataType="{x:Type viewmodel:ProjectListViewModel}">
|
||||
<ProjektViews:ProjectListView />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type viewmodel:HomeViewModel}">
|
||||
<View:HomeView />
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -28,13 +33,8 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="20" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Column="0" Grid.Row="0">
|
||||
<RadioButton Content="Kunden" Style="{StaticResource ToggleButtonList}" Command="{Binding ListClientsCommand}" />
|
||||
<RadioButton Content="Projekte" Style="{StaticResource ToggleButtonList}" Command="{Binding ListProjectCommand}" />
|
||||
<RadioButton Content="Baustellen" Style="{StaticResource ToggleButtonList}" Command="{Binding ListBuildingsiteCommand}" />
|
||||
<RadioButton Content="Objekte" Style="{StaticResource ToggleButtonList}" Command="{Binding ListSewerObjectsCommand}" />
|
||||
</StackPanel>
|
||||
<ContentControl Grid.Column="1" Grid.Row="0" Content="{Binding ActualViewModel}" />
|
||||
<controls:NavigationBar Grid.Column="0" Grid.Row="0" DataContext="{Binding Navigator }" />
|
||||
<ContentControl Grid.Column="1" Grid.Row="0" Content="{Binding Navigator.CurrentViewModel}" />
|
||||
<StatusBar Grid.Row="1" Grid.ColumnSpan="2">
|
||||
<StatusBarItem Content="{Binding SelectedClient.Firstname}" />
|
||||
</StatusBar>
|
||||
|
||||
Reference in New Issue
Block a user