private void ForwardImageToPlugin(Image image) { if (image == null) return; if (!Settings.Instance.WithoutEditor) { using (EditorForm editor = new EditorForm(image, Thread.CurrentThread.CurrentUICulture)) { if (editor.ShowDialog() == DialogResult.OK) { image = editor.GetImage(); SettingsManager.Save(); } else { image.Dispose(); SettingsManager.Save(); return; } } } NotificationForm notificationForm = null; if (settings.Notification == NotificationType.Tooltip) { tray.BalloonTipIcon = ToolTipIcon.Info; tray.BalloonTipTitle = String.Format("Fireball: {0}", activePlugin.Name); tray.BalloonTipText = "Uploading..."; tray.ShowBalloonTip(1000); } else if (settings.Notification == NotificationType.Window) { notificationForm = new NotificationForm(String.Format("Fireball: {0}", activePlugin.Name)); notificationForm.Show(); } string url = string.Empty; var uploadTask = new Task(() => { isUploading = true; try { url = activePlugin.Upload(image); image.Dispose(); } catch { } isUploading = false; if (url.StartsWith("http://")) Settings.Instance.MRUList.Enqueue(url); }); uploadTask.ContinueWith(arg => { try { if (settings.Notification == NotificationType.Tooltip) { // Скопировать в буфер и показать тултип Clipboard.SetDataObject(url, true, 5, 500); // ======= твик ======= // прячем предыдущий тултип, если он сам не скрылся tray.Visible = false; tray.Visible = true; // ==================== tray.BalloonTipIcon = ToolTipIcon.Info; tray.BalloonTipTitle = String.Format("Fireball: {0}", activePlugin.Name); tray.BalloonTipText = String.IsNullOrEmpty(url) ? "empty" : url; tray.ShowBalloonTip(1000); } else if (settings.Notification == NotificationType.Window) { // Вывести ссылку в форму уведомления if (notificationForm != null) notificationForm.SetUrl(url); } else { // Тихо копировать в буфер обмена Clipboard.SetDataObject(url, true, 5, 500); } } catch { } }, TaskScheduler.FromCurrentSynchronizationContext()); uploadTask.Start(); }
private void ForwardImageToPlugin(Image image) { if (image == null) { return; } if (!Settings.Instance.WithoutEditor) { using (EditorForm editor = new EditorForm(image, Thread.CurrentThread.CurrentUICulture)) { if (editor.ShowDialog() == DialogResult.OK) { image = editor.GetImage(); SettingsManager.Save(); } else { image.Dispose(); SettingsManager.Save(); return; } } } NotificationForm notificationForm = null; if (settings.Notification == NotificationType.Tooltip) { tray.BalloonTipIcon = ToolTipIcon.Info; tray.BalloonTipTitle = String.Format("Fireball: {0}", activePlugin.Name); tray.BalloonTipText = "Uploading..."; tray.ShowBalloonTip(1000); } else if (settings.Notification == NotificationType.Window) { notificationForm = new NotificationForm(String.Format("Fireball: {0}", activePlugin.Name)); notificationForm.Show(); } string url = string.Empty; var uploadTask = new Task(() => { isUploading = true; try { url = activePlugin.Upload(image); image.Dispose(); } catch { } isUploading = false; if (url.StartsWith("http://")) { Settings.Instance.MRUList.Enqueue(url); } }); uploadTask.ContinueWith(arg => { try { if (settings.Notification == NotificationType.Tooltip) { // Скопировать в буфер и показать тултип Clipboard.SetDataObject(url, true, 5, 500); // ======= твик ======= // прячем предыдущий тултип, если он сам не скрылся tray.Visible = false; tray.Visible = true; // ==================== tray.BalloonTipIcon = ToolTipIcon.Info; tray.BalloonTipTitle = String.Format("Fireball: {0}", activePlugin.Name); tray.BalloonTipText = String.IsNullOrEmpty(url) ? "empty" : url; tray.ShowBalloonTip(1000); } else if (settings.Notification == NotificationType.Window) { // Вывести ссылку в форму уведомления if (notificationForm != null) { notificationForm.SetUrl(url); } } else { // Тихо копировать в буфер обмена Clipboard.SetDataObject(url, true, 5, 500); } } catch { } }, TaskScheduler.FromCurrentSynchronizationContext()); uploadTask.Start(); }