diff --git a/Gremlin/MVVM/AppBootstrapper.cs b/Gremlin/MVVM/AppBootstrapper.cs index 406fd9f..6df968d 100644 --- a/Gremlin/MVVM/AppBootstrapper.cs +++ b/Gremlin/MVVM/AppBootstrapper.cs @@ -4,17 +4,17 @@ namespace Gremlin.MVVM { public class AppBootstrapper : BootstrapperBase { - private readonly SimpleContainer _container = new(); + //private readonly SimpleContainer _container = new(); public AppBootstrapper() { Initialize(); } - protected override void Configure() - { - _container.Singleton(); - } + //protected override void Configure() + //{ + // _container.Singleton(); + //} protected override void OnStartup(object sender, System.Windows.StartupEventArgs e) { diff --git a/Gremlin/MVVM/ViewModels/AccountViewModel.cs b/Gremlin/MVVM/ViewModels/AccountViewModel.cs index 22b5abf..7893a91 100644 --- a/Gremlin/MVVM/ViewModels/AccountViewModel.cs +++ b/Gremlin/MVVM/ViewModels/AccountViewModel.cs @@ -1,4 +1,5 @@ -using Gremlin.GremlinData.DBClasses; +using Caliburn.Micro; +using Gremlin.GremlinData.DBClasses; using Gremlin.GremlinData.EntityClasses; using Microsoft.EntityFrameworkCore; using System; @@ -8,7 +9,7 @@ using System.Linq; namespace Gremlin.MVVM { - internal class AccountViewModel : BaseViewModel + internal class AccountViewModel : PropertyChangedBase { public uint SAPAccountNumber { get; set; } public string AccountName { get; set; } diff --git a/Gremlin/MVVM/ViewModels/AllContactsViewModel.cs b/Gremlin/MVVM/ViewModels/AllContactsViewModel.cs index c2993d8..809b109 100644 --- a/Gremlin/MVVM/ViewModels/AllContactsViewModel.cs +++ b/Gremlin/MVVM/ViewModels/AllContactsViewModel.cs @@ -7,38 +7,14 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; -using System.Threading; -using System.Threading.Tasks; namespace Gremlin.MVVM { - public class AllContactsViewModel : PropertyChangedBase, IHandle + public class AllContactsViewModel : PropertyChangedBase { - private ObservableCollection _allContactsVM; - private IEventAggregator _eventAggregator; + public static ObservableCollection ListOfContactsVM => GetAllContactsVM(); - public ObservableCollection AllContactsVM { get => _allContactsVM; internal set { _allContactsVM = value; NotifyOfPropertyChange(() => AllContactsVM); } } - - //public AllContactsViewModel() - //{ - // LoadContacts(); - //} - - public AllContactsViewModel(IEventAggregator eventAggregator) - { - _eventAggregator = eventAggregator; - LoadContacts(); - _eventAggregator.PublishOnUIThreadAsync($"{AllContactsVM.Count} Contacts loaded."); - } - - public AllContactsViewModel() - { - } - - public void LoadContacts() - { - AllContactsVM = GetAllContactsVM(); - } + public AllContactsViewModel() { } internal static ObservableCollection GetAllContactsVM() { @@ -65,10 +41,5 @@ namespace Gremlin.MVVM throw; } } - - public Task HandleAsync(ShellViewModel message, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } } } \ No newline at end of file diff --git a/Gremlin/MVVM/ViewModels/BaseViewModel.cs b/Gremlin/MVVM/ViewModels/BaseViewModel.cs deleted file mode 100644 index e12f732..0000000 --- a/Gremlin/MVVM/ViewModels/BaseViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace Gremlin.MVVM -{ - public class BaseViewModel : INotifyPropertyChanged - { - public event PropertyChangedEventHandler PropertyChanged; - - public void OnPropertyChanged([CallerMemberName] string propName = "") - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); - Debug.WriteLine(propName + " changed in INotifyPropertyChanged"); - } - } -} diff --git a/Gremlin/MVVM/ViewModels/ContactViewModel.cs b/Gremlin/MVVM/ViewModels/ContactViewModel.cs index 9f7d0a9..b5849e2 100644 --- a/Gremlin/MVVM/ViewModels/ContactViewModel.cs +++ b/Gremlin/MVVM/ViewModels/ContactViewModel.cs @@ -18,7 +18,7 @@ namespace Gremlin.MVVM private string _accountStreet; private uint _accountZIP; private string _accountCity; - private IEventAggregator _eventAggregator; + //private IEventAggregator _eventAggregator; public byte Gender { get => _gender; internal set { _gender = value; NotifyOfPropertyChange(() => Gender); } } public string FirstName { get => _firstName; internal set { _firstName = value; NotifyOfPropertyChange(() => FirstName); } } @@ -29,10 +29,10 @@ namespace Gremlin.MVVM public uint AccountZIP { get => _accountZIP; internal set { _accountZIP = value; NotifyOfPropertyChange(() => AccountZIP); } } public string AccountCity { get => _accountCity; internal set { _accountCity = value; NotifyOfPropertyChange(() => AccountCity); } } - public ContactViewModel(IEventAggregator eventAggregator) - { - _eventAggregator = eventAggregator; - } + //public ContactViewModel(IEventAggregator eventAggregator) + //{ + // _eventAggregator = eventAggregator; + //} public ContactViewModel(byte gender, string firstName, string lastName, string eMail, string accountName, string accountStreet, uint accountZIP, string accountCity) { diff --git a/Gremlin/MVVM/ViewModels/LineItemViewModel.cs b/Gremlin/MVVM/ViewModels/LineItemViewModel.cs index 3e59350..f1063cd 100644 --- a/Gremlin/MVVM/ViewModels/LineItemViewModel.cs +++ b/Gremlin/MVVM/ViewModels/LineItemViewModel.cs @@ -1,23 +1,36 @@ -using System; +using Caliburn.Micro; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; namespace Gremlin.MVVM { - public class LineItemViewModel : BaseViewModel + public class LineItemViewModel : PropertyChangedBase { - public ushort Position { get; private set; } - public ushort Amount { get; internal set; } - public string ProductNumber { get; private set; } - public string OptionNumber { get; private set; } - public string SapShortDescription { get; private set; } - public CustomDescriptionViewModel CustomDescriptionVM { get; private set; } - public string ProductLine { get; private set; } - public decimal TotalDiscount { get; internal set; } - public decimal CalcNetPrice { get; private set; } - public decimal CalcTotalNet { get; private set; } - public decimal ListPrice { get; private set; } + private ushort _position; + private ushort _amount; + private string _productNumber; + private string _optionNumber; + private string _sapShortDescription; + private CustomDescriptionViewModel _customDescriptionVM; + private string _productLine; + private decimal _totalDiscount; + private decimal _calcNetPrice; + private decimal _calcTotalNet; + private decimal _listPrice; + + public ushort Position { get => _position; internal set { _position = value; NotifyOfPropertyChange(() => Position); } } + public ushort Amount { get => _amount; internal set { _amount = value; NotifyOfPropertyChange(() => Amount); } } + public string ProductNumber { get => _productNumber; internal set { _productNumber = value; NotifyOfPropertyChange(() => ProductNumber); }} + public string OptionNumber { get => _optionNumber; internal set { _optionNumber = value; NotifyOfPropertyChange(() => OptionNumber); }} + public string SapShortDescription { get => _sapShortDescription; internal set { _sapShortDescription = value; NotifyOfPropertyChange(() => SapShortDescription); }} + public CustomDescriptionViewModel CustomDescriptionVM { get => _customDescriptionVM; internal set { _customDescriptionVM = value; NotifyOfPropertyChange(() => CustomDescriptionVM); }} + public string ProductLine { get => _productLine; internal set { _productLine = value; NotifyOfPropertyChange(() => ProductLine); }} + public decimal TotalDiscount { get => _totalDiscount; internal set { _totalDiscount = value; NotifyOfPropertyChange(() => TotalDiscount); }} + public decimal CalcNetPrice { get => _calcNetPrice; internal set { _calcNetPrice = value; NotifyOfPropertyChange(() => CalcNetPrice); }} + public decimal CalcTotalNet { get => _calcTotalNet; internal set { _calcTotalNet = value; NotifyOfPropertyChange(() => CalcTotalNet); }} + public decimal ListPrice { get => _listPrice; internal set { _listPrice = value; NotifyOfPropertyChange(() => ListPrice); }} internal static ObservableCollection ReadLineItemsFromClipboard() { diff --git a/Gremlin/MVVM/ViewModels/QuoteViewModel.cs b/Gremlin/MVVM/ViewModels/QuoteViewModel.cs index 364f15f..25e39db 100644 --- a/Gremlin/MVVM/ViewModels/QuoteViewModel.cs +++ b/Gremlin/MVVM/ViewModels/QuoteViewModel.cs @@ -2,12 +2,10 @@ using System; using System.Collections.ObjectModel; using System.Linq; -using System.Threading; -using System.Threading.Tasks; namespace Gremlin.MVVM { - public class QuoteViewModel : PropertyChangedBase, IHandle + public class QuoteViewModel : PropertyChangedBase { private string _quoteType = "ein Analysegerät"; private string _quotePath; @@ -29,7 +27,6 @@ namespace Gremlin.MVVM private bool _quoteContains3PP; private bool _quoteContainsRB; private bool? _showDiscounts = true; - private IEventAggregator _eventAggregator; public string QuoteType { get => _quoteType; internal set { _quoteType = value; NotifyOfPropertyChange(() => QuoteType); } } public string QuotePath { get => _quotePath; internal set { _quotePath = value; NotifyOfPropertyChange(() => QuotePath); } } @@ -65,7 +62,7 @@ namespace Gremlin.MVVM }; } - //public QuoteViewModel() { } + public QuoteViewModel() { } private QuoteViewModel(string quoteNumber, string quoteType, ContactViewModel recipient, ContactViewModel salesRep, bool? brutto, float vAT, int warranty, int validity, string quotePath, bool? singlePrices, bool? brochures, bool? dataSheets, bool? mailTemplate, bool? showDiscounts) { @@ -85,15 +82,6 @@ namespace Gremlin.MVVM ShowDiscounts = showDiscounts; } - public QuoteViewModel(IEventAggregator eventAggregator) - { - _eventAggregator = eventAggregator; - } - - public QuoteViewModel() - { - } - internal static QuoteViewModel CreateQuote(string quoteNumber, ContactViewModel recipient, ContactViewModel salesRep, float vAT = 19f, string quoteType = "ein Analysegerät", bool? brutto = true, int warranty = 12, bool? singlePrices = true, bool? brochures = true, bool? dataSheets = true, bool? mailTemplate = true, string quotePath = "", int validity = 60, bool? showDiscounts = true) { decimal totalListprice = 0, totalDiscount = 0, calcTotalNet = 0; @@ -156,15 +144,9 @@ namespace Gremlin.MVVM }; } - public void ReadLineItems() { LineItemsViewModel = LineItemViewModel.ReadLineItemsFromClipboard(); } - - public Task HandleAsync(ShellViewModel message, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } } } diff --git a/Gremlin/MVVM/ViewModels/ShellViewModel.cs b/Gremlin/MVVM/ViewModels/ShellViewModel.cs index 7ec739a..9e1207f 100644 --- a/Gremlin/MVVM/ViewModels/ShellViewModel.cs +++ b/Gremlin/MVVM/ViewModels/ShellViewModel.cs @@ -1,43 +1,16 @@ using Caliburn.Micro; -using System; -using System.Threading; -using System.Threading.Tasks; namespace Gremlin.MVVM { - public class ShellViewModel : PropertyChangedBase, IHandle ,IHandle + public class ShellViewModel : PropertyChangedBase { - private AllContactsViewModel allContactsVM; - private QuoteViewModel quoteVM; - private readonly IEventAggregator _eventAggregator; - - public QuoteViewModel QuoteVM { get => quoteVM; set => quoteVM = value; } - public AllContactsViewModel AllContactsVM { get => allContactsVM; set => allContactsVM = value; } + public QuoteViewModel QuoteVM { get; set; } + public AllContactsViewModel AllContactsVM { get; set; } public ShellViewModel() { QuoteVM = new(); AllContactsVM = new(); } - - public ShellViewModel(IEventAggregator eventAggregator) - { - QuoteVM = new QuoteViewModel(eventAggregator); - AllContactsVM = new AllContactsViewModel(eventAggregator); - - _eventAggregator = eventAggregator; - _eventAggregator.PublishOnUIThreadAsync($"{AllContactsVM.AllContactsVM.Count} Contacts loaded."); - _eventAggregator.PublishOnUIThreadAsync(12); - } - - public Task HandleAsync(AllContactsViewModel message, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } - - public Task HandleAsync(QuoteViewModel message, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } } } diff --git a/Gremlin/MVVM/Views/AllContactsView.xaml b/Gremlin/MVVM/Views/AllContactsView.xaml index aa64e19..757739f 100644 --- a/Gremlin/MVVM/Views/AllContactsView.xaml +++ b/Gremlin/MVVM/Views/AllContactsView.xaml @@ -4,14 +4,10 @@ - - -