diff --git a/Data/Entries.cs b/Data/Entries.cs index e8a8ab3..a43d573 100644 --- a/Data/Entries.cs +++ b/Data/Entries.cs @@ -1,33 +1,48 @@ using CachedProgramsList.Register; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace CachedProgramsList.Data { class Entries { + private DataGridViewRow baseRow; private List entriesList = new List(); + + public event EventHandler EntryAmountUpdate; + public event EventHandler WorkEnded; public Entries(DataGridViewRow baseRow) { this.baseRow = baseRow; } + protected virtual void OnEntryAmountUpdate() + { + EntryAmountUpdate?.Invoke(this, entryAmount); + } + + protected virtual void OnWorkEnded() + { + WorkEnded?.Invoke(this, entryAmount); + } + + private int entryAmount = 0; public List getEntries(bool search = true) { if (search) { entriesList.Clear(); + entryAmount = 0; getEntriesForKey(@"SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache"); getEntriesForKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"); getEntriesForKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"); getEntriesForKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted"); + getEntriesForKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FeatureUsage\AppSwitched"); } + OnWorkEnded(); return entriesList; } @@ -91,11 +106,21 @@ public List filterEntries(string filter, string field) return filteredEntriesList; } + private void updateEntryAmountIfNecessary() + { + if (entryAmount % 100 == 0) + { + OnEntryAmountUpdate(); + } + } + private void getEntriesForKey(string keyToSearch) { + Key key = new Key(keyToSearch); foreach (Entry value in key.getEntries()) { + updateEntryAmountIfNecessary(); if (value.Valid) { bool alreadyExists = false; @@ -120,6 +145,7 @@ private void getEntriesForKey(string keyToSearch) newEntry.Cells[2].Value = value.Exists == true ? value.Creation : (DateTime?)null; newEntry.Cells[3].Value = value.Exists == true ? value.Modification : (DateTime?)null; newEntry.Cells[4].Value = value.Path; + entryAmount++; entriesList.Add(newEntry); } } diff --git a/FormMain.Designer.cs b/FormMain.Designer.cs index 14df6f2..0ff851a 100644 --- a/FormMain.Designer.cs +++ b/FormMain.Designer.cs @@ -29,11 +29,11 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); this.datagEntries = new System.Windows.Forms.DataGridView(); this.txtName = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -53,6 +53,7 @@ private void InitializeComponent() this.btCancelFilter = new System.Windows.Forms.Button(); this.btFilter = new System.Windows.Forms.Button(); this.btLog = new System.Windows.Forms.Button(); + this.lbEntryAmount = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.datagEntries)).BeginInit(); this.csmPath.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picWorking)).BeginInit(); @@ -60,9 +61,9 @@ private void InitializeComponent() // // datagEntries // - dataGridViewCellStyle26.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(47)))), ((int)(((byte)(47))))); - dataGridViewCellStyle26.ForeColor = System.Drawing.SystemColors.Control; - this.datagEntries.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle26; + dataGridViewCellStyle11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(47)))), ((int)(((byte)(47))))); + dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.Control; + this.datagEntries.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle11; this.datagEntries.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); @@ -70,14 +71,14 @@ private void InitializeComponent() this.datagEntries.BorderStyle = System.Windows.Forms.BorderStyle.None; this.datagEntries.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal; this.datagEntries.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle27.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); - dataGridViewCellStyle27.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle27.ForeColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle27.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle27.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle27.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.datagEntries.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle27; + dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle12.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + dataGridViewCellStyle12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.datagEntries.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle12; this.datagEntries.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.datagEntries.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.txtName, @@ -85,20 +86,20 @@ private void InitializeComponent() this.dateCreation, this.dateModification, this.txtPath}); - dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle30.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); - dataGridViewCellStyle30.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle30.ForeColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle30.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle30.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle30.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.datagEntries.DefaultCellStyle = dataGridViewCellStyle30; + dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle15.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + dataGridViewCellStyle15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.datagEntries.DefaultCellStyle = dataGridViewCellStyle15; this.datagEntries.EnableHeadersVisualStyles = false; this.datagEntries.GridColor = System.Drawing.SystemColors.ControlDarkDark; this.datagEntries.Location = new System.Drawing.Point(1, 33); this.datagEntries.Name = "datagEntries"; this.datagEntries.RowHeadersVisible = false; - this.datagEntries.Size = new System.Drawing.Size(697, 460); + this.datagEntries.Size = new System.Drawing.Size(697, 439); this.datagEntries.TabIndex = 1; this.datagEntries.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.datagEntries_CellMouseDown); // @@ -121,9 +122,9 @@ private void InitializeComponent() // // dateCreation // - dataGridViewCellStyle28.Format = "G"; - dataGridViewCellStyle28.NullValue = null; - this.dateCreation.DefaultCellStyle = dataGridViewCellStyle28; + dataGridViewCellStyle13.Format = "G"; + dataGridViewCellStyle13.NullValue = null; + this.dateCreation.DefaultCellStyle = dataGridViewCellStyle13; this.dateCreation.FillWeight = 93.27411F; this.dateCreation.HeaderText = "Creation Date"; this.dateCreation.Name = "dateCreation"; @@ -133,9 +134,9 @@ private void InitializeComponent() // // dateModification // - dataGridViewCellStyle29.Format = "G"; - dataGridViewCellStyle29.NullValue = null; - this.dateModification.DefaultCellStyle = dataGridViewCellStyle29; + dataGridViewCellStyle14.Format = "G"; + dataGridViewCellStyle14.NullValue = null; + this.dateModification.DefaultCellStyle = dataGridViewCellStyle14; this.dateModification.FillWeight = 93.27411F; this.dateModification.HeaderText = "Modification Date"; this.dateModification.Name = "dateModification"; @@ -273,13 +274,26 @@ private void InitializeComponent() this.btLog.UseVisualStyleBackColor = false; this.btLog.Click += new System.EventHandler(this.btLog_Click); // + // lbEntryAmount + // + this.lbEntryAmount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbEntryAmount.AutoSize = true; + this.lbEntryAmount.BackColor = System.Drawing.Color.Transparent; + this.lbEntryAmount.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.lbEntryAmount.Location = new System.Drawing.Point(1, 474); + this.lbEntryAmount.Name = "lbEntryAmount"; + this.lbEntryAmount.Size = new System.Drawing.Size(56, 13); + this.lbEntryAmount.TabIndex = 8; + this.lbEntryAmount.Text = "Awaiting..."; + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.ClientSize = new System.Drawing.Size(697, 494); + this.ClientSize = new System.Drawing.Size(697, 490); + this.Controls.Add(this.lbEntryAmount); this.Controls.Add(this.picWorking); this.Controls.Add(this.btTheme); this.Controls.Add(this.btCancelFilter); @@ -322,6 +336,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem moreInfoToolStripMenuItem; private System.Windows.Forms.Button btTheme; private System.Windows.Forms.PictureBox picWorking; + private System.Windows.Forms.Label lbEntryAmount; } } diff --git a/FormMain.cs b/FormMain.cs index 208ed21..9ceff3c 100644 --- a/FormMain.cs +++ b/FormMain.cs @@ -1,17 +1,12 @@ using CachedProgramsList.Data; using CachedProgramsList.Properties; -using CachedProgramsList.Register; using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; -using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -24,10 +19,26 @@ public FormMain() { InitializeComponent(); DoubleBufferedControl(datagEntries, true); + dataEntries = new Entries((DataGridViewRow)datagEntries.Rows[0].Clone()); + dataEntries.EntryAmountUpdate += dataEntries_EntryAmountUpdate; + dataEntries.WorkEnded += DataEntries_WorkEnded; + comboFilterOptions.SelectedIndex = 0; } + private void DataEntries_WorkEnded(object sender, int e) + { + lbEntryAmount.Text = $"Found {e} entries."; + } + + private void dataEntries_EntryAmountUpdate(object sender, int e) + { + lbEntryAmount.Text = $"{e} entries..."; + } + + + private void DoubleBufferedControl(DataGridView dgv, bool setting) { Type dgvType = dgv.GetType(); @@ -220,6 +231,8 @@ private void lightTheme() { BackColor = Color.FromArgb(235, 235, 235); + lbEntryAmount.ForeColor = Color.FromArgb(15, 15, 15); + datagEntries.BackgroundColor = Color.FromArgb(230, 230, 230); datagEntries.GridColor = Color.FromArgb(150, 150, 150); @@ -239,6 +252,8 @@ private void darkTheme() { BackColor = Color.FromArgb(20, 20, 20); + lbEntryAmount.ForeColor = Color.FromArgb(240, 240, 240); + datagEntries.BackgroundColor = Color.FromArgb(25, 25, 25); datagEntries.GridColor = Color.FromArgb(105, 105, 105); diff --git a/Program.cs b/Program.cs index c37bd78..a84fdce 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; namespace CachedProgramsList diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 8661733..641d79f 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // As informações gerais sobre um assembly são controladas por diff --git a/Register/Entry.cs b/Register/Entry.cs index 1200000..8dd9873 100644 --- a/Register/Entry.cs +++ b/Register/Entry.cs @@ -1,12 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Windows.Forms; -using Microsoft.Win32; namespace CachedProgramsList.Register { @@ -16,7 +10,7 @@ class Entry private bool valid = false, exists = false; private DateTime creation, modification; public string Path { get => path; } - public bool Valid { get => valid; } + public bool Valid { get => valid; } public bool Exists { get => exists; } public DateTime Creation { get => creation; } public DateTime Modification { get => modification; } diff --git a/Register/Key.cs b/Register/Key.cs index ec1ecd5..33b9147 100644 --- a/Register/Key.cs +++ b/Register/Key.cs @@ -1,9 +1,6 @@ using Microsoft.Win32; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace CachedProgramsList.Register @@ -22,10 +19,10 @@ public List getEntries() try { string[] keyValues = Registry.CurrentUser.OpenSubKey(key).GetValueNames(); - foreach(string keyValue in keyValues) + foreach (string keyValue in keyValues) { - Entry valueEntry = new Entry(keyValue); - entries.Add(valueEntry); + Entry valueEntry = new Entry(keyValue); + entries.Add(valueEntry); } } catch (Exception e)