Skip to content

Commit be4078f

Browse files
authored
Merge pull request #101 from Smurf-IV/79-MissingTooltip
- Fix text and icon
2 parents 0177c1f + bd732b0 commit be4078f

19 files changed

Lines changed: 3257 additions & 3259 deletions

Elucidate/Elucidate.sln.DotSettings

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
55
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
66
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
7+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=236f7aa5_002D7b06_002D43ca_002Dbf2a_002D9b31bfcff09a/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
8+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
9+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
10+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
711
<s:Boolean x:Key="/Default/UserDictionary/Words/=autodetected/@EntryIndexedValue">True</s:Boolean>
812
<s:Boolean x:Key="/Default/UserDictionary/Words/=autosave/@EntryIndexedValue">True</s:Boolean>
913
<s:Boolean x:Key="/Default/UserDictionary/Words/=blocksize/@EntryIndexedValue">True</s:Boolean>
14+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Boskys/@EntryIndexedValue">True</s:Boolean>
1015
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coghlan/@EntryIndexedValue">True</s:Boolean>
1116
<s:Boolean x:Key="/Default/UserDictionary/Words/=hashsize/@EntryIndexedValue">True</s:Boolean>
1217
<s:Boolean x:Key="/Default/UserDictionary/Words/=kibi/@EntryIndexedValue">True</s:Boolean>

Elucidate/Elucidate/Controls/LogsViewerControl.cs

Lines changed: 190 additions & 191 deletions
Large diffs are not rendered by default.
Lines changed: 138 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#region Copyright (C)
22
// <copyright file="ProtectedDrivesDisplay.cs" company="Smurf-IV">
33
//
4-
// Copyright (C) 2019-2021 Smurf-IV
4+
// Copyright (C) 2019-2025 Smurf-IV
55
//
66
// This program is free software: you can redistribute it and/or modify
77
// it under the terms of the GNU General Public License as published by
@@ -36,188 +36,186 @@
3636

3737
using NLog;
3838

