Skip to content

Commit

Permalink
Added process names to history stats output
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaex committed Dec 12, 2021
1 parent 241619c commit 86b1d71
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
22 changes: 17 additions & 5 deletions ShareX.HistoryLib/Forms/HistoryForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ private void UpdatePictureBox()

private string OutputStats(HistoryItem[] historyItems)
{
string empty = "(empty)";

StringBuilder sb = new StringBuilder();

sb.AppendLine(Resources.HistoryItemCounts);
Expand Down Expand Up @@ -360,21 +362,31 @@ 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));

sb.AppendLine();
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.Count(), x.Key));

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.Key, x.Count()));
Select(x => string.Format("[{0}] {1}", x.Count(), x.Key));

sb.Append(string.Join(Environment.NewLine, hosts));
sb.Append(string.Join(Environment.NewLine, processNames));

return sb.ToString();
}
Expand Down
6 changes: 4 additions & 2 deletions ShareX/TaskMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace ShareX
{
public class TaskMetadata : IDisposable
{
private const int WindowInfoMaxLength = 255;

public Bitmap Image { get; set; }

private string windowTitle;
Expand All @@ -43,7 +45,7 @@ public string WindowTitle
}
set
{
windowTitle = value.Truncate(255);
windowTitle = value.Truncate(WindowInfoMaxLength);
}
}

Expand All @@ -57,7 +59,7 @@ public string ProcessName
}
set
{
processName = value.Truncate(255);
processName = value.Truncate(WindowInfoMaxLength);
}
}

Expand Down

0 comments on commit 86b1d71

Please sign in to comment.