Exemple #1
0
        private void GetDevices()
        {
            this.Devices.Clear();
            List <Device> devices = new List <Device>();

            using (CGM.Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
            {
                devices = uow.Device.GetAllDevices();
            }

            foreach (var item in devices)
            {
                var device = new DeviceItemViewModel(item, _dialogService);
                device.Removed += Device_Removed;
                this.Devices.Add(device);
            }
            if (this.Devices.Count > 0)
            {
                this.SelectedDevice = this.Devices[0];
            }
            else
            {
                this.SelectedDevice = null;
            }
        }
Exemple #2
0
 private void SaveSetting()
 {
     using (CGM.Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
     {
         uow.Setting.Update(_setting);
     }
 }
 private async void DeleteDevice()
 {
     await _dialogService.ShowMessage($"Are you sure you want to delete device: {this.ToString()}?",
                                      "Confirmation",
                                      buttonConfirmText : "Ok", buttonCancelText : "Cancel",
                                      afterHideCallback : (confirmed) =>
     {
         if (confirmed)
         {
             using (CGM.Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
             {
                 uow.Device.Remove(_device);
             }
             if (Removed != null)
             {
                 Removed(this, null);
             }
         }
         else
         {
             // User has pressed the "cancel" button
             // (or has discared the dialog box).
             // ...
         }
     });
 }
Exemple #4
0
 private void ClearHistory()
 {
     using (CGM.Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
     {
         uow.History.ResetHistory();
     }
     _dialogService.ShowMessage("History has been cleared.", "Clear history");
 }
Exemple #5
0
        public SettingsViewModel(IDialogService dialogService)
        {
            _dialogService         = dialogService;
            SwitchThemeCommand     = new RelayCommand(async() => { await ThemeSelectorService.SwitchThemeAsync(); });
            this.GetDevicesCommand = new RelayCommand(() => this.GetDevices());

            this.ClearHistoryCommand = new RelayCommand(() => this.ClearHistory());
            using (CGM.Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
            {
                _setting = uow.Setting.GetSettings();
            }
            GetDevices();
            this.LocalPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
        }
Exemple #6
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            if (!e.PrelaunchActivated)
            {
                await ActivationService.ActivateAsync(e);
            }
            string DataPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;

            ApplicationLogging.LoggerFactory.AddCgmLog(DataPath);

            ApplicationLogging.LoggerFactory.AddEventAggregatorLog();

            using (Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
            {
                uow.CheckDatabaseVersion(DataPath);
                uow.Setting.CheckSettings();
            }
            //check for nightscout settings
        }
Exemple #7
0
 public async void StatusChanged(BayerUsbDevice device)
 {
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                   () =>
     {
         this.IsConnected = device.IsConnected;
         Setting settings;
         using (CGM.Communication.Data.Repository.CgmUnitOfWork uow = new Communication.Data.Repository.CgmUnitOfWork())
         {
             settings = uow.Setting.GetSettings();
             if (this.IsConnected && settings.OtherSettings.AutoStartTask)
             {
                 this.On = true;
             }
             else
             {
                 this.On = false;
             }
         }
     });
 }