Umbau angefangen auf ICommand
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class PropertyChangedClass
|
||||
public class BaseViewModel
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected internal void OnPropertyChanged([CallerMemberName] string propertyname = null)
|
||||
{
|
||||
Trace.WriteLine("OnPropertyChanged ()" + propertyname);
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyname));
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class BaustelleEditViewModel : PropertyChangedClass, INotifyPropertyChanged, IBaustelleEditViewModel
|
||||
public class BaustelleEditViewModel : BaseViewModel, INotifyPropertyChanged, IBaustelleEditViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
private Baustelle baustelle;
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class BaustellenListViewModel : IBaustelleListViewModel
|
||||
public class BaustellenListViewModel :BaseViewModel, IBaustelleListViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
private List<Baustelle> baustellen;
|
||||
|
||||
32
KanSan.ViewModel/Commands/RelayCommand.cs
Normal file
32
KanSan.ViewModel/Commands/RelayCommand.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel.Commands
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private Action<object> execute;
|
||||
private Func<object, bool> canExecute;
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
|
||||
{
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return this.canExecute == null || this.canExecute(parameter);
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
this.execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class KundenEditViewModel : PropertyChangedClass, INotifyPropertyChanged
|
||||
public class KundenEditViewModel : BaseViewModel, INotifyPropertyChanged
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
|
||||
@@ -2,19 +2,23 @@
|
||||
using KanSan.Base.Interfaces;
|
||||
using KanSan.Base.Interfaces.UI;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class KundenListViewModel : IKundenListViewModel
|
||||
public class KundenListViewModel : BaseViewModel, IKundenListViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
private List<Kunde> kunden;
|
||||
|
||||
public ICommand AddNewClientCommand { get; set; }
|
||||
|
||||
public List<Kunde> Kunden
|
||||
{
|
||||
get
|
||||
@@ -26,6 +30,8 @@ namespace KanSan.ViewModel
|
||||
public KundenListViewModel()
|
||||
{
|
||||
kunden = unitOfWork.KundenRepository.Get().ToList();
|
||||
|
||||
AddNewClientCommand = new RelayCommand(parameter => NeueKunde());
|
||||
}
|
||||
|
||||
public Kunde NeueKunde()
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace KanSan.ViewModel
|
||||
public string Tag { get => tag; set => tag = value; }
|
||||
public bool IsActiveInBaustelle { get => isActiveInBaustelle; set => isActiveInBaustelle = value; }
|
||||
}
|
||||
public class LeistungsverzeichnisBaustelleViewModel : PropertyChangedClass, INotifyPropertyChanged, ILeistungsverzeichnisBaustelleViewModel
|
||||
public class LeistungsverzeichnisBaustelleViewModel : BaseViewModel, INotifyPropertyChanged, ILeistungsverzeichnisBaustelleViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class LeistungsverzeichnisPositionenListViewModel :PropertyChangedClass, INotifyPropertyChanged, ILeistungsverzeichnisPositionListViewModel
|
||||
public class LeistungsverzeichnisPositionenListViewModel :BaseViewModel, INotifyPropertyChanged, ILeistungsverzeichnisPositionListViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
List<LeistungsverzeichnisPosition> lvPositionen;
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class LeistungsverzeichnisPositionViewModel : PropertyChangedClass, INotifyPropertyChanged, ILeistungsverzeichnisPositionViewModel
|
||||
public class LeistungsverzeichnisPositionViewModel : BaseViewModel, INotifyPropertyChanged, ILeistungsverzeichnisPositionViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using KanSan.Base;
|
||||
using KanSan.Base.Interfaces;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel.Commands;
|
||||
using Microsoft.Win32;
|
||||
using Syncfusion.XlsIO;
|
||||
using System;
|
||||
@@ -11,12 +12,17 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class MainWindowViewModel : PropertyChangedClass, INotifyPropertyChanged
|
||||
public class MainWindowViewModel : BaseViewModel, INotifyPropertyChanged
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
BaseViewModel actualViewModel;
|
||||
|
||||
|
||||
RegistryKey registry;
|
||||
const string REGISTRYKEY = "HKEY_CURRENT_USER\\Software\\Cosysda\\KanSan";
|
||||
|
||||
@@ -27,6 +33,32 @@ namespace KanSan.ViewModel
|
||||
|
||||
public static Baustelle Baustelle;
|
||||
public static List<LeistungsverzeichnisPosition> LVPositionen = null;
|
||||
|
||||
|
||||
|
||||
public ICommand ListClientsCommand { get; set; }
|
||||
public ICommand ListProjectsCommand { get; set; }
|
||||
public ICommand ListBaustellenCommand { get; set; }
|
||||
public ICommand ListObjectsCommand { get; set; }
|
||||
public ICommand ShowLeistungsverzeichnisCommand { get; set; }
|
||||
public ICommand SelectLeistungsverzeichnisBaustelleCommand { get; set; }
|
||||
|
||||
|
||||
public BaseViewModel ActualViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
Trace.WriteLine(actualViewModel);
|
||||
return actualViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (actualViewModel == value) return;
|
||||
Trace.WriteLine("Setze viewModel auf " + value);
|
||||
actualViewModel = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string ApplicationTitle
|
||||
@@ -184,10 +216,45 @@ namespace KanSan.ViewModel
|
||||
Registry.CurrentUser.CreateSubKey("Software\\Cosysda\\KanSan");
|
||||
LadeRegistry();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
|
||||
}
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
|
||||
LadeRegistry();
|
||||
LoadBaustellenLeistungsverzeichnis();
|
||||
|
||||
ListClients();
|
||||
|
||||
|
||||
ListClientsCommand = new RelayCommand(parmater => ListClients());
|
||||
ListProjectsCommand = new RelayCommand(parameter => ListProjekte());
|
||||
ListBaustellenCommand = new RelayCommand(paramter => ListBaustellen());
|
||||
ListObjectsCommand = new RelayCommand(parameter => ListObjekte());
|
||||
|
||||
}
|
||||
|
||||
private void ListClients()
|
||||
{
|
||||
ActualViewModel = new KundenListViewModel();
|
||||
}
|
||||
|
||||
private void ListProjekte()
|
||||
{
|
||||
ActualViewModel = new ProjektListViewModel(SelectedKunde);
|
||||
}
|
||||
|
||||
private void ListBaustellen()
|
||||
{
|
||||
ActualViewModel = new BaustellenListViewModel(SelectedProjekt);
|
||||
}
|
||||
|
||||
private void ListObjekte()
|
||||
{
|
||||
ActualViewModel = new ObjekteListViewModel(SelectedBaustelle);
|
||||
}
|
||||
|
||||
public void GenerateExcelFile()
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class ObjekteEditViewModel : PropertyChangedClass,IObjekteEditViewModel, INotifyPropertyChanged
|
||||
public class ObjekteEditViewModel : BaseViewModel,IObjekteEditViewModel, INotifyPropertyChanged
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
string strassename;
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
using KanSan.Base.Interfaces;
|
||||
using KanSan.Base.Interfaces.UI;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
@@ -14,8 +17,10 @@ namespace KanSan.ViewModel
|
||||
public string Strassename { get; set; }
|
||||
public IEnumerable<Sewer> Objekte { get; set; }
|
||||
}
|
||||
public class ObjekteListViewModel
|
||||
public class ObjekteListViewModel : BaseViewModel
|
||||
{
|
||||
public ICommand ObjektSelected { get; set; }
|
||||
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
List<ObjekteTransfer> kanalObjekte = new List<ObjekteTransfer>();
|
||||
@@ -37,9 +42,22 @@ namespace KanSan.ViewModel
|
||||
}).ToList();
|
||||
kanalObjekte = x;
|
||||
|
||||
ObjektSelected = new RelayCommand(SelectObjekt);
|
||||
|
||||
//kanalObjekte = unitOfWork.KanaeleRepository.Get(x => x.Baustelle.Equals(selectedBaustelle)).ToList();
|
||||
}
|
||||
|
||||
private void SelectObjekt(object obj)
|
||||
{
|
||||
if (!(obj is Sewer)) return;
|
||||
Sewer sewer = (Sewer)obj;
|
||||
if (sewer == null) return;
|
||||
|
||||
SewerMainWindowViewModel t = new SewerMainWindowViewModel(sewer);
|
||||
Debugger.Break();
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Sewer NeueObjektHinzufügen()
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class ProjektEditViewModel : PropertyChangedClass,INotifyPropertyChanged, IProjektEditViewModel
|
||||
public class ProjektEditViewModel : BaseViewModel,INotifyPropertyChanged, IProjektEditViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
private Projekt projekt;
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class ProjektListViewModel : IProjektListViewModel
|
||||
public class ProjektListViewModel : BaseViewModel, IProjektListViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
private List<Projekt> projektevonKunde;
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class ProjektViewModel : PropertyChangedClass,INotifyPropertyChanged
|
||||
public class ProjektViewModel : BaseViewModel,INotifyPropertyChanged
|
||||
{
|
||||
private Projekt _baustelle;
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class SchaedenEditViewModel : PropertyChangedClass, INotifyPropertyChanged, ISchaedenEditViewModel
|
||||
public class SchaedenEditViewModel : BaseViewModel, INotifyPropertyChanged, ISchaedenEditViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
decimal entfernung;
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class SewerMainMenuViewModel : PropertyChangedClass,INotifyPropertyChanged
|
||||
public class SewerMainWindowViewModel : BaseViewModel,INotifyPropertyChanged
|
||||
{
|
||||
private Sewer model;
|
||||
private SchaedenViewModel schadenViewModel;
|
||||
@@ -58,7 +58,7 @@ namespace KanSan.ViewModel
|
||||
|
||||
|
||||
|
||||
public SewerMainMenuViewModel(Sewer model)
|
||||
public SewerMainWindowViewModel(Sewer model)
|
||||
{
|
||||
if (model == null) throw new ArgumentNullException();
|
||||
this.model = model;
|
||||
@@ -10,7 +10,7 @@ using System.Text;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class TaetigkeitEditViewModel : PropertyChangedClass, INotifyPropertyChanged, ITaetigkeitEditViewModel
|
||||
public class TaetigkeitEditViewModel : BaseViewModel, INotifyPropertyChanged, ITaetigkeitEditViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
Fahrzeug fahrzeug;
|
||||
|
||||
Reference in New Issue
Block a user