private async void OnUploadClicked(object sender, EventArgs e) { Sensitive = false; bool success; try { await _upload(_buttonSelect.Filename, _toggleSlim.Active); success = true; } catch (ErrorAnswerException answerException) { Msg.Error(this, Tr._("Failed to upload skin!"), answerException.Message); success = false; } catch { Msg.Error(this, Tr._("Failed to upload skin!")); success = false; } Sensitive = true; if (!success) { return; } Hide(); Destroy(); }
public static void Error(Window parent, string message, string details = null) { var dialog = new MessageDialog(parent, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, message) { Title = Tr._("Error"), SecondaryText = details }; dialog.Run(); dialog.Destroy(); }
private void OnSaveClicked(object sender, EventArgs e) { var index = _comboPrefixes.Active; if (index < 0 || index >= _prefixes.Length) { Msg.Error(this, Tr._("Incorrect profile version!")); return; } var profileId = _entryName.Text; var profileData = new ProfileData { FullVersion = new FullVersionId(_prefixes[index].Id, _comboVersions.ActiveText), CheckVersionFiles = _toggleCheckVersion.Active, UseCustomJavaPath = _toggleJavaPath.Active, CustomJavaPath = _buttonJavaPath.Filename, UseCustomJavaArgs = _toggleJavaArgs.Active, CustomJavaArgs = _entryJavaArgs.Text }; _buttonSave.Sensitive = false; var success = false; try { _doSave(profileId, profileData); success = true; } catch (InvalidProfileNameException) { Msg.Error(this, Tr._("Incorrect profile name!")); } catch (InvalidProfileVersionException) { Msg.Error(this, Tr._("Incorrect game version!")); } catch { Msg.Error(this, Tr._("Failed to save profile! See details in the log.")); } _buttonSave.Sensitive = true; if (success) { Hide(); Destroy(); } }
public LauncherAppGtk(string appId) { _appId = appId; Tr.InitCatalog("ui-gtk", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Translations")); Application.Init(); GLib.ExceptionManager.UnhandledException += args => { var msg = (args.ExceptionObject as Exception)?.Message ?? "UNKNOWN_ERROR"; var dialog = new MessageDialog(_ui, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, msg); dialog.Title = $"Unhandled Exception ({args.ExceptionObject.GetType()})"; dialog.SecondaryText = (args.ExceptionObject as Exception)?.StackTrace ?? "UNKNOWN_STACK"; dialog.Run(); dialog.Destroy(); Application.Quit(); }; }