Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

feat: add error detail support and enhance result dialog UI

fatDuck8b72f7da5975
diff --git a/optimizerDuck/Domain/Execution/ExecutionScope.cs b/optimizerDuck/Domain/Execution/ExecutionScope.cs
index bfeea12..3492085 100644
--- a/optimizerDuck/Domain/Execution/ExecutionScope.cs
+++ b/optimizerDuck/Domain/Execution/ExecutionScope.cs
@@ -172,7 +172,8 @@ public sealed class ExecutionScope : IDisposable
bool success,
IRevertStep? revertStep = null,
string? error = null,
- Func<Task<bool>>? retryAction = null
+ Func<Task<bool>>? retryAction = null,
+ string? errorDetail = null
)
{
var scope = Current;
@@ -183,7 +184,8 @@ public sealed class ExecutionScope : IDisposable
success,
revertStep,
error,
- retryAction
+ retryAction,
+ errorDetail
);
}
@@ -194,7 +196,8 @@ public sealed class ExecutionScope : IDisposable
bool success,
IRevertStep? revertStep = null,
string? error = null,
- Func<Task<bool>>? retryAction = null
+ Func<Task<bool>>? retryAction = null,
+ string? errorDetail = null
)
{
var scope = Current;
@@ -206,6 +209,7 @@ public sealed class ExecutionScope : IDisposable
revertStep,
error,
retryAction,
+ errorDetail,
explicitIndex: index
);
}
@@ -283,6 +287,7 @@ public sealed class ExecutionScope : IDisposable
IRevertStep? revertStep,
string? error,
Func<Task<bool>>? retryAction = null,
+ string? errorDetail = null,
int? explicitIndex = null
)
{
@@ -298,7 +303,8 @@ public sealed class ExecutionScope : IDisposable
success,
revertStep,
error,
- retryAction
+ retryAction,
+ errorDetail
);
_executedSteps.Add(step);
@@ -328,6 +334,7 @@ public sealed class ExecutionScope : IDisposable
Description = step.Description,
Success = step.Success,
Error = step.Error,
+ ErrorDetail = step.ErrorDetail,
RetryAction = step.RetryAction,
RevertStep = step.RevertStep,
};
@@ -389,7 +396,8 @@ public sealed record ExecutedStep
bool success,
IRevertStep? revertStep,
string? error,
- Func<Task<bool>>? retryAction = null
+ Func<Task<bool>>? retryAction = null,
+ string? errorDetail = null
)
{
Index = index;
@@ -399,6 +407,7 @@ public sealed record ExecutedStep
RevertStep = revertStep;
Error = error;
RetryAction = retryAction;
+ ErrorDetail = errorDetail;
}
/// <summary>
@@ -431,6 +440,11 @@ public sealed record ExecutedStep
/// </summary>
public string? Error { get; init; }
+ /// <summary>
+ /// Detailed error information (exception details) for the step failure.
+ /// </summary>
+ public string? ErrorDetail { get; init; }
+
/// <summary>
/// An optional action to retry this step if it failed.
/// </summary>
diff --git a/optimizerDuck/Domain/Optimizations/Categories/UserExperience.cs b/optimizerDuck/Domain/Optimizations/Categories/UserExperience.cs
index 64628c4..cd79f99 100644
--- a/optimizerDuck/Domain/Optimizations/Categories/UserExperience.cs
+++ b/optimizerDuck/Domain/Optimizations/Categories/UserExperience.cs
@@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using optimizerDuck.Domain.Abstractions;
using optimizerDuck.Domain.Attributes;
+using optimizerDuck.Domain.Execution;
using optimizerDuck.Domain.Optimizations.Models;
using optimizerDuck.Domain.Optimizations.Models.Services;
using optimizerDuck.Domain.UI;
@@ -78,4 +79,67 @@ public class UserExperience : IOptimizationCategory
return Task.FromResult(CompleteFromScope());
}
}
+
+ [Optimization(
+ Id = "11111111-1111-1111-1111-111111111111",
+ Risk = OptimizationRisk.Safe,
+ Tags = OptimizationTags.System
+ )]
+ public sealed class TestPass : BaseOptimization
+ {
+ public override Task<ApplyResult> ApplyAsync(
+ IProgress<ProcessingProgress> progress,
+ OptimizationContext context
+ )
+ {
+ ExecutionScope.RecordStep("Test", "Step 1 — succeeds", true);
+ ExecutionScope.RecordStep("Test", "Step 2 — succeeds", true);
+ context.Logger.LogInformation("Test: all steps pass");
+ return Task.FromResult(CompleteFromScope());
+ }
+ }
+
+ [Optimization(
+ Id = "22222222-2222-2222-2222-222222222222",
+ Risk = OptimizationRisk.Moderate,
+ Tags = OptimizationTags.System
+ )]
+ public sealed class TestAllFail : BaseOptimization
+ {
+ public override Task<ApplyResult> ApplyAsync(
+ IProgress<ProcessingProgress> progress,
+ OptimizationContext context
+ )
+ {
+ ExecutionScope.RecordStep("Test", "Step 1 — fails", false, null, "Something went wrong");
+ ExecutionScope.RecordStep("Test", "Step 2 — also fails", false, null, "Access denied");
+ context.Logger.LogInformation("Test: all steps fail");
+ return Task.FromResult(CompleteFromScope());
+ }
+ }
+
+ [Optimization(
+ Id = "33333333-3333-3333-3333-333333333333",
+ Risk = OptimizationRisk.Risky,
+ Tags = OptimizationTags.System | OptimizationTags.Performance
+ )]
+ public sealed class TestPartialFail : BaseOptimization
+ {
+ public override Task<ApplyResult> ApplyAsync(
+ IProgress<ProcessingProgress> progress,
+ OptimizationContext context
+ )
+ {
+ ExecutionScope.RecordStep("Test", "Step 1 — succeeds", true);
+ ExecutionScope.RecordStep("Test", "Step 2 — fails", false, null,
+ "Something went wrong", null,
+ "System.UnauthorizedAccessException: Access to the registry path is denied.\n at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)\n at optimizerDuck.Services.OptimizationServices.RegistryService.Write(RegistryItem item)");
+ ExecutionScope.RecordStep("Test", "Step 3 — succeeds", true);
+ ExecutionScope.RecordStep("Test", "Step 4 — fails", false, null,
+ "Access denied", null,
+ "System.UnauthorizedAccessException: Access is not granted.\n at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)\n at optimizerDuck.Services.OptimizationServices.RegistryService.DeleteValue(RegistryItem item)");
+ context.Logger.LogInformation("Test: partial steps fail");
+ return Task.FromResult(CompleteFromScope());
+ }
+ }
}
diff --git a/optimizerDuck/Domain/Optimizations/Models/OperationStepResult.cs b/optimizerDuck/Domain/Optimizations/Models/OperationStepResult.cs
index a8e7b8d..c09c2a0 100644
--- a/optimizerDuck/Domain/Optimizations/Models/OperationStepResult.cs
+++ b/optimizerDuck/Domain/Optimizations/Models/OperationStepResult.cs
@@ -32,6 +32,11 @@ public record OperationStepResult
/// </summary>
public string? Error { get; init; }
+ /// <summary>
+ /// Detailed error information (exception details) for the step failure.
+ /// </summary>
+ public string? ErrorDetail { get; init; }
+
/// <summary>
/// An optional action to retry this step.
/// </summary>
diff --git a/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs b/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs
index 8c99767..90f76fc 100644
--- a/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs
+++ b/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs
@@ -102,7 +102,7 @@ public class RegistryRevertStep : IRevertStep
};
if (!result)
- throw new Exception(string.Format(Translations.Service_Common_Error_AccessDenied)); // Generic for now, but better than nothing
+ throw new Exception(string.Format(Translations.Revert_Error_StepFailed) + $": {Description}");
// Cleanup empty subkeys if they were created during apply
if (result && CreatedSubKeys?.Count > 0)
diff --git a/optimizerDuck/Resources/Languages/Translations.Designer.cs b/optimizerDuck/Resources/Languages/Translations.Designer.cs
index 959ecfd..7210e77 100644
--- a/optimizerDuck/Resources/Languages/Translations.Designer.cs
+++ b/optimizerDuck/Resources/Languages/Translations.Designer.cs
@@ -2518,6 +2518,15 @@ namespace optimizerDuck.Resources.Languages {
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Details.
+ /// </summary>
+ internal static string OptimizationResultDialog_Details {
+ get {
+ return ResourceManager.GetString("OptimizationResultDialog.Details", resourceCulture);
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to {0} Failed steps.
/// </summary>
@@ -4196,6 +4205,42 @@ namespace optimizerDuck.Resources.Languages {
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Access denied writing {0}:{1}.
+ /// </summary>
+ internal static string Service_Registry_ErrorDetail_AccessDeniedWrite {
+ get {
+ return ResourceManager.GetString("Service.Registry.ErrorDetail.AccessDeniedWrite", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Access denied deleting {0}:{1}.
+ /// </summary>
+ internal static string Service_Registry_ErrorDetail_AccessDeniedDelete {
+ get {
+ return ResourceManager.GetString("Service.Registry.ErrorDetail.AccessDeniedDelete", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Access denied creating {0}.
+ /// </summary>
+ internal static string Service_Registry_ErrorDetail_AccessDeniedCreateKey {
+ get {
+ return ResourceManager.GetString("Service.Registry.ErrorDetail.AccessDeniedCreateKey", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Access denied deleting key tree {0}.
+ /// </summary>
+ internal static string Service_Registry_ErrorDetail_AccessDeniedDeleteKeyTree {
+ get {
+ return ResourceManager.GetString("Service.Registry.ErrorDetail.AccessDeniedDeleteKeyTree", resourceCulture);
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Unauthorized access.
/// </summary>
@@ -4223,6 +4268,24 @@ namespace optimizerDuck.Resources.Languages {
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Access denied disabling task {0}.
+ /// </summary>
+ internal static string Service_ScheduledTask_ErrorDetail_AccessDeniedDisable {
+ get {
+ return ResourceManager.GetString("Service.ScheduledTask.ErrorDetail.AccessDeniedDisable", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Access denied enabling task {0}.
+ /// </summary>
+ internal static string Service_ScheduledTask_ErrorDetail_AccessDeniedEnable {
+ get {
+ return ResourceManager.GetString("Service.ScheduledTask.ErrorDetail.AccessDeniedEnable", resourceCulture);
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Enable scheduled task: {0}.
/// </summary>
diff --git a/optimizerDuck/Resources/Languages/Translations.resx b/optimizerDuck/Resources/Languages/Translations.resx
index bf1b0e9..b7d161b 100644
--- a/optimizerDuck/Resources/Languages/Translations.resx
+++ b/optimizerDuck/Resources/Languages/Translations.resx
@@ -415,6 +415,18 @@
<data name="Service.Registry.Error.CreateOrOpenSubkeyFailed" xml:space="preserve">
<value>Failed to create/open subkey</value>
</data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedWrite" xml:space="preserve">
+ <value>Access denied writing {0}:{1}</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDelete" xml:space="preserve">
+ <value>Access denied deleting {0}:{1}</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedCreateKey" xml:space="preserve">
+ <value>Access denied creating {0}</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDeleteKeyTree" xml:space="preserve">
+ <value>Access denied deleting key tree {0}</value>
+ </data>
<data name="Service.Service.Error.NotFound" xml:space="preserve">
<value>Service not found</value>
</data>
@@ -442,6 +454,9 @@
<data name="OptimizationResultDialog.Description" xml:space="preserve">
<value>Some steps didn't complete successfully. You can retry only the failed steps.</value>
</data>
+ <data name="OptimizationResultDialog.Details" xml:space="preserve">
+ <value>Details</value>
+ </data>
<data name="Button.Retry" xml:space="preserve">
<value>Retry</value>
</data>
@@ -1557,6 +1572,12 @@ Update now to enjoy the latest features, improvements, and bug fixes.</value>
<data name="Service.ScheduledTask.Description.Disable" xml:space="preserve">
<value>Disable scheduled task: {0}</value>
</data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedDisable" xml:space="preserve">
+ <value>Access denied disabling task {0}</value>
+ </data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedEnable" xml:space="preserve">
+ <value>Access denied enabling task {0}</value>
+ </data>
<data name="Revert.Registry.Description.Restore" xml:space="preserve">
<value>Restore registry value: {0}\{1}</value>
</data>
diff --git a/optimizerDuck/Resources/Languages/Translations.vi-VN.resx b/optimizerDuck/Resources/Languages/Translations.vi-VN.resx
index df8d951..6c21bdb 100644
--- a/optimizerDuck/Resources/Languages/Translations.vi-VN.resx
+++ b/optimizerDuck/Resources/Languages/Translations.vi-VN.resx
@@ -412,6 +412,18 @@
<data name="Service.Registry.Error.CreateOrOpenSubkeyFailed" xml:space="preserve">
<value>Không thể tạo/mở khóa con (subkey)</value>
</data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedWrite" xml:space="preserve">
+ <value>Từ chối truy cập khi ghi {0}:{1}</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDelete" xml:space="preserve">
+ <value>Từ chối truy cập khi xóa {0}:{1}</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedCreateKey" xml:space="preserve">
+ <value>Từ chối truy cập khi tạo {0}</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDeleteKeyTree" xml:space="preserve">
+ <value>Từ chối truy cập khi xóa cây khóa {0}</value>
+ </data>
<data name="Service.Service.Error.NotFound" xml:space="preserve">
<value>Không tìm thấy dịch vụ</value>
</data>
@@ -436,6 +448,9 @@
<data name="OptimizationResultDialog.Description" xml:space="preserve">
<value>Một số bước chưa hoàn tất thành công. Bạn có thể thử lại chỉ những bước bị lỗi.</value>
</data>
+ <data name="OptimizationResultDialog.Details" xml:space="preserve">
+ <value>Chi tiết</value>
+ </data>
<data name="Button.Retry" xml:space="preserve">
<value>Thử lại</value>
</data>
@@ -1459,6 +1474,12 @@ Cập nhật ngay để trải nghiệm các tính năng mới, cải tiến và
<data name="Service.ScheduledTask.Description.Disable" xml:space="preserve">
<value>Tắt tác vụ hệ thống: {0}</value>
</data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedDisable" xml:space="preserve">
+ <value>Từ chối truy cập khi tắt tác vụ {0}</value>
+ </data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedEnable" xml:space="preserve">
+ <value>Từ chối truy cập khi bật tác vụ {0}</value>
+ </data>
<data name="Revert.Registry.Description.Restore" xml:space="preserve">
<value>Khôi phục giá trị registry: {0}\{1}</value>
</data>
diff --git a/optimizerDuck/Resources/Languages/Translations.zh-CN.resx b/optimizerDuck/Resources/Languages/Translations.zh-CN.resx
index 3289493..6e6989a 100644
--- a/optimizerDuck/Resources/Languages/Translations.zh-CN.resx
+++ b/optimizerDuck/Resources/Languages/Translations.zh-CN.resx
@@ -415,6 +415,18 @@
<data name="Service.Registry.Error.CreateOrOpenSubkeyFailed" xml:space="preserve">
<value>创建/打开子项失败</value>
</data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedWrite" xml:space="preserve">
+ <value>写入 {0}:{1} 时权限被拒</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDelete" xml:space="preserve">
+ <value>删除 {0}:{1} 时权限被拒</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedCreateKey" xml:space="preserve">
+ <value>创建 {0} 时权限被拒</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDeleteKeyTree" xml:space="preserve">
+ <value>删除注册表项树 {0} 时权限被拒</value>
+ </data>
<data name="Service.Service.Error.NotFound" xml:space="preserve">
<value>未找到服务</value>
</data>
@@ -442,6 +454,9 @@
<data name="OptimizationResultDialog.Description" xml:space="preserve">
<value>部分步骤未成功完成。你可以仅重试失败的步骤。</value>
</data>
+ <data name="OptimizationResultDialog.Details" xml:space="preserve">
+ <value>详细信息</value>
+ </data>
<data name="Button.Retry" xml:space="preserve">
<value>重试</value>
</data>
@@ -1556,6 +1571,12 @@
<data name="Service.ScheduledTask.Description.Disable" xml:space="preserve">
<value>禁用计划任务:{0}</value>
</data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedDisable" xml:space="preserve">
+ <value>禁用任务 {0} 时权限被拒</value>
+ </data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedEnable" xml:space="preserve">
+ <value>启用任务 {0} 时权限被拒</value>
+ </data>
<data name="Revert.Registry.Description.Restore" xml:space="preserve">
<value>恢复注册表项:{0}\{1}</value>
</data>
diff --git a/optimizerDuck/Resources/Languages/Translations.zh-TW.resx b/optimizerDuck/Resources/Languages/Translations.zh-TW.resx
index 99afe45..795c6f1 100644
--- a/optimizerDuck/Resources/Languages/Translations.zh-TW.resx
+++ b/optimizerDuck/Resources/Languages/Translations.zh-TW.resx
@@ -384,6 +384,18 @@
<data name="Service.Registry.Error.CreateOrOpenSubkeyFailed" xml:space="preserve">
<value>無法建立或開啟子機碼</value>
</data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedWrite" xml:space="preserve">
+ <value>寫入 {0}:{1} 時存取被拒</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDelete" xml:space="preserve">
+ <value>刪除 {0}:{1} 時存取被拒</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedCreateKey" xml:space="preserve">
+ <value>建立 {0} 時存取被拒</value>
+ </data>
+ <data name="Service.Registry.ErrorDetail.AccessDeniedDeleteKeyTree" xml:space="preserve">
+ <value>刪除登錄機碼樹 {0} 時存取被拒</value>
+ </data>
<data name="Service.Service.Error.NotFound" xml:space="preserve">
<value>找不到服務</value>
</data>
@@ -411,6 +423,9 @@
<data name="OptimizationResultDialog.Description" xml:space="preserve">
<value>某些步驟未成功完成。您可以只重試失敗的步驟。</value>
</data>
+ <data name="OptimizationResultDialog.Details" xml:space="preserve">
+ <value>詳細資訊</value>
+ </data>
<data name="Button.Retry" xml:space="preserve">
<value>重試</value>
</data>
@@ -1219,6 +1234,12 @@
<data name="Service.ScheduledTask.Description.Disable" xml:space="preserve">
<value>停用排定的工作:{0}</value>
</data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedDisable" xml:space="preserve">
+ <value>停用工作 {0} 時存取被拒</value>
+ </data>
+ <data name="Service.ScheduledTask.ErrorDetail.AccessDeniedEnable" xml:space="preserve">
+ <value>啟用工作 {0} 時存取被拒</value>
+ </data>
<data name="Revert.Registry.Description.Restore" xml:space="preserve">
<value>還原登錄檔值:{0}\{1}</value>
</data>
diff --git a/optimizerDuck/Services/Optimization/OptimizationService.cs b/optimizerDuck/Services/Optimization/OptimizationService.cs
index 5a50c5f..4a6686c 100644
--- a/optimizerDuck/Services/Optimization/OptimizationService.cs
+++ b/optimizerDuck/Services/Optimization/OptimizationService.cs
@@ -169,9 +169,13 @@ public class OptimizationService(
if (scope.HasSuccessfulSteps)
await TrySaveRevertDataAsync(scope, optimization);
+ var status = scope.HasSuccessfulSteps
+ ? OptimizationSuccessResult.PartialSuccess
+ : OptimizationSuccessResult.Failed;
+
return new OptimizationResult
{
- Status = OptimizationSuccessResult.Failed,
+ Status = status,
Message = applyResult.ErrorMessage,
FailedSteps = scope.GetStepResults().Where(step => !step.Success).ToList(),
};
diff --git a/optimizerDuck/Services/Optimization/Providers/RegistryService.cs b/optimizerDuck/Services/Optimization/Providers/RegistryService.cs
index ab4e0fd..eabb345 100644
--- a/optimizerDuck/Services/Optimization/Providers/RegistryService.cs
+++ b/optimizerDuck/Services/Optimization/Providers/RegistryService.cs
@@ -309,7 +309,12 @@ public static class RegistryService
false,
null,
Translations.Service_Common_Error_AccessDenied,
- () => Task.FromResult(Write(item))
+ () => Task.FromResult(Write(item)),
+ string.Format(
+ Translations.Service_Registry_ErrorDetail_AccessDeniedWrite,
+ item.Path,
+ item.Name
+ )
);
return false;
}
@@ -328,7 +333,8 @@ public static class RegistryService
false,
null,
ex.Message,
- () => Task.FromResult(Write(item))
+ () => Task.FromResult(Write(item)),
+ ex.ToString()
);
return false;
}
@@ -415,7 +421,12 @@ public static class RegistryService
false,
null,
Translations.Service_Common_Error_AccessDenied,
- () => Task.FromResult(DeleteValue(item))
+ () => Task.FromResult(DeleteValue(item)),
+ string.Format(
+ Translations.Service_Registry_ErrorDetail_AccessDeniedDelete,
+ item.Path,
+ item.Name
+ )
);
return false;
}
@@ -434,7 +445,8 @@ public static class RegistryService
false,
null,
ex.Message,
- () => Task.FromResult(DeleteValue(item))
+ () => Task.FromResult(DeleteValue(item)),
+ ex.ToString()
);
return false;
}
@@ -499,7 +511,11 @@ public static class RegistryService
false,
null,
Translations.Service_Common_Error_AccessDenied,
- () => Task.FromResult(CreateSubKey(item))
+ () => Task.FromResult(CreateSubKey(item)),
+ string.Format(
+ Translations.Service_Registry_ErrorDetail_AccessDeniedCreateKey,
+ item.Path
+ )
);
return false;
}
@@ -513,7 +529,8 @@ public static class RegistryService
false,
null,
ex.Message,
- () => Task.FromResult(CreateSubKey(item))
+ () => Task.FromResult(CreateSubKey(item)),
+ ex.ToString()
);
return false;
}
@@ -592,7 +609,11 @@ public static class RegistryService
false,
null,
Translations.Service_Registry_Error_AccessDeniedProtectedHive,
- () => Task.FromResult(DeleteSubKeyTree(item))
+ () => Task.FromResult(DeleteSubKeyTree(item)),
+ string.Format(
+ Translations.Service_Registry_ErrorDetail_AccessDeniedDeleteKeyTree,
+ item.Path
+ )
);
return false;
}
@@ -606,7 +627,8 @@ public static class RegistryService
false,
null,
ex.Message,
- () => Task.FromResult(DeleteSubKeyTree(item))
+ () => Task.FromResult(DeleteSubKeyTree(item)),
+ ex.ToString()
);
return false;
}
diff --git a/optimizerDuck/Services/Optimization/Providers/ScheduledTaskService.cs b/optimizerDuck/Services/Optimization/Providers/ScheduledTaskService.cs
index 5addefc..be125d5 100644
--- a/optimizerDuck/Services/Optimization/Providers/ScheduledTaskService.cs
+++ b/optimizerDuck/Services/Optimization/Providers/ScheduledTaskService.cs
@@ -82,7 +82,11 @@ public static class ScheduledTaskService
false,
null,
Translations.Service_Common_Error_AccessDenied,
- () => System.Threading.Tasks.Task.FromResult(DisableTask(fullPath))
+ () => System.Threading.Tasks.Task.FromResult(DisableTask(fullPath)),
+ string.Format(
+ Translations.Service_ScheduledTask_ErrorDetail_AccessDeniedDisable,
+ fullPath
+ )
);
return false;
}
@@ -96,7 +100,8 @@ public static class ScheduledTaskService
false,
null,
ex.Message,
- () => System.Threading.Tasks.Task.FromResult(DisableTask(fullPath))
+ () => System.Threading.Tasks.Task.FromResult(DisableTask(fullPath)),
+ ex.ToString()
);
return false;
}
@@ -152,7 +157,11 @@ public static class ScheduledTaskService
false,
null,
Translations.Service_Common_Error_AccessDenied,
- () => System.Threading.Tasks.Task.FromResult(EnableTask(fullPath))
+ () => System.Threading.Tasks.Task.FromResult(EnableTask(fullPath)),
+ string.Format(
+ Translations.Service_ScheduledTask_ErrorDetail_AccessDeniedEnable,
+ fullPath
+ )
);
return false;
}
@@ -166,7 +175,8 @@ public static class ScheduledTaskService
false,
null,
ex.Message,
- () => System.Threading.Tasks.Task.FromResult(EnableTask(fullPath))
+ () => System.Threading.Tasks.Task.FromResult(EnableTask(fullPath)),
+ ex.ToString()
);
return false;
}
diff --git a/optimizerDuck/UI/Dialogs/OptimizationResultDialog.xaml b/optimizerDuck/UI/Dialogs/OptimizationResultDialog.xaml
index 1572df6..be1358d 100644
--- a/optimizerDuck/UI/Dialogs/OptimizationResultDialog.xaml
+++ b/optimizerDuck/UI/Dialogs/OptimizationResultDialog.xaml
@@ -17,48 +17,43 @@
False="Visible"
True="Collapsed" />
</UserControl.Resources>
- <StackPanel MinWidth="560">
- <!-- Header with failed count summary -->
- <StackPanel Margin="0,0,0,4" Orientation="Horizontal">
- <ui:SymbolIcon
- Margin="0,0,8,0"
- VerticalAlignment="Center"
- Filled="True"
- Foreground="{DynamicResource SystemFillColorCriticalBrush}"
- Symbol="ErrorCircle24" />
+ <Grid Style="{StaticResource DialogRootStyle}">
+ <StackPanel Style="{StaticResource DialogContentStackStyle}">
+ <!-- Header with failed count summary -->
+ <StackPanel Margin="0,0,0,4" Orientation="Horizontal">
+ <ui:SymbolIcon
+ VerticalAlignment="Center"
+ Filled="True"
+ Foreground="{DynamicResource SystemFillColorCriticalBrush}"
+ Style="{StaticResource DialogIconStyle}"
+ Symbol="ErrorCircle24" />
+
+ <ui:TextBlock
+ VerticalAlignment="Center"
+ FontTypography="Subtitle"
+ Text="{ext:Loc OptimizationResultDialog.Header,
+ {Binding FailedCount}}"
+ TextTrimming="WordEllipsis"
+ TextWrapping="Wrap" />
+ </StackPanel>
<ui:TextBlock
- FontTypography="Subtitle"
- Text="{ext:Loc OptimizationResultDialog.Header,
- {Binding FailedCount}}"
- TextTrimming="WordEllipsis"
+ Margin="0,4,0,12"
+ Appearance="Secondary"
+ FontTypography="Body"
+ Text="{ext:Loc OptimizationResultDialog.Description}"
TextWrapping="Wrap" />
- </StackPanel>
-
- <ui:TextBlock
- Margin="0,2,0,12"
- Appearance="Secondary"
- FontTypography="Body"
- Text="{ext:Loc OptimizationResultDialog.Description}"
- TextWrapping="Wrap" />
- <ScrollViewer MaxHeight="350" VerticalScrollBarVisibility="Auto">
- <ItemsControl ItemsSource="{Binding FailedSteps}">
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <ui:CardControl Margin="0,0,0,8">
- <ui:CardControl.Header>
+ <ScrollViewer MaxHeight="350" VerticalScrollBarVisibility="Auto">
+ <ItemsControl ItemsSource="{Binding FailedSteps}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Border Style="{StaticResource ListRowStyle}">
<StackPanel>
- <!-- Top row: index + service type badge + step name -->
+ <!-- Top row: badges -->
<StackPanel Margin="0,0,0,6" Orientation="Horizontal">
<!-- Step index badge -->
- <Border
- Margin="0,0,8,0"
- Padding="6,2"
- HorizontalAlignment="Left"
- VerticalAlignment="Center"
- Background="{DynamicResource CardBackgroundFillColorSecondaryBrush}"
- CornerRadius="4">
+ <Border Margin="0,0,8,0" Style="{StaticResource SubtlePillStyle}">
<ui:TextBlock
VerticalAlignment="Center"
Appearance="Disabled"
@@ -68,12 +63,11 @@
<!-- Service type badge -->
<Border
- Margin="0,0,8,0"
Padding="6,2"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="{DynamicResource SystemFillColorAttentionBackgroundBrush}"
- CornerRadius="4">
+ CornerRadius="{StaticResource CornerRadiusSmall}">
<ui:TextBlock
VerticalAlignment="Center"
FontTypography="Caption"
@@ -94,9 +88,10 @@
Margin="0,4,0,0"
Padding="8,6"
HorizontalAlignment="Left"
+ Background="{DynamicResource SystemFillColorCriticalBackgroundBrush}"
BorderBrush="{DynamicResource SystemFillColorCriticalBrush}"
BorderThickness="1"
- CornerRadius="{StaticResource CornerRadiusMedium}"
+ Style="{StaticResource SubtlePillStyle}"
Visibility="{Binding Error, Converter={StaticResource NullToVisibilityConverter}}">
<StackPanel Orientation="Horizontal">
<ui:SymbolIcon
@@ -113,12 +108,45 @@
TextWrapping="Wrap" />
</StackPanel>
</Border>
+
+ <!-- Error detail (expandable) -->
+ <Expander
+ Margin="0,4,0,0"
+ BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
+ BorderThickness="1"
+ Visibility="{Binding ErrorDetail, Converter={StaticResource NullToVisibilityConverter}}">
+ <Expander.Header>
+ <StackPanel Orientation="Horizontal">
+ <ui:SymbolIcon
+ Margin="0,0,6,0"
+ VerticalAlignment="Center"
+ Filled="True"
+ Foreground="{DynamicResource TextFillColorSecondaryBrush}"
+ Symbol="Code24" />
+ <ui:TextBlock
+ FontTypography="Caption"
+ Foreground="{DynamicResource TextFillColorSecondaryBrush}"
+ Text="{ext:Loc OptimizationResultDialog.Details}" />
+ </StackPanel>
+ </Expander.Header>
+ <Border
+ Padding="4,0,0,0"
+ Background="{DynamicResource CardBackgroundFillColorSecondaryBrush}"
+ CornerRadius="{StaticResource CornerRadiusSmall}">
+ <ui:TextBlock
+ Padding="6,4"
+ FontTypography="Caption"
+ Foreground="{DynamicResource TextFillColorSecondaryBrush}"
+ Text="{Binding ErrorDetail}"
+ TextWrapping="Wrap" />
+ </Border>
+ </Expander>
</StackPanel>
- </ui:CardControl.Header>
- </ui:CardControl>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
- </StackPanel>
+ </Border>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+ </StackPanel>
+ </Grid>
</UserControl>
diff --git a/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml b/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml
index e68ffd6..e702855 100644
--- a/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml
+++ b/optimizerDuck/UI/Pages/Optimize/Categories/OptimizationPage.xaml
@@ -358,7 +358,7 @@
Command="{Binding DataContext.ViewModel.ToggleOptimizationCommand, RelativeSource={RelativeSource AncestorType=Page}}"
CommandParameter="{Binding}"
Cursor="Hand"
- IsChecked="{Binding State.IsApplied, Mode=OneWay}"
+ IsChecked="{Binding State.IsApplied, Mode=TwoWay}"
IsEnabled="{Binding DataContext.ViewModel.IsProcessing, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource InverseBooleanConverter}}"
Style="{StaticResource ToggleSwitchStyle}" />
<ui:Button
diff --git a/optimizerDuck/UI/Styles/FluentDesign.xaml b/optimizerDuck/UI/Styles/FluentDesign.xaml
index d49b528..7e84ec6 100644
--- a/optimizerDuck/UI/Styles/FluentDesign.xaml
+++ b/optimizerDuck/UI/Styles/FluentDesign.xaml
@@ -5,15 +5,6 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
- <sys:Double x:Key="Space4">4</sys:Double>
- <sys:Double x:Key="Space8">8</sys:Double>
- <sys:Double x:Key="Space12">12</sys:Double>
- <sys:Double x:Key="Space16">16</sys:Double>
- <sys:Double x:Key="Space20">20</sys:Double>
- <sys:Double x:Key="Space24">24</sys:Double>
- <sys:Double x:Key="Space32">32</sys:Double>
- <sys:Double x:Key="Space40">40</sys:Double>
-
<CornerRadius x:Key="CornerRadiusSmall">4</CornerRadius>
<CornerRadius x:Key="CornerRadiusMedium">8</CornerRadius>
<CornerRadius x:Key="CornerRadiusLarge">12</CornerRadius>
@@ -183,8 +174,7 @@
</Style>
<Style x:Key="DialogIconStyle" TargetType="ui:SymbolIcon">
- <Setter Property="Margin" Value="0,0,0,12" />
- <Setter Property="HorizontalAlignment" Value="Center" />
+ <Setter Property="Margin" Value="0,0,6,0" />
<Setter Property="FontSize" Value="44" />
<Setter Property="Foreground" Value="{DynamicResource AccentYellowBrush}" />
</Style>
diff --git a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs
index a7624b0..170dc5a 100644
--- a/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs
+++ b/optimizerDuck/UI/ViewModels/Optimizer/OptimizationCategoryViewModel.cs
@@ -164,6 +164,7 @@ public partial class OptimizationCategoryViewModel : ViewModel
var (proceed, created) = await HandleRestorePointAsync();
if (!proceed)
{
+
optimization.State.IsApplied = wasApplied;
return;
}