Added process names to history stats output

This commit is contained in:
Jaex 2021-12-12 14:33:14 +03:00
parent 241619cc07
commit 86b1d718b0
2 changed files with 21 additions and 7 deletions

View file

@ -332,6 +332,8 @@ private void UpdatePictureBox()
private string OutputStats(HistoryItem[] historyItems)
{
string empty = "(empty)";
StringBuilder sb = new StringBuilder();
sb.AppendLine(Resources.HistoryItemCounts);
@ -360,9 +362,9 @@ private string OutputStats(HistoryItem[] historyItems)
IEnumerable<string> fileExtensions = historyItems.
Where(x => !string.IsNullOrEmpty(x.FileName) && !x.FileName.EndsWith(")")).
Select(x => Helpers.GetFileNameExtension(x.FileName)).
GroupBy(x => x).
GroupBy(x => string.IsNullOrWhiteSpace(x) ? empty : x).
OrderByDescending(x => x.Count()).
Select(x => string.Format("{0} ({1})", x.Key, x.Count()));
Select(x => string.Format("[{0}] {1}", x.Count(), x.Key));
sb.AppendLine(string.Join(Environment.NewLine, fileExtensions));
@ -370,11 +372,21 @@ private string OutputStats(HistoryItem[] historyItems)
sb.AppendLine(Resources.HistoryStats_Hosts);
IEnumerable<string> hosts = historyItems.
GroupBy(x => x.Host).
GroupBy(x => string.IsNullOrWhiteSpace(x.Host) ? empty : x.Host).
OrderByDescending(x => x.Count()).
Select(x => string.Format("{0} ({1})", x.Key, x.Count()));
Select(x => string.Format("[{0}] {1}", x.Count(), x.Key));
sb.Append(string.Join(Environment.NewLine, hosts));
sb.AppendLine(string.Join(Environment.NewLine, hosts));
sb.AppendLine();
sb.AppendLine("Process names:"); // TODO: Translate
IEnumerable<string> processNames = historyItems.
GroupBy(x => string.IsNullOrWhiteSpace(x.TagsProcessName) ? empty : x.TagsProcessName).
OrderByDescending(x => x.Count()).
Select(x => string.Format("[{0}] {1}", x.Count(), x.Key));
sb.Append(string.Join(Environment.NewLine, processNames));
return sb.ToString();
}

View file

@ -31,6 +31,8 @@ namespace ShareX
{
public class TaskMetadata : IDisposable
{
private const int WindowInfoMaxLength = 255;
public Bitmap Image { get; set; }
private string windowTitle;
@ -43,7 +45,7 @@ public string WindowTitle
}
set
{
windowTitle = value.Truncate(255);
windowTitle = value.Truncate(WindowInfoMaxLength);
}
}
@ -57,7 +59,7 @@ public string ProcessName
}
set
{
processName = value.Truncate(255);
processName = value.Truncate(WindowInfoMaxLength);
}
}