Exemple #1
0
        public HomeViewModel(IWindowService windowService)
        {
            _windowService = windowService;

            AddFieldCommand      = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteAddFieldCommand);
            OpenFieldCommand     = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteOpenFieldCommand);
            ShutdownCommand      = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteShutdownCommand);
            SyncCommand          = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSyncCommand);
            DeleteCheckedCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteDeleteCheckedCommand);

            Producers = new ObservableCollection <ComboBoxItemViewModel>();
            Farms     = new ObservableCollection <FarmComboBoxItemViewModel>();
            Fields    = new ObservableCollection <FieldComboBoxItemViewModel>();
            Lists     = new ObservableCollection <PickupListGridItem>();

            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <PickupListAddedMessage>(this, action => ProcessListAddedMessage(action));
            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <TagLoadingMessage>(this, action => ProcessTagLoadingMessage(action));
            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <TagUnloadingMessage>(this, action => ProcessTagUnloadingMessage(action));
            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <DataRefreshedMessage>(this, action => ProcessDataRefreshedMessage(action));
            Messenger.Default.Register <AllAggEventsProcessComplete>(this, (action) => ProcessLoadUnloadComplete(action));

            refresh();
            SelectedProducer = Producers[0];
            SelectedFarm     = Farms[0];
            SelectedField    = Fields[0];

            if (Lists.Count() > 0)
            {
                SelectedItem = Lists[0];
            }

            /*Timer timer = new Timer(30000);
             * timer.Elapsed += (sender, e) => HandleTimer();
             * timer.Start();*/
        }
Exemple #2
0
 public UnloadCorrectionViewModel(IWindowService windowService) : base()
 {
     _windowService     = windowService;
     ForceUnloadCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteForceUnloadCommand);
     RetryCommand       = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteRetryCommand);
     CancelCommand      = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteCancelCommand);
 }
Exemple #3
0
        public async Task Initialize()
        {
            ContinueCommand     = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteContinueCommand);
            SavePasswordCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSavePasswordCommand);
            SkipPasswordCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSkipPasswordCommand);
            CloseCommand        = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteCloseCommand);
            Trucks  = new ObservableCollection <ComboBoxItemViewModel>();
            Drivers = new ObservableCollection <ComboBoxItemViewModel>();

            HasBlockingError     = false;
            BlockingErrorMessage = "";
            ShowStep2            = false;
            ShowStep1            = false;
            ErrorMessage         = "";

            if (!CottonDBMS.DataModels.Helpers.NetworkHelper.HasNetwork())
            {
                BlockingErrorMessage = "No network.  Truck must have a data connection to complete setup";
                HasBlockingError     = true;
                return;
            }

            var  savedKeys     = trySaveDbKeysFromInstallDrive();
            bool savedTrucks   = false;
            bool savedSettings = false;

            if (!savedKeys)
            {
                BlockingErrorMessage = "Database keys could not be found or are invalid.";
                HasBlockingError     = true;
                return;
            }

            savedTrucks = await tryDownloadTrucksFromCloud();

            if (!savedTrucks)
            {
                BlockingErrorMessage = "Unabled to download list of truck ids.";
                HasBlockingError     = true;
                return;
            }
            SelectedTruck  = Trucks[0];
            SelectedDriver = Drivers[0];


            savedSettings = await tryDownloadSettings();

            if (!savedSettings)
            {
                BlockingErrorMessage = "Unabled to download settings.";
                HasBlockingError     = true;
                return;
            }

            if (!HasBlockingError)
            {
                ShowStep1 = true;
            }
        }
Exemple #4
0
        public DataSyncSettingsViewModel()
        {
            SaveCommand            = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSave);
            ClearAllCommand        = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteClearAllCommand);
            ClearModuleDataCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteClearModuleDataCommand);

            ShowClearButtons = false;
        }
Exemple #5
0
        public ChangeListViewModel(IWindowService windowService)
        {
            _windowService = windowService;
            SaveCommand    = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSaveCommand);
            CancelCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteCancelCommand);

            ModulesOnTruck = new ObservableCollection <ModuleViewModel>();
        }
