/// <summary> /// The background worker run worker completed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false); MessageBox.Show("Congratulations! You have added a new Train into the Database"); if (DataHelper.Train != null) { if (MessageBox.Show( "Lets Confirm" + $"\nTrain Number: {DataHelper.Train.TrainNumber}" + $"\nTrain Name: {DataHelper.Train.TrainName}" + $"\nTrain Type: {DataHelper.Train.Type}" + $"\nSource Station: {DataHelper.Train.SourceStation}" + $"\nDestination Station: {DataHelper.Train.DestinationStation}" + $"\nRake Zone: {DataHelper.Train.RakeZone}", "Confirm Message", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { MessageBox.Show("Ok... Data is not added"); return; } } if (DataHelper.Train != null) { DataHelper.Train.Route = this.routes.ToList(); } this.Refresh(); DataHelper.Accept = true; }
private void StartPlayback() { Bass.ChannelSetPosition(fxStream, audioLength / 3); // start from second third of the track Bass.ChannelPlay(fxStream); playIcon.Kind = PackIconKind.Pause; ButtonProgressAssist.SetIsIndicatorVisible(playButton, true); }
private void SendMail() { ButtonProgressAssist.SetIsIndicatorVisible(Send, true); ClientOptions clientOptions = Utils.ReadConfig(); MailOptions mailOptions = new MailOptions { From = From.Text.Trim(), To = GetItems(To), Cc = GetItems(Cc), Subject = Subject.Text.Trim(), Body = Body.Text.Trim() }; MailClient mailClient = new MailClient(clientOptions); mailClient.Sended += () => { Utils.InvokeUIThread(() => { ButtonProgressAssist.SetIsIndicatorVisible(Send, false); ShowMessage("Mail Sended!"); }); }; mailClient.Send(mailOptions); }
/// <summary> /// The button accept on click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ButtonAcceptOnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(this.TextBoxTteName.Text) || string.IsNullOrWhiteSpace(this.TextBoxTteEmailId.Text) || string.IsNullOrWhiteSpace(this.PasswordBoxTtePassword.Password) || string.IsNullOrWhiteSpace(this.ComboBoxZoneName.Text) || string.IsNullOrWhiteSpace(this.ComboBoxDivisionName.Text)) { MessageBox.Show("Please fill up all the fields!"); return; } if (!this.TextBoxTteName.Text.Contains(" ")) { if (MessageBox.Show( $"Is \"{this.TextBoxTteName.Text}\" Full Name of the TTE?", "Confirmation of Full Name", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } } ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); var tte = new Tte { Name = this.TextBoxTteName.Text, EmailId = this.TextBoxTteEmailId.Text, Password = this.PasswordBoxTtePassword.Password, Zone = this.ComboBoxZoneName.Text, Division = this.ComboBoxDivisionName.Text }; var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += (o, args) => { var task = this.AddTteAsync(tte); Task.WaitAll(task); }; backgroundWorker.RunWorkerCompleted += (o, args) => { MessageBox.Show("You have successfully added TTE" + $"\nName: {this.TextBoxTteName.Text}\nId: {this.tteId}"); ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false); }; try { backgroundWorker.RunWorkerAsync(); this.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void buttonOnClick(object sender, EventArgs e) { Button button = sender as Button; ButtonProgressAssist.SetIsIndicatorVisible(button, true); ButtonProgressAssist.SetIsIndeterminate(button, true); int i = (int)button.Tag; Debug.WriteLine(i + "-" + links[i]); downloadAndOpen(links[i], button); }
private void checkActivateDownloadButton() { if (Directory.Exists(this.downloaderManager.Destination) && this.dgLinks.Items.Count > 0 && !this.downloaderManager.Completed) { this.btnDownload.IsEnabled = true; ButtonProgressAssist.SetIsIndicatorVisible(this.btnDownload, true); } else { btnDownload.IsEnabled = false; ButtonProgressAssist.SetIsIndicatorVisible(this.btnDownload, false); } }
private static void OnProgressValueChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { UserControl_ProgressButton button = d as UserControl_ProgressButton; ProgressType progressType = (ProgressType)e.NewValue; switch (progressType) { case ProgressType.Ini: ButtonProgressAssist.SetValue(button.but, 0); button.packIcon.Kind = button.Kind; ButtonProgressAssist.SetIsIndicatorVisible(button.but, false); break; case ProgressType.Start: ButtonProgressAssist.SetValue(button.but, 0); ButtonProgressAssist.SetIsIndicatorVisible(button.but, true); button.packIcon.Kind = PackIconKind.Sync; new DispatcherTimer(TimeSpan.FromMilliseconds(10), DispatcherPriority.Normal, (s, ee) => { if (ButtonProgressAssist.GetValue(button.but) <= 50) { ButtonProgressAssist.SetValue(button.but, ButtonProgressAssist.GetValue(button.but) + 1); } else { ((DispatcherTimer)s).Stop(); } }, Dispatcher.CurrentDispatcher); break; case ProgressType.Done: new DispatcherTimer(TimeSpan.FromMilliseconds(10), DispatcherPriority.Normal, (s, ee) => { if (ButtonProgressAssist.GetValue(button.but) <= 100) { ButtonProgressAssist.SetValue(button.but, ButtonProgressAssist.GetValue(button.but) + 1); } else { ButtonProgressAssist.SetIsIndicatorVisible(button.but, false); button.packIcon.Kind = PackIconKind.Check; ((DispatcherTimer)s).Stop(); } }, Dispatcher.CurrentDispatcher); break; } }
/// <summary> /// The button accept on click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ButtonAcceptOnClick(object sender, RoutedEventArgs e) { if (DataHelper.Train != null) { if (this.routes.Count == 0) { MessageBox.Show($"Please add routes for the Train {DataHelper.Train.TrainNumber}"); return; } if (this.routes.Any(r => r.StationCode == DataHelper.Train.SourceStation) == false) { MessageBox.Show($"Please add a route details for Source Station {DataHelper.Train.SourceStation}"); return; } if (this.routes.Any(r => r.StationCode == DataHelper.Train.DestinationStation) == false) { MessageBox.Show( $"Please add a route details for Destination Station {DataHelper.Train.DestinationStation}"); return; } } ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); if (DataHelper.Train != null) { DataHelper.Train.Route = this.routes.ToList(); } this.backgroundWorker = new BackgroundWorker(); this.backgroundWorker.DoWork += this.BackgroundWorkerDoWork; this.backgroundWorker.RunWorkerCompleted += this.BackgroundWorkerRunWorkerCompleted; try { this.backgroundWorker.RunWorkerAsync(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private async void downloadAndOpen(string v, Button button) { var path = await v.DownloadFileAsync(AppDomain.CurrentDomain.BaseDirectory, "filed.torrent"); ButtonProgressAssist.SetIsIndicatorVisible(button, false); ButtonProgressAssist.SetIsIndeterminate(button, false); Debug.WriteLine("Path : " + path); try { Process.Start(new ProcessStartInfo(path) { UseShellExecute = true }); } catch { Debug.WriteLine("Error"); MessageBox.Show("Make sure any Torrent client is installed"); } }
/// <summary> /// The button accept on click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void ButtonAcceptOnClick([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(this.ComboBoxZoneName.Text) || string.IsNullOrWhiteSpace(this.ComboBoxDivisionName.Text) || string.IsNullOrWhiteSpace(this.TextBoxStationCode.Text) || string.IsNullOrWhiteSpace(this.TextBoxStationName.Text) || string.IsNullOrWhiteSpace(this.TextBoxPinCode.Text)) { MessageBox.Show("Please fill up all the fields!"); return; } if (this.TextBoxPinCode.Text.Length < 6) { MessageBox.Show("Pin Code must have SIX digits!"); return; } var s = MessageBox.Show( "Are you sure you want to continue? You cannot undo this operation", "Question", MessageBoxButton.YesNo); if (s == MessageBoxResult.No) { return; } ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); var station = new Station { Zone = this.ComboBoxZoneName.Text, RailwayDivision = this.ComboBoxDivisionName.Text, StationCode = this.TextBoxStationCode.Text, StationName = this.TextBoxStationName.Text, StationPinCode = Convert.ToInt32(this.TextBoxPinCode.Text) }; var backgroundWorker2 = new BackgroundWorker(); backgroundWorker2.DoWork += (o, args) => { var task = this.AddStationAsync(station); Task.WaitAll(task); }; backgroundWorker2.RunWorkerCompleted += (o, args) => { ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false); MessageBox.Show("Data Successfully added"); }; try { backgroundWorker2.RunWorkerAsync(); this.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void ToggleBusyIndicator(bool isBusy) { hasPendingTask = isBusy; ButtonProgressAssist.SetIsIndicatorVisible(SaveButton, isBusy); }
private void CreateBTN_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, true); MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(btn, -1); MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, true); btn.IsEnabled = false; bool allFine = true; MaxPlayersBox.Text = new String(MaxPlayersBox.Text.Where(Char.IsDigit).ToArray()); if (MaxPlayersBox.Text.Length > 3) { MaxPlayersBox.Text = MaxPlayersBox.Text.Substring(0, 3); } if (String.IsNullOrEmpty(MaxPlayersBox.Text)) { setError(MaxPlayersBox, "Field is required."); allFine = false; } else { int count = int.Parse(MaxPlayersBox.Text); if (count > 15) { setError(MaxPlayersBox, "Can't be more than 15 players."); allFine = false; } else if (count < 2) { setError(MaxPlayersBox, "Can't be less than 2 players."); allFine = false; } else { Validation.ClearInvalid(MaxPlayersBox.GetBindingExpression(TextBox.TextProperty)); } } QuestionsBox.Text = new String(QuestionsBox.Text.Where(Char.IsDigit).ToArray()); if (QuestionsBox.Text.Length > 3) { QuestionsBox.Text = QuestionsBox.Text.Substring(0, 3); } if (String.IsNullOrEmpty(QuestionsBox.Text)) { setError(QuestionsBox, "Field is required."); allFine = false; } else { int count = int.Parse(QuestionsBox.Text); if (count > 20) { setError(QuestionsBox, "Can't be more than 20 questions."); allFine = false; } else if (count < 2) { setError(QuestionsBox, "Can't be less than 2 questions."); allFine = false; } else { Validation.ClearInvalid(QuestionsBox.GetBindingExpression(TextBox.TextProperty)); } } SecondsBox.Text = new String(SecondsBox.Text.Where(Char.IsDigit).ToArray()); if (SecondsBox.Text.Length > 3) { SecondsBox.Text = SecondsBox.Text.Substring(0, 3); } if (String.IsNullOrEmpty(SecondsBox.Text)) { setError(SecondsBox, "Field is required."); allFine = false; } else { int count = int.Parse(SecondsBox.Text); if (count > 100) { setError(SecondsBox, "Can't be more than 100 seconds."); allFine = false; } else if (count < 10) { setError(SecondsBox, "Can't be less than 10 seconds."); allFine = false; } else { Validation.ClearInvalid(SecondsBox.GetBindingExpression(TextBox.TextProperty)); } } if (String.IsNullOrEmpty(RoomNameBox.Text)) { setError(RoomNameBox, "Field is required."); allFine = false; } else { Validation.ClearInvalid(RoomNameBox.GetBindingExpression(TextBox.TextProperty)); } if (allFine) { CreateRoomRequest createRoomRequest = new CreateRoomRequest(); createRoomRequest.answerTimeout = int.Parse(SecondsBox.Text); createRoomRequest.maxUsers = int.Parse(MaxPlayersBox.Text); createRoomRequest.questionCount = int.Parse(QuestionsBox.Text); createRoomRequest.roomName = RoomNameBox.Text; app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(createRoomRequest, Constants.CREATE_ROOM_REQUEST_CODE)).ContinueWith(task => { ResponseInfo response = task.Result; CreateRoomResponse createRoomResponse = JsonDeserializer.deserializeResponse <CreateRoomResponse>(response.buffer); switch (createRoomResponse.status) { case Constants.CREATE_ROOM_SUCCESS: MyMessageQueue.Enqueue("Room Created Successfully!"); this.Dispatcher.Invoke(() => { app.admin = true; NavigationService ns = NavigationService.GetNavigationService(this); ns.Navigate(new Uri("RoomLobby.xaml", UriKind.Relative)); }); break; case Constants.CREATE_ROOM_MAXIMUM_ROOMS_IN_SERVER: MyMessageQueue.Enqueue("Max rooms reached.\nTry again later."); break; } this.Dispatcher.Invoke(() => { ButtonProgressAssist.SetIsIndeterminate(btn, false); ButtonProgressAssist.SetIsIndicatorVisible(btn, false); btn.IsEnabled = true; }); }); } else { ButtonProgressAssist.SetIsIndeterminate(btn, false); ButtonProgressAssist.SetIsIndicatorVisible(btn, false); btn.IsEnabled = true; } }
private async void Button_OnClick(object sender, RoutedEventArgs e) { if (CurrentWork?.Result == ResultCodes.Success) { MainTransitioner.SelectedIndex = 3; Content.SelectedIndex = 2; return; } var NextButton = (Button)sender; if (MainViewModel.Instance.Encoder == null) { MainTransitioner.SelectedIndex = 1; PeerDiscovery.DiscoverPeersAsync(PeerDiscovery.DiscoveryMethod.UDPBroadcast); return; } if (workFetched) { return; } workFetched = true; ButtonProgressAssist.SetIsIndicatorVisible(NextButton, true); ButtonProgressAssist.SetIsIndeterminate(NextButton, true); var work = await Client.GetNextWork(); CurrentWork = work; Student.DataContext = work.Student; ButtonProgressAssist.SetIsIndicatorVisible(NextButton, false); ButtonProgressAssist.SetIsIndeterminate(NextButton, false); //_encoderMagic.IsGenieOut = false; var errorMessage = ""; switch (work.Result) { case ResultCodes.Success: WorkDataGrid.ItemsSource = work.ClassSchedules; //_workMagic.IsGenieOut = true; MainTransitioner.SelectedIndex = 3; Content.SelectedIndex = 2; LoginLamp.Visibility = Visibility.Collapsed; StudentId.Text = work.StudentId; StudentName.Text = work.StudentName; break; case ResultCodes.NotFound: //MessageBox.Show("No more pending items."); errorMessage = "No more requests"; break; case ResultCodes.Offline: errorMessage = "Can not find server"; break; case ResultCodes.Timeout: errorMessage = "Request timeout"; break; case ResultCodes.Error: errorMessage = "Request timeout"; break; } await ShowMessage(errorMessage); workFetched = false; }
public HomeView() { InitializeComponent(); this.WhenActivated(disposables => { // Link and Start this.Bind(ViewModel, viewModel => viewModel.Link, view => view.linkTextBox.Text) .DisposeWith(disposables); linkTextBox.Events().KeyDown .Where(x => x.Key == Key.Enter) .Select(x => Unit.Default) .InvokeCommand(ViewModel !.StartDownloadCommand) // Null forgiving reason: upstream limitation. .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.BackendService.GlobalDownloadProgressPercentage, view => view.downloadButton.Content, percentage => percentage > 0.0 ? percentage.ToString("P1") : "_Download") .DisposeWith(disposables); // ButtonProgressAssist bindings ViewModel.WhenAnyValue(x => x.BackendInstance.IsRunning) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { ButtonProgressAssist.SetIsIndicatorVisible(downloadButton, x); ButtonProgressAssist.SetIsIndicatorVisible(listFormatsButton, x); }) .DisposeWith(disposables); ViewModel.WhenAnyValue(x => x.BackendService.ProgressState) .Select(x => x == TaskbarItemProgressState.Indeterminate) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => ButtonProgressAssist.SetIsIndeterminate(downloadButton, x)) .DisposeWith(disposables); ViewModel.WhenAnyValue(x => x.BackendService.GlobalDownloadProgressPercentage) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => ButtonProgressAssist.SetValue(downloadButton, x * 100)) .DisposeWith(disposables); ViewModel.WhenAnyValue(x => x.BackendService.ProgressState) .Select(x => x == TaskbarItemProgressState.Indeterminate) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => ButtonProgressAssist.SetIsIndeterminate(listFormatsButton, x)) .DisposeWith(disposables); // presetComboBox this.OneWayBind(ViewModel, viewModel => viewModel.Presets, view => view.presetComboBox.ItemsSource) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.SelectedPreset, view => view.presetComboBox.SelectedItem) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.SelectedPresetText, view => view.presetComboBox.Text) .DisposeWith(disposables); // Subtitles this.Bind(ViewModel, viewModel => viewModel.SharedSettings.DownloadSubtitles, view => view.subtitlesDefaultCheckBox.IsChecked) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.DownloadSubtitlesAllLanguages, view => view.subtitlesAllLanguagesCheckBox.IsChecked) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.DownloadAutoGeneratedSubtitles, view => view.subtitlesAutoGeneratedCheckBox.IsChecked) .DisposeWith(disposables); // Options row 1 this.Bind(ViewModel, viewModel => viewModel.SharedSettings.AddMetadata, view => view.metadataToggle.IsChecked) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.DownloadThumbnail, view => view.thumbnailToggle.IsChecked) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.DownloadPlaylist, view => view.playlistToggle.IsChecked) .DisposeWith(disposables); // Options row 2 this.Bind(ViewModel, viewModel => viewModel.SharedSettings.UseCustomOutputTemplate, view => view.filenameTemplateToggle.IsChecked) .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.SharedSettings.UseCustomOutputTemplate, view => view.filenameTemplateTextBox.IsEnabled) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.CustomOutputTemplate, view => view.filenameTemplateTextBox.Text) .DisposeWith(disposables); // Options row 3 this.Bind(ViewModel, viewModel => viewModel.SharedSettings.UseCustomPath, view => view.pathToggle.IsChecked) .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.SharedSettings.UseCustomPath, view => view.pathComboBox.IsEnabled) .DisposeWith(disposables); this.OneWayBind(ViewModel, viewModel => viewModel.DownloadPathHistory, view => view.pathComboBox.ItemsSource) .DisposeWith(disposables); this.Bind(ViewModel, viewModel => viewModel.SharedSettings.DownloadPath, view => view.pathComboBox.Text) .DisposeWith(disposables); // Arguments this.OneWayBind(ViewModel, viewModel => viewModel.DownloadArguments, view => view.argumentsItemsControl.ItemsSource) .DisposeWith(disposables); // Output this.Bind(ViewModel, viewModel => viewModel.QueuedTextBoxSink.Content, view => view.resultTextBox.Text) .DisposeWith(disposables); resultTextBox.Events().TextChanged .Where(_ => WpfHelper.IsScrolledToEnd(resultTextBox)) .Subscribe(_ => resultTextBox.ScrollToEnd()) .DisposeWith(disposables); // Download, list, abort button this.BindCommand(ViewModel, viewModel => viewModel.StartDownloadCommand, view => view.downloadButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.ListFormatsCommand, view => view.listFormatsButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.AbortDlCommand, view => view.abortButton) .DisposeWith(disposables); // Browse and open folder button this.BindCommand(ViewModel, viewModel => viewModel.BrowseDownloadFolderCommand, view => view.browseButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.OpenDownloadFolderCommand, view => view.openFolderButton) .DisposeWith(disposables); // Reset custom filename template button this.BindCommand(ViewModel, viewModel => viewModel.ResetCustomFilenameTemplateCommand, view => view.resetFilenameTemplateButton) .DisposeWith(disposables); // Custom preset buttons this.BindCommand(ViewModel, viewModel => viewModel.OpenAddCustomPresetDialogCommand, view => view.addPresetButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.OpenEditCustomPresetDialogCommand, view => view.editPresetButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.DuplicatePresetCommand, view => view.duplicatePresetButton) .DisposeWith(disposables); this.BindCommand(ViewModel, viewModel => viewModel.DeleteCustomPresetCommand, view => view.deletePresetButton) .DisposeWith(disposables); }); }
/// <summary> /// The background worker run worker completed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { MessageBox.Show("You have successfully added Station Master" + $"\nName: {this.TextBoxStationMasterName.Text}\nId: {this.stationMasterId}"); ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false); }
/// <summary> /// The background worker do work. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private async void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e) { var stationMasterName = string.Empty; var zone = string.Empty; var division = string.Empty; this.Dispatcher.Invoke( () => { ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true); stationMasterName = this.TextBoxStationMasterName.Text; zone = this.ComboBoxZoneName.Text; division = this.ComboBoxDivisionName.Text; }, DispatcherPriority.Normal); var id = StaticDbContext.ConnectFireStore.GetAllDocumentId( "Root", "Employee", zone, division, "StationMaster"); var max = 0; if (id.Count != 0) { max = Convert.ToInt32(id.OrderByDescending(i => int.Parse(i.Substring(8))).First().Substring(8)); } this.stationMasterId = $"{(int)EnumEmployeeGroups.GroupB:D2}" + $"{(int)EnumEmployeeType.StationMaster:D2}" + $"{DataHelper.ZoneAndDivisionModel.ZoneList.IndexOf(zone):D2}" + $"{DataHelper.ZoneAndDivisionModel.DivisionList[zone].IndexOf(division):D2}" + $"{(max + 1):D7}"; var stationMaster = new StationMaster { Name = stationMasterName, Id = this.stationMasterId }; var noOfStationMaster = 0; var divisionField = StaticDbContext.ConnectFireStore.GetCollectionFields("Root", "Employee", zone, division); if (divisionField != null) { noOfStationMaster = Convert.ToInt32(divisionField["noOfStationMaster"]); } noOfStationMaster++; await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync( new Dictionary <string, int> { { "noOfStationMaster", noOfStationMaster } }, "Root", "Employee", zone, division); await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync( stationMaster, "Root", "Employee", zone, division, "StationMaster", stationMaster.Id); }
private void LoginBTN_Clicked(object sender, RoutedEventArgs e) { Button btn = sender as Button; MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, true); MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(btn, -1); MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, true); btn.IsEnabled = false; SignupBTN.IsEnabled = false; bool EverythingFine = true; if (String.IsNullOrEmpty(UsernameBox.Text)) { UsernameBox.GetBindingExpression(TextBox.TextProperty); ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), UsernameBox.GetBindingExpression(TextBox.TextProperty)); validationError.ErrorContent = "Field is required."; Validation.MarkInvalid( UsernameBox.GetBindingExpression(TextBox.TextProperty), validationError); EverythingFine = false; } else { Validation.ClearInvalid(UsernameBox.GetBindingExpression(TextBox.TextProperty)); } if (String.IsNullOrEmpty(PasswordBox.Password)) { PasswordBox.GetBindingExpression(TextBox.TextProperty); ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty)); validationError.ErrorContent = "Field is required."; Validation.MarkInvalid( PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty), validationError); EverythingFine = false; } else if (PasswordBox.Password.Length < 1) { PasswordBox.GetBindingExpression(TextBox.TextProperty); ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty)); validationError.ErrorContent = "At least 8 characters."; Validation.MarkInvalid( PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty), validationError); EverythingFine = false; } else { Validation.ClearInvalid(PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty)); } if (EverythingFine) { LoginRequest loginRequest = new LoginRequest(); loginRequest.username = UsernameBox.Text; loginRequest.password = PasswordBox.Password; app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(loginRequest, Constants.LOGIN_REQUEST_CODE)).ContinueWith(task => { ResponseInfo response = task.Result; LoginResponse loginResponse = JsonDeserializer.deserializeResponse <LoginResponse>(response.buffer); switch (loginResponse.status) { case Constants.LOGIN_SUCCESS: MyMessageQueue.Enqueue("Sign in Successfully!"); this.Dispatcher.Invoke(() => { app.username = UsernameBox.Text; NavigationService ns = NavigationService.GetNavigationService(this); ns.Navigate(new Uri("Menu.xaml", UriKind.Relative)); }); break; case Constants.LOGIN_INCORRECT_PASSWORD: MyMessageQueue.Enqueue("Incorrect password."); break; case Constants.LOGIN_USERNAME_NOT_EXIST: MyMessageQueue.Enqueue("Username not exist."); break; case Constants.LOGIN_UNEXPECTED_ERR: MyMessageQueue.Enqueue("There was an unexpected error."); break; case Constants.LOGIN_ALREADY_ONLINE: MyMessageQueue.Enqueue("This Username is already online."); break; } this.Dispatcher.Invoke(() => { ButtonProgressAssist.SetIsIndeterminate(btn, false); ButtonProgressAssist.SetIsIndicatorVisible(btn, false); btn.IsEnabled = true; SignupBTN.IsEnabled = true; }); }); } else { MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, false); MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, false); btn.IsEnabled = true; SignupBTN.IsEnabled = true; } }
private void StopPlayback() { Bass.ChannelStop(fxStream); playIcon.Kind = PackIconKind.Play; ButtonProgressAssist.SetIsIndicatorVisible(playButton, false); }