示例#1
0
        public MainWindowViewModel()
        {
            ServiceModel = new WindowsServiceSettingsModel();
            ClientModel  = new WindowsClientSettingsModel();

            StartServiceCommand       = new DelegateCommand(async() => await StartServiceAsync());
            StopServiceCommand        = new DelegateCommand(async() => await StopServiceAsync());
            UpdateSettingsCommand     = new DelegateCommand(async() => await ServiceModel.UpdateServiceSettingsAsync());
            ConnectClientCommand      = new DelegateCommand(async() => await ClientModel.ConnectClientAsync());
            SelectFileToUploadCommand = new DelegateCommand(async() => await UploadFilesAsync());

            // Check the status of the service every second.
            Observable.Interval(TimeSpan.FromSeconds(1))
            .Subscribe(async _ => await GetServiceStatusAsync());
        }
示例#2
0
 private async Task GetServiceStatusAsync()
 {
     Status = await WindowsServiceSettingsModel.GetServiceStatus();
 }
示例#3
0
        private async Task StartServiceAsync()
        {
            await WindowsServiceSettingsModel.InitializeClientAsync();

            await GetServiceStatusAsync();
        }
示例#4
0
        private async Task StopServiceAsync()
        {
            await WindowsServiceSettingsModel.StopClientAsync();

            await GetServiceStatusAsync();
        }