├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.yml
│ ├── config.yml
│ ├── feature_suggestion.yml
│ └── new_feature.yml
├── PULL_REQUEST_TEMPLATE.md
├── RELEASE_TEMPLATE.md
├── RELEASE_TEMPLATE_SIMPLIFIED.md
└── workflows
│ └── create-release.yml
├── .gitignore
├── LICENSE.txt
├── README.md
├── Winhance.ps1
├── Winhance.sln
├── extras
├── Winhance.Installer.iss
└── build-and-package.ps1
└── src
├── Winhance.Core
├── Features
│ ├── Common
│ │ ├── Enums
│ │ │ ├── CancellationReason.cs
│ │ │ ├── ControlType.cs
│ │ │ ├── LinkedSettingsLogic.cs
│ │ │ ├── LogLevel.cs
│ │ │ ├── OptimizationEnums.cs
│ │ │ ├── PowerShellStreamType.cs
│ │ │ ├── RegistryActionType.cs
│ │ │ ├── RegistrySettingStatus.cs
│ │ │ └── UacLevel.cs
│ │ ├── Exceptions
│ │ │ ├── AppLoadingException.cs
│ │ │ ├── InstallationException.cs
│ │ │ └── InstallationStatusException.cs
│ │ ├── Extensions
│ │ │ └── RegistrySettingExtensions.cs
│ │ ├── Helpers
│ │ │ └── ValidationHelper.cs
│ │ ├── Interfaces
│ │ │ ├── IApplicationCloseService.cs
│ │ │ ├── ICommandService.cs
│ │ │ ├── IConfigurationCoordinatorService.cs
│ │ │ ├── IConfigurationService.cs
│ │ │ ├── IDependencyManager.cs
│ │ │ ├── IDialogService.cs
│ │ │ ├── IFileSystemService.cs
│ │ │ ├── IInternetConnectivityService.cs
│ │ │ ├── ILogService.cs
│ │ │ ├── IMessengerService.cs
│ │ │ ├── INavigationService.cs
│ │ │ ├── IParameterSerializer.cs
│ │ │ ├── IParameterSerializerService.cs
│ │ │ ├── IPowerShellExecutionService.cs
│ │ │ ├── IRegistryService.cs
│ │ │ ├── IScheduledTaskService.cs
│ │ │ ├── IScriptBuilderService.cs
│ │ │ ├── IScriptDetectionService.cs
│ │ │ ├── IScriptFactory.cs
│ │ │ ├── IScriptTemplateProvider.cs
│ │ │ ├── ISearchService.cs
│ │ │ ├── ISearchable.cs
│ │ │ ├── ISettingItem.cs
│ │ │ ├── ISettingsRegistry.cs
│ │ │ ├── ISystemServices.cs
│ │ │ ├── ITaskProgressService.cs
│ │ │ ├── IUacSettingsService.cs
│ │ │ ├── IUnifiedConfigurationService.cs
│ │ │ ├── IVersionService.cs
│ │ │ ├── IViewModel.cs
│ │ │ └── IVisibleSettingItem.cs
│ │ ├── Messaging
│ │ │ └── Messages.cs
│ │ ├── Models
│ │ │ ├── ApplicationAction.cs
│ │ │ ├── ApplicationSetting.cs
│ │ │ ├── CommandSetting.cs
│ │ │ ├── ConfigurationFile.cs
│ │ │ ├── ConfigurationItem.cs
│ │ │ ├── IInstallableItem.cs
│ │ │ ├── InstallStatus.cs
│ │ │ ├── LinkedRegistrySettings.cs
│ │ │ ├── LogMessageEventArgs.cs
│ │ │ ├── OperationResult.cs
│ │ │ ├── OptimizationConfig.cs
│ │ │ ├── OptimizationModels.cs
│ │ │ ├── PowerShellProgressData.cs
│ │ │ ├── RefreshResult.cs
│ │ │ ├── RegistryModels.cs
│ │ │ ├── RegistryTestResult.cs
│ │ │ ├── TaskProgressDetail.cs
│ │ │ ├── TaskProgressEventArgs.cs
│ │ │ ├── UnifiedConfigurationFile.cs
│ │ │ ├── VerificationResult.cs
│ │ │ ├── VersionInfo.cs
│ │ │ └── WinGetModels.cs
│ │ ├── Services
│ │ │ ├── DependencyManager.cs
│ │ │ ├── LogService.cs
│ │ │ ├── LoggingService.cs
│ │ │ ├── ModelMapper.cs
│ │ │ └── SettingsRegistry.cs
│ │ └── Verification
│ │ │ └── VerificationMethodBase.cs
│ ├── Customize
│ │ ├── Enums
│ │ │ ├── CustomizationCategory.cs
│ │ │ └── CustomizationSettingType.cs
│ │ ├── Interfaces
│ │ │ ├── IThemeService.cs
│ │ │ └── IWallpaperService.cs
│ │ └── Models
│ │ │ ├── CustomizationGroup.cs
│ │ │ ├── CustomizationSetting.cs
│ │ │ ├── ExplorerCustomizations.cs
│ │ │ ├── StartMenuCustomizations.cs
│ │ │ ├── StartMenuLayouts.cs
│ │ │ ├── TaskbarCustomizations.cs
│ │ │ └── WindowsThemeSettings.cs
│ ├── Optimize
│ │ ├── Interfaces
│ │ │ └── IPowerPlanService.cs
│ │ └── Models
│ │ │ ├── CustomUacSettings.cs
│ │ │ ├── ExplorerOptimizations.cs
│ │ │ ├── GamingandPerformanceOptimizations.cs
│ │ │ ├── NotificationOptimizations.cs
│ │ │ ├── OptimizationSetting.cs
│ │ │ ├── PowerOptimizations.cs
│ │ │ ├── PowerPlan.cs
│ │ │ ├── PrivacyOptimizations.cs
│ │ │ ├── SoundOptimizations.cs
│ │ │ ├── UacOptimizations.cs
│ │ │ └── UpdateOptimizations.cs
│ ├── SoftwareApps
│ │ ├── Enums
│ │ │ └── InstallationErrorType.cs
│ │ ├── Exceptions
│ │ │ ├── InstallationException.cs
│ │ │ ├── InstallationStatusException.cs
│ │ │ └── RemovalException.cs
│ │ ├── Helpers
│ │ │ └── InstallationErrorHelper.cs
│ │ ├── Interfaces
│ │ │ ├── IAppDiscoveryService.cs
│ │ │ ├── IAppInstallationCoordinatorService.cs
│ │ │ ├── IAppInstallationService.cs
│ │ │ ├── IAppLoadingService.cs
│ │ │ ├── IAppRemovalService.cs
│ │ │ ├── IAppService.cs
│ │ │ ├── IAppVerificationService.cs
│ │ │ ├── ICapabilityInstallationService.cs
│ │ │ ├── ICapabilityRemovalService.cs
│ │ │ ├── ICustomAppInstallationService.cs
│ │ │ ├── IFeatureInstallationService.cs
│ │ │ ├── IFeatureRemovalService.cs
│ │ │ ├── IInstallationOrchestrator.cs
│ │ │ ├── IInstallationService.cs
│ │ │ ├── IInstallationStatusService.cs
│ │ │ ├── IOneDriveInstallationService.cs
│ │ │ ├── IPackageManager.cs
│ │ │ ├── IScriptGenerationService.cs
│ │ │ ├── ISpecialAppHandlerService.cs
│ │ │ └── IWinGetInstallationService.cs
│ │ └── Models
│ │ │ ├── AppInfo.cs
│ │ │ ├── AppModels.cs
│ │ │ ├── CapabilityCatalog.cs
│ │ │ ├── CapabilityInfo.cs
│ │ │ ├── ExternalAppCatalog.cs
│ │ │ ├── FeatureCatalog.cs
│ │ │ ├── FeatureInfo.cs
│ │ │ ├── RemovalScript.cs
│ │ │ ├── SpecialAppHandler.cs
│ │ │ ├── WindowsAppCatalog.cs
│ │ │ └── WindowsPackageModels.cs
│ └── UI
│ │ └── Interfaces
│ │ └── INotificationService.cs
├── Properties
│ └── PublishProfiles
│ │ ├── FolderProfile.pubxml
│ │ └── FolderProfile.pubxml.user
└── Winhance.Core.csproj
├── Winhance.Infrastructure
├── Features
│ ├── Common
│ │ ├── Extensions
│ │ │ └── WinGetProgressExtensions.cs
│ │ ├── Registry
│ │ │ ├── RegistryExtensions.cs
│ │ │ ├── RegistryService.cs
│ │ │ ├── RegistryServiceCompletion.cs
│ │ │ ├── RegistryServiceCore.cs
│ │ │ ├── RegistryServiceEnsureKey.cs
│ │ │ ├── RegistryServiceKeyOperations.cs
│ │ │ ├── RegistryServicePowerShell.cs
│ │ │ ├── RegistryServiceStatusMethods.cs
│ │ │ ├── RegistryServiceTestMethods.cs
│ │ │ ├── RegistryServiceUtilityOperations.cs
│ │ │ └── RegistryServiceValueOperations.cs
│ │ ├── ScriptGeneration
│ │ │ ├── CapabilityScriptModifier.cs
│ │ │ ├── CompositeScriptContentModifier.cs
│ │ │ ├── FeatureScriptModifier.cs
│ │ │ ├── ICapabilityScriptModifier.cs
│ │ │ ├── IFeatureScriptModifier.cs
│ │ │ ├── IPackageScriptModifier.cs
│ │ │ ├── IRegistryScriptModifier.cs
│ │ │ ├── IScriptContentModifier.cs
│ │ │ ├── IScriptUpdateService.cs
│ │ │ ├── PackageScriptModifier.cs
│ │ │ ├── PowerShellScriptBuilderService.cs
│ │ │ ├── PowerShellScriptFactory.cs
│ │ │ ├── PowerShellScriptTemplateProvider.cs
│ │ │ ├── RegistryScriptHelper.cs
│ │ │ ├── RegistryScriptModifier.cs
│ │ │ ├── ScheduledTaskService.cs
│ │ │ ├── ScriptContentModifier.cs
│ │ │ ├── ScriptGenerationService.cs
│ │ │ ├── ScriptGenerationServiceExtensions.cs
│ │ │ ├── ScriptModifierServiceExtensions.cs
│ │ │ └── ScriptUpdateService.cs
│ │ ├── Services
│ │ │ ├── CommandService.cs
│ │ │ ├── ConfigurationService.cs
│ │ │ ├── FileSystemService.cs
│ │ │ ├── FrameNavigationService.cs
│ │ │ ├── InternetConnectivityService.cs
│ │ │ ├── JsonParameterSerializer.cs
│ │ │ ├── PowerShellExecutionService.cs
│ │ │ ├── PowerShellHelper.cs
│ │ │ ├── ScriptDetectionService.cs
│ │ │ ├── SearchService.cs
│ │ │ ├── TaskProgressService.cs
│ │ │ ├── VersionService.cs
│ │ │ └── WindowsSystemService.cs
│ │ └── Utilities
│ │ │ └── PowerShellFactory.cs
│ ├── Customize
│ │ └── Services
│ │ │ ├── ThemeService.cs
│ │ │ └── WallpaperService.cs
│ ├── Optimize
│ │ └── Services
│ │ │ └── PowerPlanService.cs
│ ├── SoftwareApps
│ │ └── Services
│ │ │ ├── AppDiscoveryService.cs
│ │ │ ├── AppInstallationCoordinatorService.cs
│ │ │ ├── AppInstallationService.cs
│ │ │ ├── AppLoadingService.cs
│ │ │ ├── AppRemovalService.cs
│ │ │ ├── AppRemovalServiceAdapter.cs
│ │ │ ├── AppServiceAdapter.cs
│ │ │ ├── AppVerificationService.cs
│ │ │ ├── BaseInstallationService.cs
│ │ │ ├── CapabilityInstallationService.cs
│ │ │ ├── CapabilityRemovalService.cs
│ │ │ ├── CustomAppInstallationService.cs
│ │ │ ├── FeatureInstallationService.cs
│ │ │ ├── FeatureRemovalService.cs
│ │ │ ├── InstallationOrchestrator.cs
│ │ │ ├── InstallationStatusService.cs
│ │ │ ├── OneDriveInstallationService.cs
│ │ │ ├── PackageManager.cs
│ │ │ ├── SpecialAppHandlerService.cs
│ │ │ ├── WinGet
│ │ │ ├── Implementations
│ │ │ │ └── WinGetInstaller.cs
│ │ │ ├── Interfaces
│ │ │ │ ├── IInstallationVerifier.cs
│ │ │ │ ├── IVerificationMethod.cs
│ │ │ │ └── IWinGetInstaller.cs
│ │ │ ├── Utilities
│ │ │ │ ├── WinGetInstallationScript.cs
│ │ │ │ └── WinGetOutputParser.cs
│ │ │ └── Verification
│ │ │ │ ├── CompositeInstallationVerifier.cs
│ │ │ │ ├── Methods
│ │ │ │ ├── AppxPackageVerificationMethod.cs
│ │ │ │ ├── FileSystemVerificationMethod.cs
│ │ │ │ ├── RegistryVerificationMethod.cs
│ │ │ │ └── WinGetVerificationMethod.cs
│ │ │ │ └── VerificationMethodBase.cs
│ │ │ ├── WinGetInstallationService.cs.bak
│ │ │ └── WinGetInstallationServiceAdapter.cs
│ └── UI
│ │ └── Services
│ │ └── NotificationService.cs
├── Properties
│ └── PublishProfiles
│ │ ├── FolderProfile.pubxml
│ │ └── FolderProfile.pubxml.user
└── Winhance.Infrastructure.csproj
└── Winhance.WPF
├── App.manifest
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── Features
├── Common
│ ├── Behaviors
│ │ └── ResponsiveLayoutBehavior.cs
│ ├── Controls
│ │ ├── MaterialSymbol.xaml
│ │ ├── MaterialSymbol.xaml.cs
│ │ ├── MoreMenu.xaml
│ │ ├── MoreMenu.xaml.cs
│ │ ├── ProgressIndicator.cs
│ │ ├── ResponsiveScrollViewer.cs
│ │ ├── SearchBox.xaml
│ │ ├── SearchBox.xaml.cs
│ │ ├── TaskProgressControl.xaml
│ │ └── TaskProgressControl.xaml.cs
│ ├── Converters
│ │ ├── AppliedStatusToVisibilityConverter.cs
│ │ ├── BoolToArrowConverter.cs
│ │ ├── BoolToChevronConverter.cs
│ │ ├── BooleanConverter.cs
│ │ ├── BooleanToGridSpanConverter.cs
│ │ ├── BooleanToReinstallableIconConverter.cs
│ │ ├── BooleanToReinstallableTextConverter.cs
│ │ ├── BooleanToThemeConverter.cs
│ │ ├── BooleanToThemeIconConverter.cs
│ │ ├── BooleanToVisibilityConverter.cs
│ │ ├── CategoryToIconConverter.cs
│ │ ├── CountToVisibilityConverter.cs
│ │ ├── EnumToVisibilityConverter.cs
│ │ ├── GreaterThanOneConverter.cs
│ │ ├── IconNameToSymbolConverter.cs
│ │ ├── InstalledStatusToColorConverter.cs
│ │ ├── InstalledStatusToTextConverter.cs
│ │ ├── InverseBooleanConverter.cs
│ │ ├── InverseBooleanToVisibilityConverter.cs
│ │ ├── InverseCountToVisibilityConverter.cs
│ │ ├── IsPrimaryToVisibilityConverter.cs
│ │ ├── LogLevelToColorConverter.cs
│ │ ├── NullToVisibilityConverter.cs
│ │ ├── RegistryHiveToFullNameConverter.cs
│ │ ├── RegistryValueStatusConverter.cs
│ │ ├── RemoveActionToVisibilityConverter.cs
│ │ ├── ScriptStatusToColorConverter.cs
│ │ ├── ScriptStatusToTextConverter.cs
│ │ ├── StatusToColorConverter.cs
│ │ ├── StatusToTextConverter.cs
│ │ ├── StringToMaximizeIconConverter.cs
│ │ ├── ViewNameToBackgroundConverter.cs
│ │ └── WindowStateToCommandConverter.cs
│ ├── Extensions
│ │ └── SettingViewModelExtensions.cs
│ ├── Interfaces
│ │ └── IViewModelLocator.cs
│ ├── Messages
│ │ └── ResetExpansionStateMessage.cs
│ ├── Models
│ │ ├── ApplicationSettingGroup.cs
│ │ ├── ApplicationSettingItem.cs
│ │ ├── LinkedRegistrySettingWithValue.cs
│ │ └── LogMessageViewModel.cs
│ ├── Resources
│ │ ├── Converters
│ │ │ └── Converters.xaml
│ │ ├── Dimensions
│ │ │ └── Dimensions.xaml
│ │ ├── Icons.xaml
│ │ ├── MaterialSymbols.cs
│ │ ├── ResourceDictionary.xaml
│ │ ├── Styles
│ │ │ ├── AppItemStyles.xaml
│ │ │ ├── ButtonStyles.xaml
│ │ │ ├── CheckBoxStyles.xaml
│ │ │ ├── CombinedSettingTooltipTemplate.xaml
│ │ │ ├── ComboBoxStyles.xaml
│ │ │ ├── CommandTooltipTemplate.xaml
│ │ │ ├── ContainerStyles.xaml
│ │ │ ├── DialogStyles.xaml
│ │ │ ├── MenuStyles.xaml
│ │ │ ├── ProgressIndicatorStyles.xaml
│ │ │ ├── RegistryTooltipTemplate.xaml
│ │ │ ├── ResponsiveStyles.xaml
│ │ │ ├── ScrollBarStyles.xaml
│ │ │ ├── SliderStyles.xaml
│ │ │ ├── Styles.xaml
│ │ │ ├── TextStyles.xaml
│ │ │ ├── ToggleSwitchStyles.xaml
│ │ │ └── ToolTipStyles.xaml
│ │ ├── Theme
│ │ │ ├── ColorDictionary.xaml
│ │ │ ├── IThemeManager.cs
│ │ │ └── ThemeManager.cs
│ │ └── Themes
│ │ │ └── Themes.xaml
│ ├── Services
│ │ ├── ApplicationCloseService.cs
│ │ ├── Configuration
│ │ │ ├── ConfigurationApplierService.cs
│ │ │ ├── ConfigurationPropertyUpdater.cs
│ │ │ ├── ConfigurationServiceExtensions.cs
│ │ │ ├── CustomizeConfigurationApplier.cs
│ │ │ ├── ExternalAppsConfigurationApplier.cs
│ │ │ ├── IConfigurationApplierService.cs
│ │ │ ├── IConfigurationPropertyUpdater.cs
│ │ │ ├── ISectionConfigurationApplier.cs
│ │ │ ├── IViewModelRefresher.cs
│ │ │ ├── OptimizeConfigurationApplier.cs
│ │ │ ├── ViewModelRefresher.cs
│ │ │ └── WindowsAppsConfigurationApplier.cs
│ │ ├── ConfigurationCollectorService.cs
│ │ ├── ConfigurationCoordinatorService.cs
│ │ ├── ConfigurationUIService.cs
│ │ ├── DesignTimeDataService.cs
│ │ ├── DialogService.cs
│ │ ├── IDesignTimeDataService.cs
│ │ ├── MessengerService.cs
│ │ ├── UacSettingsService.cs
│ │ ├── UnifiedConfigurationService.cs
│ │ ├── UserPreferencesService.cs
│ │ └── ViewModelLocator.cs
│ ├── Theme
│ │ ├── FontLoader.cs
│ │ └── MaterialSymbols.cs
│ ├── Utilities
│ │ ├── FileLogger.cs
│ │ └── WindowSizeManager.cs
│ ├── ViewModels
│ │ ├── ApplicationSettingViewModel.cs
│ │ ├── BaseSettingsViewModel.cs
│ │ ├── BaseViewModel.cs
│ │ ├── ConfigurationViewModelBase.cs
│ │ ├── LoadingWindowViewModel.cs
│ │ ├── MainViewModel.cs
│ │ ├── MoreMenuViewModel.cs
│ │ ├── SearchableViewModel.cs
│ │ ├── UnifiedConfigurationDialogViewModel.cs
│ │ └── UpdateNotificationViewModel.cs
│ └── Views
│ │ ├── CustomDialog.xaml
│ │ ├── CustomDialog.xaml.cs
│ │ ├── DonationDialog.xaml
│ │ ├── DonationDialog.xaml.cs
│ │ ├── LoadingWindow.xaml
│ │ ├── LoadingWindow.xaml.cs
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── UnifiedConfigurationDialog.xaml
│ │ ├── UnifiedConfigurationDialog.xaml.cs
│ │ ├── UpdateDialog.xaml
│ │ ├── UpdateDialog.xaml.cs
│ │ ├── UpdateNotificationDialog.xaml
│ │ └── UpdateNotificationDialog.xaml.cs
├── Customize
│ ├── ViewModels
│ │ ├── CustomizeViewModel.cs
│ │ ├── ExplorerCustomizationsViewModel.cs
│ │ ├── StartMenuCustomizationsViewModel.cs
│ │ ├── TaskbarCustomizationsViewModel.cs
│ │ └── WindowsThemeCustomizationsViewModel.cs
│ └── Views
│ │ ├── CustomizeView.xaml
│ │ ├── CustomizeView.xaml.cs
│ │ ├── ExplorerCustomizationsView.cs
│ │ ├── ExplorerCustomizationsView.xaml
│ │ ├── StartMenuCustomizationsView.xaml
│ │ ├── StartMenuCustomizationsView.xaml.cs
│ │ ├── TaskbarCustomizationsView.xaml
│ │ ├── TaskbarCustomizationsView.xaml.cs
│ │ ├── WindowsThemeCustomizationsView.xaml
│ │ └── WindowsThemeCustomizationsView.xaml.cs
├── Optimize
│ ├── ViewModels
│ │ ├── ExplorerOptimizationsViewModel.cs
│ │ ├── GamingandPerformanceOptimizationsViewModel.cs
│ │ ├── NotificationOptimizationsViewModel.cs
│ │ ├── OptimizeViewModel.cs
│ │ ├── PowerOptimizationsViewModel.cs
│ │ ├── PrivacyOptimizationsViewModel.cs
│ │ ├── SoundOptimizationsViewModel.cs
│ │ ├── UpdateOptimizationsViewModel.cs
│ │ └── WindowsSecurityOptimizationsViewModel.cs
│ └── Views
│ │ ├── ExplorerOptimizationsView.cs
│ │ ├── ExplorerOptimizationsView.xaml
│ │ ├── GamingandPerformanceOptimizationsView.xaml
│ │ ├── GamingandPerformanceOptimizationsView.xaml.cs
│ │ ├── NotificationOptimizationsView.xaml
│ │ ├── NotificationOptimizationsView.xaml.cs
│ │ ├── OptimizeView.xaml
│ │ ├── OptimizeView.xaml.cs
│ │ ├── PowerOptimizationsView.xaml
│ │ ├── PowerOptimizationsView.xaml.cs
│ │ ├── PrivacyOptimizationsView.xaml
│ │ ├── PrivacyOptimizationsView.xaml.cs
│ │ ├── SoundOptimizationsView.xaml
│ │ ├── SoundOptimizationsView.xaml.cs
│ │ ├── UpdateOptimizationsView.xaml
│ │ ├── UpdateOptimizationsView.xaml.cs
│ │ ├── WindowsSecurityOptimizationsView.xaml
│ │ └── WindowsSecurityOptimizationsView.xaml.cs
└── SoftwareApps
│ ├── Models
│ ├── ExternalApp.cs
│ ├── ExternalAppSettingItem.cs
│ ├── ThirdPartyApp.cs
│ ├── WindowsApp.cs
│ └── WindowsAppSettingItem.cs
│ ├── Services
│ └── SoftwareAppsDialogService.cs
│ ├── ViewModels
│ ├── AppListViewModel.cs
│ ├── BaseInstallationViewModel.cs
│ ├── CapabilitiesViewModel.cs
│ ├── ExternalAppsCategoryViewModel.cs
│ ├── ExternalAppsViewModel.cs
│ ├── SoftwareAppsViewModel.cs
│ └── WindowsAppsViewModel.cs
│ └── Views
│ ├── ExternalAppsView.xaml
│ ├── ExternalAppsView.xaml.cs
│ ├── SoftwareAppsDialog.cs
│ ├── SoftwareAppsDialog.xaml
│ ├── SoftwareAppsView.xaml
│ ├── SoftwareAppsView.xaml.cs
│ ├── WindowsAppsView.xaml
│ └── WindowsAppsView.xaml.cs
├── Properties
├── PublishProfiles
│ ├── FolderProfile.pubxml
│ └── FolderProfile.pubxml.user
├── Settings.Designer.cs
└── Settings.settings
├── Resources
├── AppIcons
│ ├── LICENSE.txt
│ ├── winhance-rocket-black-transparent-bg.ico
│ ├── winhance-rocket-white-transparent-bg.ico
│ └── winhance-rocket.ico
└── Fonts
│ └── MaterialSymbolsOutlined.ttf
└── Winhance.WPF.csproj
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: 🤔 Having doubts or questions?
4 | url: https://github.com/memstechtips/Winhance/discussions/183
5 | about: Create a discussion and get help from other members of the community
6 | - name: 📧 Contact me privately by email
7 | url: mailto:contact@memstechtips.com
8 | about: Please use only if the issue (for example, a vulnerability) cannot be posted publicly
9 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_suggestion.yml:
--------------------------------------------------------------------------------
1 | name: "🚀 Suggest an improvement for an existing feature"
2 | description: "Propose an improvement to Winhance."
3 | title: "[SUGGESTION] "
4 | labels: ["enhancement"]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to suggest an improvement!
10 |
11 | - type: checkboxes
12 | id: prerequisites
13 | attributes:
14 | label: "Please confirm these before moving forward"
15 | description: "Please confirm the following before posting your suggestion."
16 | options:
17 | - label: "I have searched for similar suggestions and have not found a duplicate."
18 | required: true
19 | - label: "This is an improvement to an existing feature (not a new feature request)."
20 | required: true
21 |
22 | - type: textarea
23 | id: description
24 | attributes:
25 | label: "Describe your suggestion"
26 | description: "A clear and concise description of what you want to improve."
27 | placeholder: "I would like to see..."
28 | validations:
29 | required: true
30 |
31 | - type: textarea
32 | id: current
33 | attributes:
34 | label: "Current behavior"
35 | description: "Describe how the feature currently works."
36 | placeholder: "Currently, the feature..."
37 | validations:
38 | required: true
39 |
40 | - type: textarea
41 | id: proposed
42 | attributes:
43 | label: "Proposed behavior"
44 | description: "Describe how you would like the feature to work."
45 | placeholder: "I would like the feature to..."
46 | validations:
47 | required: true
48 |
49 | - type: textarea
50 | id: benefit
51 | attributes:
52 | label: "Benefit"
53 | description: "Why would this improvement be useful?"
54 | placeholder: "This would be useful because..."
55 | validations:
56 | required: true
57 |
58 | - type: textarea
59 | id: additional
60 | attributes:
61 | label: "Additional context"
62 | description: "Any other details or observations that may be helpful."
63 | placeholder: "Add any other context about the suggestion here."
64 | validations:
65 | required: false
66 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Description
2 |
3 |
4 | ## Type of Change
5 |
6 | - [ ] Bug fix (non-breaking change which fixes an issue)
7 | - [ ] New feature (non-breaking change which adds functionality)
8 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
9 | - [ ] Documentation update
10 | - [ ] Code refactoring (no functional changes)
11 | - [ ] Performance improvement
12 | - [ ] Build/CI configuration change
13 |
14 | ## Related Issues
15 |
16 |
17 |
18 | ## Testing Performed
19 |
20 | - [ ] Unit tests added/updated
21 | - [ ] Manual testing performed
22 | - [ ] Regression testing performed
23 |
24 | ## Screenshots/Videos
25 |
26 |
27 | ## Checklist
28 |
29 | - [ ] My code follows the code style of this project
30 | - [ ] I have commented my code, particularly in hard-to-understand areas
31 | - [ ] I have made corresponding changes to the documentation
32 | - [ ] My changes generate no new warnings
33 | - [ ] I have added tests that prove my fix is effective or that my feature works
34 | - [ ] New and existing unit tests pass locally with my changes
35 |
36 | ## Additional Notes
37 |
38 |
--------------------------------------------------------------------------------
/.github/RELEASE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## What's Changed
2 |
3 |
4 | **Full Changelog**:
5 |
6 | ## 🔐 Security Info
7 |
8 | **Important:** Please verify your download using the information below. Any file with different values for this particular version is not from the official source.
9 |
10 | - **Winhance.Installer.exe**
11 | - Size:
12 | - SHA256:
13 |
14 | - **Winhance.exe**
15 | - Size:
16 | - SHA256:
17 |
18 | ## Known Issues
19 |
20 | -
21 |
22 | ## Installation
23 | Download from [winhance.net](https://winhance.net) or directly from this release.
24 |
25 | The Winhance.Installer.exe includes both Installable and Portable versions during setup.
26 |
27 | ## Compatibility
28 | - Windows 10/11
29 | - Tested on Windows 10 x64 22H2 and Windows 11 24H2
30 |
31 | ## Feedback
32 | Please report any issues on the [GitHub Issues page](https://github.com/memstechtips/Winhance/issues).
33 |
--------------------------------------------------------------------------------
/.github/RELEASE_TEMPLATE_SIMPLIFIED.md:
--------------------------------------------------------------------------------
1 | # Winhance v[VERSION] Release
2 |
3 | ## What's New
4 |
5 | -
6 |
7 | ## Bug Fixes
8 |
9 | -
10 |
11 | ## Security Updates
12 |
13 | -
14 |
15 | ## Known Issues
16 |
17 | -
18 |
19 | ## Installation
20 | Download from [winhance.net](https://winhance.net) or directly from this release.
21 |
22 | The Winhance.Installer.exe includes both Installable and Portable versions during setup.
23 |
24 | ## Compatibility
25 | - Windows 10/11
26 | - Tested on Windows 10 x64 22H2 and Windows 11 24H2
27 |
28 | ## Feedback
29 | Please report any issues on the [GitHub Issues page](https://github.com/memstechtips/Winhance/issues).
30 |
--------------------------------------------------------------------------------
/Winhance.ps1:
--------------------------------------------------------------------------------
1 | # Display message in console
2 | Write-Host "Winhance has moved! https://winhance.net" -ForegroundColor Green
3 |
4 | # Open default web browser to the URL
5 | Start-Process "https://winhance.net"
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/CancellationReason.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums
2 | {
3 | ///
4 | /// Represents the reason for a cancellation operation.
5 | ///
6 | public enum CancellationReason
7 | {
8 | ///
9 | /// No cancellation occurred.
10 | ///
11 | None = 0,
12 |
13 | ///
14 | /// Cancellation was initiated by the user.
15 | ///
16 | UserCancelled = 1,
17 |
18 | ///
19 | /// Cancellation occurred due to internet connectivity issues.
20 | ///
21 | InternetConnectivityLost = 2,
22 |
23 | ///
24 | /// Cancellation occurred due to a system error.
25 | ///
26 | SystemError = 3
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/ControlType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Enums
4 | {
5 | ///
6 | /// Defines the type of control to use for a setting.
7 | ///
8 | public enum ControlType
9 | {
10 | ///
11 | /// A binary toggle (on/off) control.
12 | ///
13 | BinaryToggle,
14 |
15 | ///
16 | /// A three-state slider control.
17 | ///
18 | ThreeStateSlider,
19 |
20 | ///
21 | /// A combo box control for selecting from a list of options.
22 | ///
23 | ComboBox,
24 |
25 | ///
26 | /// A custom control.
27 | ///
28 | Custom,
29 |
30 | ///
31 | /// A slider control.
32 | ///
33 | Slider,
34 |
35 | ///
36 | /// A dropdown control.
37 | ///
38 | Dropdown,
39 |
40 | ///
41 | /// A color picker control.
42 | ///
43 | ColorPicker
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/LinkedSettingsLogic.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums;
2 |
3 | ///
4 | /// Defines the logic to use when determining the status of linked registry settings.
5 | ///
6 | public enum LinkedSettingsLogic
7 | {
8 | ///
9 | /// If any of the linked settings is applied, the entire setting is considered applied.
10 | ///
11 | Any,
12 |
13 | ///
14 | /// All linked settings must be applied for the entire setting to be considered applied.
15 | ///
16 | All,
17 |
18 | ///
19 | /// Only use the first (primary) setting to determine the status.
20 | ///
21 | Primary,
22 |
23 | ///
24 | /// Use a custom logic defined in the code.
25 | ///
26 | Custom
27 | }
28 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/LogLevel.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums
2 | {
3 | public enum LogLevel
4 | {
5 | Info,
6 | Warning,
7 | Error,
8 | Success,
9 | Debug
10 | }
11 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/OptimizationEnums.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums;
2 |
3 | public enum OptimizationCategory
4 | {
5 | Privacy,
6 | Gaming,
7 | Updates,
8 | Performance,
9 | GamingandPerformance,
10 | Personalization,
11 | Taskbar,
12 | StartMenu,
13 | Explorer,
14 | Notifications,
15 | Sound,
16 | Accessibility,
17 | Search,
18 | Services,
19 | Power
20 | }
21 |
22 | public enum WindowsAppType
23 | {
24 | AppX,
25 | Capability,
26 | Special // For Edge, OneDrive, etc.
27 | }
28 |
29 | public enum ServiceStartupType
30 | {
31 | Automatic = 2,
32 | Manual = 3,
33 | Disabled = 4
34 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/PowerShellStreamType.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums
2 | {
3 | ///
4 | /// Defines the types of PowerShell streams.
5 | ///
6 | public enum PowerShellStreamType
7 | {
8 | ///
9 | /// The output stream.
10 | ///
11 | Output,
12 |
13 | ///
14 | /// The error stream.
15 | ///
16 | Error,
17 |
18 | ///
19 | /// The warning stream.
20 | ///
21 | Warning,
22 |
23 | ///
24 | /// The verbose stream.
25 | ///
26 | Verbose,
27 |
28 | ///
29 | /// The debug stream.
30 | ///
31 | Debug,
32 |
33 | ///
34 | /// The information stream.
35 | ///
36 | Information,
37 |
38 | ///
39 | /// The progress stream.
40 | ///
41 | Progress
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/RegistryActionType.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums;
2 |
3 | ///
4 | /// Defines the intended action for a registry setting.
5 | ///
6 | public enum RegistryActionType
7 | {
8 | ///
9 | /// The setting is intended to set a specific value.
10 | ///
11 | Set,
12 |
13 | ///
14 | /// The setting is intended to remove a key or value.
15 | ///
16 | Remove,
17 |
18 | ///
19 | /// The setting is intended to modify an existing value.
20 | ///
21 | Modify
22 | }
23 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/RegistrySettingStatus.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Enums;
2 |
3 | public enum RegistrySettingStatus
4 | {
5 | Unknown, // Status couldn't be determined
6 | NotApplied, // Registry key doesn't exist or has default value
7 | Applied, // Current value matches recommended value
8 | Modified, // Value exists but doesn't match recommended or default
9 | Error // Error occurred while checking status
10 | }
11 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Enums/UacLevel.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Models.Enums
2 | {
3 | ///
4 | /// Represents User Account Control (UAC) levels in Windows.
5 | ///
6 | public enum UacLevel
7 | {
8 | ///
9 | /// Never notify the user when programs try to install software or make changes to the computer.
10 | ///
11 | NeverNotify = 0,
12 |
13 | ///
14 | /// Notify the user only when programs try to make changes to the computer, without dimming the desktop.
15 | ///
16 | NotifyNoDesktopDim = 1,
17 |
18 | ///
19 | /// Notify the user only when programs try to make changes to the computer (default).
20 | ///
21 | NotifyChangesOnly = 2,
22 |
23 | ///
24 | /// Always notify the user when programs try to install software or make changes to the computer
25 | /// or when the user makes changes to Windows settings.
26 | ///
27 | AlwaysNotify = 3,
28 |
29 | ///
30 | /// Custom UAC setting that doesn't match any of the standard Windows GUI options.
31 | /// This is used when the registry contains values that don't match the standard options.
32 | ///
33 | Custom = 99,
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Exceptions/AppLoadingException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Models.Exceptions
4 | {
5 | public enum AppLoadingErrorCode
6 | {
7 | Unknown,
8 | CacheFailure,
9 | Timeout,
10 | PackageManagerError,
11 | InvalidConfiguration,
12 | NetworkError
13 | }
14 |
15 | public class AppLoadingException : Exception
16 | {
17 | public AppLoadingErrorCode ErrorCode { get; }
18 | public Exception? OriginalException { get; }
19 |
20 | public AppLoadingException(AppLoadingErrorCode errorCode, string message,
21 | Exception? originalException = null)
22 | : base(message, originalException)
23 | {
24 | ErrorCode = errorCode;
25 | OriginalException = originalException;
26 | }
27 | }
28 |
29 | public class PackageManagerException : Exception
30 | {
31 | public string PackageId { get; }
32 | public string Operation { get; }
33 | public Exception? OriginalException { get; }
34 |
35 | public PackageManagerException(string packageId, string operation, string message,
36 | Exception? originalException = null)
37 | : base($"Package {operation} failed for {packageId}: {message}", originalException)
38 | {
39 | PackageId = packageId;
40 | Operation = operation;
41 | OriginalException = originalException;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Exceptions/InstallationStatusException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Models.Exceptions
4 | {
5 | public class InstallationStatusException : Exception
6 | {
7 | public InstallationStatusException(string message) : base(message)
8 | {
9 | }
10 |
11 | public InstallationStatusException(string message, Exception innerException)
12 | : base(message, innerException)
13 | {
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IApplicationCloseService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Service for handling application close functionality
7 | ///
8 | public interface IApplicationCloseService
9 | {
10 | ///
11 | /// Shows the support dialog if needed and handles the application close process
12 | ///
13 | /// A task representing the asynchronous operation
14 | Task CloseApplicationWithSupportDialogAsync();
15 |
16 | ///
17 | /// Saves the "Don't show support dialog" preference
18 | ///
19 | /// Whether to show the support dialog in the future
20 | /// A task representing the asynchronous operation
21 | Task SaveDontShowSupportPreferenceAsync(bool dontShow);
22 |
23 | ///
24 | /// Checks if the support dialog should be shown based on user preferences
25 | ///
26 | /// True if the dialog should be shown, false otherwise
27 | Task ShouldShowSupportDialogAsync();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/ICommandService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.Core.Features.Common.Interfaces
6 | {
7 | ///
8 | /// Service for executing system commands related to optimizations.
9 | ///
10 | public interface ICommandService
11 | {
12 | ///
13 | /// Executes the specified command with elevated privileges if required.
14 | ///
15 | /// The command to execute.
16 | /// Whether the command requires elevation.
17 | /// The result of the command execution.
18 | Task<(bool Success, string Output, string Error)> ExecuteCommandAsync(string command, bool requiresElevation = true);
19 |
20 | ///
21 | /// Applies the command settings based on the enabled state.
22 | ///
23 | /// The command settings to apply.
24 | /// Whether the optimization is enabled.
25 | /// A result indicating success or failure with details.
26 | Task<(bool Success, string Message)> ApplyCommandSettingsAsync(IEnumerable settings, bool isEnabled);
27 |
28 | ///
29 | /// Gets the current state of a command setting.
30 | ///
31 | /// The command setting to check.
32 | /// True if the setting is in its enabled state, false otherwise.
33 | Task IsCommandSettingEnabledAsync(CommandSetting setting);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IConfigurationCoordinatorService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.Core.Features.Common.Interfaces
6 | {
7 | ///
8 | /// Service for coordinating configuration operations across multiple view models.
9 | ///
10 | public interface IConfigurationCoordinatorService
11 | {
12 | ///
13 | /// Creates a unified configuration file containing settings from all view models.
14 | ///
15 | /// A task representing the asynchronous operation. Returns the unified configuration file.
16 | Task CreateUnifiedConfigurationAsync();
17 |
18 | ///
19 | /// Applies a unified configuration to the selected sections.
20 | ///
21 | /// The unified configuration file.
22 | /// The sections to apply.
23 | /// A task representing the asynchronous operation. Returns true if successful, false otherwise.
24 | Task ApplyUnifiedConfigurationAsync(UnifiedConfigurationFile config, IEnumerable selectedSections);
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/ILogService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Winhance.Core.Features.Common.Enums;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.Core.Features.Common.Interfaces
6 | {
7 | ///
8 | /// Provides logging functionality for the application.
9 | ///
10 | public interface ILogService
11 | {
12 | ///
13 | /// Starts logging to a file.
14 | ///
15 | void StartLog();
16 |
17 | ///
18 | /// Stops logging to a file.
19 | ///
20 | void StopLog();
21 |
22 | ///
23 | /// Logs an informational message.
24 | ///
25 | /// The message to log.
26 | void LogInformation(string message);
27 |
28 | ///
29 | /// Logs a warning message.
30 | ///
31 | /// The message to log.
32 | void LogWarning(string message);
33 |
34 | ///
35 | /// Logs an error message.
36 | ///
37 | /// The message to log.
38 | /// The exception associated with the error, if any.
39 | void LogError(string message, Exception? exception = null);
40 |
41 | ///
42 | /// Logs a success message.
43 | ///
44 | /// The message to log.
45 | void LogSuccess(string message);
46 |
47 | ///
48 | /// Gets the path to the current log file.
49 | ///
50 | /// The path to the log file.
51 | string GetLogPath();
52 |
53 | ///
54 | /// Logs a message with the specified level.
55 | ///
56 | /// The log level.
57 | /// The message to log.
58 | /// The exception associated with the message, if any.
59 | void Log(LogLevel level, string message, Exception? exception = null);
60 |
61 | ///
62 | /// Event raised when a log message is generated.
63 | ///
64 | event EventHandler? LogMessageGenerated;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IMessengerService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Provides functionality for messaging between components.
7 | ///
8 | public interface IMessengerService
9 | {
10 | ///
11 | /// Sends a message of the specified type.
12 | ///
13 | /// The type of the message to send.
14 | /// The message to send.
15 | void Send(TMessage message);
16 |
17 | ///
18 | /// Registers a recipient for messages of the specified type.
19 | ///
20 | /// The type of message to register for.
21 | /// The recipient object.
22 | /// The action to perform when a message is received.
23 | void Register(object recipient, Action action);
24 |
25 | ///
26 | /// Unregisters a recipient from receiving messages.
27 | ///
28 | /// The recipient to unregister.
29 | void Unregister(object recipient);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IParameterSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Interface for serializing and deserializing navigation parameters.
7 | ///
8 | public interface IParameterSerializer
9 | {
10 | ///
11 | /// Serializes an object to a string representation.
12 | ///
13 | /// The object to serialize.
14 | /// A string representation of the object.
15 | string Serialize(object parameter);
16 |
17 | ///
18 | /// Deserializes a string to an object of the specified type.
19 | ///
20 | /// The type to deserialize to.
21 | /// The string to deserialize.
22 | /// The deserialized object.
23 | object Deserialize(Type targetType, string value);
24 |
25 | ///
26 | /// Deserializes a string to an object of the specified type.
27 | ///
28 | /// The type to deserialize to.
29 | /// The string to deserialize.
30 | /// The deserialized object.
31 | T Deserialize(string serialized);
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IParameterSerializerService.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Interfaces.Services
2 | {
3 | ///
4 | /// Service for serializing and deserializing navigation parameters.
5 | ///
6 | public interface IParameterSerializerService
7 | {
8 | ///
9 | /// Serializes an object to a string.
10 | ///
11 | /// The object to serialize.
12 | /// The serialized string.
13 | string Serialize(object value);
14 |
15 | ///
16 | /// Deserializes a string to an object of the specified type.
17 | ///
18 | /// The type to deserialize to.
19 | /// The string to deserialize.
20 | /// The deserialized object.
21 | T Deserialize(string value);
22 |
23 | ///
24 | /// Deserializes a string to an object of the specified type.
25 | ///
26 | /// The type to deserialize to.
27 | /// The string to deserialize.
28 | /// The deserialized object.
29 | object Deserialize(System.Type type, string value);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IPowerShellExecutionService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Winhance.Core.Features.Common.Models;
5 |
6 | namespace Winhance.Core.Features.Common.Interfaces
7 | {
8 | ///
9 | /// Provides functionality for executing PowerShell scripts.
10 | ///
11 | public interface IPowerShellExecutionService
12 | {
13 | ///
14 | /// Executes a PowerShell script.
15 | ///
16 | /// The script to execute.
17 | /// The progress reporter.
18 | /// The cancellation token.
19 | /// The output of the script.
20 | Task ExecuteScriptAsync(
21 | string script,
22 | IProgress? progress = null,
23 | CancellationToken cancellationToken = default);
24 |
25 | ///
26 | /// Executes a PowerShell script file.
27 | ///
28 | /// The path to the script file.
29 | /// The arguments to pass to the script.
30 | /// The progress reporter.
31 | /// The cancellation token.
32 | /// The output of the script.
33 | Task ExecuteScriptFileAsync(
34 | string scriptPath,
35 | string arguments = "",
36 | IProgress? progress = null,
37 | CancellationToken cancellationToken = default);
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IScheduledTaskService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Winhance.Core.Features.SoftwareApps.Models;
3 |
4 | namespace Winhance.Core.Features.Common.Interfaces
5 | {
6 | ///
7 | /// Interface for a service that manages scheduled tasks for script execution.
8 | ///
9 | public interface IScheduledTaskService
10 | {
11 | ///
12 | /// Registers a scheduled task to run the specified script.
13 | ///
14 | /// The script to register as a scheduled task.
15 | /// True if the task was registered successfully, false otherwise.
16 | Task RegisterScheduledTaskAsync(RemovalScript script);
17 |
18 | ///
19 | /// Unregisters a scheduled task with the specified name.
20 | ///
21 | /// The name of the task to unregister.
22 | /// True if the task was unregistered successfully, false otherwise.
23 | Task UnregisterScheduledTaskAsync(string taskName);
24 |
25 | ///
26 | /// Checks if a scheduled task with the specified name is registered.
27 | ///
28 | /// The name of the task to check.
29 | /// True if the task exists, false otherwise.
30 | Task IsTaskRegisteredAsync(string taskName);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IScriptDetectionService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Service for detecting the presence of script files used by Winhance to remove applications.
7 | ///
8 | public interface IScriptDetectionService
9 | {
10 | ///
11 | /// Checks if any removal scripts are present.
12 | ///
13 | /// True if any removal scripts are present, false otherwise.
14 | bool AreRemovalScriptsPresent();
15 |
16 | ///
17 | /// Gets information about all active removal scripts.
18 | ///
19 | /// A collection of script information objects.
20 | IEnumerable GetActiveScripts();
21 | }
22 |
23 | ///
24 | /// Represents information about a script file.
25 | ///
26 | public class ScriptInfo
27 | {
28 | ///
29 | /// Gets or sets the name of the script file.
30 | ///
31 | public string Name { get; set; }
32 |
33 | ///
34 | /// Gets or sets the description of what the script does.
35 | ///
36 | public string Description { get; set; }
37 |
38 | ///
39 | /// Gets or sets the full path to the script file.
40 | ///
41 | public string FilePath { get; set; }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IScriptFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Winhance.Core.Features.Common.Models;
3 | using Winhance.Core.Features.SoftwareApps.Models;
4 |
5 | namespace Winhance.Core.Features.Common.Interfaces
6 | {
7 | ///
8 | /// Factory for creating script objects.
9 | ///
10 | public interface IScriptFactory
11 | {
12 | ///
13 | /// Creates a batch removal script.
14 | ///
15 | /// The names of the applications to remove.
16 | /// Dictionary mapping app names to registry settings.
17 | /// Dictionary mapping app names to their subpackages.
18 | /// A removal script object.
19 | RemovalScript CreateBatchRemovalScript(
20 | List appNames,
21 | Dictionary> appsWithRegistry,
22 | Dictionary appSubPackages = null);
23 |
24 | ///
25 | /// Creates a single app removal script.
26 | ///
27 | /// The app to remove.
28 | /// A removal script object.
29 | RemovalScript CreateSingleAppRemovalScript(AppInfo app);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IScriptTemplateProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Provides templates for PowerShell scripts used in the application.
7 | ///
8 | public interface IScriptTemplateProvider
9 | {
10 | ///
11 | /// Gets the template for removing a package.
12 | ///
13 | /// The template string for package removal.
14 | string GetPackageRemovalTemplate();
15 |
16 | ///
17 | /// Gets the template for removing a capability.
18 | ///
19 | /// The template string for capability removal.
20 | string GetCapabilityRemovalTemplate();
21 |
22 | ///
23 | /// Gets the template for removing an optional feature.
24 | ///
25 | /// The template string for optional feature removal.
26 | string GetFeatureRemovalTemplate();
27 |
28 | ///
29 | /// Gets the template for a registry setting operation.
30 | ///
31 | /// True if this is a delete operation; false if it's a set operation.
32 | /// The template string for registry operations.
33 | string GetRegistrySettingTemplate(bool isDelete);
34 |
35 | ///
36 | /// Gets the header for a script.
37 | ///
38 | /// The name of the script.
39 | /// The header string for the script.
40 | string GetScriptHeader(string scriptName);
41 |
42 | ///
43 | /// Gets the footer for a script.
44 | ///
45 | /// The footer string for the script.
46 | string GetScriptFooter();
47 | }
48 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/ISearchService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 |
4 | namespace Winhance.Core.Features.Common.Interfaces
5 | {
6 | ///
7 | /// Interface for services that handle search operations.
8 | ///
9 | public interface ISearchService
10 | {
11 | ///
12 | /// Filters a collection of items based on a search term.
13 | ///
14 | /// The type of items to filter.
15 | /// The collection of items to filter.
16 | /// The search term to filter by.
17 | /// A filtered collection of items that match the search term.
18 | IEnumerable FilterItems(IEnumerable items, string searchTerm) where T : ISearchable;
19 |
20 | ///
21 | /// Asynchronously filters a collection of items based on a search term.
22 | ///
23 | /// The type of items to filter.
24 | /// The collection of items to filter.
25 | /// The search term to filter by.
26 | /// A task that represents the asynchronous operation. The task result contains a filtered collection of items that match the search term.
27 | Task> FilterItemsAsync(IEnumerable items, string searchTerm) where T : ISearchable;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/ISearchable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Interface for objects that can be searched.
7 | ///
8 | public interface ISearchable
9 | {
10 | ///
11 | /// Determines if the object matches the given search term.
12 | ///
13 | /// The search term to match against.
14 | /// True if the object matches the search term, false otherwise.
15 | bool MatchesSearch(string searchTerm);
16 |
17 | ///
18 | /// Gets the searchable properties of the object.
19 | ///
20 | /// An array of property names that should be searched.
21 | string[] GetSearchableProperties();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/ISettingItem.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows.Input;
3 | using Winhance.Core.Features.Common.Enums;
4 | using Winhance.Core.Features.Common.Models;
5 |
6 | namespace Winhance.Core.Features.Common.Interfaces
7 | {
8 | ///
9 | /// Defines the common properties that all setting items should have.
10 | ///
11 | public interface ISettingItem
12 | {
13 | ///
14 | /// Gets or sets the unique identifier for the setting.
15 | ///
16 | string Id { get; set; }
17 |
18 | ///
19 | /// Gets or sets the name of the setting.
20 | ///
21 | string Name { get; set; }
22 |
23 | ///
24 | /// Gets or sets the description of the setting.
25 | ///
26 | string Description { get; set; }
27 |
28 | ///
29 | /// Gets or sets a value indicating whether the setting is selected.
30 | ///
31 | bool IsSelected { get; set; }
32 |
33 | ///
34 | /// Gets or sets the group name that this setting belongs to.
35 | ///
36 | string GroupName { get; set; }
37 |
38 | ///
39 | /// Gets or sets a value indicating whether the setting is visible in the UI.
40 | ///
41 | bool IsVisible { get; set; }
42 |
43 | ///
44 | /// Gets or sets the type of control used for this setting.
45 | ///
46 | ControlType ControlType { get; set; }
47 |
48 | ///
49 | /// Gets or sets the dependencies for this setting.
50 | ///
51 | List Dependencies { get; set; }
52 |
53 | ///
54 | /// Gets or sets a value indicating whether the setting is being updated from code.
55 | ///
56 | bool IsUpdatingFromCode { get; set; }
57 |
58 | ///
59 | /// Gets the command to apply the setting.
60 | ///
61 | ICommand ApplySettingCommand { get; }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/ISettingsRegistry.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Winhance.Core.Features.Common.Interfaces;
3 |
4 | namespace Winhance.Core.Features.Common.Interfaces
5 | {
6 | ///
7 | /// Interface for a registry of settings.
8 | ///
9 | public interface ISettingsRegistry
10 | {
11 | ///
12 | /// Registers a setting in the registry.
13 | ///
14 | /// The setting to register.
15 | void RegisterSetting(ISettingItem setting);
16 |
17 | ///
18 | /// Gets a setting by its ID.
19 | ///
20 | /// The ID of the setting to get.
21 | /// The setting if found, otherwise null.
22 | ISettingItem? GetSettingById(string id);
23 |
24 | ///
25 | /// Gets all settings in the registry.
26 | ///
27 | /// A list of all settings.
28 | List GetAllSettings();
29 |
30 | ///
31 | /// Gets all settings of a specific type.
32 | ///
33 | /// The type of settings to get.
34 | /// A list of settings of the specified type.
35 | List GetSettingsByType() where T : ISettingItem;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IUacSettingsService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Winhance.Core.Features.Optimize.Models;
3 | using Winhance.Core.Models.Enums;
4 |
5 | namespace Winhance.Core.Features.Common.Interfaces
6 | {
7 | ///
8 | /// Interface for a service that manages UAC settings persistence.
9 | ///
10 | public interface IUacSettingsService
11 | {
12 | ///
13 | /// Saves custom UAC settings.
14 | ///
15 | /// The ConsentPromptBehaviorAdmin registry value.
16 | /// The PromptOnSecureDesktop registry value.
17 | /// A task representing the asynchronous operation.
18 | Task SaveCustomUacSettingsAsync(int consentPromptValue, int secureDesktopValue);
19 |
20 | ///
21 | /// Loads custom UAC settings.
22 | ///
23 | /// A CustomUacSettings object if settings exist, null otherwise.
24 | Task LoadCustomUacSettingsAsync();
25 |
26 | ///
27 | /// Checks if custom UAC settings exist.
28 | ///
29 | /// True if custom settings exist, false otherwise.
30 | Task HasCustomUacSettingsAsync();
31 |
32 | ///
33 | /// Gets custom UAC settings if they exist.
34 | ///
35 | /// The ConsentPromptBehaviorAdmin registry value.
36 | /// The PromptOnSecureDesktop registry value.
37 | /// True if custom settings were retrieved, false otherwise.
38 | bool TryGetCustomUacValues(out int consentPromptValue, out int secureDesktopValue);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IVersionService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Winhance.Core.Features.Common.Models;
3 |
4 | namespace Winhance.Core.Features.Common.Interfaces
5 | {
6 | public interface IVersionService
7 | {
8 | ///
9 | /// Gets the current application version
10 | ///
11 | VersionInfo GetCurrentVersion();
12 |
13 | ///
14 | /// Checks if an update is available
15 | ///
16 | /// A task that resolves to true if an update is available, false otherwise
17 | Task CheckForUpdateAsync();
18 |
19 | ///
20 | /// Downloads and launches the installer for the latest version
21 | ///
22 | /// A task that completes when the download is initiated
23 | Task DownloadAndInstallUpdateAsync();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Interfaces
2 | {
3 | ///
4 | /// Base interface for all view models.
5 | ///
6 | public interface IViewModel
7 | {
8 | ///
9 | /// Called when navigation to the view model has occurred.
10 | ///
11 | /// The navigation parameter.
12 | void OnNavigatedTo(object? parameter = null);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Interfaces/IVisibleSettingItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Interfaces
4 | {
5 | ///
6 | /// Interface for setting items that can be shown or hidden in the UI.
7 | ///
8 | public interface IVisibleSettingItem
9 | {
10 | ///
11 | /// Gets or sets a value indicating whether this setting item is visible in the UI.
12 | ///
13 | bool IsVisible { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Messaging/Messages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Winhance.Core.Features.Common.Enums;
3 |
4 | namespace Winhance.Core.Features.Common.Messaging
5 | {
6 | ///
7 | /// Base class for all messages that will be sent through the messenger
8 | ///
9 | public abstract class MessageBase
10 | {
11 | public DateTime Timestamp { get; } = DateTime.Now;
12 | }
13 |
14 | ///
15 | /// Message sent when a log entry is created
16 | ///
17 | public class LogMessage : MessageBase
18 | {
19 | public string Message { get; set; }
20 | public LogLevel Level { get; set; }
21 | public Exception Exception { get; set; }
22 | }
23 |
24 | ///
25 | /// Message sent when progress changes
26 | ///
27 | public class ProgressMessage : MessageBase
28 | {
29 | public double Progress { get; set; }
30 | public string StatusText { get; set; }
31 | public bool IsIndeterminate { get; set; }
32 | public bool IsTaskRunning { get; set; }
33 | }
34 |
35 | ///
36 | /// Message sent when detailed task progress changes
37 | ///
38 | public class TaskProgressMessage : MessageBase
39 | {
40 | public string TaskName { get; set; }
41 | public double Progress { get; set; }
42 | public string StatusText { get; set; }
43 | public bool IsIndeterminate { get; set; }
44 | public bool IsTaskRunning { get; set; }
45 | public bool CanCancel { get; set; }
46 | }
47 |
48 | ///
49 | /// Message sent when window state changes
50 | ///
51 | public class WindowStateMessage : MessageBase
52 | {
53 | public enum WindowStateAction
54 | {
55 | Minimize,
56 | Maximize,
57 | Restore,
58 | Close
59 | }
60 |
61 | public WindowStateAction Action { get; set; }
62 | }
63 |
64 | ///
65 | /// Message sent to update the UI theme
66 | ///
67 | public class ThemeChangedMessage : MessageBase
68 | {
69 | public bool IsDarkTheme { get; set; }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/ApplicationAction.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Threading.Tasks;
5 | using Winhance.Core.Features.Common.Models;
6 |
7 | namespace Winhance.Core.Features.Common.Models
8 | {
9 | ///
10 | /// Base class for application actions that can be performed in both Optimization and Customization features.
11 | ///
12 | public partial class ApplicationAction : ObservableObject
13 | {
14 | [ObservableProperty]
15 | private string _id = string.Empty;
16 |
17 | [ObservableProperty]
18 | private string _name = string.Empty;
19 |
20 | [ObservableProperty]
21 | private string _description = string.Empty;
22 |
23 | [ObservableProperty]
24 | private string _groupName = string.Empty;
25 |
26 | [ObservableProperty]
27 | private string _confirmationMessage = string.Empty;
28 |
29 | [ObservableProperty]
30 | private string _actionType = string.Empty;
31 |
32 | [ObservableProperty]
33 | private string _command = string.Empty;
34 |
35 | [ObservableProperty]
36 | private string _commandAction = string.Empty;
37 |
38 | ///
39 | /// Gets or sets the registry setting or other action to perform.
40 | ///
41 | public RegistrySetting? RegistrySetting { get; set; }
42 |
43 | ///
44 | /// Gets or sets optional additional actions to perform.
45 | ///
46 | public Func>? CustomAction { get; set; }
47 |
48 | ///
49 | /// Gets or sets a value indicating whether this action supports backup.
50 | ///
51 | public bool SupportsBackup { get; set; }
52 |
53 | ///
54 | /// Gets or sets optional backup action to perform.
55 | ///
56 | public Func>? BackupAction { get; set; }
57 |
58 | ///
59 | /// Gets or sets the parameters for this action.
60 | ///
61 | public Dictionary Parameters { get; set; } = new Dictionary();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/CommandSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Models
4 | {
5 | ///
6 | /// Represents a command-based setting that can be executed to enable or disable an optimization.
7 | ///
8 | public class CommandSetting
9 | {
10 | ///
11 | /// Gets or sets the unique identifier for this command setting.
12 | ///
13 | public string Id { get; set; } = string.Empty;
14 |
15 | ///
16 | /// Gets or sets the category this command belongs to.
17 | ///
18 | public string Category { get; set; } = string.Empty;
19 |
20 | ///
21 | /// Gets or sets the description of what this command does.
22 | ///
23 | public string Description { get; set; } = string.Empty;
24 |
25 | ///
26 | /// Gets or sets the command to execute when the setting is enabled.
27 | ///
28 | public string EnabledCommand { get; set; } = string.Empty;
29 |
30 | ///
31 | /// Gets or sets the command to execute when the setting is disabled.
32 | ///
33 | public string DisabledCommand { get; set; } = string.Empty;
34 |
35 | ///
36 | /// Gets or sets whether this command requires elevation.
37 | ///
38 | public bool RequiresElevation { get; set; } = true;
39 |
40 | ///
41 | /// Gets or sets whether this is the primary command in a group.
42 | ///
43 | public bool IsPrimary { get; set; } = true;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/ConfigurationFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Winhance.Core.Features.Common.Models
5 | {
6 | ///
7 | /// Represents a configuration file that stores application settings.
8 | ///
9 | public class ConfigurationFile
10 | {
11 | ///
12 | /// Gets or sets the type of configuration (e.g., "ExternalApps", "WindowsApps").
13 | ///
14 | public string ConfigType { get; set; }
15 |
16 | ///
17 | /// Gets or sets the version of the configuration file format.
18 | ///
19 | public string Version { get; set; } = "1.0";
20 |
21 | ///
22 | /// Gets or sets the date and time when the configuration file was created.
23 | ///
24 | public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
25 |
26 | ///
27 | /// Gets or sets the collection of configuration items.
28 | ///
29 | public List Items { get; set; } = new List();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/IInstallableItem.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Models
2 | {
3 | public interface IInstallableItem
4 | {
5 | string PackageId { get; }
6 | string DisplayName { get; }
7 | InstallItemType ItemType { get; }
8 | bool IsInstalled { get; set; }
9 | bool RequiresRestart { get; }
10 | }
11 |
12 | public enum InstallItemType
13 | {
14 | WindowsApp,
15 | Capability,
16 | Feature,
17 | ThirdParty
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/InstallStatus.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Common.Models
2 | {
3 | public enum InstallStatus
4 | {
5 | Success,
6 | NotFound,
7 | Failed,
8 | Pending
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/LogMessageEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Winhance.Core.Features.Common.Enums;
3 |
4 | namespace Winhance.Core.Features.Common.Models
5 | {
6 | ///
7 | /// Event arguments for log message events.
8 | ///
9 | public class LogMessageEventArgs : EventArgs
10 | {
11 | ///
12 | /// Gets the message content.
13 | ///
14 | public string Message { get; }
15 |
16 | ///
17 | /// Gets the log level.
18 | ///
19 | public LogLevel Level { get; }
20 |
21 | ///
22 | /// Gets the timestamp when the message was created.
23 | ///
24 | public DateTime Timestamp { get; }
25 |
26 | ///
27 | /// Gets the exception associated with the log message, if any.
28 | ///
29 | public Exception? Exception { get; }
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// The message content.
35 | /// The log level.
36 | public LogMessageEventArgs(string message, LogLevel level)
37 | {
38 | Message = message ?? throw new ArgumentNullException(nameof(message));
39 | Level = level;
40 | Timestamp = DateTime.Now;
41 | Exception = null;
42 | }
43 |
44 | ///
45 | /// Initializes a new instance of the class.
46 | ///
47 | /// The log level.
48 | /// The message content.
49 | /// The exception associated with the message, if any.
50 | public LogMessageEventArgs(LogLevel level, string message, Exception? exception)
51 | {
52 | Message = message ?? throw new ArgumentNullException(nameof(message));
53 | Level = level;
54 | Timestamp = DateTime.Now;
55 | Exception = exception;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/OptimizationConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Winhance.Core.Features.Common.Enums;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.Common.Models;
7 |
8 | public class OptimizationConfig
9 | {
10 | public required IDictionary> RegistrySettings { get; init; }
11 | public required IReadOnlyList WindowsPackages { get; init; }
12 | public required IReadOnlyList LegacyCapabilities { get; init; }
13 | public required IReadOnlyList Services { get; init; }
14 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/PowerShellProgressData.cs:
--------------------------------------------------------------------------------
1 | using Winhance.Core.Features.Common.Enums;
2 |
3 | namespace Winhance.Core.Features.Common.Models
4 | {
5 | ///
6 | /// Represents progress data from PowerShell operations.
7 | ///
8 | public class PowerShellProgressData
9 | {
10 | ///
11 | /// Gets or sets the percent complete value (0-100).
12 | ///
13 | public int? PercentComplete { get; set; }
14 |
15 | ///
16 | /// Gets or sets the activity description.
17 | ///
18 | public string Activity { get; set; }
19 |
20 | ///
21 | /// Gets or sets the status description.
22 | ///
23 | public string StatusDescription { get; set; }
24 |
25 | ///
26 | /// Gets or sets the current operation description.
27 | ///
28 | public string CurrentOperation { get; set; }
29 |
30 | ///
31 | /// Gets or sets the PowerShell stream type.
32 | ///
33 | public PowerShellStreamType StreamType { get; set; }
34 |
35 | ///
36 | /// Gets or sets the message content.
37 | ///
38 | public string Message { get; set; }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/RefreshResult.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Winhance.Core.Features.Common.Models
4 | {
5 | ///
6 | /// Represents the result of a refresh operation for installation statuses.
7 | ///
8 | public class RefreshResult
9 | {
10 | ///
11 | /// Gets or sets a value indicating whether the refresh operation was successful.
12 | ///
13 | public bool Success { get; set; }
14 |
15 | ///
16 | /// Gets or sets the error message if the refresh operation failed.
17 | ///
18 | public string? ErrorMessage { get; set; }
19 |
20 | ///
21 | /// Gets or sets the collection of app IDs that were successfully refreshed.
22 | ///
23 | public IEnumerable RefreshedAppIds { get; set; } = new List();
24 |
25 | ///
26 | /// Gets or sets the collection of app IDs that failed to refresh.
27 | ///
28 | public IEnumerable FailedAppIds { get; set; } = new List();
29 |
30 | ///
31 | /// Gets or sets the number of successfully refreshed apps.
32 | ///
33 | public int SuccessCount { get; set; }
34 |
35 | ///
36 | /// Gets or sets the number of failed refreshed apps.
37 | ///
38 | public int FailedCount { get; set; }
39 |
40 | ///
41 | /// Gets or sets the collection of errors.
42 | ///
43 | public Dictionary Errors { get; set; } = new Dictionary();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/RegistryTestResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Models
4 | {
5 | ///
6 | /// Represents the result of a registry value test.
7 | ///
8 | public class RegistryTestResult
9 | {
10 | ///
11 | /// Gets or sets the registry key path.
12 | ///
13 | public string KeyPath { get; set; }
14 |
15 | ///
16 | /// Gets or sets the registry value name.
17 | ///
18 | public string ValueName { get; set; }
19 |
20 | ///
21 | /// Gets or sets the expected value.
22 | ///
23 | public object ExpectedValue { get; set; }
24 |
25 | ///
26 | /// Gets or sets the actual value.
27 | ///
28 | public object ActualValue { get; set; }
29 |
30 | ///
31 | /// Gets or sets a value indicating whether the test was successful.
32 | ///
33 | public bool IsSuccess { get; set; }
34 |
35 | ///
36 | /// Gets or sets the test result message.
37 | ///
38 | public string Message { get; set; }
39 |
40 | ///
41 | /// Gets or sets the category of the registry setting.
42 | ///
43 | public string Category { get; set; }
44 |
45 | ///
46 | /// Gets or sets the description of the registry setting.
47 | ///
48 | public string Description { get; set; }
49 |
50 | ///
51 | /// Gets a formatted string representation of the test result.
52 | ///
53 | /// A formatted string representation of the test result.
54 | public override string ToString()
55 | {
56 | return $"{(IsSuccess ? "✓" : "✗")} {KeyPath}\\{ValueName}: {Message}";
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/TaskProgressDetail.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Winhance.Core.Features.Common.Enums;
3 |
4 | namespace Winhance.Core.Features.Common.Models
5 | {
6 | ///
7 | /// Represents detailed progress information for a task.
8 | ///
9 | public class TaskProgressDetail
10 | {
11 | ///
12 | /// Gets or sets the progress value (0-100), or null if not applicable.
13 | ///
14 | public double? Progress { get; set; }
15 |
16 | ///
17 | /// Gets or sets the status text.
18 | ///
19 | public string StatusText { get; set; }
20 |
21 | ///
22 | /// Gets or sets a detailed message about the current operation.
23 | ///
24 | public string DetailedMessage { get; set; }
25 |
26 | ///
27 | /// Gets or sets the log level for the detailed message.
28 | ///
29 | public LogLevel LogLevel { get; set; } = LogLevel.Info;
30 |
31 | ///
32 | /// Gets or sets whether the progress is indeterminate.
33 | ///
34 | public bool IsIndeterminate { get; set; }
35 |
36 | ///
37 | /// Gets or sets additional information about the progress as key-value pairs.
38 | /// This can be used to provide more detailed information for logging or debugging.
39 | ///
40 | public Dictionary AdditionalInfo { get; set; } = new Dictionary();
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Common/Models/VersionInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Common.Models
4 | {
5 | public class VersionInfo
6 | {
7 | public string Version { get; set; } = string.Empty;
8 | public DateTime ReleaseDate { get; set; }
9 | public string DownloadUrl { get; set; } = string.Empty;
10 | public bool IsUpdateAvailable { get; set; }
11 |
12 | public static VersionInfo FromTag(string tag)
13 | {
14 | // Parse version tag in format v25.05.02
15 | if (string.IsNullOrEmpty(tag) || !tag.StartsWith("v"))
16 | return new VersionInfo();
17 |
18 | string versionString = tag.Substring(1); // Remove 'v' prefix
19 | string[] parts = versionString.Split('.');
20 |
21 | if (parts.Length != 3)
22 | return new VersionInfo();
23 |
24 | if (!int.TryParse(parts[0], out int year) ||
25 | !int.TryParse(parts[1], out int month) ||
26 | !int.TryParse(parts[2], out int day))
27 | return new VersionInfo();
28 |
29 | // Construct a date from the version components
30 | DateTime releaseDate;
31 | try
32 | {
33 | releaseDate = new DateTime(2000 + year, month, day);
34 | }
35 | catch
36 | {
37 | // Invalid date components
38 | return new VersionInfo();
39 | }
40 |
41 | return new VersionInfo
42 | {
43 | Version = tag,
44 | ReleaseDate = releaseDate
45 | };
46 | }
47 |
48 | public bool IsNewerThan(VersionInfo other)
49 | {
50 | if (other == null)
51 | return true;
52 |
53 | return ReleaseDate > other.ReleaseDate;
54 | }
55 |
56 | public override string ToString()
57 | {
58 | return Version;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Customize/Enums/CustomizationCategory.cs:
--------------------------------------------------------------------------------
1 | namespace Winhance.Core.Features.Customize.Enums;
2 |
3 | ///
4 | /// Defines the categories for customization settings.
5 | ///
6 | public enum CustomizationCategory
7 | {
8 | ///
9 | /// Theme-related customization settings.
10 | ///
11 | Theme,
12 |
13 | ///
14 | /// Taskbar-related customization settings.
15 | ///
16 | Taskbar,
17 |
18 | ///
19 | /// Start menu-related customization settings.
20 | ///
21 | StartMenu,
22 |
23 | ///
24 | /// Explorer-related customization settings.
25 | ///
26 | Explorer,
27 |
28 | ///
29 | /// Notification-related customization settings.
30 | ///
31 | Notifications,
32 |
33 | ///
34 | /// Sound-related customization settings.
35 | ///
36 | Sound,
37 |
38 | ///
39 | /// Accessibility-related customization settings.
40 | ///
41 | Accessibility
42 | }
43 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Customize/Enums/CustomizationSettingType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Customize.Enums
4 | {
5 | ///
6 | /// Defines the type of customization setting.
7 | ///
8 | public enum CustomizationSettingType
9 | {
10 | ///
11 | /// A standard setting.
12 | ///
13 | Standard,
14 |
15 | ///
16 | /// A slider setting.
17 | ///
18 | Slider,
19 |
20 | ///
21 | /// A dropdown setting.
22 | ///
23 | Dropdown,
24 |
25 | ///
26 | /// A color picker setting.
27 | ///
28 | ColorPicker
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Customize/Interfaces/IThemeService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace Winhance.Core.Features.Customize.Interfaces
4 | {
5 | ///
6 | /// Interface for theme-related operations.
7 | ///
8 | public interface IThemeService
9 | {
10 | ///
11 | /// Checks if dark mode is enabled.
12 | ///
13 | /// True if dark mode is enabled; otherwise, false.
14 | bool IsDarkModeEnabled();
15 |
16 | ///
17 | /// Sets the theme mode.
18 | ///
19 | /// True to enable dark mode; false to enable light mode.
20 | /// True if the operation succeeded; otherwise, false.
21 | bool SetThemeMode(bool isDarkMode);
22 |
23 | ///
24 | /// Sets the theme mode and optionally changes the wallpaper.
25 | ///
26 | /// True to enable dark mode; false to enable light mode.
27 | /// True to change the wallpaper; otherwise, false.
28 | /// A task representing the asynchronous operation.
29 | Task ApplyThemeAsync(bool isDarkMode, bool changeWallpaper);
30 |
31 | ///
32 | /// Gets the name of the current theme.
33 | ///
34 | /// The name of the current theme ("Light Mode" or "Dark Mode").
35 | string GetCurrentThemeName();
36 |
37 | ///
38 | /// Refreshes the Windows GUI to apply theme changes.
39 | ///
40 | /// True to restart Explorer; otherwise, false.
41 | /// A task representing the asynchronous operation.
42 | Task RefreshGUIAsync(bool restartExplorer);
43 | }
44 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Customize/Interfaces/IWallpaperService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace Winhance.Core.Features.Customize.Interfaces
4 | {
5 | ///
6 | /// Interface for wallpaper operations.
7 | ///
8 | public interface IWallpaperService
9 | {
10 | ///
11 | /// Sets the desktop wallpaper.
12 | ///
13 | /// The path to the wallpaper image.
14 | /// A task representing the asynchronous operation.
15 | Task SetWallpaperAsync(string wallpaperPath);
16 |
17 | ///
18 | /// Sets the default wallpaper based on Windows version and theme.
19 | ///
20 | /// Whether the system is Windows 11.
21 | /// Whether dark mode is enabled.
22 | /// A task representing the asynchronous operation.
23 | Task SetDefaultWallpaperAsync(bool isWindows11, bool isDarkMode);
24 |
25 | ///
26 | /// Gets the default wallpaper path based on Windows version and theme.
27 | ///
28 | /// Whether the system is Windows 11.
29 | /// Whether dark mode is enabled.
30 | /// The path to the default wallpaper.
31 | string GetDefaultWallpaperPath(bool isWindows11, bool isDarkMode);
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Customize/Models/CustomizationGroup.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Winhance.Core.Features.Customize.Enums;
3 |
4 | namespace Winhance.Core.Features.Customize.Models
5 | {
6 | ///
7 | /// Represents a group of customization settings.
8 | ///
9 | public record CustomizationGroup
10 | {
11 | ///
12 | /// Gets or sets the name of the customization group.
13 | ///
14 | public required string Name { get; init; }
15 |
16 | ///
17 | /// Gets or sets the category of the customization group.
18 | ///
19 | public required CustomizationCategory Category { get; init; }
20 |
21 | ///
22 | /// Gets or sets the settings in the customization group.
23 | ///
24 | public required IReadOnlyList Settings { get; init; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Customize/Models/CustomizationSetting.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Winhance.Core.Features.Common.Models;
3 | using Winhance.Core.Features.Customize.Enums;
4 |
5 | namespace Winhance.Core.Features.Customize.Models
6 | {
7 | ///
8 | /// Represents a setting that customizes the system by modifying registry values.
9 | ///
10 | public record CustomizationSetting : ApplicationSetting
11 | {
12 | ///
13 | /// Gets or sets the customization category for this setting.
14 | ///
15 | public required CustomizationCategory Category { get; init; }
16 |
17 | ///
18 | /// Gets or sets the linked settings for this setting.
19 | /// This allows grouping multiple settings together under a parent setting.
20 | ///
21 | public List LinkedSettings { get; init; } = new List();
22 |
23 | ///
24 | /// Gets or sets a value indicating whether this setting is only applicable to Windows 11.
25 | ///
26 | public bool IsWindows11Only { get; init; }
27 |
28 | ///
29 | /// Gets or sets a value indicating whether this setting is only applicable to Windows 10.
30 | ///
31 | public bool IsWindows10Only { get; init; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Optimize/Models/CustomUacSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace Winhance.Core.Features.Optimize.Models
5 | {
6 | ///
7 | /// Represents custom User Account Control (UAC) settings that don't match standard Windows GUI options.
8 | ///
9 | [Serializable]
10 | public class CustomUacSettings
11 | {
12 | ///
13 | /// Gets or sets the ConsentPromptBehaviorAdmin registry value.
14 | ///
15 | [JsonProperty("ConsentPromptValue")]
16 | public int ConsentPromptValue { get; set; }
17 |
18 | ///
19 | /// Gets or sets the PromptOnSecureDesktop registry value.
20 | ///
21 | [JsonProperty("SecureDesktopValue")]
22 | public int SecureDesktopValue { get; set; }
23 |
24 | ///
25 | /// Gets or sets a timestamp when these settings were last detected or saved.
26 | ///
27 | [JsonProperty("LastUpdated")]
28 | public DateTime LastUpdated { get; set; }
29 |
30 | ///
31 | /// Initializes a new instance of the class.
32 | ///
33 | public CustomUacSettings()
34 | {
35 | // Default constructor for serialization
36 | }
37 |
38 | ///
39 | /// Initializes a new instance of the class with specific values.
40 | ///
41 | /// The ConsentPromptBehaviorAdmin registry value.
42 | /// The PromptOnSecureDesktop registry value.
43 | public CustomUacSettings(int consentPromptValue, int secureDesktopValue)
44 | {
45 | ConsentPromptValue = consentPromptValue;
46 | SecureDesktopValue = secureDesktopValue;
47 | LastUpdated = DateTime.Now;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Optimize/Models/OptimizationSetting.cs:
--------------------------------------------------------------------------------
1 | using Winhance.Core.Features.Common.Enums;
2 | using Winhance.Core.Features.Common.Models;
3 |
4 | namespace Winhance.Core.Features.Optimize.Models
5 | {
6 | ///
7 | /// Represents a setting that optimizes the system by modifying registry values.
8 | ///
9 | public record OptimizationSetting : ApplicationSetting
10 | {
11 | ///
12 | /// Gets or sets the optimization category for this setting.
13 | ///
14 | public required OptimizationCategory Category { get; init; }
15 |
16 | ///
17 | /// Gets or sets custom properties for this setting.
18 | /// This can be used to store additional data specific to certain optimization types,
19 | /// such as PowerCfg settings.
20 | ///
21 | public Dictionary CustomProperties { get; init; } = new Dictionary();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/Optimize/Models/PowerPlan.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.Optimize.Models
4 | {
5 | ///
6 | /// Represents a Windows power plan.
7 | ///
8 | public class PowerPlan
9 | {
10 | ///
11 | /// Gets or sets the name of the power plan.
12 | ///
13 | public string Name { get; set; }
14 |
15 | ///
16 | /// Gets or sets the GUID of the power plan.
17 | ///
18 | public string Guid { get; set; }
19 |
20 | ///
21 | /// Gets or sets the source GUID for plans that need to be created from another plan.
22 | ///
23 | public string SourceGuid { get; set; }
24 |
25 | ///
26 | /// Gets or sets the description of the power plan.
27 | ///
28 | public string Description { get; set; }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Enums/InstallationErrorType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.SoftwareApps.Enums
4 | {
5 | ///
6 | /// Defines the types of errors that can occur during installation operations.
7 | ///
8 | public enum InstallationErrorType
9 | {
10 | ///
11 | /// An unknown error occurred during installation.
12 | ///
13 | UnknownError,
14 |
15 | ///
16 | /// A network-related error occurred during installation.
17 | ///
18 | NetworkError,
19 |
20 | ///
21 | /// A permission-related error occurred during installation.
22 | ///
23 | PermissionError,
24 |
25 | ///
26 | /// The package was not found in the repositories.
27 | ///
28 | PackageNotFoundError,
29 |
30 | ///
31 | /// WinGet is not installed and could not be installed automatically.
32 | ///
33 | WinGetNotInstalledError,
34 |
35 | ///
36 | /// The package is already installed.
37 | ///
38 | AlreadyInstalledError,
39 |
40 | ///
41 | /// The installation was cancelled by the user.
42 | ///
43 | CancelledByUserError,
44 |
45 | ///
46 | /// The system is in a state that prevents installation.
47 | ///
48 | SystemStateError,
49 |
50 | ///
51 | /// The package is corrupted or invalid.
52 | ///
53 | PackageCorruptedError,
54 |
55 | ///
56 | /// The package dependencies could not be resolved.
57 | ///
58 | DependencyResolutionError
59 | }
60 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Exceptions/InstallationStatusException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.SoftwareApps.Exceptions
4 | {
5 | ///
6 | /// Exception thrown when there is an error with installation status operations.
7 | ///
8 | public class InstallationStatusException : Exception
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public InstallationStatusException() : base()
14 | {
15 | }
16 |
17 | ///
18 | /// Initializes a new instance of the class with a specified error message.
19 | ///
20 | /// The message that describes the error.
21 | public InstallationStatusException(string message) : base(message)
22 | {
23 | }
24 |
25 | ///
26 | /// Initializes a new instance of the class with a specified error message
27 | /// and a reference to the inner exception that is the cause of this exception.
28 | ///
29 | /// The message that describes the error.
30 | /// The exception that is the cause of the current exception.
31 | public InstallationStatusException(string message, Exception innerException) : base(message, innerException)
32 | {
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IAppDiscoveryService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.SoftwareApps.Models;
4 |
5 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
6 | {
7 | ///
8 | /// Service for discovering and retrieving information about installed applications.
9 | ///
10 | public interface IAppDiscoveryService
11 | {
12 | ///
13 | /// Gets all standard (built-in) applications.
14 | ///
15 | /// A collection of standard applications.
16 | Task> GetStandardAppsAsync();
17 |
18 | ///
19 | /// Gets all installable third-party applications.
20 | ///
21 | /// A collection of installable applications.
22 | Task> GetInstallableAppsAsync();
23 |
24 | ///
25 | /// Gets all available Windows capabilities.
26 | ///
27 | /// A collection of Windows capabilities.
28 | Task> GetCapabilitiesAsync();
29 |
30 | ///
31 | /// Gets all available Windows optional features.
32 | ///
33 | /// A collection of Windows optional features.
34 | Task> GetOptionalFeaturesAsync();
35 |
36 | ///
37 | /// Checks if Microsoft Edge is installed.
38 | ///
39 | /// True if Edge is installed; otherwise, false.
40 | Task IsEdgeInstalledAsync();
41 |
42 | ///
43 | /// Checks if OneDrive is installed.
44 | ///
45 | /// True if OneDrive is installed; otherwise, false.
46 | Task IsOneDriveInstalledAsync();
47 |
48 | ///
49 | /// Checks if OneNote is installed.
50 | ///
51 | /// True if OneNote is installed; otherwise, false.
52 | Task IsOneNoteInstalledAsync();
53 | }
54 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IAppInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Service for installing Windows applications.
10 | ///
11 | public interface IAppInstallationService : IInstallationService
12 | {
13 | ///
14 | /// Installs an application.
15 | ///
16 | /// The application to install.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// An operation result indicating success or failure with error details.
20 | Task> InstallAppAsync(AppInfo app, IProgress? progress = null, CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Checks if an application can be installed.
24 | ///
25 | /// The application to check.
26 | /// An operation result indicating if the application can be installed, with error details if not.
27 | Task> CanInstallAppAsync(AppInfo app);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IAppRemovalService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Service for removing Windows applications.
10 | ///
11 | public interface IAppRemovalService
12 | {
13 | ///
14 | /// Removes an application.
15 | ///
16 | /// The application to remove.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// An operation result indicating success or failure with error details.
20 | Task> RemoveAppAsync(AppInfo app, IProgress? progress = null, CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Generates a removal script for an application.
24 | ///
25 | /// The application to generate a removal script for.
26 | /// An operation result containing the removal script or error details.
27 | Task> GenerateRemovalScriptAsync(AppInfo app);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IAppVerificationService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace Winhance.Core.Features.SoftwareApps.Interfaces;
4 |
5 | ///
6 | /// Interface for services that handle verification of application installations.
7 | ///
8 | public interface IAppVerificationService
9 | {
10 | ///
11 | /// Verifies if an app is installed.
12 | ///
13 | /// The package name to verify.
14 | /// True if the app is installed; otherwise, false.
15 | Task VerifyAppInstallationAsync(string packageName);
16 | }
17 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/ICapabilityInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Service for installing Windows capabilities.
10 | ///
11 | public interface ICapabilityInstallationService : IInstallationService
12 | {
13 | ///
14 | /// Installs a capability.
15 | ///
16 | /// The capability to install.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// An operation result indicating success or failure with error details.
20 | Task> InstallCapabilityAsync(CapabilityInfo capability, IProgress? progress = null, CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Checks if a capability can be installed.
24 | ///
25 | /// The capability to check.
26 | /// An operation result indicating if the capability can be installed, with error details if not.
27 | Task> CanInstallCapabilityAsync(CapabilityInfo capability);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/ICapabilityRemovalService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Service for removing Windows capabilities.
10 | ///
11 | public interface ICapabilityRemovalService
12 | {
13 | ///
14 | /// Removes a capability.
15 | ///
16 | /// The capability to remove.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// True if the removal was successful; otherwise, false.
20 | Task RemoveCapabilityAsync(CapabilityInfo capability, IProgress? progress = null, CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Checks if a capability can be removed.
24 | ///
25 | /// The capability to check.
26 | /// True if the capability can be removed; otherwise, false.
27 | Task CanRemoveCapabilityAsync(CapabilityInfo capability);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/ICustomAppInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Winhance.Core.Features.Common.Models;
5 | using Winhance.Core.Features.SoftwareApps.Models;
6 |
7 | namespace Winhance.Core.Features.SoftwareApps.Interfaces;
8 |
9 | ///
10 | /// Interface for services that handle custom application installations.
11 | ///
12 | public interface ICustomAppInstallationService
13 | {
14 | ///
15 | /// Installs a custom application.
16 | ///
17 | /// Information about the application to install.
18 | /// Optional progress reporter.
19 | /// Optional cancellation token.
20 | /// True if installation was successful; otherwise, false.
21 | Task InstallCustomAppAsync(
22 | AppInfo appInfo,
23 | IProgress? progress = null,
24 | CancellationToken cancellationToken = default);
25 |
26 | ///
27 | /// Checks if internet connection is available.
28 | ///
29 | /// True if internet connection is available; otherwise, false.
30 | Task CheckInternetConnectionAsync();
31 | }
32 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IFeatureInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Service for installing Windows optional features.
10 | ///
11 | public interface IFeatureInstallationService : IInstallationService
12 | {
13 | ///
14 | /// Installs a feature.
15 | ///
16 | /// The feature to install.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// An operation result indicating success or failure with error details.
20 | Task> InstallFeatureAsync(FeatureInfo feature, IProgress? progress = null, CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Checks if a feature can be installed.
24 | ///
25 | /// The feature to check.
26 | /// An operation result indicating if the feature can be installed, with error details if not.
27 | Task> CanInstallFeatureAsync(FeatureInfo feature);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IFeatureRemovalService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Service for removing Windows optional features.
10 | ///
11 | public interface IFeatureRemovalService
12 | {
13 | ///
14 | /// Removes a feature.
15 | ///
16 | /// The feature to remove.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// True if the removal was successful; otherwise, false.
20 | Task RemoveFeatureAsync(FeatureInfo feature, IProgress? progress = null, CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Checks if a feature can be removed.
24 | ///
25 | /// The feature to check.
26 | /// True if the feature can be removed; otherwise, false.
27 | Task CanRemoveFeatureAsync(FeatureInfo feature);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Winhance.Core.Features.Common.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
7 | {
8 | ///
9 | /// Generic interface for installation services.
10 | ///
11 | /// The type of item to install, which must implement IInstallableItem.
12 | public interface IInstallationService where T : IInstallableItem
13 | {
14 | ///
15 | /// Installs an item.
16 | ///
17 | /// The item to install.
18 | /// Optional progress reporter.
19 | /// Optional cancellation token.
20 | /// An operation result indicating success or failure with error details.
21 | Task> InstallAsync(
22 | T item,
23 | IProgress? progress = null,
24 | CancellationToken cancellationToken = default);
25 |
26 | ///
27 | /// Checks if an item can be installed.
28 | ///
29 | /// The item to check.
30 | /// An operation result indicating if the item can be installed, with error details if not.
31 | Task> CanInstallAsync(T item);
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IInstallationStatusService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
6 | {
7 | public interface IInstallationStatusService
8 | {
9 | Task GetInstallStatusAsync(string appId);
10 | Task RefreshStatusAsync(IEnumerable appIds);
11 | Task SetInstallStatusAsync(string appId, InstallStatus status);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IOneDriveInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Winhance.Core.Features.Common.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces;
7 |
8 | ///
9 | /// Interface for services that handle OneDrive installation.
10 | ///
11 | public interface IOneDriveInstallationService
12 | {
13 | ///
14 | /// Installs OneDrive from the Microsoft download link.
15 | ///
16 | /// Optional progress reporter.
17 | /// Optional cancellation token.
18 | /// True if installation was successful; otherwise, false.
19 | Task InstallOneDriveAsync(
20 | IProgress? progress,
21 | CancellationToken cancellationToken);
22 | }
23 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/ISpecialAppHandlerService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.SoftwareApps.Models;
4 |
5 | namespace Winhance.Core.Features.SoftwareApps.Interfaces
6 | {
7 | ///
8 | /// Provides functionality for handling special applications that require custom removal procedures.
9 | ///
10 | public interface ISpecialAppHandlerService
11 | {
12 | ///
13 | /// Gets all registered special app handlers.
14 | ///
15 | /// A collection of special app handlers.
16 | IEnumerable GetAllHandlers();
17 |
18 | ///
19 | /// Gets a special app handler by its type.
20 | ///
21 | /// The type of handler to retrieve.
22 | /// The requested special app handler, or null if not found.
23 | SpecialAppHandler? GetHandler(string handlerType);
24 |
25 | ///
26 | /// Removes Microsoft Edge.
27 | ///
28 | /// True if the operation succeeded; otherwise, false.
29 | Task RemoveEdgeAsync();
30 |
31 | ///
32 | /// Removes OneDrive.
33 | ///
34 | /// True if the operation succeeded; otherwise, false.
35 | Task RemoveOneDriveAsync();
36 |
37 | ///
38 | /// Removes OneNote.
39 | ///
40 | /// True if the operation succeeded; otherwise, false.
41 | Task RemoveOneNoteAsync();
42 |
43 | ///
44 | /// Removes a special application using its registered handler.
45 | ///
46 | /// The type of handler to use.
47 | /// True if the operation succeeded; otherwise, false.
48 | Task RemoveSpecialAppAsync(string handlerType);
49 | }
50 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Interfaces/IWinGetInstallationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Winhance.Core.Features.Common.Models;
5 |
6 | namespace Winhance.Core.Features.SoftwareApps.Interfaces;
7 |
8 | ///
9 | /// Interface for services that handle WinGet-related installation operations.
10 | ///
11 | public interface IWinGetInstallationService
12 | {
13 | ///
14 | /// Installs a package using WinGet.
15 | ///
16 | /// The package name or ID to install.
17 | /// Optional progress reporter.
18 | /// Optional cancellation token.
19 | /// The display name of the package for progress reporting.
20 | /// True if installation was successful; otherwise, false.
21 | Task InstallWithWingetAsync(
22 | string packageName,
23 | IProgress? progress = null,
24 | CancellationToken cancellationToken = default,
25 | string? displayName = null);
26 |
27 | ///
28 | /// Installs WinGet if not already installed.
29 | ///
30 | Task InstallWinGetAsync(IProgress? progress = null);
31 |
32 | ///
33 | /// Checks if WinGet is installed on the system.
34 | ///
35 | /// True if WinGet is installed, false otherwise
36 | Task IsWinGetInstalledAsync();
37 | }
38 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Models/AppModels.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | public enum AppInstallType
7 | {
8 | Store,
9 | WinGet,
10 | DirectDownload,
11 | Custom
12 | }
13 |
14 | public enum TaskAction
15 | {
16 | Apply,
17 | Test,
18 | Rollback
19 | }
20 |
21 | public record AppInstallConfig
22 | {
23 | public required string FriendlyName { get; init; }
24 | public required AppInstallType InstallType { get; init; }
25 | public string? PackageId { get; init; }
26 | public string? DownloadUrl { get; init; }
27 | public string? CustomInstallHandler { get; init; }
28 | public IDictionary? CustomProperties { get; init; }
29 | public bool IsInstalled { get; init; }
30 | }
31 |
32 | public record InstallResult
33 | {
34 | public required bool Success { get; init; }
35 | public string? ErrorMessage { get; init; }
36 | public Exception? Exception { get; init; }
37 | }
38 |
39 | public class RegistryTestResult
40 | {
41 | public string KeyPath { get; set; } = string.Empty;
42 | public string ValueName { get; set; } = string.Empty;
43 | public bool IsSuccess { get; set; }
44 | public object? ActualValue { get; set; }
45 | public object? ExpectedValue { get; set; }
46 | public string Message { get; set; } = string.Empty;
47 | public string Description { get; set; } = string.Empty;
48 | public string Category { get; set; } = string.Empty;
49 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Models/RemovalScript.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | ///
7 | /// Represents a script for removing applications and preventing their reinstallation.
8 | ///
9 | public class RemovalScript
10 | {
11 | ///
12 | /// Gets or sets the name of the script.
13 | ///
14 | public string Name { get; init; } = string.Empty;
15 |
16 | ///
17 | /// Gets or sets the content of the script.
18 | ///
19 | public string Content { get; init; } = string.Empty;
20 |
21 | ///
22 | /// Gets or sets the name of the scheduled task to create for running the script.
23 | ///
24 | public string TargetScheduledTaskName { get; init; } = string.Empty;
25 |
26 | ///
27 | /// Gets or sets a value indicating whether the script should run on system startup.
28 | ///
29 | public bool RunOnStartup { get; init; }
30 |
31 | ///
32 | /// Gets the path where the script will be saved.
33 | ///
34 | public string ScriptPath => Path.Combine(
35 | Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
36 | "Winhance",
37 | "Scripts",
38 | $"{Name}.ps1");
39 | }
40 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/SoftwareApps/Models/WindowsPackageModels.cs:
--------------------------------------------------------------------------------
1 | using Winhance.Core.Features.Common.Enums;
2 | using Winhance.Core.Features.Common.Models;
3 |
4 | namespace Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | public record WindowsPackage
7 | {
8 | public required string Category { get; init; }
9 | public required string FriendlyName { get; init; }
10 | public required string PackageName { get; init; }
11 | public WindowsAppType AppType { get; init; }
12 | public IReadOnlyList? SubPackages { get; init; }
13 | public string? Description { get; init; }
14 | public IReadOnlyList? RegistrySettings { get; init; }
15 | public bool IsInstalled { get; init; }
16 | }
17 |
18 | public record LegacyCapability
19 | {
20 | public required string FriendlyName { get; init; }
21 | public required string Name { get; init; }
22 | public bool IsInstalled { get; init; }
23 | }
24 |
25 | public record WindowsService
26 | {
27 | public required string Name { get; init; }
28 | public required string DisplayName { get; init; }
29 | public required string Description { get; init; }
30 | public required ServiceStartupType RecommendedState { get; init; }
31 | public ServiceStartupType? CurrentState { get; init; }
32 | }
--------------------------------------------------------------------------------
/src/Winhance.Core/Features/UI/Interfaces/INotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Core.Features.UI.Interfaces
4 | {
5 | ///
6 | /// Interface for notification services that can display toast notifications and other alerts.
7 | ///
8 | public interface INotificationService
9 | {
10 | ///
11 | /// Shows a toast notification.
12 | ///
13 | /// The title of the notification.
14 | /// The message content of the notification.
15 | /// The type of notification.
16 | void ShowToast(string title, string message, ToastType type);
17 | }
18 |
19 | ///
20 | /// Defines the types of toast notifications.
21 | ///
22 | public enum ToastType
23 | {
24 | ///
25 | /// Information notification.
26 | ///
27 | Information,
28 |
29 | ///
30 | /// Success notification.
31 | ///
32 | Success,
33 |
34 | ///
35 | /// Warning notification.
36 | ///
37 | Warning,
38 |
39 | ///
40 | /// Error notification.
41 | ///
42 | Error
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Release
6 | Any CPU
7 | bin\Release\net9.0\publish\
8 | FileSystem
9 | <_TargetId>Folder
10 |
11 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Properties/PublishProfiles/FolderProfile.pubxml.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/Winhance.Core/Winhance.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0-windows
4 | enable
5 | enable
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/Registry/RegistryExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Win32;
3 | using Winhance.Core.Features.Common.Interfaces;
4 | using Winhance.Core.Features.Common.Models;
5 |
6 | namespace Winhance.Infrastructure.Features.Common.Registry
7 | {
8 | ///
9 | /// Extension methods for registry operations.
10 | ///
11 | public static class RegistryExtensions
12 | {
13 | ///
14 | /// Converts a RegistryHive enum to its string representation (HKCU, HKLM, etc.)
15 | ///
16 | /// The registry hive.
17 | /// The string representation of the registry hive.
18 | public static string GetRegistryHiveString(this RegistryHive hive)
19 | {
20 | return hive switch
21 | {
22 | RegistryHive.LocalMachine => "HKLM",
23 | RegistryHive.CurrentUser => "HKCU",
24 | RegistryHive.ClassesRoot => "HKCR",
25 | RegistryHive.Users => "HKU",
26 | RegistryHive.CurrentConfig => "HKCC",
27 | _ => throw new ArgumentException($"Unsupported registry hive: {hive}")
28 | };
29 | }
30 |
31 | ///
32 | /// Gets the full registry path by combining the hive and subkey.
33 | ///
34 | /// The registry hive.
35 | /// The registry subkey.
36 | /// The full registry path.
37 | public static string GetFullRegistryPath(this RegistryHive hive, string subKey)
38 | {
39 | return $"{hive.GetRegistryHiveString()}\\{subKey}";
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/Registry/RegistryServiceCore.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using System;
3 | using System.Runtime.InteropServices;
4 | using System.Runtime.Versioning;
5 | using Winhance.Core.Features.Common.Interfaces;
6 | using Winhance.Core.Features.Common.Enums;
7 |
8 | namespace Winhance.Infrastructure.Features.Common.Registry
9 | {
10 | ///
11 | /// Core implementation of the registry service.
12 | ///
13 | [SupportedOSPlatform("windows")]
14 | public partial class RegistryService : IRegistryService
15 | {
16 | private readonly ILogService _logService;
17 |
18 | ///
19 | /// Initializes a new instance of the class.
20 | ///
21 | /// The log service.
22 | public RegistryService(ILogService logService)
23 | {
24 | _logService = logService ?? throw new ArgumentNullException(nameof(logService));
25 | }
26 |
27 | ///
28 | /// Checks if the current platform is Windows.
29 | ///
30 | /// True if the platform is Windows; otherwise, logs an error and returns false.
31 | private bool CheckWindowsPlatform()
32 | {
33 | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
34 | {
35 | _logService.Log(LogLevel.Error, "Registry operations are only supported on Windows");
36 | return false;
37 | }
38 | return true;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/ICapabilityScriptModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration
4 | {
5 | ///
6 | /// Provides methods for modifying capability-related script content.
7 | ///
8 | public interface ICapabilityScriptModifier
9 | {
10 | ///
11 | /// Removes a capability from the script content.
12 | ///
13 | /// The script content.
14 | /// The name of the capability to remove.
15 | /// The updated script content.
16 | string RemoveCapabilityFromScript(string scriptContent, string capabilityName);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/IFeatureScriptModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration
4 | {
5 | ///
6 | /// Provides methods for modifying feature-related script content.
7 | ///
8 | public interface IFeatureScriptModifier
9 | {
10 | ///
11 | /// Removes an optional feature from the script content.
12 | ///
13 | /// The script content.
14 | /// The name of the optional feature to remove.
15 | /// The updated script content.
16 | string RemoveOptionalFeatureFromScript(string scriptContent, string featureName);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/IPackageScriptModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration
4 | {
5 | ///
6 | /// Provides methods for modifying package-related script content.
7 | ///
8 | public interface IPackageScriptModifier
9 | {
10 | ///
11 | /// Removes a package from the script content.
12 | ///
13 | /// The script content.
14 | /// The name of the package to remove.
15 | /// The updated script content.
16 | string RemovePackageFromScript(string scriptContent, string packageName);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/IRegistryScriptModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration
4 | {
5 | ///
6 | /// Provides methods for modifying registry-related script content.
7 | ///
8 | public interface IRegistryScriptModifier
9 | {
10 | ///
11 | /// Removes app-specific registry settings from the script content.
12 | ///
13 | /// The script content.
14 | /// The name of the app whose registry settings should be removed.
15 | /// The updated script content.
16 | string RemoveAppRegistrySettingsFromScript(string scriptContent, string appName);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/IScriptContentModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Winhance.Core.Features.Common.Models;
4 | using Winhance.Core.Features.SoftwareApps.Models;
5 |
6 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration;
7 |
8 | ///
9 | /// Provides methods for modifying script content.
10 | ///
11 | public interface IScriptContentModifier
12 | {
13 | ///
14 | /// Removes a capability from the script content.
15 | ///
16 | /// The script content.
17 | /// The name of the capability to remove.
18 | /// The updated script content.
19 | string RemoveCapabilityFromScript(string scriptContent, string capabilityName);
20 |
21 | ///
22 | /// Removes a package from the script content.
23 | ///
24 | /// The script content.
25 | /// The name of the package to remove.
26 | /// The updated script content.
27 | string RemovePackageFromScript(string scriptContent, string packageName);
28 |
29 | ///
30 | /// Removes an optional feature from the script content.
31 | ///
32 | /// The script content.
33 | /// The name of the optional feature to remove.
34 | /// The updated script content.
35 | string RemoveOptionalFeatureFromScript(string scriptContent, string featureName);
36 |
37 | ///
38 | /// Removes app-specific registry settings from the script content.
39 | ///
40 | /// The script content.
41 | /// The name of the app whose registry settings should be removed.
42 | /// The updated script content.
43 | string RemoveAppRegistrySettingsFromScript(string scriptContent, string appName);
44 | }
45 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/RegistryScriptHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Win32;
3 |
4 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration;
5 |
6 | ///
7 | /// Provides helper methods for working with registry scripts.
8 | ///
9 | public static class RegistryScriptHelper
10 | {
11 | ///
12 | /// Converts a RegistryValueKind to the corresponding reg.exe type string.
13 | ///
14 | /// The registry value kind.
15 | /// The reg.exe type string.
16 | public static string GetRegTypeString(RegistryValueKind valueKind)
17 | {
18 | return valueKind switch
19 | {
20 | RegistryValueKind.String => "REG_SZ",
21 | RegistryValueKind.ExpandString => "REG_EXPAND_SZ",
22 | RegistryValueKind.Binary => "REG_BINARY",
23 | RegistryValueKind.DWord => "REG_DWORD",
24 | RegistryValueKind.MultiString => "REG_MULTI_SZ",
25 | RegistryValueKind.QWord => "REG_QWORD",
26 | _ => "REG_SZ"
27 | };
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/Common/ScriptGeneration/ScriptModifierServiceExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using System;
3 | using Winhance.Infrastructure.Features.Common.ScriptGeneration;
4 |
5 | namespace Winhance.Infrastructure.Features.Common.ScriptGeneration
6 | {
7 | ///
8 | /// Extension methods for registering script modifier services with the dependency injection container.
9 | ///
10 | public static class ScriptModifierServiceExtensions
11 | {
12 | ///
13 | /// Adds script modifier services to the specified .
14 | ///
15 | /// The to add the services to.
16 | /// The so that additional calls can be chained.
17 | public static IServiceCollection AddScriptModifierServices(this IServiceCollection services)
18 | {
19 | // Register the specialized modifiers
20 | services.AddTransient();
21 | services.AddTransient();
22 | services.AddTransient();
23 | services.AddTransient();
24 |
25 | // Register the composite modifier as the implementation of IScriptContentModifier
26 | services.AddTransient();
27 |
28 | return services;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/SoftwareApps/Services/AppRemovalServiceAdapter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Winhance.Core.Features.Common.Models;
5 | using Winhance.Core.Features.SoftwareApps.Interfaces;
6 | using Winhance.Core.Features.SoftwareApps.Models;
7 |
8 | namespace Winhance.Infrastructure.Features.SoftwareApps.Services
9 | {
10 | ///
11 | /// Adapter class that adapts IAppRemovalService to IInstallationService<AppInfo>.
12 | /// This is used to maintain backward compatibility with code that expects the AppRemovalService
13 | /// property of IPackageManager to return an IInstallationService<AppInfo>.
14 | ///
15 | public class AppRemovalServiceAdapter : IInstallationService
16 | {
17 | private readonly IAppRemovalService _appRemovalService;
18 |
19 | ///
20 | /// Initializes a new instance of the class.
21 | ///
22 | /// The app removal service to adapt.
23 | public AppRemovalServiceAdapter(IAppRemovalService appRemovalService)
24 | {
25 | _appRemovalService = appRemovalService ?? throw new ArgumentNullException(nameof(appRemovalService));
26 | }
27 |
28 | ///
29 | public Task> InstallAsync(
30 | AppInfo item,
31 | IProgress? progress = null,
32 | CancellationToken cancellationToken = default)
33 | {
34 | // This is an adapter for removal service, so "install" actually means "remove"
35 | return _appRemovalService.RemoveAppAsync(item, progress, cancellationToken);
36 | }
37 |
38 | ///
39 | public Task> CanInstallAsync(AppInfo item)
40 | {
41 | // Since this is an adapter for removal, we'll always return true
42 | // The actual validation will happen in the RemoveAppAsync method
43 | return Task.FromResult(OperationResult.Succeeded(true));
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/SoftwareApps/Services/WinGet/Interfaces/IInstallationVerifier.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.Infrastructure.Features.SoftwareApps.Services.WinGet.Interfaces
6 | {
7 | ///
8 | /// Defines the contract for verifying software installations.
9 | ///
10 | public interface IInstallationVerifier
11 | {
12 | ///
13 | /// Verifies if a package is installed.
14 | ///
15 | /// The ID of the package to verify.
16 | /// A cancellation token to cancel the operation.
17 | /// A task representing the asynchronous operation with the verification result.
18 | Task VerifyInstallationAsync(
19 | string packageId,
20 | CancellationToken cancellationToken = default);
21 |
22 | ///
23 | /// Verifies if a package is installed with the specified version.
24 | ///
25 | /// The ID of the package to verify.
26 | /// The expected version of the package.
27 | /// A cancellation token to cancel the operation.
28 | /// A task representing the asynchronous operation with the verification result.
29 | Task VerifyInstallationAsync(
30 | string packageId,
31 | string version,
32 | CancellationToken cancellationToken = default);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/SoftwareApps/Services/WinGet/Interfaces/IVerificationMethod.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.Infrastructure.Features.SoftwareApps.Services.WinGet.Interfaces
6 | {
7 | ///
8 | /// Defines the contract for different verification methods to check if a package is installed.
9 | ///
10 | public interface IVerificationMethod
11 | {
12 | ///
13 | /// Gets the name of the verification method.
14 | ///
15 | string Name { get; }
16 |
17 | ///
18 | /// Gets the priority of this verification method. Lower numbers indicate higher priority.
19 | ///
20 | int Priority { get; }
21 |
22 | ///
23 | /// Verifies if a package is installed using this verification method.
24 | ///
25 | /// The ID of the package to verify.
26 | /// Optional version to verify. If null, only the presence is checked.
27 | /// A cancellation token to cancel the operation.
28 | /// A task representing the asynchronous operation with the verification result.
29 | Task VerifyAsync(
30 | string packageId,
31 | string version = null,
32 | CancellationToken cancellationToken = default);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Features/UI/Services/NotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Winhance.Core.Features.Common.Interfaces;
3 | using Winhance.Core.Features.UI.Interfaces;
4 |
5 | namespace Winhance.Infrastructure.Features.UI.Services
6 | {
7 | ///
8 | /// Implementation of the notification service that shows toast notifications.
9 | ///
10 | public class NotificationService : INotificationService
11 | {
12 | private readonly ILogService _logService;
13 |
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | /// The log service.
18 | public NotificationService(ILogService logService)
19 | {
20 | _logService = logService;
21 | }
22 |
23 | ///
24 | public void ShowToast(string title, string message, ToastType type)
25 | {
26 | // Log the notification
27 | switch (type)
28 | {
29 | case ToastType.Information:
30 | _logService.LogInformation($"Toast Notification - {title}: {message}");
31 | break;
32 | case ToastType.Success:
33 | _logService.LogSuccess($"Toast Notification - {title}: {message}");
34 | break;
35 | case ToastType.Warning:
36 | _logService.LogWarning($"Toast Notification - {title}: {message}");
37 | break;
38 | case ToastType.Error:
39 | _logService.LogError($"Toast Notification - {title}: {message}");
40 | break;
41 | default:
42 | _logService.LogInformation($"Toast Notification - {title}: {message}");
43 | break;
44 | }
45 |
46 | // In a real implementation, this would show a toast notification in the UI
47 | // For now, we're just logging the notification
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Release
6 | Any CPU
7 | bin\Release\net9.0-windows\publish\
8 | FileSystem
9 | <_TargetId>Folder
10 |
11 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Properties/PublishProfiles/FolderProfile.pubxml.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/Winhance.Infrastructure/Winhance.Infrastructure.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0-windows
4 | enable
5 | enable
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/App.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | PerMonitorV2
24 |
25 |
26 |
27 |
28 | true
29 |
30 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly:ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Controls/MaterialSymbol.xaml:
--------------------------------------------------------------------------------
1 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Controls/MaterialSymbol.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Media;
4 | using Winhance.WPF.Features.Common.Resources;
5 |
6 | namespace Winhance.WPF.Features.Common.Controls
7 | {
8 | ///
9 | /// Interaction logic for MaterialSymbol.xaml
10 | ///
11 | public partial class MaterialSymbol : UserControl
12 | {
13 | public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
14 | "Icon", typeof(string), typeof(MaterialSymbol),
15 | new PropertyMetadata(string.Empty, OnIconChanged));
16 |
17 | public static readonly DependencyProperty IconTextProperty = DependencyProperty.Register(
18 | "IconText", typeof(string), typeof(MaterialSymbol),
19 | new PropertyMetadata(string.Empty));
20 |
21 | public string Icon
22 | {
23 | get { return (string)GetValue(IconProperty); }
24 | set { SetValue(IconProperty, value); }
25 | }
26 |
27 | public string IconText
28 | {
29 | get { return (string)GetValue(IconTextProperty); }
30 | set { SetValue(IconTextProperty, value); }
31 | }
32 |
33 | public MaterialSymbol()
34 | {
35 | InitializeComponent();
36 | }
37 |
38 | private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
39 | {
40 | if (d is MaterialSymbol control && e.NewValue is string iconName)
41 | {
42 | control.IconText = MaterialSymbols.GetIcon(iconName);
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/AppliedStatusToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 | using Winhance.Core.Features.Common.Enums;
6 |
7 | namespace Winhance.WPF.Features.Common.Converters
8 | {
9 | public class AppliedStatusToVisibilityConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | // If the status is Applied, return Visible, otherwise return Collapsed
14 | if (value is RegistrySettingStatus status)
15 | {
16 | return status == RegistrySettingStatus.Applied ? Visibility.Visible : Visibility.Collapsed;
17 | }
18 |
19 | return Visibility.Collapsed;
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | throw new NotImplementedException();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BoolToArrowConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Features.Common.Converters
6 | {
7 | ///
8 | /// Converts a boolean value to an arrow character for UI display.
9 | /// True returns an up arrow, False returns a down arrow.
10 | ///
11 | public class BoolToArrowConverter : IValueConverter
12 | {
13 | public static BoolToArrowConverter Instance { get; } = new BoolToArrowConverter();
14 |
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value is bool isExpanded)
18 | {
19 | // Up arrow for expanded, down arrow for collapsed
20 | return isExpanded ? "\uE70E" : "\uE70D";
21 | }
22 |
23 | // Default to down arrow if value is not a boolean
24 | return "\uE70D";
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | // This converter doesn't support converting back
30 | throw new NotImplementedException();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BoolToChevronConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using MaterialDesignThemes.Wpf;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | public class BoolToChevronConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (value is bool isExpanded)
13 | {
14 | return isExpanded ? PackIconKind.ChevronUp : PackIconKind.ChevronDown;
15 | }
16 |
17 | return PackIconKind.ChevronDown;
18 | }
19 |
20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
21 | {
22 | if (value is PackIconKind kind)
23 | {
24 | return kind == PackIconKind.ChevronUp;
25 | }
26 |
27 | return false;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Features.Common.Converters
6 | {
7 | ///
8 | /// A simple boolean converter that returns the parameter when true, and null when false.
9 | /// Useful for conditional resource selection.
10 | ///
11 | public class BooleanConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | if (value is bool boolValue)
16 | {
17 | return boolValue ? parameter : null;
18 | }
19 |
20 | return null;
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | return value != null;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BooleanToGridSpanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Converters
6 | {
7 | ///
8 | /// Converts a boolean value to an integer grid span - true returns 4 (full width), false returns 1
9 | ///
10 | public class BooleanToGridSpanConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | if (value is bool boolValue)
15 | {
16 | return boolValue ? 4 : 1; // Return 4 for true (header spans full width), 1 for false
17 | }
18 | return 1;
19 | }
20 |
21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | throw new NotImplementedException();
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BooleanToReinstallableIconConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using MaterialDesignThemes.Wpf;
5 |
6 | namespace Winhance.WPF.Converters
7 | {
8 | ///
9 | /// Converts a boolean value indicating whether an item can be reinstalled to the appropriate MaterialDesign icon.
10 | ///
11 | public class BooleanToReinstallableIconConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | // Return the appropriate MaterialDesign PackIconKind
16 | return (bool)value ? PackIconKind.Sync : PackIconKind.SyncDisabled;
17 | }
18 |
19 | public object ConvertBack(
20 | object value,
21 | Type targetType,
22 | object parameter,
23 | CultureInfo culture
24 | )
25 | {
26 | throw new NotImplementedException();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BooleanToReinstallableTextConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Converters
6 | {
7 | ///
8 | /// Converts a boolean value indicating whether an item can be reinstalled to a descriptive text.
9 | ///
10 | public class BooleanToReinstallableTextConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | return (bool)value ? "Is Installable" : "Is Not Installable";
15 | }
16 |
17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | throw new NotImplementedException();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/BooleanToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 | using System.Windows.Media;
6 |
7 | namespace Winhance.WPF.Converters;
8 |
9 | public class BooleanToVisibilityConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | return (bool)value ? Visibility.Visible : Visibility.Collapsed;
14 | }
15 |
16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | return (Visibility)value == Visibility.Visible;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/CountToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts an integer count to a Visibility value.
10 | /// Returns Visible if the count is greater than 0, otherwise returns Collapsed.
11 | ///
12 | public class CountToVisibilityConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value is int count)
17 | {
18 | return count > 0 ? Visibility.Visible : Visibility.Collapsed;
19 | }
20 |
21 | return Visibility.Collapsed;
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25 | {
26 | throw new NotImplementedException();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/EnumToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts an enum value to a Visibility value based on whether it matches the parameter.
10 | ///
11 | public class EnumToVisibilityConverter : IValueConverter
12 | {
13 | ///
14 | /// Converts an enum value to a Visibility value.
15 | ///
16 | /// The enum value to convert.
17 | /// The type of the binding target property.
18 | /// The parameter to compare against.
19 | /// The culture to use in the converter.
20 | ///
21 | /// Visibility.Visible if the value matches the parameter; otherwise, Visibility.Collapsed.
22 | ///
23 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | if (value == null || parameter == null)
26 | {
27 | return Visibility.Collapsed;
28 | }
29 |
30 | // Check if the value is equal to the parameter
31 | bool isEqual = value.Equals(parameter);
32 | return isEqual ? Visibility.Visible : Visibility.Collapsed;
33 | }
34 |
35 | ///
36 | /// Converts a Visibility value back to an enum value.
37 | ///
38 | /// The Visibility value to convert back.
39 | /// The type of the binding source property.
40 | /// The parameter to use in the converter.
41 | /// The culture to use in the converter.
42 | ///
43 | /// The parameter if the value is Visibility.Visible; otherwise, null.
44 | ///
45 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
46 | {
47 | if (value is Visibility visibility && visibility == Visibility.Visible)
48 | {
49 | return parameter;
50 | }
51 |
52 | return Binding.DoNothing;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/GreaterThanOneConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Features.Common.Converters
6 | {
7 | ///
8 | /// Converter that returns true if the input value is greater than one.
9 | ///
10 | public class GreaterThanOneConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | if (value is int count)
15 | {
16 | return count > 1;
17 | }
18 | return false;
19 | }
20 |
21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | throw new NotImplementedException();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/IconNameToSymbolConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using Winhance.WPF.Features.Common.Resources;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts an icon name to a Material Symbols Unicode character.
10 | ///
11 | public class IconNameToSymbolConverter : IValueConverter
12 | {
13 | public static IconNameToSymbolConverter Instance { get; } = new IconNameToSymbolConverter();
14 |
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value is string iconName)
18 | {
19 | return MaterialSymbols.GetIcon(iconName);
20 | }
21 |
22 | return "?";
23 | }
24 |
25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
26 | {
27 | throw new NotImplementedException();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/InstalledStatusToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using System.Windows;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace Winhance.WPF.Converters;
7 |
8 | public class InstalledStatusToColorConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | return (bool)value
13 | ? new SolidColorBrush(Color.FromRgb(0, 255, 60)) // Electric Green (#00FF3C)
14 | : new SolidColorBrush(Color.FromRgb(255, 40, 0)); // Ferrari Red (#FF2800)
15 | }
16 |
17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | throw new NotImplementedException();
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/InstalledStatusToTextConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using System.Windows;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace Winhance.WPF.Converters;
7 |
8 | public class InstalledStatusToTextConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | return (bool)value ? "Installed" : "Not Installed";
13 | }
14 |
15 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/InverseBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Features.Common.Converters
6 | {
7 | ///
8 | /// Converts a boolean value to its inverse (true to false, false to true)
9 | ///
10 | public class InverseBooleanConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | if (value is bool boolValue)
15 | {
16 | return !boolValue;
17 | }
18 |
19 | return value;
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | if (value is bool boolValue)
25 | {
26 | return !boolValue;
27 | }
28 |
29 | return value;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/InverseBooleanToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts a boolean value to a Visibility value, with the boolean value inverted.
10 | /// True becomes Collapsed, False becomes Visible.
11 | ///
12 | public class InverseBooleanToVisibilityConverter : IValueConverter
13 | {
14 | ///
15 | /// Converts a boolean value to a Visibility value, with the boolean value inverted.
16 | ///
17 | /// The boolean value to convert.
18 | /// The type of the binding target property.
19 | /// The converter parameter to use.
20 | /// The culture to use in the converter.
21 | /// Visibility.Collapsed if the value is true, Visibility.Visible if the value is false.
22 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | if (value is bool boolValue)
25 | {
26 | return boolValue ? Visibility.Collapsed : Visibility.Visible;
27 | }
28 |
29 | return Visibility.Visible;
30 | }
31 |
32 | ///
33 | /// Converts a Visibility value back to a boolean value, with the boolean value inverted.
34 | ///
35 | /// The Visibility value to convert back.
36 | /// The type of the binding target property.
37 | /// The converter parameter to use.
38 | /// The culture to use in the converter.
39 | /// False if the value is Visibility.Visible, true otherwise.
40 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
41 | {
42 | if (value is Visibility visibility)
43 | {
44 | return visibility != Visibility.Visible;
45 | }
46 |
47 | return false;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/InverseCountToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts an integer count to a Visibility value, with the count inverted.
10 | /// Returns Visible if the count is 0, otherwise returns Collapsed.
11 | ///
12 | public class InverseCountToVisibilityConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value is int count)
17 | {
18 | return count == 0 ? Visibility.Visible : Visibility.Collapsed;
19 | }
20 |
21 | return Visibility.Visible;
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25 | {
26 | throw new NotImplementedException();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/IsPrimaryToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts a boolean IsPrimary value to a Visibility value.
10 | /// Returns Visible if the value is true, otherwise returns Collapsed.
11 | ///
12 | public class IsPrimaryToVisibilityConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value is bool isPrimary && isPrimary)
17 | {
18 | return Visibility.Visible;
19 | }
20 |
21 | return Visibility.Collapsed;
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25 | {
26 | throw new NotImplementedException();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/LogLevelToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 | using Winhance.Core.Features.Common.Enums;
6 |
7 | namespace Winhance.WPF.Features.Common.Converters
8 | {
9 | ///
10 | /// Converts a LogLevel to a color for display in the UI.
11 | ///
12 | public class LogLevelToColorConverter : IValueConverter
13 | {
14 | ///
15 | /// Converts a LogLevel to a color.
16 | ///
17 | /// The LogLevel value.
18 | /// The target type.
19 | /// The converter parameter.
20 | /// The culture information.
21 | /// A color brush based on the log level.
22 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | if (value is LogLevel level)
25 | {
26 | switch (level)
27 | {
28 | case LogLevel.Error:
29 | return new SolidColorBrush(Colors.Red);
30 | case LogLevel.Warning:
31 | return new SolidColorBrush(Colors.Orange);
32 | case LogLevel.Debug:
33 | return new SolidColorBrush(Colors.Gray);
34 | default:
35 | return new SolidColorBrush(Colors.White);
36 | }
37 | }
38 | return new SolidColorBrush(Colors.White);
39 | }
40 |
41 | ///
42 | /// Converts a color back to a LogLevel (not implemented).
43 | ///
44 | /// The color value.
45 | /// The target type.
46 | /// The converter parameter.
47 | /// The culture information.
48 | /// Not implemented.
49 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
50 | {
51 | throw new NotImplementedException();
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/NullToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Converters
7 | {
8 | public class NullToVisibilityConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | // If the value is null, return Visible, otherwise return Collapsed
13 | return value == null ? Visibility.Visible : Visibility.Collapsed;
14 | }
15 |
16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | throw new NotImplementedException();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/RegistryHiveToFullNameConverter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using System;
3 | using System.Globalization;
4 | using System.Windows.Data;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts a RegistryHive enum to its full string representation (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, etc.)
10 | ///
11 | public class RegistryHiveToFullNameConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | if (value is RegistryHive hive)
16 | {
17 | return hive switch
18 | {
19 | RegistryHive.ClassesRoot => "HKEY_CLASSES_ROOT",
20 | RegistryHive.CurrentUser => "HKEY_CURRENT_USER",
21 | RegistryHive.LocalMachine => "HKEY_LOCAL_MACHINE",
22 | RegistryHive.Users => "HKEY_USERS",
23 | RegistryHive.CurrentConfig => "HKEY_CURRENT_CONFIG",
24 | _ => value.ToString()
25 | };
26 | }
27 |
28 | return value?.ToString() ?? string.Empty;
29 | }
30 |
31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
32 | {
33 | throw new NotImplementedException();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/RemoveActionToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 | using Winhance.Core.Features.Common.Enums;
6 |
7 | namespace Winhance.WPF.Features.Common.Converters
8 | {
9 | public class RemoveActionToVisibilityConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | // If the action type is Remove, return Visible, otherwise return Collapsed
14 | if (value is RegistryActionType actionType)
15 | {
16 | return actionType == RegistryActionType.Remove ? Visibility.Visible : Visibility.Collapsed;
17 | }
18 |
19 | return Visibility.Collapsed;
20 | }
21 |
22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | throw new NotImplementedException();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/ScriptStatusToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | ///
9 | /// Converts a boolean script status to a color.
10 | ///
11 | public class ScriptStatusToColorConverter : IValueConverter
12 | {
13 | ///
14 | /// Converts a boolean value to a color.
15 | ///
16 | /// The boolean value indicating if scripts are active.
17 | /// The type of the binding target property.
18 | /// The converter parameter to use.
19 | /// The culture to use in the converter.
20 | /// A color based on the script status.
21 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | if (value is bool isActive)
24 | {
25 | // Return green if scripts are active, gray if not
26 | return isActive
27 | ? new SolidColorBrush(Color.FromRgb(0, 200, 83)) // Green for active
28 | : new SolidColorBrush(Color.FromRgb(150, 150, 150)); // Gray for inactive
29 | }
30 |
31 | return new SolidColorBrush(Colors.Gray);
32 | }
33 |
34 | ///
35 | /// Converts a color back to a boolean value.
36 | ///
37 | /// The color to convert back.
38 | /// The type of the binding target property.
39 | /// The converter parameter to use.
40 | /// The culture to use in the converter.
41 | /// A boolean value based on the color.
42 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
43 | {
44 | throw new NotImplementedException();
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/ScriptStatusToTextConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Winhance.WPF.Features.Common.Converters
6 | {
7 | ///
8 | /// Converts a boolean script status to a descriptive text.
9 | ///
10 | public class ScriptStatusToTextConverter : IValueConverter
11 | {
12 | ///
13 | /// Converts a boolean value to a descriptive text.
14 | ///
15 | /// The boolean value indicating if scripts are active.
16 | /// The type of the binding target property.
17 | /// The converter parameter to use.
18 | /// The culture to use in the converter.
19 | /// A descriptive text based on the script status.
20 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
21 | {
22 | if (value is bool isActive)
23 | {
24 | return isActive
25 | ? "Winhance Removing Apps"
26 | : "No Active Removals";
27 | }
28 |
29 | return "Unknown Status";
30 | }
31 |
32 | ///
33 | /// Converts a descriptive text back to a boolean value.
34 | ///
35 | /// The text to convert back.
36 | /// The type of the binding target property.
37 | /// The converter parameter to use.
38 | /// The culture to use in the converter.
39 | /// A boolean value based on the text.
40 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
41 | {
42 | throw new NotImplementedException();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/StatusToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows.Media;
5 | using Winhance.Core.Features.Common.Enums;
6 |
7 | namespace Winhance.WPF.Features.Common.Converters
8 | {
9 | public class StatusToColorConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | // Handle RegistrySettingStatus
14 | if (value is RegistrySettingStatus status)
15 | {
16 | return status switch
17 | {
18 | RegistrySettingStatus.Applied => new SolidColorBrush(Color.FromRgb(0, 255, 60)), // Electric Green (#00FF3C)
19 | RegistrySettingStatus.NotApplied => new SolidColorBrush(Color.FromRgb(255, 40, 0)), // Ferrari Red (#FF2800)
20 | RegistrySettingStatus.Modified => new SolidColorBrush(Colors.Orange),
21 | RegistrySettingStatus.Error => new SolidColorBrush(Colors.Gray),
22 | _ => new SolidColorBrush(Colors.Gray)
23 | };
24 | }
25 |
26 | // Handle boolean for reinstallability status
27 | if (value is bool canBeReinstalled)
28 | {
29 | return canBeReinstalled
30 | ? new SolidColorBrush(Color.FromRgb(0, 165, 255)) // Blue (#00A5FF)
31 | : new SolidColorBrush(Color.FromRgb(255, 40, 0)); // Ferrari Red (#FF2800)
32 | }
33 |
34 | return new SolidColorBrush(Colors.Gray);
35 | }
36 |
37 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
38 | {
39 | throw new NotImplementedException();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/StatusToTextConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using Winhance.Core.Features.Common.Enums;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | public class StatusToTextConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (value is RegistrySettingStatus status)
13 | {
14 | return status switch
15 | {
16 | RegistrySettingStatus.Applied => "Applied",
17 | RegistrySettingStatus.NotApplied => "Not Applied",
18 | RegistrySettingStatus.Modified => "Modified",
19 | RegistrySettingStatus.Error => "Error",
20 | _ => "Unknown"
21 | };
22 | }
23 |
24 | return "Unknown";
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28 | {
29 | throw new NotImplementedException();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/StringToMaximizeIconConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using MaterialDesignThemes.Wpf;
5 |
6 | namespace Winhance.WPF.Features.Common.Converters
7 | {
8 | public class StringToMaximizeIconConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (value is string iconName)
13 | {
14 | switch (iconName)
15 | {
16 | case "WindowMaximize":
17 | return PackIconKind.WindowMaximize;
18 | case "WindowRestore":
19 | return PackIconKind.WindowRestore;
20 | default:
21 | return PackIconKind.WindowMaximize;
22 | }
23 | }
24 |
25 | return PackIconKind.WindowMaximize;
26 | }
27 |
28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
29 | {
30 | if (value is PackIconKind kind)
31 | {
32 | switch (kind)
33 | {
34 | case PackIconKind.WindowMaximize:
35 | return "WindowMaximize";
36 | case PackIconKind.WindowRestore:
37 | return "WindowRestore";
38 | default:
39 | return "WindowMaximize";
40 | }
41 | }
42 |
43 | return "WindowMaximize";
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Converters/WindowStateToCommandConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 | using System.Windows.Input;
6 |
7 | namespace Winhance.WPF.Converters
8 | {
9 | public class WindowStateToCommandConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | if (value is WindowState windowState)
14 | {
15 | return windowState == WindowState.Maximized
16 | ? SystemCommands.RestoreWindowCommand
17 | : SystemCommands.MaximizeWindowCommand;
18 | }
19 |
20 | return SystemCommands.MaximizeWindowCommand;
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | throw new NotImplementedException();
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Messages/ResetExpansionStateMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.WPF.Features.Common.Messages
4 | {
5 | ///
6 | /// Message to notify the view to reset the expansion state of collapsible sections.
7 | ///
8 | public class ResetExpansionStateMessage
9 | {
10 | ///
11 | /// Gets the timestamp when the message was created.
12 | ///
13 | public DateTime Timestamp { get; } = DateTime.Now;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Models/ApplicationSettingGroup.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System.Collections.ObjectModel;
3 |
4 | namespace Winhance.WPF.Features.Common.Models
5 | {
6 | ///
7 | /// Base class for application setting groups used in both Optimization and Customization features.
8 | ///
9 | public partial class ApplicationSettingGroup : ObservableObject
10 | {
11 | [ObservableProperty]
12 | private string _name = string.Empty;
13 |
14 | [ObservableProperty]
15 | private string _description = string.Empty;
16 |
17 | [ObservableProperty]
18 | private bool _isSelected;
19 |
20 | [ObservableProperty]
21 | private bool _isGroupHeader;
22 |
23 | [ObservableProperty]
24 | private string _groupName = string.Empty;
25 |
26 | [ObservableProperty]
27 | private bool _isVisible = true;
28 |
29 | ///
30 | /// Gets the collection of settings in this group.
31 | ///
32 | public ObservableCollection Settings { get; } = new();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Models/LinkedRegistrySettingWithValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Winhance.Core.Features.Common.Models;
3 |
4 | namespace Winhance.WPF.Features.Common.Models
5 | {
6 | ///
7 | /// Wrapper class for RegistrySetting that includes the current value.
8 | /// Used for displaying registry settings with their current values in tooltips.
9 | ///
10 | public class LinkedRegistrySettingWithValue
11 | {
12 | ///
13 | /// Gets the underlying registry setting.
14 | ///
15 | public RegistrySetting Setting { get; }
16 |
17 | ///
18 | /// Gets or sets the current value of the registry setting.
19 | ///
20 | public object? CurrentValue { get; set; }
21 |
22 | ///
23 | /// Creates a new instance of the LinkedRegistrySettingWithValue class.
24 | ///
25 | /// The registry setting.
26 | /// The current value of the registry setting.
27 | public LinkedRegistrySettingWithValue(RegistrySetting setting, object? currentValue)
28 | {
29 | Setting = setting ?? throw new ArgumentNullException(nameof(setting));
30 | CurrentValue = currentValue;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Models/LogMessageViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Winhance.Core.Features.Common.Enums;
3 |
4 | namespace Winhance.WPF.Features.Common.Models
5 | {
6 | ///
7 | /// View model for log messages displayed in the UI.
8 | ///
9 | public class LogMessageViewModel
10 | {
11 | ///
12 | /// Gets or sets the message content.
13 | ///
14 | public string Message { get; set; }
15 |
16 | ///
17 | /// Gets or sets the log level.
18 | ///
19 | public LogLevel Level { get; set; }
20 |
21 | ///
22 | /// Gets or sets the timestamp when the message was created.
23 | ///
24 | public DateTime Timestamp { get; set; }
25 |
26 | ///
27 | /// Gets the formatted message with timestamp.
28 | ///
29 | public string FormattedMessage => $"[{Timestamp:HH:mm:ss}] {Message}";
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/Dimensions/Dimensions.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | 10
6 | 5
7 | 20
8 | 0,10,0,0
9 | 8,5,10,5
10 | 0,5,0,0
11 | 0,20,10,10
12 |
13 |
14 | 12
15 | 14
16 | 18
17 | 24
18 | 32
19 | 60
20 |
21 |
22 | 35
23 | 130
24 | 16
25 | 24
26 | 70
27 | 35
28 | 22
29 | 80
30 | 70
31 | 10
32 |
33 |
34 | 10
35 | 5
36 | 20
37 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/Icons.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/ResourceDictionary.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/Styles/Styles.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/Styles/ToolTipStyles.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/Theme/IThemeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Winhance.WPF.Features.Common.Resources.Theme
4 | {
5 | public interface IThemeManager : IDisposable
6 | {
7 | bool IsDarkTheme { get; set; }
8 | void ToggleTheme();
9 | void ApplyTheme();
10 | void LoadThemePreference();
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Resources/Themes/Themes.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Services/Configuration/ConfigurationServiceExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 |
3 | namespace Winhance.WPF.Features.Common.Services.Configuration
4 | {
5 | ///
6 | /// Extension methods for registering configuration services with the dependency injection container.
7 | ///
8 | public static class ConfigurationServiceExtensions
9 | {
10 | ///
11 | /// Adds all configuration services to the service collection.
12 | ///
13 | /// The service collection.
14 | /// The service collection for chaining.
15 | public static IServiceCollection AddConfigurationServices(this IServiceCollection services)
16 | {
17 | // Register the main configuration applier service
18 | services.AddTransient();
19 |
20 | // Register the property updater and view model refresher
21 | services.AddTransient();
22 | services.AddTransient();
23 |
24 | // Register all section-specific appliers
25 | services.AddTransient();
26 | services.AddTransient();
27 | services.AddTransient();
28 | services.AddTransient();
29 |
30 | return services;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Services/Configuration/IConfigurationApplierService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.WPF.Features.Common.Services.Configuration
6 | {
7 | ///
8 | /// Interface for the service that applies configuration settings to different view models.
9 | ///
10 | public interface IConfigurationApplierService
11 | {
12 | ///
13 | /// Applies configuration settings to the selected sections.
14 | ///
15 | /// The unified configuration file.
16 | /// The sections to apply.
17 | /// A dictionary of section names and their application result.
18 | Task> ApplySectionsAsync(UnifiedConfigurationFile config, IEnumerable selectedSections);
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Winhance.WPF/Features/Common/Services/Configuration/IConfigurationPropertyUpdater.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Threading.Tasks;
3 | using Winhance.Core.Features.Common.Models;
4 |
5 | namespace Winhance.WPF.Features.Common.Services.Configuration
6 | {
7 | ///
8 | /// Interface for a service that updates properties of configuration items.
9 | ///
10 | public interface IConfigurationPropertyUpdater
11 | {
12 | ///
13 | /// Updates properties of items based on the configuration.
14 | ///
15 | /// The items to update.
16 | /// The configuration file containing the updates.
17 | /// The number of items that were updated.
18 | Task UpdateItemsAsync(IEnumerable