-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pptimized estimation prediction Fixed bug with source selection availability Fixed parsing raw output regex bug Partial raw output localization light UI improvements
- Loading branch information
Showing
30 changed files
with
1,600 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#nullable enable | ||
|
||
|
||
namespace SDeleteGUI.Core.SDelete | ||
{ | ||
|
||
internal class DataReceivedEventArgsEx : System.EventArgs | ||
{ | ||
|
||
#region OutputLocalization | ||
|
||
|
||
private const string C_METHOD_TryParse = "TryParse"; | ||
//Get all classes from 'SDeleteGUI.Core.SDelete.OutputLocalization' namespace which have static|public TryParse() method | ||
private static Lazy<MethodInfo[]> _localizedOutputParsers = new(() => | ||
Assembly | ||
.GetExecutingAssembly() | ||
.GetTypes() | ||
.Where( | ||
t => | ||
t.Namespace == typeof(OutputLocalization.Progress_BaseEventArgs).Namespace | ||
&& !t.IsAbstract | ||
&& t.GetMember(C_METHOD_TryParse, BindingFlags.Static | BindingFlags.Public).Any() | ||
) | ||
.Select(t => (System.Reflection.MethodInfo)t.GetMember(C_METHOD_TryParse, BindingFlags.Static | BindingFlags.Public).First()) | ||
.ToArray()); | ||
|
||
#endregion | ||
|
||
|
||
public DateTime Timestamp { get; private set; } = DateTime.Now; | ||
public readonly string RAWData = string.Empty; | ||
|
||
|
||
public DataReceivedEventArgsEx(string data) : base() | ||
{ | ||
this.RAWData = data; | ||
} | ||
|
||
|
||
public void UpdateTimestamp(DateTime newTimestamp) | ||
{ | ||
Timestamp = newTimestamp; | ||
RecalculateEstimation(); | ||
} | ||
|
||
|
||
protected virtual void RecalculateEstimation() { } | ||
|
||
|
||
public override string ToString() => RAWData; | ||
|
||
|
||
public static DataReceivedEventArgsEx Parse(DataReceivedEventArgs e) | ||
{ | ||
string rawDada = e.Data; | ||
|
||
#if DEBUG | ||
Debug.Write($"Parsing RAW '{rawDada}'... "); | ||
#endif | ||
DataReceivedEventArgsEx? dreax = null; | ||
try | ||
{ | ||
|
||
var lop = _localizedOutputParsers.Value; | ||
foreach (var miTryParse in lop) | ||
{ | ||
var input = new object[] { rawDada, null }; | ||
if ((bool)miTryParse.Invoke(null, input)) | ||
{ | ||
dreax = (DataReceivedEventArgsEx)input[1]; | ||
break; | ||
} | ||
} | ||
|
||
/* OLD | ||
if (OutputLocalization.Header_CleaningPhyDiskEventArgs.TryParse(rawDada, out var hdr_pd)) | ||
dreax = hdr_pd; | ||
else if (OutputLocalization.Header_PassInfoEventArgs.TryParse(rawDada, out var hdr_pi)) | ||
dreax = hdr_pi; | ||
else if (OutputLocalization.Progress_VolumeFreeSpace_ZeroingFreeSpace.TryParse(rawDada, out var vol_pi)) | ||
dreax = vol_pi; | ||
else if (OutputLocalization.Progress_PhyDisk_ProgressEventArgs.TryParse(rawDada, out var pri)) | ||
dreax = pri; | ||
*/ | ||
|
||
} | ||
catch (Exception ex) | ||
{ | ||
#if DEBUG | ||
Debug.WriteLine($"*** ERROR DataReceivedEventArgsEx.Parse: {ex}"); | ||
#endif | ||
} | ||
|
||
dreax ??= new DataReceivedEventArgsEx(rawDada); | ||
#if DEBUG | ||
Debug.WriteLine(dreax.ToString()); | ||
#endif | ||
return dreax!; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
46 changes: 46 additions & 0 deletions
46
SDeleteGUI/Core/SDelete/OutputLocalization/Header_CleaningPhyDiskEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#nullable enable | ||
|
||
namespace SDeleteGUI.Core.SDelete.OutputLocalization | ||
{ | ||
internal class Header_CleaningPhyDiskEventArgs : DataReceivedEventArgsEx | ||
{ | ||
|
||
private const string C_PREFIX = "Cleaning disk "; | ||
|
||
//Cleaning disk 6: | ||
private static readonly Regex _rx = new(@"Cleaning \s disk \s (?<DiskNumber>\d+)\:", | ||
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); | ||
|
||
|
||
public readonly uint DiskNumber; | ||
|
||
|
||
internal Header_CleaningPhyDiskEventArgs(string raw, uint passCount) : base(raw) => DiskNumber = passCount; | ||
|
||
|
||
public static bool TryParse(string raw, out Header_CleaningPhyDiskEventArgs? piea) | ||
{ | ||
piea = null; | ||
|
||
if (!raw.StartsWith(C_PREFIX, StringComparison.InvariantCultureIgnoreCase)) return false; | ||
|
||
Match? mx = _rx.Match(raw.Trim()); | ||
if (!mx?.Success ?? false) return false; | ||
|
||
GroupCollection rGroups = mx!.Groups; | ||
piea = new(raw, uint.Parse(rGroups["DiskNumber"].Value)); | ||
return true; | ||
} | ||
|
||
|
||
public override string ToString() | ||
{ | ||
string localizedFormat = Localization.Strings.M_OUTPUT_LOCALIZATION_PHY_DISK_NO; | ||
|
||
return localizedFormat.e_IsNullOrWhiteSpace() | ||
? RAWData | ||
: localizedFormat.e_Format(DiskNumber); | ||
} | ||
|
||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
SDeleteGUI/Core/SDelete/OutputLocalization/Header_PassInfoEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#nullable enable | ||
|
||
namespace SDeleteGUI.Core.SDelete.OutputLocalization | ||
{ | ||
internal class Header_PassInfoEventArgs : DataReceivedEventArgsEx | ||
{ | ||
|
||
private const string C_PREFIX = "SDelete is set for "; | ||
|
||
//SDelete is set for 1 pass. | ||
private static readonly Regex _rx = new(@".+ set \s for \s (?<PassCount>\d+) \s pass", | ||
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); | ||
|
||
|
||
public readonly uint PassCount; | ||
|
||
|
||
internal Header_PassInfoEventArgs(string raw, uint passCount) : base(raw) => PassCount = passCount; | ||
|
||
|
||
public static bool TryParse(string raw, out Header_PassInfoEventArgs? piea) | ||
{ | ||
piea = null; | ||
|
||
if (!raw.StartsWith(C_PREFIX, StringComparison.InvariantCultureIgnoreCase)) return false; | ||
|
||
Match? mx = _rx.Match(raw.Trim()); | ||
if (!mx?.Success ?? false) return false; | ||
|
||
GroupCollection rGroups = mx!.Groups; | ||
piea = new(raw, uint.Parse(rGroups["PassCount"].Value)); | ||
return true; | ||
} | ||
|
||
|
||
public override string ToString() | ||
{ | ||
string localizedFormat = Localization.Strings.M_OUTPUT_LOCALIZATION_PASS_COUNT; | ||
|
||
return localizedFormat.e_IsNullOrWhiteSpace() | ||
? RAWData | ||
: localizedFormat.e_Format(PassCount); | ||
} | ||
|
||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
SDeleteGUI/Core/SDelete/OutputLocalization/Progress_BaseEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#nullable enable | ||
|
||
namespace SDeleteGUI.Core.SDelete.OutputLocalization | ||
{ | ||
internal abstract class Progress_BaseEventArgs : DataReceivedEventArgsEx | ||
{ | ||
public readonly uint CurrentOperationProgressPercent; | ||
|
||
internal Progress_BaseEventArgs(string raw, uint currentOperationProgressPercent) : base(raw) | ||
=> CurrentOperationProgressPercent = currentOperationProgressPercent; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
SDeleteGUI/Core/SDelete/OutputLocalization/Progress_DirOrFile_Deleted.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#nullable enable | ||
|
||
namespace SDeleteGUI.Core.SDelete.OutputLocalization | ||
{ | ||
|
||
/* | ||
T:\file.txt...deleted. | ||
T:\folder...deleted. | ||
*/ | ||
internal class Progress_DirOrFile_Deleted : DataReceivedEventArgsEx | ||
{ | ||
private const string C_SUFFIX = "...deleted."; | ||
|
||
public readonly string FileSystemObject; | ||
|
||
|
||
internal Progress_DirOrFile_Deleted(string raw, string fileSystemObject) : base(raw) | ||
=> FileSystemObject = fileSystemObject; | ||
|
||
|
||
public static bool TryParse(string raw, out Progress_DirOrFile_Deleted? piea) | ||
{ | ||
piea = null; | ||
|
||
if (!(raw.EndsWith(C_SUFFIX, StringComparison.InvariantCultureIgnoreCase) && (raw.Length >= C_SUFFIX.Length))) return false; | ||
string fileSystemObject = raw.Substring(0, raw.Length - C_SUFFIX.Length); | ||
|
||
piea = new(raw, fileSystemObject); | ||
return true; | ||
} | ||
|
||
|
||
public override string ToString() | ||
{ | ||
string localizedFormat = Localization.Strings.M_OUTPUT_LOCALIZATION_FSO_DELETED; | ||
|
||
return localizedFormat.e_IsNullOrWhiteSpace() | ||
? RAWData | ||
: localizedFormat.e_Format(FileSystemObject); | ||
} | ||
} | ||
} |
Oops, something went wrong.