Exemple #6
0
        public AddPickUpListViewModel(IWindowService windowService)
        {
            _windowService = windowService;
            SaveCommand    = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSaveCommand);
            CancelCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteCancelCommand);

            NewFarmText     = "";
            ListName        = "";
            NewProducerText = "";
            NewFieldText    = "";

            ErrorMessages = new ObservableCollection <string>();

            Producers = new ObservableCollection <ComboBoxItemViewModel>();
            Producers.Add(new ComboBoxItemViewModel {
                ID = "-1", DisplayText = "-- Select One --"
            });
            Producers.Add(new ComboBoxItemViewModel {
                ID = "", DisplayText = "-- Add New --"
            });

            Farms = new ObservableCollection <FarmComboBoxItemViewModel>();
            Farms.Add(new FarmComboBoxItemViewModel {
                ID = "-1", ClientID = "", DisplayText = "-- Select One --"
            });
            Farms.Add(new FarmComboBoxItemViewModel {
                ID = "", ClientID = "", DisplayText = "-- Add New --"
            });

            Fields = new ObservableCollection <FieldComboBoxItemViewModel>();
            Fields.Add(new FieldComboBoxItemViewModel {
                ID = "-1", ClientID = "", DisplayText = "-- Select One --"
            });
            Fields.Add(new FieldComboBoxItemViewModel {
                ID = "", ClientID = "", DisplayText = "-- Add New --"
            });

            using (var uow = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork())
            {
                foreach (var p in uow.ClientRepository.GetAll().OrderBy(x => x.Name))
                {
                    if (p.Id != GUIDS.UNASSIGNED_CLIENT_ID)
                    {
                        Producers.Add(new ComboBoxItemViewModel {
                            DisplayText = p.Name, ID = p.Id
                        });
                    }
                }
            }

            SelectedProducer = Producers[0];
        }
        public PickUpListViewModel(IWindowService windowService)
        {
            _windowService = windowService;

            CloseCommand       = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteCloseCommand);
            DirectionsCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteDirectionsCommand);
            ShowMapCommand     = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteShowMapCommand);
            ShowListCommand    = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteShowListCommand);
            SetGinCommand      = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteGinCommand);
            SetYardCommand     = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteYardCommand);
            ForceUnloadCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteForceUnloadCommand);
            ForceLoadCommand   = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteLoadCommand);
            Modules            = new ObservableCollection <ModuleViewModel>();
            ListModules        = new ObservableCollection <ModuleViewModel>();
        }
        public MainViewModel()
        {
            _countdown.PropertyChanged += TriggerPropertyChange;
            _countdown.CompletedChanged += CompletedChangedTriggered;
            _sound.Open(_soundFileUri);
            _sound.MediaEnded += Repeat;

            StartCommand = new RelayCommand(StartCommandHandler, () => !IsCompleted);
            StopCommand = new RelayCommand(StopCommandHandler, () => !IsCompleted);
            GoToResetModeCommand = new RelayCommand(GoToResetModeCommandHandler);
            ResetCommand = new RelayCommand<TimeSpan>(ResetCommandHandler);
            RestartCommand = new RelayCommand(RestartCommandHandler);
            SwitchThemeCommand = new RelayCommand(SwitchThemeCommandHandler);
            CloseCommand = new RelayCommand(CloseCommandHandler);
            //for the sake of debugging the sound
#if DEBUG
            _countdown.Reset(TimeSpan.FromSeconds(2));
            _countdown.Start();
#endif
        }
        public DiagnosticsViewModel()
        {
            QuadratureEvents = new ObservableCollection <QuadratureEvent>();
            GPSEvents        = new ObservableCollection <GPSEvent>();
            RFIDEvents       = new ObservableCollection <RFIDEvent>();
            AggregateEvents  = new ObservableCollection <AggregateEvent>();

            Messenger.Default.Register <GPSEventMessage>(this, (action) => ProcessGPSMessage(action));
            Messenger.Default.Register <List <TagItem> >(this, (action) => ProcessTags(action));
            Messenger.Default.Register <AggregateEvent>(this, (action) => NewAggregateEvent(action));
            Messenger.Default.Register <QuadratureStateChangeMessage>(this, (action) => ProcessQuadratureStateChange(action));

            ExportGpsCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteExportGpsCommand);
            ClearGpsCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteClearGpsCommand);

            ExportRFIDCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteExportRFIDCommand);
            ClearRFIDCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteClearRFIDCommand);

            ExportQuadratureCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteExportQuadratureCommand);
            ClearQuadratureCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteClearQuadratureCommand);

            ExportAggregateCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteExportAggregateCommand);
            ClearAggregateCommand  = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteClearAggregateCommand);
        }