39-
namespace Elucidate.Controls
39+
namespace Elucidate.Controls;
40+
41+
internal partial class ProtectedDrivesDisplay : UserControl
4042
{
41-
internal partial class ProtectedDrivesDisplay : UserControl
43+
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
44+
private CancellationTokenSource cancelTokenSrc;
45+
46+
private volatile int useWaitCursor;
47+
48+
internal ProtectedDrivesDisplay()
4249
{
43-
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
44-
private CancellationTokenSource cancelTokenSrc;
50+
InitializeComponent();
51+
cancelTokenSrc = new CancellationTokenSource();
52+
}
4553

46-
private volatile int useWaitCursor;
54+
internal void StopProcessing()
55+
{
56+
// have to stop "any" processes that might be refreshing as this is now closing
57+
cancelTokenSrc.Cancel();
58+
}
4759

48-
internal ProtectedDrivesDisplay()
60+
private void IncrementWaitCursor()
61+
{
62+
if (Interlocked.Increment(ref useWaitCursor) == 1)
4963
{
50-
InitializeComponent();
51-
cancelTokenSrc = new CancellationTokenSource();
64+
BeginInvoke((MethodInvoker)(() => UseWaitCursor = true));
5265
}
66+
}
5367

54-
internal void StopProcessing()
68+
private void DecrementWaitCursor()
69+
{
70+
if (Interlocked.Decrement(ref useWaitCursor) <= 0)
5571
{
56-
// have to stop "any" processes that might be refreshing as this is now closing
57-
cancelTokenSrc.Cancel();
72+
BeginInvoke((MethodInvoker)(() => UseWaitCursor = false));
5873
}
74+
}
5975

60-
private void IncrementWaitCursor()
76+
/// <summary>
77+
/// Take an existing config file and populate the Grid
78+
/// </summary>
79+
/// <param name="srConfig"></param>
80+
/// <param name="excludeParity"></param>
81+
public void RefreshGrid(ConfigFileHelper srConfig, bool excludeParity)
82+
{
83+
Interlocked.Exchange(ref useWaitCursor, 0);
84+
IncrementWaitCursor();
85+
// have to stop "any" processes that might be refreshing as this is a new list
86+
cancelTokenSrc.Cancel();
87+
while (driveGrid.Rows.Count > 1) // Got to leave the "New" edit row
6188
{
62-
if (Interlocked.Increment(ref useWaitCursor) == 1)
89+
driveGrid.Rows.RemoveAt(0);
90+
}
91+
var pathsOfInterest = srConfig.GetPathsOfInterest();
92+
cancelTokenSrc = new CancellationTokenSource();
93+
if (excludeParity)
94+
{
95+
foreach (CoveragePath coveragePath in pathsOfInterest.Where(static s => s.PathType == PathTypeEnum.Source))
6396
{
64-
BeginInvoke((MethodInvoker)(() => UseWaitCursor = true));
97+
AddCoverage(coveragePath);
6598
}
6699
}
100+
else
101+
{
102+
pathsOfInterest.ForEach(AddCoverage);
103+
}
104+
105+
DecrementWaitCursor();
106+
}
67107

68-
private void DecrementWaitCursor()
108+
public void AddCoverage(CoveragePath coveragePath)
109+
{
110+
var row = (DataGridViewRow)driveGrid.RowTemplate.Clone()!;
111+
row.CreateCells(driveGrid, coveragePath.FullPath, coveragePath.Name, null, @"Processing");
112+
row.Tag = coveragePath;
113+
driveGrid.Rows.Add(row);
114+
}
115+
116+
private void driveGrid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
117+
{
118+
if (!cancelTokenSrc.IsCancellationRequested)
69119
{
70-
if (Interlocked.Decrement(ref useWaitCursor) <= 0)
120+
for (var index = e.RowIndex; index < e.RowIndex + e.RowCount; index++)
71121
{
72-
BeginInvoke((MethodInvoker)(() => UseWaitCursor = false));
122+
// Get data to perform drive usage display
123+
DataGridViewRow row = driveGrid.Rows[index];
124+
StartDriveUsage(row, cancelTokenSrc.Token);
73125
}
74126
}
127+
}
75128

76-
/// <summary>
77-
/// Take an existing config file and populate the Grid
78-
/// </summary>
79-
/// <param name="srConfig"></param>
80-
/// <param name="excludeParity"></param>
81-
public void RefreshGrid(ConfigFileHelper srConfig, bool excludeParity)
129+
private void StartDriveUsage(DataGridViewRow row, CancellationToken token)
130+
{
131+
if (row.Tag is CoveragePath coveragePath)
82132
{
83-
Interlocked.Exchange(ref useWaitCursor, 0);
84-
IncrementWaitCursor();
85-
// have to stop "any" processes that might be refreshing as this is a new list
86-
cancelTokenSrc.Cancel();
87-
while (driveGrid.Rows.Count > 1) // Got to leave the "New" edit row
88-
{
89-
driveGrid.Rows.RemoveAt(0);
90-
}
91-
var pathsOfInterest = srConfig.GetPathsOfInterest();
92-
cancelTokenSrc = new CancellationTokenSource();
93-
if (excludeParity)
133+
var dirInfo = new DirectoryInfo(coveragePath.DirectoryPath, PathFormat.FullPath);
134+
var driveInfo = new DriveInfo(dirInfo.Root.FullName);
135+
if (coveragePath.PathType == PathTypeEnum.Parity)
94136
{
95-
foreach (CoveragePath coveragePath in pathsOfInterest.Where(static s => s.PathType == PathTypeEnum.Source))
96-
{
97-
AddCoverage(coveragePath);
98-
}
137+
var totalUsed = driveInfo.TotalSize - driveInfo.AvailableFreeSpace;
138+
var protectedUse = File.Exists(coveragePath.FullPath) ? new FileInfo(coveragePath.FullPath).Length : 0L;
139+
row.Cells[2].Value = $@"{protectedUse}:{totalUsed}:{driveInfo.TotalSize}";
140+
row.Cells[3].Value = $@"{new ByteSize(protectedUse)} : {new ByteSize(totalUsed)} : {new ByteSize(driveInfo.TotalSize)}";
99141
}
100142
else
101143
{
102-
pathsOfInterest.ForEach(AddCoverage);
144+
// Start background processing
145+
IncrementWaitCursor();
146+
Task.Run(() => ProcessProtectedSpace(row, driveInfo, dirInfo, token), token);
103147
}
104-
105-
DecrementWaitCursor();
106148
}
149+
}
107150

108-
public void AddCoverage(CoveragePath coveragePath)
109-
{
110-
DataGridViewRow row = (DataGridViewRow)driveGrid.RowTemplate.Clone();
111-
row.CreateCells(driveGrid, coveragePath.FullPath, coveragePath.Name, null, @"Processing");
112-
row.Tag = coveragePath;
113-
driveGrid.Rows.Add(row);
114-
}
151+
private void ProcessProtectedSpace(DataGridViewRow row, DriveInfo driveInfo,
152+
DirectoryInfo dirInfo, CancellationToken token)
153+
{
154+
var totalUsed = driveInfo.TotalSize - driveInfo.AvailableFreeSpace;
115155

116-
private void driveGrid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
156+
var protectedUse = DirSize(dirInfo, token);
157+
if (!token.IsCancellationRequested)
117158
{
118-
if (!cancelTokenSrc.IsCancellationRequested)
119-
{
120-
for (var index = e.RowIndex; index < e.RowIndex + e.RowCount; index++)
121-
{
122-
// Get data to perform drive usage display
123-
DataGridViewRow row = driveGrid.Rows[index];
124-
StartDriveUsage(row, cancelTokenSrc.Token);
125-
}
126-
}
159+
BeginInvoke((MethodInvoker)delegate
160+
{
161+
try
162+
{
163+
row.Cells[2].Value = $@"{protectedUse}:{totalUsed}:{driveInfo.TotalSize}";
164+
row.Cells[3].Value =
165+
$@"{new ByteSize(protectedUse)} : {new ByteSize(totalUsed)} : {new ByteSize(driveInfo.TotalSize)}";
166+
}
167+
catch
168+
{
169+
// Do nothing
170+
// Might be caused by fast closure
171+
}
172+
});
127173
}
128174

129-
private void StartDriveUsage(DataGridViewRow row, CancellationToken token)
175+
DecrementWaitCursor();
176+
}
177+
178+
/// <summary>
179+
/// Recursive and allow cancellation
180+
/// </summary>
181+
/// <param name="dir"></param>
182+
/// <param name="token"></param>
183+
/// <returns></returns>
184+
private static ulong DirSize(DirectoryInfo dir, CancellationToken token)
185+
{
186+
try
130187
{
131-
if (row.Tag is CoveragePath coveragePath)
188+
if (token.IsCancellationRequested)
132189
{
133-
var dirInfo = new DirectoryInfo(coveragePath.DirectoryPath, PathFormat.FullPath);
134-
var driveInfo = new DriveInfo(dirInfo.Root.FullName);
135-
if (coveragePath.PathType == PathTypeEnum.Parity)
136-
{
137-
var totalUsed = driveInfo.TotalSize - driveInfo.AvailableFreeSpace;
138-
var protectedUse = File.Exists(coveragePath.FullPath) ? new FileInfo(coveragePath.FullPath).Length : 0L;
139-
row.Cells[2].Value = $@"{protectedUse}:{totalUsed}:{driveInfo.TotalSize}";
140-
row.Cells[3].Value = $@"{new ByteSize(protectedUse)} : {new ByteSize(totalUsed)} : {new ByteSize(driveInfo.TotalSize)}";
141-
}
142-
else
143-
{
144-
// Start background processing
145-
IncrementWaitCursor();
146-
Task.Run(() => ProcessProtectedSpace(row, driveInfo, dirInfo, token), token);
147-
}
190+
return 0UL;
148191
}
149192

193+
return dir.EnumerateFiles().AsParallel().Sum(static fi => (ulong)fi.Length)
194+
+ dir.EnumerateDirectories()
195+
.Where(static d => (d.Attributes & System.IO.FileAttributes.System) == 0
196+
&& (d.Attributes & System.IO.FileAttributes.Hidden) == 0)
197+
.AsParallel()
198+
.Sum(info => DirSize(info, token));
150199
}
151-
152-
private void ProcessProtectedSpace(DataGridViewRow row, DriveInfo driveInfo,
153-
DirectoryInfo dirInfo, CancellationToken token)
200+
catch (UnauthorizedAccessException ex)
154201
{
155-
var totalUsed = driveInfo.TotalSize - driveInfo.AvailableFreeSpace;
156-
157-
var protectedUse = DirSize(dirInfo, token);
158-
if (!token.IsCancellationRequested)
159-
{
160-
BeginInvoke((MethodInvoker)delegate
161-
{
162-
try
163-
{
164-
row.Cells[2].Value = $@"{protectedUse}:{totalUsed}:{driveInfo.TotalSize}";
165-
row.Cells[3].Value =
166-
$@"{new ByteSize(protectedUse)} : {new ByteSize(totalUsed)} : {new ByteSize(driveInfo.TotalSize)}";
167-
}
168-
catch
169-
{
170-
// Do nothing
171-
// Might be caused by fast closure
172-
}
173-
});
174-
}
175-
176-
DecrementWaitCursor();
202+
Log.Warn(ex, @"No Access to [{0}]", dir.FullName);
177203
}
178-
179-
/// <summary>
180-
/// Recursive and allow cancellation
181-
/// </summary>
182-
/// <param name="dir"></param>
183-
/// <param name="token"></param>
184-
/// <returns></returns>
185-
private static ulong DirSize(DirectoryInfo dir, CancellationToken token)
204+
catch (Exception ex)
186205
{
187-
try
188-
{
189-
if (token.IsCancellationRequested)
190-
{
191-
return 0UL;
192-
}
193-
194-
return dir.EnumerateFiles().AsParallel().Sum(static fi => (ulong)fi.Length)
195-
+ dir.EnumerateDirectories()
196-
.Where(static d => (d.Attributes & System.IO.FileAttributes.System) == 0
197-
&& (d.Attributes & System.IO.FileAttributes.Hidden) == 0)
198-
.AsParallel()
199-
.Sum(info => DirSize(info, token));
200-
}
201-
catch (UnauthorizedAccessException ex)
202-
{
203-
Log.Warn(ex, @"No Access to [{0}]", dir.FullName);
204-
}
205-
catch (Exception ex)
206-
{
207-
Log.Warn(ex);
208-
}
209-
210-
return 0UL;
206+
Log.Warn(ex);
211207
}
212208

213-
private void DriveGrid_MouseDown(object sender, MouseEventArgs e)
209+
return 0UL;
210+
}
211+
212+
private void DriveGrid_MouseDown(object sender, MouseEventArgs e)
213+
{
214+
if (e.Button == MouseButtons.Right)
214215
{
215-
if (e.Button == MouseButtons.Right)
216-
{
217-
DataGridView.HitTestInfo hti = driveGrid.HitTest(e.X, e.Y);
218-
driveGrid.ClearSelection();
219-
driveGrid.Rows[hti.RowIndex].Selected = true;
220-
}
216+
DataGridView.HitTestInfo hti = driveGrid.HitTest(e.X, e.Y);
217+
driveGrid.ClearSelection();
218+
driveGrid.Rows[hti.RowIndex].Selected = true;
221219
}
222220
}
223221
}

0 commit comments

Comments
 (0)