void Instance_DownloadEnded(object sender, DownloaderEventArgs e) { UpdateList(); // close download progress dialog HideProgressDialog(e.Downloader); // check if should show finish dialog if (e.Downloader.State != DownloaderState.EndedWithError) { if (MonoDM.App.Settings.Default.ShowFinishedDialog) { using (DownloadFinishedDialog dlg = new DownloadFinishedDialog()) { dlg.Url = e.Downloader.ResourceLocation.URL; dlg.SaveTo = e.Downloader.LocalFile; dlg.Downloader = e.Downloader; dlg.RefreshUI(); dlg.Run(); } } } else { GtkUtils.ShowMessageBox(null, "Error downloading " + System.IO.Path.GetFileName(e.Downloader.LocalFile) + "\n" + e.Downloader.LastError?.Message, MessageType.Error); } Log( e.Downloader, String.Format( "Download ended {0}", e.Downloader.ResourceLocation.URL), LogMode.Information); }
private void LoadToolbarIcons(bool defaultUseIdmIcons) { if (defaultUseIdmIcons) { foreach (var c in MainToolbar.Children) { ToolButton item = (ToolButton)c; if (item != null) { //if (item.IconWidget is Image iconWidget) //{ item.IconWidget = new Gtk.Image(GtkUtils.GetIdmToolbarIcon((string)item.Data["iconKey"])); //iconWidget.Pixbuf = GtkUtils.GetIdmToolbarIcon((string)item.Data["iconKey"]); //} } } } else { foreach (var c in MainToolbar.Children) { ToolButton item = (ToolButton)c; if (item != null) { //if (item.IconWidget is Image iconWidget) //{ item.IconWidget = new Gtk.Image(GtkUtils.GetGtkToolbarIcon(this, (string)item.Data["iconKey"])); //} } } } MainToolbar.ShowAll(); }
private MessageDialog CreateMessageDialog(MessageDialogType type, string caption, string text, ButtonsType buttons) { var messageType = type switch { MessageDialogType.Error => MessageType.Error, MessageDialogType.Warning => MessageType.Warning, MessageDialogType.Information => MessageType.Info, MessageDialogType.Question => MessageType.Question, _ => MessageType.Other }; return(GtkUtils.CreateMessageDialog(window, messageType, caption, text, buttons)); }
public void HandleException(string caption, string message, bool canIgnore, Exception e) { App.Logger.Error(e.ToString()); Window?window = WindowManager.MainWindow; bool isWindowOwned = false; if (window == null) { window = WindowManager.CreateWindow(Lib.BrandName); isWindowOwned = true; } if (Thread.CurrentThread.ManagedThreadId == originalThread) { DoShow(); } else { Gtk.Application.Invoke((_, _) => DoShow()); } void DoShow() { using var dialog = GtkUtils.CreateMessageDialog(window, MessageType.Error, caption, message, ButtonsType.None); dialog.AddButton("Exit", ResponseType.Close); if (canIgnore) { dialog.AddButton("Ignore", ResponseType.Ok); } ResponseType response = (ResponseType)dialog.Run(); dialog.Hide(); if (isWindowOwned) { window.Dispose(); } if (response == ResponseType.Close) { try { Process.GetCurrentProcess().Kill(); } catch { Environment.FailFast(message, e); } } } }
public void SaveChanges() { if (!ResourceLocation.IsURL(_txtUrl.Text)) { GtkUtils.ShowMessageBox(null, "Invalid URL.", MessageType.Error); return; } if (!_downloader.IsWorking()) { _downloader.ResourceLocation.URL = _txtUrl.Text; _downloader.ResourceLocation.Authenticate = _cbAuth.Active; _downloader.ResourceLocation.Login = _txtUser.Text; _downloader.ResourceLocation.Password = _txtPassword.Text; } if (_txtDest.Text != _downloader.LocalFile) { _downloader.MoveTo(_txtDest.Text); } }
public void OpenFile(string title, bool multiple, List <FileDialogFilter> filters, Action <string[]> onAccepted, Action onCancelled) { Application.Invoke(delegate { using FileChooserDialog dialog = new FileChooserDialog(title, window, FileChooserAction.Open); dialog.SelectMultiple = multiple; dialog.AddButton(Stock.Cancel, ResponseType.Cancel); dialog.AddButton(Stock.Save, ResponseType.Accept); foreach (var filter in filters) { dialog.AddFilter(GtkUtils.CreateFileFilter(filter)); } if (dialog.Run() == (int)ResponseType.Accept) { onAccepted(dialog.Filenames); } else { onCancelled(); } });
public void SaveFile(SaveFileDialogSettings settings, Action <string> onAccepted) { Gtk.Application.Invoke(delegate { using FileChooserDialog dialog = new FileChooserDialog(settings.DialogTitle, WindowManager.MainWindow, FileChooserAction.Save); dialog.AddButton(Stock.Cancel, ResponseType.Cancel); dialog.AddButton(Stock.Save, ResponseType.Accept); dialog.DoOverwriteConfirmation = settings.OverwritePrompt; dialog.CurrentName = settings.FileName; if (settings.Filters is {} filters) { foreach (var filter in filters) { dialog.AddFilter(GtkUtils.CreateFileFilter(filter)); } } if (dialog.Run() == (int)ResponseType.Accept) { onAccepted.Invoke(dialog.Filename); } });
private void btnOk_Click(object o, ResponseArgs args) { if (args.ResponseId != ResponseType.Ok) { Destroy(); return; } try { rl = new ResourceLocation(); rl.URL = Url.ToString(); rl.Authenticate = HasAuth; if (HasAuth) { rl.Login = Username; rl.Password = Password; } rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { GtkUtils.ShowMessageBox(null, "Invalid URL format, please check the location field.", MessageType.Error); rl = null; return; } Destroy(); } catch (Exception) { rl = null; GtkUtils.ShowMessageBox(null, "Not recognized URL type.", MessageType.Error); Destroy(); } }