Ejemplo n.º 1
0
        // ********************************************* //
        #region "constructor"

        public MainViewModel(IMainWindow view, IOtherSettingsView viewOtherSettings)
        {
            _view = view;

            _measRepository   = new MeasRepository("data/measurements.csv");
            _configRepository = new ConfigRepository("data/OmsLite.exe.config");

            _vmOtherSettings     = new OtherSettingsViewModel(_configRepository, viewOtherSettings);
            _vmChosenMeasurement = new ChosenMeasurementViewModel(_configRepository, _measRepository);
            _vmAllMeasurements   = new AllMeasurementsViewModel(_measRepository, _vmChosenMeasurement);

            // ----------------- commands
            SaveCmd = new RelayCommand(Save, () => _dirty);

            // ----------------- messages
            Messenger.Default.Register <bool>(this, _ => { _dirty = true; });
        }
Ejemplo n.º 2
0
        public MainViewModel(IMainWindow view, IOtherSettingsView viewOtherSettings)
        {
            _view = view;

            _measRepository = new MeasRepository("data/measurements.csv");
            _configRepository = new ConfigRepository("data/OmsLite.exe.config");

            _vmOtherSettings = new OtherSettingsViewModel(_configRepository, viewOtherSettings);
            _vmChosenMeasurement = new ChosenMeasurementViewModel(_configRepository, _measRepository);
            _vmAllMeasurements = new AllMeasurementsViewModel(_measRepository, _vmChosenMeasurement);

            // ----------------- commands
            SaveCmd = new RelayCommand(Save, () => _dirty);

            // ----------------- messages
            Messenger.Default.Register<bool>(this, _ => { _dirty = true; });
        }
        public AllMeasurementsViewModel(MeasRepository measRepository, ChosenMeasurementViewModel vmChosenMeasurements)
        {
            _allMeasurements = (from m in measRepository.Measurements
                                select new MeasurementViewModel(m)).ToArray();

            _filtered = new ObservableCollection<MeasurementViewModel>(_allMeasurements);

            MeasurementsView = CollectionViewSource.GetDefaultView(_filtered);
            MeasurementsView.SortDescriptions.Add(new SortDescription("Device", ListSortDirection.Ascending));
            MeasurementsView.SortDescriptions.Add(new SortDescription("SignalType", ListSortDirection.Descending));
            MeasurementsView.GroupDescriptions.Add(new PropertyGroupDescription("Device"));

            SignalTypeOptions = Enumerable.Repeat("All", 1).Concat(_allMeasurements.Select(m => m.SignalType).Distinct().OrderBy(s => s)).ToArray();
            CurrentSignalType = SignalTypeOptions[0];

            FilterCmd = new RelayCommand(OnFilter);
            SelectAllCmd = new RelayCommand(OnSelectAll);
            AddCmd = new RelayCommand(OnAdd);

            _vmChosenMeasurements = vmChosenMeasurements;
        }
Ejemplo n.º 4
0
        public AllMeasurementsViewModel(MeasRepository measRepository, ChosenMeasurementViewModel vmChosenMeasurements)
        {
            _allMeasurements = (from m in measRepository.Measurements
                                select new MeasurementViewModel(m)).ToArray();

            _filtered = new ObservableCollection <MeasurementViewModel>(_allMeasurements);

            MeasurementsView = CollectionViewSource.GetDefaultView(_filtered);
            MeasurementsView.SortDescriptions.Add(new SortDescription("Device", ListSortDirection.Ascending));
            MeasurementsView.SortDescriptions.Add(new SortDescription("SignalType", ListSortDirection.Descending));
            MeasurementsView.GroupDescriptions.Add(new PropertyGroupDescription("Device"));

            SignalTypeOptions = Enumerable.Repeat("All", 1).Concat(_allMeasurements.Select(m => m.SignalType).Distinct().OrderBy(s => s)).ToArray();
            CurrentSignalType = SignalTypeOptions[0];

            FilterCmd    = new RelayCommand(OnFilter);
            SelectAllCmd = new RelayCommand(OnSelectAll);
            AddCmd       = new RelayCommand(OnAdd);

            _vmChosenMeasurements = vmChosenMeasurements;
        }