Exemple #1
0
        public StatistikViemodel(WpfUIDialogWindowService dialogService)
        {
            Auswertung = new ObservableCollection<StatistikItem>(StatistikReader.Read());
            _view = CollectionViewSource.GetDefaultView(Auswertung);
            _view.SortDescriptions.Add(new SortDescription("Timestamp",ListSortDirection.Descending));

            _dialogService = dialogService;
            _lazyDeleteStatistikEintragCommand = new Lazy<DelegateCommand<StatistikItem>>(()=> new DelegateCommand<StatistikItem>(DeleteExecute, CanDeleteExecute));
            _lazyShowDetailsStatistikEintragCommand = new Lazy<DelegateCommand<StatistikItem>>(()=> new DelegateCommand<StatistikItem>(ShowDetailsCommandExecute, CanShowDetailsCommandExecute));
        }
        public MainWindowViewmodel()
        {
            Titel = ConfigurationManager.AppSettings["Titel"];
            Module = new ObservableCollection<IModule>();

            var add = new AdditionModul();
            add.StatistikEvent += (sender, args) => Auswertung.Add(args.Auswertung);

            var sub = new SubtraktionModul();
            sub.StatistikEvent += (sender, args) => Auswertung.Add(args.Auswertung);

            var mal = new MultiplikationModul();
            mal.StatistikEvent += (sender, args) => Auswertung.Add(args.Auswertung);

            Module.Add(add);
            Module.Add(sub);
            Module.Add(mal);

            _dialogService = new WpfUIDialogWindowService();

            Auswertung = new StatistikViemodel(_dialogService);

            _lazyStatistikCommand = new Lazy<DelegateCommand>(() => new DelegateCommand(StatistikCommandExecute, CanStatistikCommandExecute));
        }