private async void UploadScreenshot_Click(object sender, EventArgs e) { btnUpload.Text = L18n.Get("OtherHelper", "Text_cancel"); btnUpload.Click -= UploadScreenshot_Click; btnUpload.Click += UploadScreenshotCanceled; txbLink.Text = ""; txbLink.Enabled = false; try { var filename = Path.GetFileName(label.Text); txbLink.Text = await Screenshot.UploadScreenshot(label.Text); MediaHistoryManager.AddLinkToEntry(filename, txbLink.Text, MediaHistoryManager.MediaType.Screenshot); label.Text = L18n.Get("OtherHelper", "Text_uploaded"); label.ForeColor = Color.Green; txbLink.Enabled = true; btnUpload.Enabled = false; } catch (OperationCanceledException) { } finally { btnUpload.Click -= UploadScreenshotCanceled; btnUpload.Click += UploadScreenshot_Click; btnUpload.Text = L18n.Get("OtherHelper", "Text_upload"); } }
public MediaHistory() { InitializeComponent(); this.Text = L18n.Get("MediaHistory", "MediaHistory_name"); TableLayoutPanel Wrapper = new TableLayoutPanel(); Wrapper.AutoScroll = true; Wrapper.AutoSize = true; Wrapper.Dock = DockStyle.Top; Wrapper.Controls.Clear(); Wrapper.RowCount = 0; Wrapper.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; Wrapper.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); PanelWrapper.Controls.Add(Wrapper); AddEntries(Wrapper, MediaHistoryManager.GetHistoryFromFile()); self = this; }
public void UploadVideoCompleted(string id, string filename) { if (InvokeRequired) { this.Invoke(new UploadVideoCompletedDelegate(UploadVideoCompleted), new object[] { id, filename }); return; } try { wrapper.Controls.Remove(bar); wrapper.Controls.Remove(txbLink); } catch (Exception) { } label.Text = L18n.Get("OtherHelper", "Text_uploaded"); label.ForeColor = Color.Green; txbLink.Text = $@"https://youtu.be/{id}"; MediaHistoryManager.AddLinkToEntry(filename, txbLink.Text, MediaHistoryManager.MediaType.Video); txbLink.Enabled = true; wrapper.Controls.Add(txbLink, 0, 2); btnUpload.Enabled = false; }
public static async Task Save(Bitmap img, string prefix) { ImageFormat format; ImageCodecInfo encoder; EncoderParameters encParams; DateTime now = DateTime.Now; string name = $"{prefix}{now.ToString().Replace(" ", "_").Replace(".", "_").Replace(":", "_")}.{SettingsManager.screenshots_format}"; string path = Path.Combine(SettingsManager.screenshots_path, name); if (SettingsManager.screenshots_format == "jpg" || SettingsManager.screenshots_format == "jpeg") { format = ImageFormat.Jpeg; encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid); encParams = new EncoderParameters() { Param = new[] { new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 90L) } }; } else { format = ImageFormat.Png; encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Png.Guid); encParams = new EncoderParameters() { Param = new[] { new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L) } }; } string link = string.Empty; img.Save(path, encoder, encParams); if (SettingsManager.screenshots_upload) { link = await UploadScreenshot(img); Clipboard.SetText(link); MainWindow.TrayApp.ShowBalloonTip(2000, "TankiTools", $"{L18n.Get("TrayApp", "Balloon_screenshot1")} {link}\n{L18n.Get("TrayApp", "Balloon_screenshot2")}", ToolTipIcon.None); } MediaHistoryManager.SaveEntryToHistory(new MediaHistoryManager.HistoryEntry( MediaHistoryManager.MediaType.Screenshot, link, name, now)); }
public void Save() { MediaHistoryManager.SaveEntryToHistory(new MediaHistoryManager.HistoryEntry( MediaHistoryManager.MediaType.Video, string.Empty, name, now)); }