private void Window_Loaded(object sender, RoutedEventArgs e) { #region Validation if (Global.UpdateModel == null) { WhatsNewParagraph.Inlines.Add("Something wrong happened."); return; } #endregion try { //Detect if this is portable or installed. Download the proper file. IsChocolatey = AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"Chocolatey\lib\screentogif\content\"); IsInstaller = Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory).Any(x => x.ToLowerInvariant().EndsWith("screentogif.visualelementsmanifest.xml")); VersionRun.Text = "Version " + Global.UpdateModel.Version; SizeRun.Text = Humanizer.BytesToString(IsInstaller ? Global.UpdateModel.InstallerSize : Global.UpdateModel.PortableSize); TypeRun.Text = IsInstaller ? LocalizationHelper.Get("Update.Installer") : LocalizationHelper.Get("Update.Portable"); var splited = Global.UpdateModel.Description.Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); WhatsNewParagraph.Inlines.Add(splited[0].Replace(" What's new?\r\n\r\n", "")); FixesParagraph.Inlines.Add(splited.Length > 1 ? splited[1].Replace(" Bug fixes:\r\n\r\n", "") : "Aparently nothing."); } catch (Exception ex) { LogWriter.Log(ex, "Loading download informations"); WhatsNewParagraph.Inlines.Add("Something wrong happened."); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { #region Validation if (Element == null) { WhatsNewParagraph.Inlines.Add("Something wrong happened."); return; } #endregion try { VersionRun.Text = "Version " + Element.XPathSelectElement("tag_name").Value; SizeRun.Text = Humanizer.BytesToString(Convert.ToInt32(Element.XPathSelectElement("assets").FirstNode.XPathSelectElement("size").Value)); var body = Element.XPathSelectElement("body").Value; var splited = body.Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); WhatsNewParagraph.Inlines.Add(splited[0].Replace(" What's new?\r\n\r\n", "")); FixesParagraph.Inlines.Add(splited[1].Replace(" Bug fixes:\r\n\r\n", "")); } catch (Exception ex) { LogWriter.Log(ex, "Loading download informations"); WhatsNewParagraph.Inlines.Add("Something wrong happened."); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is not long length) { return(DependencyProperty.UnsetValue); } return(Humanizer.BytesToString(length)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var lenght = value as long?; if (!lenght.HasValue) { return(DependencyProperty.UnsetValue); } return(Humanizer.BytesToString(lenght.Value)); }
private string BuildBody(string title, string message, string email, bool issue, bool suggestion) { var sb = new StringBuilder(); sb.Append("<html xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">"); sb.Append("<head><meta content=\"en-us\" http-equiv=\"Content-Language\" />" + "<meta content=\"text/html; charset=utf-16\" http-equiv=\"Content-Type\" />" + "<title>Screen To Gif - Feedback</title>" + "</head>"); sb.AppendFormat("<style>{0}</style>", Util.Other.GetTextResource("ScreenToGif.Resources.Style.css")); sb.Append("<body>"); sb.AppendFormat("<h1>{0}</h1>", title); sb.Append("<div id=\"content\"><div>"); sb.Append("<h2>Overview</h2>"); sb.Append("<div id=\"overview\"><table><tr>"); sb.Append("<th>User</th>"); if (email.Length > 0) { sb.Append("<th>Mail</th>"); } sb.Append("<th>Version</th>"); sb.Append("<th>Windows</th>"); sb.Append("<th>Instruction Size</th>"); sb.Append("<th>Working Memory</th>"); sb.Append("<th>Issue?</th>"); sb.Append("<th>Suggestion?</th></tr>"); sb.AppendFormat("<tr><td class=\"textcentered\">{0}</td>", Environment.UserName); if (email.Length > 0) { sb.AppendFormat("<td class=\"textcentered\">{0}</td>", email); } sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Assembly.GetExecutingAssembly().GetName().Version.ToString(4)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.OSVersion.Version); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.Is64BitOperatingSystem ? "64 bits" : "32 Bits"); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(Environment.WorkingSet)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", issue ? "Yes" : "No"); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr></table></div></div>", suggestion ? "Yes" : "No"); sb.Append("<h2>Details</h2><div><div><table>"); sb.Append("<tr id=\"ProjectNameHeaderRow\"><th class=\"messageHeader\">Message</th></tr>"); sb.Append("<tr name=\"MessageRowClassProjectName\">"); sb.AppendFormat("<td class=\"messageCell\">{0}</td></tr></table>", message); sb.Append("</div></div></div></body></html>"); return(sb.ToString()); }
private void Window_Loaded(object sender, RoutedEventArgs e) { #region Validation if (Element == null) { WhatsNewParagraph.Inlines.Add("Something wrong happened."); return; } #endregion try { //Detect if this is portable or installed. Download the proper file. IsChocolatey = AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"Chocolatey\lib\screentogif\content\"); IsInstaller = Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory).Any(x => x.EndsWith("ScreenToGif.visualelementsmanifest.xml")); VersionRun.Text = "Version " + Element.XPathSelectElement("tag_name").Value; SizeRun.Text = Humanizer.BytesToString(Convert.ToInt32((IsInstaller ? Element.XPathSelectElement("assets").LastNode : Element.XPathSelectElement("assets").FirstNode).XPathSelectElement("size").Value)); TypeRun.Text = IsInstaller ? this.TextResource("Update.Installer") : this.TextResource("Update.Portable"); var body = Element.XPathSelectElement("body").Value; var splited = body.Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); WhatsNewParagraph.Inlines.Add(splited[0].Replace(" What's new?\r\n\r\n", "")); FixesParagraph.Inlines.Add(splited.Length > 1 ? splited[1].Replace(" Bug fixes:\r\n\r\n", "") : "Aparently, nothing."); } catch (Exception ex) { LogWriter.Log(ex, "Loading download informations"); WhatsNewParagraph.Inlines.Add("Something wrong happened."); } }
private string BuildBody(string title, string message, string email, bool issue, bool suggestion) { var sb = new StringBuilder(); sb.Append("<html xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">"); sb.Append("<head><meta content=\"en-us\" http-equiv=\"Content-Language\" />" + "<meta content=\"text/html; charset=utf-16\" http-equiv=\"Content-Type\" />" + "<title>ScreenToGif - Feedback</title>" + "</head>"); sb.AppendFormat("<style>{0}</style>", Util.Other.GetTextResource("ScreenToGif.Resources.Style.css")); sb.Append("<body>"); sb.AppendFormat("<h1>{0}</h1>", (title ?? "").Length > 0 ? title : "Title of the feedback"); sb.Append("<div id=\"content\"><div>"); sb.Append("<h2>Overview</h2>"); sb.Append("<div id=\"overview\"><table>"); //First overview row. sb.Append("<tr><th>User</th>"); sb.Append("<th>Machine</th>"); sb.Append("<th>Startup</th>"); sb.Append("<th>Date</th>"); sb.Append("<th>Running</th>"); sb.Append("<th>Version</th></tr>"); var culture = new CultureInfo("pt-BR"); sb.AppendFormat("<tr><td class=\"textcentered\">{0}</td>", Environment.UserName); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.MachineName); sb.AppendFormat(culture, "<td class=\"textcentered\">{0:g}</td>", Global.StartupDateTime); sb.AppendFormat(culture, "<td class=\"textcentered\">{0:g}</td>", DateTime.Now); sb.AppendFormat(culture, "<td class=\"textcentered\">{0:d':'hh':'mm':'ss}</td>", Global.StartupDateTime != DateTime.MinValue ? DateTime.Now - Global.StartupDateTime : TimeSpan.Zero); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", Assembly.GetExecutingAssembly().GetName().Version.ToString(4)); //Second overview row. sb.Append("<tr><th colspan=\"2\">Windows</th>"); sb.Append("<th>Architecture</th>"); sb.Append("<th>Used</th>"); sb.Append("<th>Available</th>"); sb.Append("<th>Total</th></tr>"); var status = new Util.Native.MemoryStatusEx(true); Util.Native.GlobalMemoryStatusEx(ref status); sb.AppendFormat("<td class=\"textcentered\" colspan=\"2\">{0}</td>", Environment.OSVersion.Version); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.Is64BitOperatingSystem ? "64 bits" : "32 Bits"); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(Environment.WorkingSet)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(status.AvailablePhysicalMemory)); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", Humanizer.BytesToString(status.TotalPhysicalMemory)); //Third overview row. sb.Append("<tr><th colspan=\"3\">E-mail</th>"); sb.Append("<th>.Net version</th>"); sb.Append("<th>Issue?</th>"); sb.Append("<th>Suggestion?</th></tr>"); sb.AppendFormat("<td colspan=\"3\" class=\"textcentered\">{0}</td>", (email ?? "").Length > 0 ? email : "*****@*****.**"); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", FrameworkHelper.QueryFrameworkVersion()); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", issue ? "Yes" : "No"); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr></table></div></div>", suggestion ? "Yes" : "No"); //Processors. sb.Append("<br><h2>Processors</h2><table>"); sb.Append(GetProcessor()); sb.Append(GetGraphicsAdapter()); sb.Append("</table>"); //System.Windows.Forms.SystemInformation.PowerStatus.BatteryChargeStatus == System.Windows.Forms.BatteryChargeStatus.NoSystemBattery //Monitors. sb.Append("<br><h2>Monitors</h2><table>"); sb.Append("<tr><th>Name</th>"); sb.Append("<th>Bounds</th>"); sb.Append("<th>Working area</th>"); sb.Append("<th>DPI/Scale</th>"); sb.Append("<th>Graphics adapter</th>"); sb.Append("<th>Primary?</th></tr>"); foreach (var monitor in Monitor.AllMonitors) { sb.AppendFormat("<td class=\"textcentered\">{0} ({1})</td>", monitor.FriendlyName, monitor.Name); sb.AppendFormat("<td class=\"textcentered\">{0}:{1} • {2}x{3}</td>", monitor.Bounds.Left, monitor.Bounds.Top, monitor.Bounds.Width, monitor.Bounds.Height); sb.AppendFormat("<td class=\"textcentered\">{0}:{1} • {2}x{3}</td>", monitor.WorkingArea.Left, monitor.WorkingArea.Top, monitor.WorkingArea.Width, monitor.WorkingArea.Height); sb.AppendFormat("<td class=\"textcentered\">{0}dpi / {1:#00}%</td>", monitor.Dpi, monitor.Dpi / 96d * 100d); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", monitor.AdapterName); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", monitor.IsPrimary ? "Yes" : "No"); } sb.Append("</table>"); if (Monitor.AllMonitors.Count > 0) { sb.AppendFormat(""); //sb.Append("<svg>" + // "<circle cx=\"40\" cy=\"40\" r=\"24\" style=\"stroke:#006600; fill:#00cc00\"/>" + // "<rect id=\"box\" x=\"0\" y=\"0\" width=\"50\" height=\"50\" style=\"stroke:#006600; fill:#00cc00\"/>" + // "</svg>"); } //Drives. sb.Append("<br><h2>Drives</h2><table>"); sb.Append("<tr><th>Root</th>"); sb.Append("<th>Used</th>"); sb.Append("<th>Free</th>"); sb.Append("<th>Total</th>"); sb.Append("<th>Format</th>"); sb.Append("<th>Type</th>"); sb.Append("<th>Ready?</th></tr>"); foreach (var drive in DriveInfo.GetDrives()) { #region Try get the size var total = 0L; var available = 0L; var format = ""; try { total = drive.TotalSize; available = drive.AvailableFreeSpace; format = drive.DriveFormat; } catch (Exception e) { //LogWriter.Log(e, "Not possible to get driver details"); } #endregion var used = total - available; var usedPerc = Math.Round(Util.Other.CrossMultiplication(total, used, null), 1); var avaiPerc = Math.Round(Util.Other.CrossMultiplication(total, available, null), 1); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", drive.Name); sb.AppendFormat("<td class=\"textRight\">({0} %) {1}</td>", usedPerc, Humanizer.BytesToString(used, "N1")); sb.AppendFormat("<td class=\"textRight\">({0} %) {1}</td>", avaiPerc, Humanizer.BytesToString(available, "N1")); sb.AppendFormat("<td class=\"textRight\">{0}</td>", Humanizer.BytesToString(total, "N1")); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", format); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", drive.DriveType); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", drive.IsReady ? "Yes" : "No"); } sb.Append("<table>"); //Details. sb.Append("<br><h2>Details</h2><div><div><table>"); sb.Append("<tr id=\"ProjectNameHeaderRow\"><th class=\"messageHeader\">Message</th></tr>"); sb.Append("<tr name=\"MessageRowClassProjectName\">"); sb.AppendFormat("<td class=\"messageCell\">{0}</td></tr></table>", message.Replace(Environment.NewLine, "<br>")); sb.Append("</div></div></div></body></html>"); return(sb.ToString()); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { #region Validation if (Global.UpdateAvailable == null) { WhatsNewParagraph.Inlines.Add("Something wrong happened. No update was found."); return; } if (Global.UpdateAvailable.MustDownloadManually) { StatusBand.Warning(LocalizationHelper.Get("S.Updater.NoNewRelease.Info")); } #endregion try { //Detect if this is portable or installed. Download the proper file. IsChocolatey = AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"Chocolatey\lib\screentogif\content\"); IsInstaller = Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory).Any(x => x.ToLowerInvariant().EndsWith("screentogif.visualelementsmanifest.xml")); VersionRun.Text = $"{LocalizationHelper.Get("S.Updater.Version")} {Global.UpdateAvailable.Version}"; SizeRun.Text = !UserSettings.All.PortableUpdate ? (Global.UpdateAvailable.InstallerSize > 0 ? Humanizer.BytesToString(Global.UpdateAvailable.InstallerSize) : "") : (Global.UpdateAvailable.PortableSize > 0 ? Humanizer.BytesToString(Global.UpdateAvailable.PortableSize) : ""); TypeRun.Text = IsInstaller ? LocalizationHelper.Get("S.Updater.Installer") : LocalizationHelper.Get("S.Updater.Portable"); //Details. if (Global.UpdateAvailable.IsFromGithub) { //From Github, the description is available. var splited = Global.UpdateAvailable.Description.Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); WhatsNewParagraph.Inlines.Add(splited[0].Replace(" What's new?\r\n\r\n", "")); FixesParagraph.Inlines.Add(splited.Length > 1 ? splited[1].Replace(" Bug fixes:\r\n\r\n", "").Replace(" Fixed:\r\n\r\n", "") : "Aparently nothing."); } else { //If the release detail was obtained by querying Fosshub, no release note is available. MainFlowDocument.Blocks.Remove(WhatsNewParagraphTitle); MainFlowDocument.Blocks.Remove(FixesParagraphTitle); MainFlowDocument.Blocks.Remove(FixesParagraph); var run = new Run(); run.SetResourceReference(Run.TextProperty, "S.Updater.Info.NewVersionAvailable"); WhatsNewParagraph.Inlines.Add(run); } DocumentViewer.UpdateLayout(); //If set to force the download the portable version of the app, check if it was downloaded. if (UserSettings.All.PortableUpdate) { //If the update was already downloaded. if (File.Exists(Global.UpdateAvailable.PortablePath)) { //If it's still downloading, wait for it to finish before displaying "Open". if (Global.UpdateAvailable.IsDownloading) { Global.UpdateAvailable.TaskCompletionSource = new TaskCompletionSource <bool>(); await Global.UpdateAvailable.TaskCompletionSource.Task; if (!IsLoaded) { return; } } DownloadButton.SetResourceReference(ExtendedButton.TextProperty, "S.Updater.InstallManually"); } return; } //If set to download automatically, check if the installer was downloaded. if (UserSettings.All.InstallUpdates) { //If the update was already downloaded. if (File.Exists(Global.UpdateAvailable.InstallerPath)) { //If it's still downloading, wait for it to finish before displaying "Install". if (Global.UpdateAvailable.IsDownloading) { Global.UpdateAvailable.TaskCompletionSource = new TaskCompletionSource <bool>(); await Global.UpdateAvailable.TaskCompletionSource.Task; if (!IsLoaded) { return; } } DownloadButton.SetResourceReference(ExtendedButton.TextProperty, "S.Updater.Install"); //When the update was prompted manually, the user can set the installer to run the app afterwards. if (WasPromptedManually) { RunAfterwardsCheckBox.Visibility = Visibility.Visible; RunAfterwardsCheckBox.IsChecked = true; } } } } catch (Exception ex) { LogWriter.Log(ex, "Impossible to load the download details"); StatusBand.Error(LocalizationHelper.Get("S.Updater.Warning.Show")); } finally { Height = ActualHeight; SizeToContent = SizeToContent.Width; Width = ActualWidth; SizeToContent = SizeToContent.Manual; MaxHeight = double.PositiveInfinity; MaxWidth = double.PositiveInfinity; CenterOnScreen(); } }
private void SendButton_Click(object sender, RoutedEventArgs e) { StatusBand.Hide(); #region Validation if (TitleTextBox.Text.Length == 0) { StatusBand.Warning("You need to inform the title of the feedback."); TitleTextBox.Focus(); return; } if (MessageTextBox.Text.Length == 0) { StatusBand.Warning("You need to inform the message of the feedback."); MessageTextBox.Focus(); return; } #endregion #region UI StatusBand.Info(FindResource("Feedback.Sending").ToString()); Cursor = Cursors.AppStarting; MainGrid.IsEnabled = false; MainGrid.UpdateLayout(); #endregion var passList = Secret.Password.Split('|'); var smtp = new SmtpClient { Timeout = (5 * 60 * 1000), //Minutes, seconds, miliseconds Port = Secret.Port, Host = Secret.Host, EnableSsl = true, UseDefaultCredentials = true, Credentials = new NetworkCredential(Secret.Email, passList[current]) }; var mail = new MailMessage { From = new MailAddress("*****@*****.**"), Subject = "Screen To Gif - Feedback", IsBodyHtml = true }; mail.To.Add("*****@*****.**"); #region Text var sb = new StringBuilder(); sb.Append("<html xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">"); sb.Append("<head><meta content=\"en-us\" http-equiv=\"Content-Language\" />" + "<meta content=\"text/html; charset=utf-16\" http-equiv=\"Content-Type\" />" + "<title>Screen To Gif - Feedback</title>" + "</head>"); sb.AppendFormat("<style>{0}</style>", Util.Other.GetTextResource("ScreenToGif.Resources.Style.css")); sb.Append("<body>"); sb.AppendFormat("<h1>{0}</h1>", TitleTextBox.Text); sb.Append("<div id=\"content\"><div>"); sb.Append("<h2>Overview</h2>"); sb.Append("<div id=\"overview\"><table><tr>"); sb.Append("<th _locid=\"UserTableHeader\">User</th>"); if (MailTextBox.Text.Length > 0) { sb.Append("<th _locid=\"FromTableHeader\">Mail</th>"); } sb.Append("<th _locid=\"VersionTableHeader\">Version</th>"); sb.Append("<th _locid=\"WindowsTableHeader\">Windows</th>"); sb.Append("<th _locid=\"BitsTableHeader\">Instruction Size</th>"); sb.Append("<th _locid=\"MemoryTableHeader\">Working Memory</th>"); sb.Append("<th _locid=\"IssueTableHeader\">Issue?</th>"); sb.Append("<th _locid=\"SuggestionTableHeader\">Suggestion?</th></tr>"); sb.AppendFormat("<tr><td class=\"textcentered\">{0}</td>", Environment.UserName); if (MailTextBox.Text.Length > 0) { sb.AppendFormat("<td class=\"textcentered\">{0}</td>", MailTextBox.Text); } sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Assembly.GetExecutingAssembly().GetName().Version.ToString(4)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.OSVersion); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.Is64BitOperatingSystem ? "64 bits" : "32 Bits"); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(Environment.WorkingSet)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", IssueCheckBox.IsChecked.Value ? "Yes" : "No"); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr></table></div></div>", SuggestionCheckBox.IsChecked.Value ? "Yes" : "No"); sb.Append("<h2>Details</h2><div><div><table>"); sb.Append("<tr id=\"ProjectNameHeaderRow\"><th class=\"messageCell\" _locid=\"MessageTableHeader\">Message</th></tr>"); sb.Append("<tr name=\"MessageRowClassProjectName\">"); sb.AppendFormat("<td class=\"messageCell\">{0}</td></tr></table>", MessageTextBox.Text); sb.Append("</div></div></div></body></html>"); #endregion mail.Body = sb.ToString(); foreach (AttachmentListBoxItem attachment in AttachmentListBox.Items) { mail.Attachments.Add(new Attachment(attachment.Attachment)); } smtp.SendCompleted += Smtp_OnSendCompleted; smtp.SendMailAsync(mail); }
private async Task Download() { try { //Save to a temp folder. var temp = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); var downloadUrl = GetDownloadUrl(); if (string.IsNullOrWhiteSpace(downloadUrl)) { StatusBand.Error("Download URL not provided..."); return; } //Download. using (var client = new WebClient { Proxy = WebRequest.GetSystemWebProxy() }) { client.DownloadProgressChanged += (_, args) => { TotalTextBlock.Text = LocalizationHelper.GetWithFormat("S.Downloader.Size", "{0} of {1}", Humanizer.BytesToString(args.BytesReceived), Humanizer.BytesToString(args.TotalBytesToReceive)); MainProgressBar.Value = args.ProgressPercentage; if (_cancel) { client.CancelAsync(); Environment.Exit(35); } }; await client.DownloadFileTaskAsync(new Uri(downloadUrl), temp); } if (_cancel) { Environment.Exit(90); return; } //Decompress. using (var zip = ZipFile.Open(temp, ZipArchiveMode.Read)) { switch (DownloadMode) { case "gifski": { var entry = zip.Entries.FirstOrDefault(x => x.Name.Contains("gifski.dll")); if (File.Exists(DestinationPath)) { File.Delete(DestinationPath); } entry?.ExtractToFile(DestinationPath, true); break; } case "ffmpeg": { var entry = zip.Entries.FirstOrDefault(x => x.Name.Contains("ffmpeg.exe")); if (File.Exists(DestinationPath)) { File.Delete(DestinationPath); } entry?.ExtractToFile(DestinationPath, true); break; } case "sharpdx": { foreach (var entry in zip.Entries) { if (File.Exists(Path.Combine(DestinationPath, entry.Name))) { File.Delete(Path.Combine(DestinationPath, entry.Name)); } entry?.ExtractToFile(Path.Combine(DestinationPath, entry.Name), true); } break; } } } File.Delete(temp); Environment.Exit(10); } catch (Exception e) { LogWriter.Log(e, "Impossible to download"); StatusBand.Error(e.Message); RetryButton.IsEnabled = true; } }
private string BuildBody(string title, string message, string email, bool issue, bool suggestion) { var sb = new StringBuilder(); sb.Append("<html xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">"); sb.Append("<head><meta content=\"en-us\" http-equiv=\"Content-Language\" />" + "<meta content=\"text/html; charset=utf-16\" http-equiv=\"Content-Type\" />" + "<title>ScreenToGif - Feedback</title>" + "</head>"); sb.AppendFormat("<style>{0}</style>", Util.Other.GetTextResource("ScreenToGif.Resources.Style.css")); sb.Append("<body>"); sb.AppendFormat("<h1>{0}</h1>", title); sb.Append("<div id=\"content\"><div>"); sb.Append("<h2>Overview</h2>"); sb.Append("<div id=\"overview\"><table>"); //First overview row. sb.Append("<tr><th>User</th>"); sb.Append("<th>Machine</th>"); sb.Append("<th>Startup</th>"); sb.Append("<th>Date</th>"); sb.Append("<th>Running</th>"); sb.Append("<th>Version</th></tr>"); var format = new CultureInfo("pt-BR"); sb.AppendFormat("<tr><td class=\"textcentered\">{0}</td>", Environment.UserName); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.MachineName); sb.AppendFormat(format, "<td class=\"textcentered\">{0:g}</td>", Global.StartupDateTime); sb.AppendFormat(format, "<td class=\"textcentered\">{0:g}</td>", DateTime.Now); sb.AppendFormat(format, "<td class=\"textcentered\">{0:d':'hh':'mm':'ss}</td>", Global.StartupDateTime != DateTime.MinValue ? DateTime.Now - Global.StartupDateTime : TimeSpan.Zero); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", Assembly.GetExecutingAssembly().GetName().Version.ToString(4)); //Second overview row. sb.Append("<tr><th colspan=\"2\">Windows</th>"); sb.Append("<th>Architecture</th>"); sb.Append("<th>Used</th>"); sb.Append("<th>Available</th>"); sb.Append("<th>Total</th></tr>"); var status = new Native.MemoryStatusEx(true); Native.GlobalMemoryStatusEx(ref status); sb.AppendFormat("<td class=\"textcentered\" colspan=\"2\">{0}</td>", Environment.OSVersion.Version); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.Is64BitOperatingSystem ? "64 bits" : "32 Bits"); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(Environment.WorkingSet)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(status.AvailablePhysicalMemory)); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", Humanizer.BytesToString(status.TotalPhysicalMemory)); //Third overview row. sb.Append("<tr><th colspan=\"3\">E-mail</th>"); sb.Append("<th>.Net Version</th>"); sb.Append("<th>Issue?</th>"); sb.Append("<th>Suggestion?</th></tr>"); sb.AppendFormat("<td colspan=\"3\" class=\"textcentered\">{0}</td>", email); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", FrameworkHelper.QueryFrameworkVersion()); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", issue ? "Yes" : "No"); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr></table></div></div>", suggestion ? "Yes" : "No"); //Monitors. sb.Append("<br><h2>Monitors</h2><table>"); sb.Append("<tr><th>Bounds</th>"); sb.Append("<th>Working Area</th>"); sb.Append("<th>DPI/Scale</th>"); sb.Append("<th>Primary?</th></tr>"); foreach (var monitor in Monitor.AllMonitors) { sb.AppendFormat("<td class=\"textcentered\">{0}:{1} • {2}x{3}</td>", monitor.Bounds.Left, monitor.Bounds.Top, monitor.Bounds.Width, monitor.Bounds.Height); sb.AppendFormat("<td class=\"textcentered\">{0}:{1} • {2}x{3}</td>", monitor.WorkingArea.Left, monitor.WorkingArea.Top, monitor.WorkingArea.Width, monitor.WorkingArea.Height); sb.AppendFormat("<td class=\"textcentered\">{0}dpi / {1:#00}%</td>", monitor.Dpi, monitor.Dpi / 96d * 100d); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", monitor.IsPrimary ? "Yes" : "No"); } sb.Append("<table>"); //TODO: Show drawing of monitors, with the position of each window. //sb.Append("<svg>" + // "<circle cx=\"40\" cy=\"40\" r=\"24\" style=\"stroke:#006600; fill:#00cc00\"/>" + // "<rect id=\"box\" x=\"0\" y=\"0\" width=\"50\" height=\"50\" style=\"stroke:#006600; fill:#00cc00\"/>" + // "</svg>"); //Details. sb.Append("<br><h2>Details</h2><div><div><table>"); sb.Append("<tr id=\"ProjectNameHeaderRow\"><th class=\"messageHeader\">Message</th></tr>"); sb.Append("<tr name=\"MessageRowClassProjectName\">"); sb.AppendFormat("<td class=\"messageCell\">{0}</td></tr></table>", message.Replace(Environment.NewLine, "<br>")); sb.Append("</div></div></div></body></html>"); return(sb.ToString()); }
private void Window_Loaded(object sender, RoutedEventArgs e) { #region Validation if (Global.UpdateAvailable == null) { WhatsNewParagraph.Inlines.Add("Something wrong happened. No update was found."); return; } #endregion try { //Detect if this is portable or installed. Download the proper file. IsChocolatey = AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"Chocolatey\lib\screentogif\content\"); IsInstaller = Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory).Any(x => x.ToLowerInvariant().EndsWith("screentogif.visualelementsmanifest.xml")); VersionRun.Text = $"{LocalizationHelper.Get("S.Updater.Version")} {Global.UpdateAvailable.Version}"; SizeRun.Text = Global.UpdateAvailable.InstallerSize > 0 ? Humanizer.BytesToString(IsInstaller ? Global.UpdateAvailable.InstallerSize : Global.UpdateAvailable.PortableSize) : ""; TypeRun.Text = IsInstaller ? LocalizationHelper.Get("S.Updater.Installer") : LocalizationHelper.Get("S.Updater.Portable"); //If set to download automatically, check if the installer was downloaded. if (UserSettings.All.InstallUpdates) { //If the update was already downloaded. if (File.Exists(Global.UpdateAvailable.InstallerPath)) { DownloadButton.SetResourceReference(ImageButton.TextProperty, "S.Updater.Install"); //When the update was prompted manually, the user can set the installer to run the app afterwards. if (WasPromptedManually) { RunAfterwardsCheckBox.Visibility = Visibility.Visible; RunAfterwardsCheckBox.IsChecked = true; } } } //Details. if (Global.UpdateAvailable.IsFromGithub) { //From Github, the description is available. var splited = Global.UpdateAvailable.Description.Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); WhatsNewParagraph.Inlines.Add(splited[0].Replace(" What's new?\r\n\r\n", "")); FixesParagraph.Inlines.Add(splited.Length > 1 ? splited[1].Replace(" Bug fixes:\r\n\r\n", "").Replace(" Fixed:\r\n\r\n", "") : "Aparently nothing."); } else { //If the release detail was obtained by querying Fosshub, no release note is available. MainFlowDocument.Blocks.Remove(WhatsNewParagraphTitle); MainFlowDocument.Blocks.Remove(FixesParagraphTitle); MainFlowDocument.Blocks.Remove(FixesParagraph); var run = new Run(); run.SetResourceReference(Run.TextProperty, "S.Updater.Info.NewVersionAvailable"); WhatsNewParagraph.Inlines.Add(run); } } catch (Exception ex) { LogWriter.Log(ex, "Impossible to load the download details"); StatusBand.Error(LocalizationHelper.Get("S.Updater.Warning.Show")); } }
private void CheckTools() { if (!IsLoaded) { return; } try { if (Util.Other.IsFfmpegPresent(true)) { var info = new FileInfo(UserSettings.All.FfmpegLocation); info.Refresh(); FfmpegImageCard.Status = ExtrasStatus.Ready; FfmpegImageCard.Description = string.Format(LocalizationHelper.Get("Extras.Ready", "{0}"), Humanizer.BytesToString(info.Length)); } else { FfmpegImageCard.Status = ExtrasStatus.Available; FfmpegImageCard.Description = string.Format(LocalizationHelper.Get("Extras.Download", "{0}"), "~ 43,7 MB"); } if (Util.Other.IsGifskiPresent(true)) { var info = new FileInfo(UserSettings.All.GifskiLocation); info.Refresh(); GifskiImageCard.Status = ExtrasStatus.Ready; GifskiImageCard.Description = string.Format(LocalizationHelper.Get("Extras.Ready", "{0}"), Humanizer.BytesToString(info.Length)); } else { GifskiImageCard.Status = ExtrasStatus.Available; GifskiImageCard.Description = string.Format(LocalizationHelper.Get("Extras.Download", "{0}"), "~ 1 MB"); } } catch (Exception ex) { LogWriter.Log(ex, "Checking the existance of external tools."); } }
private string BuildBody(string title, string message, string email, bool issue, bool suggestion) { var sb = new StringBuilder(); sb.Append("<html xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">"); sb.Append("<head><meta content=\"en-us\" http-equiv=\"Content-Language\" />" + "<meta content=\"text/html; charset=utf-16\" http-equiv=\"Content-Type\" />" + "<title>Screen To Gif - Feedback</title>" + "</head>"); sb.AppendFormat("<style>{0}</style>", Util.Other.GetTextResource("ScreenToGif.Resources.Style.css")); sb.Append("<body>"); sb.AppendFormat("<h1>{0}</h1>", title); sb.Append("<div id=\"content\"><div>"); sb.Append("<h2>Overview</h2>"); sb.Append("<div id=\"overview\"><table>"); //First overview row. sb.Append("<tr><th>User</th>"); sb.Append("<th>Machine</th>"); sb.Append("<th>Startup</th>"); sb.Append("<th>Date</th>"); sb.Append("<th>Running</th>"); sb.Append("<th>Version</th></tr>"); sb.AppendFormat("<tr><td class=\"textcentered\">{0}</td>", Environment.UserName); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.MachineName); sb.AppendFormat("<td class=\"textcentered\">{0:g}</td>", Global.StartupDateTime); sb.AppendFormat("<td class=\"textcentered\">{0:g}</td>", DateTime.Now); sb.AppendFormat("<td class=\"textcentered\">{0:d':'hh':'mm':'ss}</td>", Global.StartupDateTime != DateTime.MinValue ? DateTime.Now - Global.StartupDateTime : TimeSpan.Zero); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", Assembly.GetExecutingAssembly().GetName().Version.ToString(4)); //Second overview row. sb.Append("<tr><th colspan=\"2\">Windows</th>"); sb.Append("<th>Architecture</th>"); sb.Append("<th>Used</th>"); sb.Append("<th>Available</th>"); sb.Append("<th>Total</th></tr>"); var status = new Native.MemoryStatusEx(true); Native.GlobalMemoryStatusEx(ref status); sb.AppendFormat("<td class=\"textcentered\" colspan=\"2\">{0}</td>", Environment.OSVersion.Version); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Environment.Is64BitOperatingSystem ? "64 bits" : "32 Bits"); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(Environment.WorkingSet)); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", Humanizer.BytesToString(status.AvailablePhysicalMemory)); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr>", Humanizer.BytesToString(status.TotalPhysicalMemory)); //Third overview row. sb.Append("<tr><th colspan=\"4\">E-mail</th>"); sb.Append("<th>Issue?</th>"); sb.Append("<th>Suggestion?</th></tr>"); sb.AppendFormat("<td colspan=\"4\" class=\"textcentered\">{0}</td>", email); sb.AppendFormat("<td class=\"textcentered\">{0}</td>", issue ? "Yes" : "No"); sb.AppendFormat("<td class=\"textcentered\">{0}</td></tr></table></div></div>", suggestion ? "Yes" : "No"); sb.Append("<h2>Details</h2><div><div><table>"); sb.Append("<tr id=\"ProjectNameHeaderRow\"><th class=\"messageHeader\">Message</th></tr>"); sb.Append("<tr name=\"MessageRowClassProjectName\">"); sb.AppendFormat("<td class=\"messageCell\">{0}</td></tr></table>", message.Replace(Environment.NewLine, "<br>")); sb.Append("</div></div></div></body></html>"); return(sb.ToString()); }