Exemple #10
0
        public NavViewModel()
        {
            LockSettingsCommand        = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteLockSettings);
            SavePasswordCommand        = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSavePasswordCommand);
            CancelCommand              = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteCancelCommand);
            UnlockCommand              = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteUnlockCommand);
            SaveUnlockCommand          = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteSaveUnlockCommand);
            Drivers                    = new ObservableCollection <ComboBoxItemViewModel>();
            PasswordModalVisible       = false;
            UnlockPasswordModalVisible = false;



            using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork())
            {
                var setting = dp.SettingsRepository.FindSingle(k => k.Key == TruckClientSettingKeys.ADMIN_PASSWORD);

                if (setting != null && !string.IsNullOrWhiteSpace(setting.Value))
                {
                    SettingsLocked = true;
                }
                else
                {
                    SettingsLocked = false;
                }

                var documentDbSetting   = dp.SettingsRepository.FindSingle(x => x.Key == TruckClientSettingKeys.DOCUMENT_DB_KEY);
                var syncIntervalSetting = dp.SettingsRepository.FindSingle(x => x.Key == TruckClientSettingKeys.DATA_SYNC_INTERVAL);
                var endpointSetting     = dp.SettingsRepository.FindSingle(x => x.Key == TruckClientSettingKeys.DOCUMENTDB_ENDPOINT);

                string key      = "";
                string endpoint = "";

                if (documentDbSetting != null)
                {
                    key = documentDbSetting.Value;
                }

                if (endpointSetting != null)
                {
                    endpoint = endpointSetting.Value;
                }

                if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(endpoint))
                {
                    CloudDBInitialized = false;
                    HasCloudSettings   = false;
                }
                else
                {
                    HasCloudSettings = true;
                    try
                    {
                        Task.Run(async() => {
                            DocumentDBContext.Initialize(endpoint, key);
                            if (!await DocumentDBContext.DatabaseExistsAsync())
                            {
                                CloudDBInitialized = true;
                            }
                        });
                    }
                    catch (Exception exc)
                    {
                        Logging.Logger.Log(exc);
                    }
                }
            }
            Messenger.Default.Register <BusyMessage>(this, (action) => ReceiveBusyMessage(action));
            Messenger.Default.Register <DialogClosedMessage>(this, (action => ReceiveDialogClosed(action)));
            Messenger.Default.Register <DialogOpenedMessage>(this, (action => ReceiveDialogOpened(action)));

            refresh();
            Timer timer = new Timer(25000);

            timer.Elapsed += (sender, e) => refresh();
            timer.Start();
        }
Exemple #11
0
        public UnloadingModuleViewModel(IWindowService windowService) : base()
        {
            _windowService = windowService;

            OverrideCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteOverrideCommand);
        }
Exemple #12
0
 public LoadingIncorrectModuleViewModel(IWindowService windowService) : base()
 {
     _windowService  = windowService;
     UnloadCommand   = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteUnloadCommand);
     ContinueCommand = new GalaSoft.MvvmLight.CommandWpf.RelayCommand(this.ExecuteContinueCommand);
 }
 private void CreateCommands()
 {
     Login = new Rc.RelayCommand(OnLogin, () => !(string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)));
     Logout = new Rc.RelayCommand(OnLogout);
     Send = new Rc.RelayCommand(OnSend);
     LoadImage = new Rc.RelayCommand(OnLoadImage);
     SaveChanges = new Rc.RelayCommand(OnSaveChanges);
 }