private void CompressWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs args) { if (args.Cancelled) { RemainingTimeLabel.Text = Tx.T("msg.cancelled"); RemainingTimeLabel.ForeColor = SystemColors.ControlText; progressBar1.Value = 0; DiscardArchive(); } else if (args.Error != null) { RemainingTimeLabel.Text = Tx.TC("msg.title.error") + " " + args.Error.Message; RemainingTimeLabel.ForeColor = Color.FromArgb(240, 0, 0); DiscardArchive(); } else { RemainingTimeLabel.Text = Tx.T("msg.completed"); RemainingTimeLabel.ForeColor = Color.FromArgb(0, 160, 0); CompressedSizeLabel.Text = Tx.DataSize(SharedData.Instance.ArchiveFileSize); dataReady = true; UpdateButtons(); MainForm.Instance.FocusNextButton(); } }
private void AddDirectory(LogBasePathInfo info) { ListViewItem lvi = new ListViewItem(info.LogBasePath); lvi.Tag = info; lvi.SubItems.Add(CommonFormats.DateTimeToShortString(info.UpdatedTime.ToLocalTime())); lvi.SubItems.Add(Tx.DataSize(info.Size)); LogDirsListView.Items.Add(lvi); info.ListViewItem = lvi; }
/// <inheritdoc /> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is string) { return((string)value); } var v = System.Convert.ToInt64(value); return(Tx.DataSize(v)); }
private void CompressWorker_ProgressChanged(object sender, ProgressChangedEventArgs args) { bool someTimePassed = false; if (DateTime.UtcNow > lastProgressTime.AddMilliseconds(500)) { lastProgressTime = DateTime.UtcNow; someTimePassed = true; } progressBar1.Value = args.ProgressPercentage; if (args.ProgressPercentage == 0) { startTime = DateTime.UtcNow; RemainingTimeLabel.Text = Tx.T("msg.starting"); RemainingTimeLabel.ForeColor = SystemColors.ControlText; } else if (args.ProgressPercentage >= 20) // Permille { if (someTimePassed) { double elapsedSeconds = (DateTime.UtcNow - startTime).TotalSeconds; double totalSeconds = elapsedSeconds * 1000 / args.ProgressPercentage; // Permille if (totalSeconds >= 0 && totalSeconds < int.MaxValue) { TimeSpan remainingTime = TimeSpan.FromSeconds((int)Math.Ceiling(totalSeconds - elapsedSeconds)); RemainingTimeLabel.Text = Tx.TimeSpanRaw(remainingTime, false); RemainingTimeLabel.ForeColor = SystemColors.ControlText; } } } ProgressInfo pi = args.UserState as ProgressInfo; if (pi != null) { SharedData.Instance.ArchiveFileSize = pi.CompressedSize; if (someTimePassed) { CompressedSizeLabel.Text = Tx.DataSize(pi.CompressedSize); } } }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // Return the text key only in design mode. Nothing better to do for now. if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) { return(Tx.DataSize(0)); } // values[0] is the Dummy binding, don't use it // Read the number value from binding number two. if (values[1] == DependencyProperty.UnsetValue) { return(DependencyProperty.UnsetValue); } long l = System.Convert.ToInt64(values[1]); return(Tx.DataSize(l)); }
public DetailedWikiPageCompletionData(string title, PageInfo pageInfo) : base(title, pageInfo.Title) { if (pageInfo == null) { throw new ArgumentNullException(nameof(pageInfo)); } _Description = pageInfo.Title + "\n\n" + Utility.TruncateString(pageInfo.Description ?? "", 300) + "\n\n" + Tx.TC("page.content length") + Tx.DataSize(pageInfo.ContentLength) + "\n" + Tx.TC("page.last revision by") + pageInfo.LastRevisionUser + " " + Tx.Time(pageInfo.LastRevisionTime, TxTime.YearMonthDay | TxTime.HourMinuteSecond); if (pageInfo.RedirectPath != null && pageInfo.RedirectPath.Count > 0) { _Description += "\n" + Tx.TC("page.redirect") + string.Join("→", pageInfo.RedirectPath); } if (pageInfo.TemplateArguments.Count > 0) { _Description += "\n\n" + Tx.TC("page.arguments") + "\n" + string.Join("\n", pageInfo.TemplateArguments.Select(ta => ta.Name)); } }
public string GetValueString() { switch (Value) { case var value when value is TextValueDto val: return(val.Value); case var value when value is TranslatedTextValueDto val: return(Tx.T($"SystemInformation:Labels.{val.TranslationKey}")); case var value when value is NumberValueDto val: return(Tx.Number(val.Value)); case var value when value is DataSizeValueDto val: return(Tx.DataSize(val.Value)); case var value when value is ProgressValueDto val: return($"{val.Value} / {val.Maximum}"); case var value when value is CultureValueDto val: var culture = CultureInfo.GetCultureInfo(val.Value); return($"{culture.DisplayName} ({culture.TwoLetterISOLanguageName})"); case var value when value is DateTimeValueDto val: return(Tx.Time(val.Value.LocalDateTime, TxTime.YearMonthLong | TxTime.HourMinuteSecond)); case var value when value is BoolValueDto val: return(val.ToString()); case var value when value is HeaderValueDto val: return(string.Empty); default: return(string.Empty); } }
private void UpdateDirectory(LogBasePathInfo info) { info.ListViewItem.SubItems[1].Text = CommonFormats.DateTimeToShortString(info.UpdatedTime.ToLocalTime()); info.ListViewItem.SubItems[2].Text = Tx.DataSize(info.Size); }