Stats related improvements

This commit is contained in:
Jaex 2019-06-17 09:02:16 +03:00
parent 1f9bcaf902
commit 62a1016e1b
3 changed files with 55 additions and 21 deletions

View file

@ -56,12 +56,14 @@ private void InitializeComponent()
this.cbDateFilter = new System.Windows.Forms.CheckBox();
this.dtpFilterTo = new System.Windows.Forms.DateTimePicker();
this.txtFilenameFilter = new System.Windows.Forms.TextBox();
this.pStats = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit();
this.scMain.Panel1.SuspendLayout();
this.scMain.Panel2.SuspendLayout();
this.scMain.SuspendLayout();
this.panel1.SuspendLayout();
this.gbFilters.SuspendLayout();
this.pStats.SuspendLayout();
this.SuspendLayout();
//
// scMain
@ -72,7 +74,7 @@ private void InitializeComponent()
//
// scMain.Panel1
//
this.scMain.Panel1.Controls.Add(this.rtbStats);
this.scMain.Panel1.Controls.Add(this.pStats);
this.scMain.Panel1.Controls.Add(this.lvHistory);
//
// scMain.Panel2
@ -258,6 +260,12 @@ private void InitializeComponent()
resources.ApplyResources(this.txtFilenameFilter, "txtFilenameFilter");
this.txtFilenameFilter.Name = "txtFilenameFilter";
//
// pStats
//
this.pStats.Controls.Add(this.rtbStats);
resources.ApplyResources(this.pStats, "pStats");
this.pStats.Name = "pStats";
//
// HistoryForm
//
resources.ApplyResources(this, "$this");
@ -276,6 +284,7 @@ private void InitializeComponent()
this.panel1.ResumeLayout(false);
this.gbFilters.ResumeLayout(false);
this.gbFilters.PerformLayout();
this.pStats.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -308,5 +317,6 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtURLFilter;
private System.Windows.Forms.Button btnShowStats;
private System.Windows.Forms.RichTextBox rtbStats;
private System.Windows.Forms.Panel pStats;
}
}

View file

@ -54,7 +54,7 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
InitializeComponent();
Icon = ShareXResources.Icon;
defaultTitle = Text;
//UpdateTitle();
UpdateTitle();
// Mark the Date column as having a date; used for sorting
chDateTime.Tag = new DateTime();
@ -97,10 +97,9 @@ private void OutputStats(HistoryItem[] historyItems)
rtbStats.AppendLine("Total: " + historyItems.Length);
IEnumerable<string> types = historyItems.
Select(x => x.Type).
GroupBy(x => x).
GroupBy(x => x.Type).
OrderByDescending(x => x.Count()).
Select(x => string.Format("{0}: {1}", x.Key, x.Count()));
Select(x => string.Format("{0}: {1} ({2:N0}%)", x.Key, x.Count(), x.Count() / (float)historyItems.Length * 100));
rtbStats.AppendLine(string.Join(Environment.NewLine, types));
@ -136,8 +135,7 @@ private void OutputStats(HistoryItem[] historyItems)
rtbStats.SetFontRegular();
IEnumerable<string> hosts = historyItems.
Select(x => x.Host).
GroupBy(x => x).
GroupBy(x => x.Host).
OrderByDescending(x => x.Count()).
Select(x => string.Format("{0} ({1})", x.Key, x.Count()));
@ -235,7 +233,7 @@ private void AddHistoryItems(HistoryItem[] historyItems)
{
Cursor = Cursors.WaitCursor;
//UpdateTitle(historyItems);
UpdateTitle(historyItems);
lvHistory.Items.Clear();
@ -292,11 +290,10 @@ private void UpdateTitle(HistoryItem[] historyItems = null)
status.AppendFormat(" - " + Resources.HistoryForm_UpdateItemCount___Filtered___0_, historyItems.Length.ToString("N0"));
}
IEnumerable<string> types = from hi in historyItems
group hi by hi.Type
into t
let count = t.Count()
select string.Format(" - {0}: {1:N0}", t.Key, count);
IEnumerable<string> types = historyItems.
GroupBy(x => x.Type).
OrderByDescending(x => x.Count()).
Select(x => string.Format(" - {0}: {1}", x.Key, x.Count()));
foreach (string type in types)
{
@ -403,14 +400,14 @@ private void BtnShowStats_Click(object sender, EventArgs e)
if (showingStats)
{
lvHistory.Visible = true;
rtbStats.Visible = false;
pStats.Visible = false;
// TODO: Translate
btnShowStats.Text = "Show stats";
showingStats = false;
}
else
{
rtbStats.Visible = true;
pStats.Visible = true;
lvHistory.Visible = false;
// TODO: Translate
btnShowStats.Text = "Hide stats";

View file

@ -132,10 +132,10 @@
<value>Arial, 9.75pt</value>
</data>
<data name="rtbStats.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
<value>3, 3</value>
</data>
<data name="rtbStats.Size" type="System.Drawing.Size, System.Drawing">
<value>550, 641</value>
<value>544, 635</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="rtbStats.TabIndex" type="System.Int32, mscorlib">
@ -144,9 +144,6 @@
<data name="rtbStats.Text" xml:space="preserve">
<value />
</data>
<data name="rtbStats.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;rtbStats.Name" xml:space="preserve">
<value>rtbStats</value>
</data>
@ -154,11 +151,41 @@
<value>System.Windows.Forms.RichTextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;rtbStats.Parent" xml:space="preserve">
<value>scMain.Panel1</value>
<value>pStats</value>
</data>
<data name="&gt;&gt;rtbStats.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pStats.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="pStats.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="pStats.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="pStats.Size" type="System.Drawing.Size, System.Drawing">
<value>550, 641</value>
</data>
<data name="pStats.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="pStats.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;pStats.Name" xml:space="preserve">
<value>pStats</value>
</data>
<data name="&gt;&gt;pStats.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pStats.Parent" xml:space="preserve">
<value>scMain.Panel1</value>
</data>
<data name="&gt;&gt;pStats.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="chIcon.Text" xml:space="preserve">
<value />
</data>