private async Task StartService(ServiceViewModel service, bool start) { try { var svc = service.Service; IsBusy = true; if (start) { svc.Start(); } else { svc.Stop(); } await Task.Run(() => { svc.WaitForStatus(start ? ServiceControllerStatus.Running : ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10)); }); } catch (System.ServiceProcess.TimeoutException) { MessageBoxService.ShowMessage("Operation timed out.", Constants.AppName); } catch (Exception ex) { MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName); } finally { IsBusy = false; service.Refresh(); StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); } }
private void button2_Click(object sender, EventArgs e) { var sc = new DelegateCallbackSampleClass(); sc.DoSomething(); _messageBoxService.ShowMessage(sc.DoOtherThing(2).ToString()); }
private void AuthorizationForm_LogIn(object sender, EventArgs e) { var userInfo = model.CheckUser(authorizationForm.Email, authorizationForm.Password); if (userInfo.Status == UserStatus.User.ToString()) { authorizationForm.Status = UserStatus.User; messageService.ShowMessage("Авторизация прошла успешно"); } else if (userInfo.Status == UserStatus.Admin.ToString()) { authorizationForm.Status = UserStatus.Admin; messageService.ShowMessage("Вы вошли как админ"); } else { authorizationForm.Status = UserStatus.Guest; messageService.ShowExclamation("Неверный логин или пароль."); } authorizationForm.Name = userInfo.Name; authorizationForm.Id = userInfo.Id; authorizationForm.Cash = userInfo.Cash; }
private void button1_Click(object sender, EventArgs e) { var col1 = _companyDataService.GetData().Take(100); _messageBoxService.ShowMessage( col1.First().GetHashCode().ToString() ); _messageBoxService.ShowMessage( col1.First().GetHashCode().ToString() ); var col2 = _companyDataService.GetData().Take(100).ToList(); _messageBoxService.ShowMessage( col2.First().GetHashCode().ToString() ); _messageBoxService.ShowMessage( col2.First().GetHashCode().ToString() ); _asyncService.PerformAsyncAction( () => { _data = _companyDataService.GetData().Take(100).ToList(); return(_data); }, data => dataGridView1.DataSource = data ); }
void Test() { string provider = "System.Data.SqlClient"; bool integratedSecurity = false; if (IntegratedSecuritySql) { integratedSecurity = false; } if (IntegratedSecurityWin) { integratedSecurity = true; } if (TestConnection2(provider, _databasename, _databasecatalog, _databaseuser, _databasepass, integratedSecurity)) { MessageBoxService.ShowMessage("Połaczenie Ustawione"); ZapiszConfig(); Zapisz(); } else { MessageBoxService.ShowMessage("Połaczenie nie powiodło się"); connectionString = String.Empty; } }
public string TranslateText(string text, string sourceLanguage, string targetLanguage) { try { var request = new RestRequest("/mt/translations/async", Method.POST) { RequestFormat = DataFormat.Json }; var traceId = GetTraceId(request); string[] texts = { text }; request.AddBody(new { input = texts, sourceLanguageId = sourceLanguage, targetLanguageId = targetLanguage, model = _flavor, inputFormat = "xliff" }); var response = _client.Execute(request); if (response.StatusCode == HttpStatusCode.Unauthorized && !string.IsNullOrEmpty(_authenticationMethod) && _authenticationMethod.Equals(Enums.GetDisplayName(Enums.LoginOptions.StudioAuthentication))) { // Get refresh token var token = _studioCredentials.EnsureValidConnection(); if (!string.IsNullOrEmpty(token)) { UpdateRequestHeadersForRefreshToken(request, token); var translationAsyncResponse = _client.Execute(request); if (translationAsyncResponse.StatusCode == HttpStatusCode.Unauthorized) { _messageBoxService.ShowMessage(Constants.UnauthorizedCredentials, Constants.PluginName); Log.Logger.Error($"{Constants.UnauthorizedToken} {traceId}"); } else if (!translationAsyncResponse.IsSuccessful && translationAsyncResponse.StatusCode != HttpStatusCode.Unauthorized) { ShowErrors(translationAsyncResponse); } return(ReturnTranslation(translationAsyncResponse)); } } else if (!response.IsSuccessful && response.StatusCode != HttpStatusCode.Unauthorized) { ShowErrors(response); } return(ReturnTranslation(response)); } catch (Exception e) { Log.Logger.Error($"{Constants.TranslateTextMethod} {e.Message}\n {e.StackTrace}"); } return(string.Empty); }
private async Task CheckForNewAppVersionAsync() { if (await _updateHelper.IsNewAppVersionAvailableAsync()) { IsUpdateAvailable = true; _messageBoxService.ShowMessage(Application.Current.MainWindow, _localizationHelper.GetLocalization("UpdatePreferencesNewAppUpdateAvailable") + Environment.NewLine + Environment.NewLine + "https://github.com/AnnoDesigner/anno-designer/releases/", _localizationHelper.GetLocalization("UpdatePreferencesUpdates")); } else { IsUpdateAvailable = false; } }
public View2(IMessageBoxService messageBoxService) { _messageBoxService = messageBoxService; InitializeComponent(); //button6.Click += (s, e) => // { // _messageBoxService.ShowMessage("trala"); // }; button6.Click += (s, e) => _messageBoxService.ShowMessage("trala"); //var lst = new List<Action>(); //for(int i=0;i<5;++i) //{ // //int d = i; // lst.Add( // () => _messageBoxService.ShowMessage(d.ToString()) // ); //} //lst.ForEach(e=>e()); //var lst = new List<_____Anonymous_lambdsa_type_XY>(); //for (int i = 0; i < 5; ++i) //{ // lst.Add( // new _____Anonymous_lambdsa_type_XY(ref i, _messageBoxService) // ); //} //lst.ForEach(e => e.Anonymous_function_XX()); }
public void AddRole(object button) { var info = GridPopupMenuBase.GetGridMenuInfo((DependencyObject)button) as GridMenuInfo; string roleName = string.Empty; var bulkEditStringsViewModel = BulkEditStringsViewModel.Create(roleName); if (AddRoleDialogService.ShowDialog(MessageButton.OKCancel, "Add new role", "BulkEditStrings", bulkEditStringsViewModel) == MessageResult.OK) { if (bulkEditStringsViewModel.EditValue != null) { roleName = (string)bulkEditStringsViewModel.EditValue; } ROLE newROLE = new ROLE() { NAME = roleName, SORTORDER = 0, PARENTGUID = Guid.Empty }; string errorMessage = string.Empty; if (ROLECollection.IsValidEntity(newROLE, ref errorMessage)) { ROLECollection.Save(newROLE); } else { MessageBoxService.ShowMessage(errorMessage + " already exists", "Error", MessageButton.OK, MessageIcon.Error); } } }
// Execute the default task sequence on the project. // When a template is created from a Single file project, task sequencies is null. private void ExecuteTaskSequence(FileBasedProject project, ProjectFile[] projectFiles, ProjectRequest request) { try { var taskSequence = project.RunDefaultTaskSequence(projectFiles.GetIds(), (sender, e) => { if (Requests != null) { OnProgressChanged(_currentProgress + (double)e.PercentComplete / Requests.Count); } }, (sender, e) => { OnMessageReported(project, e.Message); }); project.Save(); if (taskSequence.Status.Equals(TaskStatus.Completed)) { if (SuccessfulRequests != null) { SuccessfulRequests.Add(Tuple.Create(request, project)); OnMessageReported(project, $"Project {request.Name} created successfully."); } } else { OnMessageReported(project, $"Project {request.Name} creation failed."); } } catch (Exception ex) { _logger.Error($"ExecuteTaskSequence method: {ex.Message}\n {ex.StackTrace}"); _messageBoxService.ShowMessage(PluginResources.ProjectTemplateSequenceSelection_Message, string.Empty); } }
/// <summary> /// Creates new Scrum Team and initialize Planning Poker game. /// </summary> /// <param name="teamName">Name of the team.</param> /// <param name="scrumMasterName">Name of Scrum Master.</param> /// <returns><c>True</c> if the operation was successful; otherwise <c>false</c>.</returns> public async Task <bool> CreateTeam(string teamName, string scrumMasterName) { if (string.IsNullOrEmpty(teamName) || string.IsNullOrEmpty(scrumMasterName)) { return(false); } try { ScrumTeam team = null; using (_busyIndicatorService.Show()) { team = await _planningPokerService.CreateTeam(teamName, scrumMasterName, CancellationToken.None); } if (team != null) { await _planningPokerInitializer.InitializeTeam(team, scrumMasterName); ControllerHelper.OpenPlanningPokerPage(_uriHelper, team, scrumMasterName); return(true); } } catch (PlanningPokerException ex) { var message = ControllerHelper.GetErrorMessage(ex); await _messageBoxService.ShowMessage(message, Resources.MessagePanel_Error); } return(false); }
public void OpenInternal(string filename, bool newWindow) { MessageBoxService.SetOwner(Application.Current.MainWindow); if (newWindow) { Process.Start(Process.GetCurrentProcess().MainModule.FileName, filename); return; } CloseCommand.Execute(null); try { PEFile = new PEFile(_stm = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), false); PEHeader = PEFile.Header; if (PEHeader == null) { throw new InvalidOperationException("No PE header detected."); } FileName = Path.GetFileName(filename); PathName = filename; RaisePropertyChanged(nameof(Title)); MapFile(); BuildTree(); RecentFiles.Remove(PathName); RecentFiles.Insert(0, PathName); if (RecentFiles.Count > 10) { RecentFiles.RemoveAt(RecentFiles.Count - 1); } } catch (Exception ex) { MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName); } }
/// <summary> /// Joins existing Scrum Team and initialize Planning Poker game. /// </summary> /// <param name="teamName">Name of the team.</param> /// <param name="memberName">Name of the joining member.</param> /// <param name="asObserver"><c>True</c> if member is joining as observer only; otherwise <c>false</c>.</param> /// <returns><c>True</c> if the operation was successful; otherwise <c>false</c>.</returns> public async Task <bool> JoinTeam(string teamName, string memberName, bool asObserver) { if (string.IsNullOrEmpty(teamName) || string.IsNullOrEmpty(memberName)) { return(false); } try { ScrumTeam team = null; using (_busyIndicatorService.Show()) { team = await _planningPokerService.JoinTeam(teamName, memberName, asObserver, CancellationToken.None); } if (team != null) { await _planningPokerInitializer.InitializeTeam(team, memberName); ControllerHelper.OpenPlanningPokerPage(_uriHelper, team, memberName); return(true); } } catch (PlanningPokerException ex) { var message = ex.Message; if (message.IndexOf(MemberExistsError1, StringComparison.OrdinalIgnoreCase) >= 0 && message.IndexOf(MemberExistsError2, StringComparison.OrdinalIgnoreCase) >= 0) { message = ControllerHelper.GetErrorMessage(ex); message = $"{message}{Environment.NewLine}{Resources.JoinTeam_ReconnectMessage}"; if (await _messageBoxService.ShowMessage(message, Resources.JoinTeam_ReconnectTitle, Resources.JoinTeam_ReconnectButton)) { return(await ReconnectTeam(teamName, memberName, false, CancellationToken.None)); } } else { message = ControllerHelper.GetErrorMessage(ex); await _messageBoxService.ShowMessage(message, Resources.MessagePanel_Error); } } return(false); }
public static MessageResult ShowMessage(this IMessageBoxService service, string messageBoxText, string caption, MessageButton button) { #if !SILVERLIGHT return(service.ShowMessage(messageBoxText, caption, button, MessageIcon.None)); #else VerifyService(service); return(service.Show(messageBoxText, caption, button, MessageResult.None)); #endif }
public static void ShowMessage(this IMessageBoxService service, string message, string title = "Information") { if (service == null) { throw new ArgumentNullException(nameof(service)); } service.ShowMessage(null, message, title); }
/// <summary> /// Method to invoke when the RemoveBackupSet command is executed. /// </summary> private void OnRemoveBackupSetCollectionExecute() { //if (_messageService.Show(string.Format("Are you sure you want to delete the BackupSet '{0}'?", SelectedBackupSet), // "Are you sure?", MessageButton.YesNo, MessageImage.Question) == MessageResult.Yes) if (_messageBoxService.ShowMessage(string.Format("Are you sure you want to delete the BackupSet '{0}'?", SelectedBackupSet.Name), "Delete Backup Set", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { BackupSets.Remove(SelectedBackupSet); SelectedBackupSet = null; } }
public override void OnClosing(CancelEventArgs cancelEventArgs) { base.OnClosing(cancelEventArgs); if (!cancelEventArgs.Cancel) { if (State == AppState.Authorized && MessageService.ShowMessage("Do you really want to close the application?", "Confirm", MessageButton.YesNo) == MessageResult.No) { cancelEventArgs.Cancel = true; } } }
private void RegistrationForm_Register(object sender, EventArgs e) { try { model.AddUser(registrationForm.FirstName, registrationForm.SecondName, registrationForm.Email, registrationForm.Password); messageService.ShowMessage("Регистрация прошла успешно!"); } catch (EmptyParameterException ex) { registrationForm.IsSuccessful = false; messageService.ShowError(ex.Message); } catch (AlreadyExistsUserClientException ex) { registrationForm.IsSuccessful = false; messageService.ShowError(ex.Message); } }
public void NullService1() { IMessageBoxService service = null; Assert.Throws <ArgumentNullException>(() => { service.Show(""); }); Assert.Throws <ArgumentNullException>(() => { service.Show("", ""); }); Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel); }); Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel, MessageIcon.Warning); }); Assert.Throws <ArgumentNullException>(() => { service.ShowMessage(""); }); Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", ""); }); Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel); }); Assert.Throws <ArgumentNullException>(() => { service.ShowMessage("", "", MessageButton.OKCancel, MessageIcon.Warning); }); }
public void OnSelectedBoardItemChanged() { if (SelectedBoardItem != null) { if (SelectedBoardItem.IsUsed) { return; } if (CurrentRound >= RoundsCount) { messageBoxService.ShowMessage("Brak Shura!", ""); return; } SelectedBoardItem.IsSelected = true; CurrentTurn = Turn.Second; ++CurrentRound; if (!ColorBoardItemDictionary.Any()) { for (var i = 0; i < ColorsCount; ++i) { ColorBoardItemDictionary[i] = new List <BoardItem>(); } } SelectedBoardItem.IsUsed = true; var isSchur = new SchurSolverService().CheckSchur(ColorBoardItemDictionary, SelectedBoardItem); if (isSchur) { messageBoxService.ShowMessage("Shur!", ""); } else { CurrentTurn = Turn.First; } if (!isSchur && ColorBoardItemDictionary.Sum(p => p.Value.Count) == BoardSize) { messageBoxService.ShowMessage("Brak Shura!", ""); } } }
private void HandleIsPavedStreet() { if (!_appSettings.ShowPavedRoadsWarning) { _messageBoxService.ShowMessage(_localizationHelper.GetLocalization("PavedStreetToolTip"), _localizationHelper.GetLocalization("PavedStreetWarningTitle")); _appSettings.ShowPavedRoadsWarning = true; } if (!GetDistanceRange(IsPavedStreet, AnnoCanvasToUse.BuildingPresets.Buildings.FirstOrDefault(_ => _.Identifier == BuildingIdentifier))) { logger.Trace("$Calculate Paved Street/Dirt Street Error: Can not obtain new Distance Value, value set to 0"); } else { //I like to have here a isObjectOnMouse routine, to check of the command 'ApplyCurrentObject();' must be excecuted or not: //Check of Mouse has an object or not -> if mouse has Object then Renew Object, withouth placnig. (do ApplyCurrentObject();) } }
protected override async void Execute() { _messageBoxService = new MessageBoxService(); Utils.EnsureApplicationResources(); var pathToTempFolder = CreateTempPackageFolder(); try { var fileDialog = new OpenFileDialog { Filter = @"Transit Project Package Files (*.ppf)|*.ppf" }; var dialogResult = fileDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { var path = fileDialog.FileName; var packageService = new PackageService(); var package = await packageService.OpenPackage(path, pathToTempFolder); var templateService = new TemplateService(); var templateList = templateService.LoadProjectTemplates(); var packageModel = new PackageModel { Name = package.Name, Description = package.Description, StudioTemplates = templateList, LanguagePairs = package.LanguagePairs, PathToPrjFile = package.PathToPrjFile }; // Start BackgroundWorder in InitializeMain method to have app working separately than Trados Studio process Program.InitializeMain(packageModel); } } catch (PathTooLongException ptle) { _messageBoxService.ShowMessage(ptle.Message, string.Empty); Log.Logger.Error($"OpenPackage method: {ptle.Message}\n {ptle.StackTrace}"); } }
private void OpenInternal(string filename) { CloseCommand.Execute(null); try { PEFile = new PEFile(_stm = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read), false); PEHeader = PEFile.Header; FileName = Path.GetFileName(filename); PathName = filename; OnPropertyChanged(nameof(Title)); MapFile(); BuildTree(); RecentFiles.Remove(PathName); RecentFiles.Insert(0, PathName); if (RecentFiles.Count > 10) { RecentFiles.RemoveAt(RecentFiles.Count - 1); } } catch (Exception ex) { MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName); } }
public bool QueryCloseAll() { if (!OpenFiles.Any(file => file.IsModified)) { return(true); } var result = MessageBoxService.ShowMessage("Save modified files before exit?", Constants.AppTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { foreach (var file in OpenFiles) { if (file.IsModified) { file.SaveInternal(); } } return(true); } return(result == MessageBoxResult.No); }
public void NullService14() { IMessageBoxService service = null; service.ShowMessage("", "", MessageButton.OKCancel, MessageIcon.Warning); }
public void NullService13() { IMessageBoxService service = null; service.ShowMessage("", "", MessageButton.OKCancel); }
public void NullService12() { IMessageBoxService service = null; service.ShowMessage("", ""); }
public async Task Cancel(object o) { var order = (OrderViewModel)o; using (var client = new BinanceClient()) { var result = await client.Spot.Order.CancelOrderAsync(SelectedSymbol.Symbol, order.Id); if (result.Success) { messageBoxService.ShowMessage("Order canceled!", "Sucess", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); } else { messageBoxService.ShowMessage($"Order canceling failed: {result.Error.Message}", "Failed", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } } }
public void ExecuteTileClickedCommand(object parameter) { messageBoxService.ShowMessage(string.Format("you clicked {0}", this.Text)); }
public override void Delete() { IMessageBoxService messageBoxService = citiesMapViewModel.GetRequiredService <IMessageBoxService>(); messageBoxService.ShowMessage("To ensure data integrity, the Customers module doesn't allow records to be deleted. Record deletion is supported by the Employees module.", "Delete Customer", MessageButton.OK); }