diff --git a/trunk/CHANGELOG.txt b/trunk/CHANGELOG.txt index 84530feb8..5658bb642 100644 --- a/trunk/CHANGELOG.txt +++ b/trunk/CHANGELOG.txt @@ -4,6 +4,7 @@ Process Hacker * NEW: * Statistics times in System Information and process properties * Highlighting system + * Configurable max. samples * FIXED: * #2694437 - "Crash when sorting the process list" * Network connections would be readded if their state changed diff --git a/trunk/ProcessHacker/Forms/HackerWindow.cs b/trunk/ProcessHacker/Forms/HackerWindow.cs index 7c56354d4..ee63a31d9 100644 --- a/trunk/ProcessHacker/Forms/HackerWindow.cs +++ b/trunk/ProcessHacker/Forms/HackerWindow.cs @@ -1999,6 +1999,8 @@ namespace ProcessHacker foreach (string s in Properties.Settings.Default.ImposterNames.Split(',')) Program.ImposterNames.Add(s.Trim()); + + HistoryManagerGlobal.GlobalMaxCount = Properties.Settings.Default.MaxSamples; } public void QueueMessage(string message) diff --git a/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs b/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs index 68030edcc..bd6f3da22 100644 --- a/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs +++ b/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs @@ -51,6 +51,8 @@ this.label23 = new System.Windows.Forms.Label(); this.textIconMenuProcesses = new System.Windows.Forms.NumericUpDown(); this.tabAdvanced = new System.Windows.Forms.TabPage(); + this.textMaxSamples = new System.Windows.Forms.NumericUpDown(); + this.label6 = new System.Windows.Forms.Label(); this.buttonChangeReplaceTaskManager = new System.Windows.Forms.Button(); this.checkReplaceTaskManager = new System.Windows.Forms.CheckBox(); this.checkEnableKPH = new System.Windows.Forms.CheckBox(); @@ -87,6 +89,7 @@ this.tabGeneral.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.textIconMenuProcesses)).BeginInit(); this.tabAdvanced.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.textMaxSamples)).BeginInit(); this.tabHighlighting.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.textHighlightingDuration)).BeginInit(); this.tabPlotting.SuspendLayout(); @@ -125,7 +128,7 @@ this.textUpdateInterval.Size = new System.Drawing.Size(66, 20); this.textUpdateInterval.TabIndex = 1; this.textUpdateInterval.Value = new decimal(new int[] { - 250, + 1000, 0, 0, 0}); @@ -380,6 +383,8 @@ // // tabAdvanced // + this.tabAdvanced.Controls.Add(this.textMaxSamples); + this.tabAdvanced.Controls.Add(this.label6); this.tabAdvanced.Controls.Add(this.buttonChangeReplaceTaskManager); this.tabAdvanced.Controls.Add(this.checkReplaceTaskManager); this.tabAdvanced.Controls.Add(this.checkEnableKPH); @@ -393,6 +398,43 @@ this.tabAdvanced.Text = "Advanced"; this.tabAdvanced.UseVisualStyleBackColor = true; // + // textMaxSamples + // + this.textMaxSamples.Increment = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.textMaxSamples.Location = new System.Drawing.Point(118, 102); + this.textMaxSamples.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.textMaxSamples.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.textMaxSamples.Name = "textMaxSamples"; + this.textMaxSamples.Size = new System.Drawing.Size(72, 20); + this.textMaxSamples.TabIndex = 20; + this.textMaxSamples.Value = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 104); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(106, 13); + this.label6.TabIndex = 19; + this.label6.Text = "Max. Sample History:"; + this.toolTipProvider.SetToolTip(this.label6, "The number of performance data samples that are retained."); + // // buttonChangeReplaceTaskManager // this.buttonChangeReplaceTaskManager.FlatStyle = System.Windows.Forms.FlatStyle.System; @@ -767,6 +809,7 @@ ((System.ComponentModel.ISupportInitialize)(this.textIconMenuProcesses)).EndInit(); this.tabAdvanced.ResumeLayout(false); this.tabAdvanced.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.textMaxSamples)).EndInit(); this.tabHighlighting.ResumeLayout(false); this.tabHighlighting.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.textHighlightingDuration)).EndInit(); @@ -832,5 +875,7 @@ private System.Windows.Forms.Label label5; private System.Windows.Forms.Button buttonChangeReplaceTaskManager; private System.Windows.Forms.CheckBox checkAllowOnlyOneInstance; + private System.Windows.Forms.NumericUpDown textMaxSamples; + private System.Windows.Forms.Label label6; } } \ No newline at end of file diff --git a/trunk/ProcessHacker/Forms/OptionsWindow.cs b/trunk/ProcessHacker/Forms/OptionsWindow.cs index 181be22ca..5e4acc39c 100644 --- a/trunk/ProcessHacker/Forms/OptionsWindow.cs +++ b/trunk/ProcessHacker/Forms/OptionsWindow.cs @@ -45,6 +45,7 @@ namespace ProcessHacker buttonFont.Font = _font; textUpdateInterval.Value = Properties.Settings.Default.RefreshInterval; textIconMenuProcesses.Value = Properties.Settings.Default.IconMenuProcessCount; + textMaxSamples.Value = Properties.Settings.Default.MaxSamples; textSearchEngine.Text = Properties.Settings.Default.SearchEngine; comboSizeUnits.SelectedItem = Misc.SizeUnitNames[Properties.Settings.Default.UnitSpecifier]; @@ -254,6 +255,9 @@ namespace ProcessHacker Properties.Settings.Default.EnableKPH = checkEnableKPH.Checked; Properties.Settings.Default.ImposterNames = textImposterNames.Text.ToLower(); + Properties.Settings.Default.MaxSamples = (int)textMaxSamples.Value; + HistoryManagerGlobal.GlobalMaxCount = Properties.Settings.Default.MaxSamples; + Program.ImposterNames = new System.Collections.Specialized.StringCollection(); foreach (string s in Properties.Settings.Default.ImposterNames.Split(',')) diff --git a/trunk/ProcessHacker/HistoryManager.cs b/trunk/ProcessHacker/HistoryManager.cs index a9a0d0307..8cfedc88c 100644 --- a/trunk/ProcessHacker/HistoryManager.cs +++ b/trunk/ProcessHacker/HistoryManager.cs @@ -27,10 +27,21 @@ using System.Text; namespace ProcessHacker { + public static class HistoryManagerGlobal + { + private static int _globalMaxCount = 750; + + public static int GlobalMaxCount + { + get { return _globalMaxCount; } + set { _globalMaxCount = value; } + } + } + public class HistoryManager { private Dictionary> _history = new Dictionary>(); - private int _maxCount = 1000; + private int _maxCount = -1; public int MaxCount { @@ -55,10 +66,12 @@ namespace ProcessHacker public void Update(TKey key, TValue value) { + int maxCount = _maxCount == -1 ? HistoryManagerGlobal.GlobalMaxCount : _maxCount; + _history[key].Insert(0, value); - if (_history[key].Count > _maxCount) - _history[key].RemoveRange(_history[key].Count - 1, _history[key].Count - _maxCount); + if (_history[key].Count > maxCount) + _history[key].RemoveRange(maxCount, _history[key].Count - maxCount); } } } diff --git a/trunk/ProcessHacker/Properties/Settings.Designer.cs b/trunk/ProcessHacker/Properties/Settings.Designer.cs index 8cc89ebdd..97315447f 100644 --- a/trunk/ProcessHacker/Properties/Settings.Designer.cs +++ b/trunk/ProcessHacker/Properties/Settings.Designer.cs @@ -1164,5 +1164,17 @@ namespace ProcessHacker.Properties { this["NeedsUpgrade"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("750")] + public int MaxSamples { + get { + return ((int)(this["MaxSamples"])); + } + set { + this["MaxSamples"] = value; + } + } } } diff --git a/trunk/ProcessHacker/Properties/Settings.settings b/trunk/ProcessHacker/Properties/Settings.settings index 59d1aa3d9..659e25da4 100644 --- a/trunk/ProcessHacker/Properties/Settings.settings +++ b/trunk/ProcessHacker/Properties/Settings.settings @@ -287,5 +287,8 @@ True + + 750 + \ No newline at end of file diff --git a/trunk/ProcessHacker/app.config b/trunk/ProcessHacker/app.config index 98bb09d49..cfeebca91 100644 --- a/trunk/ProcessHacker/app.config +++ b/trunk/ProcessHacker/app.config @@ -292,6 +292,9 @@ True + + 750 + \ No newline at end of file