├── .gitattributes ├── .gitignore ├── Directory.Build.props ├── LICENSE.txt ├── MyComputerManager.sln ├── MyComputerManager ├── App.config ├── App.xaml ├── App.xaml.cs ├── Controls │ ├── ClippingBorder.cs │ ├── PathBox.xaml │ ├── PathBox.xaml.cs │ ├── RegBox.xaml │ └── RegBox.xaml.cs ├── Converters │ ├── ItemTypeConverter.cs │ ├── ItemTypeToEnabledConverter.cs │ └── ValueNullToInverseVisibilityConverter.cs ├── Extensions │ └── ClickExt.cs ├── Helpers │ ├── BitmapHelper.cs │ ├── Icon │ │ ├── IImageList.cs │ │ ├── IMAGEINFO.cs │ │ ├── IMAGELISTDRAWPARAMS.cs │ │ ├── IconHelper.cs │ │ ├── IconSize.cs │ │ ├── NativeMethods.cs │ │ ├── RECT.cs │ │ └── SHFILEINFOW.cs │ ├── NamespaceHelper.cs │ ├── Regedit │ │ ├── KeyInfo.cs │ │ └── RegistryEditor.cs │ └── StringHelper.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Models │ ├── AppConfig.cs │ ├── CommonResult.cs │ ├── DialogMessage.cs │ ├── NamespaceItem.cs │ └── NamespaceItemType.cs ├── Mvvm │ ├── AsyncCommandBase.cs │ ├── AsyncRelayCommand.cs │ └── RoutedEventTrigger.cs ├── MyComputerManager.csproj ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── addimage.svg │ ├── copy.svg │ ├── folder.svg │ ├── openbox.ico │ ├── openbox.svg │ ├── reg.svg │ ├── title.png │ └── title.psd ├── Services │ ├── ApplicationHostService.cs │ ├── Contracts │ │ ├── IDataService.cs │ │ ├── IDialogService.cs │ │ └── ISnackBarService.cs │ ├── DataService.cs │ ├── DialogService.cs │ ├── PageService.cs │ └── SnackBarService.cs ├── Styles │ ├── ItemListStyle.xaml │ ├── MenuButtonStyle.xaml │ └── PathBoxStyle.xaml ├── ViewModels │ ├── DetailPageViewModel.cs │ └── MainPageViewModel.cs ├── Views │ ├── AboutPage.xaml │ ├── AboutPage.xaml.cs │ ├── DetailPage.xaml │ ├── DetailPage.xaml.cs │ ├── MainPage.xaml │ └── MainPage.xaml.cs └── packages.config ├── README.md ├── ReadmeItems ├── intro-p1.png ├── intro-p1.psd ├── intro-p2.png ├── intro-p2.psd ├── intro-p3.png └── intro-p3.psd └── Settings.XamlStyler /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0.1.0 5 | 10.0 6 | true 7 | 8 | 9 | 10 | $(Version) 11 | 12 | 13 | -------------------------------------------------------------------------------- /MyComputerManager.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32505.426 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyComputerManager", "MyComputerManager\MyComputerManager.csproj", "{B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Debug|x64.ActiveCfg = Debug|x64 21 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Debug|x64.Build.0 = Debug|x64 22 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Debug|x86.ActiveCfg = Debug|x86 23 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Debug|x86.Build.0 = Debug|x86 24 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Release|x64.ActiveCfg = Release|x64 27 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Release|x64.Build.0 = Release|x64 28 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Release|x86.ActiveCfg = Release|x86 29 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E}.Release|x86.Build.0 = Release|x86 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {0FC6F600-7794-4E6A-8ADF-D23B9CE32E05} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /MyComputerManager/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MyComputerManager/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 微软雅黑 18 | 微软雅黑 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MyComputerManager/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Runtime.ExceptionServices; 9 | using System.Threading.Tasks; 10 | using System.Windows; 11 | using System.Windows.Media; 12 | using Microsoft.Extensions.Configuration; 13 | using Microsoft.Extensions.DependencyInjection; 14 | using Microsoft.Extensions.Hosting; 15 | using MyComputerManager.Models; 16 | using MyComputerManager.Services; 17 | using MyComputerManager.Services.Contracts; 18 | using MyComputerManager.ViewModels; 19 | using MyComputerManager.Views; 20 | using Wpf.Ui.Demo.Models; 21 | using Wpf.Ui.Demo.Services; 22 | using Wpf.Ui.Mvvm.Contracts; 23 | using Wpf.Ui.Mvvm.Services; 24 | using DialogService = MyComputerManager.Services.DialogService; 25 | using IDialogService = MyComputerManager.Services.Contracts.IDialogService; 26 | 27 | namespace MyComputerManager 28 | { 29 | /// 30 | /// App.xaml 的交互逻辑 31 | /// 32 | public partial class App : Application 33 | { 34 | private IHost _host; 35 | 36 | protected override void OnStartup(StartupEventArgs e) 37 | { 38 | base.OnStartup(e); 39 | AppDomain.CurrentDomain.FirstChanceException += FirstChanceHandler; 40 | //Wpf.Ui.Appearance.Accent.Apply(Color.FromRgb(15, 123, 210)); 41 | 42 | _host = Host.CreateDefaultBuilder(e.Args) 43 | .ConfigureAppConfiguration(c => 44 | { 45 | c.SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); 46 | }) 47 | .ConfigureServices(ConfigureServices) 48 | .Build(); 49 | 50 | _host.Start(); 51 | } 52 | 53 | private void ConfigureServices(HostBuilderContext context, IServiceCollection services) 54 | { 55 | // App Host 56 | services.AddHostedService(); 57 | 58 | // Theme manipulation 59 | services.AddSingleton(); 60 | 61 | // Taskbar manipulation 62 | services.AddSingleton(); 63 | 64 | // Page resolver service 65 | services.AddSingleton(); 66 | 67 | // Service containing navigation, same as INavigationWindow... but without window 68 | services.AddSingleton(); 69 | 70 | 71 | services.AddSingleton(); 72 | services.AddSingleton(); 73 | services.AddSingleton(); 74 | 75 | // Main window container with navigation 76 | services.AddScoped(); 77 | //services.AddScoped(); 78 | 79 | // Views and ViewModels 80 | services.AddScoped(); 81 | services.AddScoped(); 82 | 83 | services.AddTransient(); 84 | services.AddTransient(); 85 | 86 | services.AddSingleton(); 87 | 88 | // Configuration 89 | services.Configure(context.Configuration.GetSection(nameof(AppConfig))); 90 | } 91 | 92 | protected override void OnExit(ExitEventArgs e) 93 | { 94 | base.OnExit(e); 95 | _host.StopAsync().ConfigureAwait(false); 96 | _host.Dispose(); 97 | _host = null; 98 | } 99 | 100 | public static void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e) 101 | { 102 | Console.WriteLine("FirstChanceException event raised in {0}: {1}", 103 | AppDomain.CurrentDomain.FriendlyName, e.Exception.Message); 104 | //MessageBox.Show(e.Exception.ToString()); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /MyComputerManager/Controls/ClippingBorder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Media; 9 | 10 | namespace MyComputerManager.Controls 11 | { 12 | public class ClippingBorder : Border 13 | { 14 | protected override void OnRender(DrawingContext dc) 15 | { 16 | OnApplyChildClip(); 17 | base.OnRender(dc); 18 | } 19 | 20 | public override UIElement Child 21 | { 22 | get 23 | { 24 | return base.Child; 25 | } 26 | set 27 | { 28 | if (this.Child != value) 29 | { 30 | if (this.Child != null) 31 | { 32 | // Restore original clipping 33 | this.Child.SetValue(UIElement.ClipProperty, _oldClip); 34 | } 35 | 36 | if (value != null) 37 | { 38 | _oldClip = value.ReadLocalValue(UIElement.ClipProperty); 39 | } 40 | else 41 | { 42 | // If we dont set it to null we could leak a Geometry object 43 | _oldClip = null; 44 | } 45 | 46 | base.Child = value; 47 | } 48 | } 49 | } 50 | 51 | protected virtual void OnApplyChildClip() 52 | { 53 | UIElement child = this.Child; 54 | if (child != null) 55 | { 56 | _clipRect.RadiusX = _clipRect.RadiusY = Math.Max(0.0, this.CornerRadius.TopLeft - (this.BorderThickness.Left * 0.5)); 57 | Rect rect = new Rect(this.RenderSize); 58 | rect.Height -= (this.BorderThickness.Top + this.BorderThickness.Bottom); 59 | rect.Width -= (this.BorderThickness.Left + this.BorderThickness.Right); 60 | _clipRect.Rect = rect; 61 | child.Clip = _clipRect; 62 | } 63 | } 64 | 65 | public void Update() { OnApplyChildClip(); } 66 | 67 | private RectangleGeometry _clipRect = new RectangleGeometry(); 68 | private object _oldClip; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /MyComputerManager/Controls/PathBox.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 31 | 32 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /MyComputerManager/Controls/PathBox.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using MyComputerManager.Helpers; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Data; 11 | using System.Windows.Documents; 12 | using System.Windows.Input; 13 | using System.Windows.Media; 14 | using System.Windows.Media.Imaging; 15 | using System.Windows.Navigation; 16 | using System.Windows.Shapes; 17 | 18 | namespace MyComputerManager.Controls 19 | { 20 | public partial class PathBox : UserControl 21 | { 22 | public PathBox() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | 28 | public string Path 29 | { 30 | get { return (string)GetValue(PathProperty); } 31 | set { SetValue(PathProperty, value); } 32 | } 33 | 34 | public static readonly DependencyProperty PathProperty = DependencyProperty.Register( 35 | nameof(Path), typeof(string), typeof(PathBox), 36 | new PropertyMetadata(null)); 37 | 38 | public string AllowExt 39 | { 40 | get { return (string)GetValue(AllowExtProperty); } 41 | set { SetValue(AllowExtProperty, value); } 42 | } 43 | 44 | public static readonly DependencyProperty AllowExtProperty = 45 | DependencyProperty.Register("AllowExt", typeof(string), typeof(PathBox), new PropertyMetadata(null)); 46 | 47 | private void ButtonOpen_Click(object sender, RoutedEventArgs e) 48 | { 49 | //Process.Start("explorer", "/select," + Path); 50 | OpenFileDialog d = new OpenFileDialog(); 51 | d.Filter = StringHelper.BuildFilter(AllowExt); 52 | if (d.ShowDialog() ?? false) 53 | Path = d.FileName; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MyComputerManager/Controls/RegBox.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | 36 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /MyComputerManager/Controls/RegBox.xaml.cs: -------------------------------------------------------------------------------- 1 | using DevTools.RegistryJump; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Text; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace MyComputerManager.Controls 17 | { 18 | public partial class RegBox : UserControl 19 | { 20 | public RegBox() 21 | { 22 | InitializeComponent(); 23 | } 24 | 25 | public static readonly DependencyProperty RegPathProperty = DependencyProperty.Register(nameof(RegPath), typeof(string), typeof(RegBox), 26 | new PropertyMetadata(null)); 27 | 28 | public string RegPath 29 | { 30 | get { return (string)GetValue(RegPathProperty); } 31 | set { SetValue(RegPathProperty, value); } 32 | } 33 | 34 | private void ButtonOpen_Click(object sender, RoutedEventArgs e) 35 | { 36 | try 37 | { 38 | RegistryEditor.OpenRegistryEditor(RegPath); 39 | } 40 | catch(Exception ex) 41 | { 42 | MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Exclamation); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /MyComputerManager/Converters/ItemTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Data; 9 | 10 | namespace MyComputerManager.Converters 11 | { 12 | public class ItemTypeConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | ItemType type = (ItemType)value; 17 | switch(type) 18 | { 19 | case ItemType.MyComputer: 20 | return ""; 21 | case ItemType.Desktop: 22 | return "(侧边栏)"; 23 | default: 24 | return ""; 25 | } 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MyComputerManager/Converters/ItemTypeToEnabledConverter.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Data; 9 | 10 | namespace MyComputerManager.Converters 11 | { 12 | public class ItemTypeToEnabledConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | ItemType type = (ItemType)value; 17 | switch(type) 18 | { 19 | case ItemType.MyComputer: 20 | return true; 21 | case ItemType.Desktop: 22 | return false; 23 | default: 24 | return false; 25 | } 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MyComputerManager/Converters/ValueNullToInverseVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Data; 9 | using System.Windows.Markup; 10 | 11 | namespace MyComputerManager.Converters 12 | { 13 | public class ValueNullToInverseVisibilityConverter : IValueConverter 14 | { 15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | if (value == null) 18 | return Visibility.Visible; 19 | 20 | return Visibility.Collapsed; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 24 | { 25 | throw new NotSupportedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MyComputerManager/Extensions/ClickExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using Microsoft.Xaml.Behaviors; 9 | 10 | namespace MyComputerManager.Extensions 11 | { 12 | public class ClickExtensions 13 | { 14 | public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent 15 | ("Click", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ClickExtensions)); 16 | 17 | // 为界面元素添加路由事件侦听 18 | public static void AddClickHandler(DependencyObject d, RoutedEventHandler h) 19 | { 20 | UIElement e = d as UIElement; 21 | if (e != null) 22 | { 23 | e.AddHandler(ClickExtensions.ClickEvent, h); 24 | } 25 | } 26 | 27 | // 移除侦听 28 | public static void RemoveClickHandler(DependencyObject d, RoutedEventHandler h) 29 | { 30 | UIElement e = d as UIElement; 31 | if (e != null) 32 | { 33 | e.RemoveHandler(ClickExtensions.ClickEvent, h); 34 | } 35 | } 36 | } 37 | 38 | public class ClickBehavior : Behavior 39 | { 40 | int status = 0; 41 | protected override void OnAttached() 42 | { 43 | base.OnAttached(); 44 | AssociatedObject.MouseEnter += AssociatedObject_MouseEnter; 45 | AssociatedObject.MouseLeave += AssociatedObject_MouseLeave; 46 | AssociatedObject.MouseLeftButtonDown += AssociatedObject_MouseLeftButtonDown; 47 | AssociatedObject.MouseLeftButtonUp += AssociatedObject_MouseLeftButtonUp; 48 | } 49 | 50 | private void AssociatedObject_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) 51 | { 52 | if (status > 0) 53 | { 54 | RoutedEventArgs arg = new RoutedEventArgs(ClickExtensions.ClickEvent, AssociatedObject); 55 | AssociatedObject.RaiseEvent(arg); 56 | } 57 | status = 0; 58 | } 59 | 60 | private void AssociatedObject_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 61 | { 62 | status = 1; 63 | } 64 | 65 | private void AssociatedObject_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) 66 | { 67 | status = 0; 68 | } 69 | 70 | private void AssociatedObject_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) 71 | { 72 | if (status == 0) 73 | status = -1; 74 | } 75 | 76 | protected override void OnDetaching() 77 | { 78 | base.OnDetaching(); 79 | AssociatedObject.MouseEnter -= AssociatedObject_MouseEnter; 80 | AssociatedObject.MouseLeave -= AssociatedObject_MouseLeave; 81 | AssociatedObject.MouseLeftButtonDown -= AssociatedObject_MouseLeftButtonDown; 82 | AssociatedObject.MouseLeftButtonUp -= AssociatedObject_MouseLeftButtonUp; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/BitmapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Media; 9 | using System.Windows.Media.Imaging; 10 | 11 | namespace MyComputerManager 12 | { 13 | public class BitmapHelper 14 | { 15 | public static BitmapSource ToBitmapSource(Image image) 16 | { 17 | return ToBitmapSource(image as Bitmap); 18 | } 19 | 20 | public static BitmapSource ToBitmapSource(System.Drawing.Bitmap bitmap) 21 | { 22 | if (bitmap == null) return null; 23 | 24 | using (System.Drawing.Bitmap source = (System.Drawing.Bitmap)bitmap.Clone()) 25 | { 26 | IntPtr ptr = source.GetHbitmap(); //obtain the Hbitmap 27 | 28 | BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( 29 | ptr, 30 | IntPtr.Zero, 31 | System.Windows.Int32Rect.Empty, 32 | System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); 33 | 34 | NativeMethods.DeleteObject(ptr); //release the HBitmap 35 | bs.Freeze(); 36 | return bs; 37 | } 38 | } 39 | 40 | public static BitmapSource ToBitmapSource(byte[] bytes, int width, int height, int dpiX, int dpiY) 41 | { 42 | var result = BitmapSource.Create( 43 | width, 44 | height, 45 | dpiX, 46 | dpiY, 47 | PixelFormats.Bgra32, 48 | null /* palette */, 49 | bytes, 50 | width * 4 /* stride */); 51 | result.Freeze(); 52 | 53 | return result; 54 | } 55 | 56 | 57 | } 58 | 59 | internal static class NativeMethods 60 | { 61 | [DllImport("gdi32.dll")] 62 | [return: MarshalAs(UnmanagedType.Bool)] 63 | public static extern bool DeleteObject([In] IntPtr hObject); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/IImageList.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing.Structs; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace System.Drawing.Interfaces 5 | { 6 | [ComImport] 7 | [Guid("46EB5926-582E-4017-9FDF-E8998DAA0950")] 8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 9 | internal interface IImageList 10 | { 11 | [PreserveSig] 12 | int Add(IntPtr hbmImage, IntPtr hbmMask, ref int pi); 13 | [PreserveSig] 14 | int ReplaceIcon(int i, IntPtr hicon, ref int pi); 15 | [PreserveSig] 16 | int SetOverlayImage(int iImage, int iOverlay); 17 | [PreserveSig] 18 | int Replace(int i, IntPtr hbmImage, IntPtr hbmMask); 19 | [PreserveSig] 20 | int AddMasked(IntPtr hbmImage, int crMask, ref int pi); 21 | [PreserveSig] 22 | int Draw(ref IMAGELISTDRAWPARAMS pimldp); 23 | [PreserveSig] 24 | int Remove(int i); 25 | [PreserveSig] 26 | int GetIcon(int i, int flags, ref IntPtr picon); 27 | [PreserveSig] 28 | int GetImageInfo(int i, ref IMAGEINFO pImageInfo); 29 | [PreserveSig] 30 | int Copy(int iDst, IImageList punkSrc, int iSrc, int uFlags); 31 | [PreserveSig] 32 | int Merge(int i1, IImageList punk2, int i2, int dx, int dy, ref Guid riid, ref IntPtr ppv); 33 | [PreserveSig] 34 | int Clone(ref Guid riid, ref IntPtr ppv); 35 | [PreserveSig] 36 | int GetImageRect(int i, ref RECT prc); 37 | [PreserveSig] 38 | int GetIconSize(ref int cx, ref int cy); 39 | [PreserveSig] 40 | int SetIconSize(int cx, int cy); 41 | [PreserveSig] 42 | int GetImageCount(ref int pi); 43 | [PreserveSig] 44 | int SetImageCount(int uNewCount); 45 | [PreserveSig] 46 | int SetBkColor(int clrBk, ref int pclr); 47 | [PreserveSig] 48 | int GetBkColor(ref int pclr); 49 | [PreserveSig] 50 | int BeginDrag(int iTrack, int dxHotspot, int dyHotspot); 51 | [PreserveSig] 52 | int EndDrag(); 53 | [PreserveSig] 54 | int DragEnter(IntPtr hwndLock, int x, int y); 55 | [PreserveSig] 56 | int DragLeave(IntPtr hwndLock); 57 | [PreserveSig] 58 | int DragMove(int x, int y); 59 | [PreserveSig] 60 | int SetDragCursorImage(ref IImageList punk, int iDrag, int dxHotspot, int dyHotspot); 61 | [PreserveSig] 62 | int DragShowNolock(int fShow); 63 | [PreserveSig] 64 | int GetDragImage(ref Point ppt, ref Point pptHotspot, ref Guid riid, ref IntPtr ppv); 65 | [PreserveSig] 66 | int GetItemFlags(int i, ref int dwFlags); 67 | [PreserveSig] 68 | int GetOverlayImage(int iOverlay, ref int piIndex); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/IMAGEINFO.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace System.Drawing.Structs 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | internal struct IMAGEINFO 7 | { 8 | public IntPtr hbmImage; 9 | public IntPtr hbmMask; 10 | public int Unused1; 11 | public int Unused2; 12 | public RECT rcImage; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/IMAGELISTDRAWPARAMS.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace System.Drawing.Structs 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | internal struct IMAGELISTDRAWPARAMS 7 | { 8 | public int cbSize; 9 | public IntPtr himl; 10 | public int i; 11 | public IntPtr hdcDst; 12 | public int x; 13 | public int y; 14 | public int cx; 15 | public int cy; 16 | public int xBitmap; 17 | public int yBitmap; 18 | public int rgbBk; 19 | public int rgbFg; 20 | public int fStyle; 21 | public int dwRop; 22 | public int fState; 23 | public int Frame; 24 | public int crEffect; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/IconHelper.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.Drawing.Imaging; 6 | using System.Drawing.Interfaces; 7 | using System.Drawing.Structs; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Runtime.InteropServices; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using System.Windows; 14 | using System.Windows.Media; 15 | using System.Windows.Media.Imaging; 16 | 17 | namespace System.Drawing 18 | { 19 | public static class IconHelper 20 | { 21 | [DllImport("User32.dll")] 22 | internal static extern uint PrivateExtractIcons(string szFileName, int nIconIndex, int cxIcon, int cyIcon, IntPtr[] phicon, uint[] piconid, uint nIcons, uint flags); 23 | public static Icon ReadIconFromExe(string filePath, IconSize size) 24 | { 25 | Icon icon = null; 26 | var fileInfo = new SHFILEINFOW(); 27 | 28 | if (NativeMethods.SHGetFileInfoW(filePath, NativeMethods.FILE_ATTRIBUTE_NORMAL, ref fileInfo, Marshal.SizeOf(fileInfo), NativeMethods.SHGFI_SYSICONINDEX) == 0) 29 | throw new FileNotFoundException(); 30 | 31 | var iidImageList = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950"); 32 | IImageList imageList = null; 33 | 34 | NativeMethods.SHGetImageList((int)size, ref iidImageList, ref imageList); 35 | 36 | if (imageList != null) 37 | { 38 | var hIcon = IntPtr.Zero; 39 | //imageList.GetIcon(fileInfo.iIcon, (int)NativeMethods.ILD_TRANSPARENT, ref hIcon); 40 | imageList.GetIcon(fileInfo.iIcon, (int)NativeMethods.ILD_IMAGE, ref hIcon); 41 | icon = Icon.FromHandle(hIcon).Clone() as Icon; 42 | 43 | NativeMethods.DestroyIcon(hIcon); 44 | 45 | if (icon.ToBitmap().PixelFormat != Imaging.PixelFormat.Format32bppArgb) 46 | { 47 | icon.Dispose(); 48 | 49 | imageList.GetIcon(fileInfo.iIcon, (int)NativeMethods.ILD_TRANSPARENT, ref hIcon); 50 | icon = Icon.FromHandle(hIcon).Clone() as Icon; 51 | 52 | NativeMethods.DestroyIcon(hIcon); 53 | } 54 | } 55 | 56 | return icon; 57 | } 58 | 59 | public static Bitmap ReadIconFromDll(string filePath) 60 | { 61 | uint _nIcons = PrivateExtractIcons(filePath, 0, 0, 0, null, null, 0, 0); 62 | IntPtr[] phicon = new IntPtr[_nIcons]; 63 | uint[] piconid = new uint[_nIcons]; 64 | uint nIcons = PrivateExtractIcons(filePath, 0, 48, 48, phicon, piconid, _nIcons, 0); 65 | 66 | for (int i = 0; i < nIcons; i++) 67 | { 68 | Icon icon = Icon.FromHandle(phicon[i]); 69 | Bitmap bitmap = icon.ToBitmap(); 70 | icon.Dispose(); 71 | NativeMethods.DestroyIcon(phicon[i]); 72 | 73 | if (bitmap.PixelFormat == Imaging.PixelFormat.Format32bppArgb) 74 | return bitmap; 75 | } 76 | return null; 77 | } 78 | 79 | public static ImageSource ReadIcon(string iconPath) 80 | { 81 | if (File.Exists(iconPath)) 82 | { 83 | var f = new FileInfo(iconPath); 84 | if (f.Extension.ToLower() == ".ico") 85 | { 86 | Stream iconStream = new FileStream(iconPath, FileMode.Open, FileAccess.Read); 87 | IconBitmapDecoder decoder = new IconBitmapDecoder( 88 | iconStream, 89 | BitmapCreateOptions.PreservePixelFormat, 90 | BitmapCacheOption.None); 91 | var reslist = decoder.Frames.ToList(); 92 | 93 | if (reslist.Count > 0) 94 | { 95 | return reslist.OrderBy(x => (x.Format == PixelFormats.Bgra32 ? 1 : 2)).ThenByDescending(x => x.PixelHeight).First(); 96 | } 97 | } 98 | else if (f.Extension.ToLower() == ".exe") 99 | { 100 | Icon i = IconHelper.ReadIconFromExe(iconPath, IconSize.ExtraLarge); 101 | return BitmapHelper.ToBitmapSource(i.ToBitmap()); 102 | } 103 | else if (f.Extension.ToLower() == ".dll") 104 | { 105 | Bitmap i = IconHelper.ReadIconFromDll(iconPath); 106 | return BitmapHelper.ToBitmapSource(i); 107 | } 108 | } 109 | return null; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/IconSize.cs: -------------------------------------------------------------------------------- 1 | namespace System.Drawing 2 | { 3 | public enum IconSize : int 4 | { 5 | /// 6 | /// 32x32 px 7 | /// 8 | Large = 0x0, 9 | 10 | /// 11 | /// 16x16 px 12 | /// 13 | Small = 0x1, 14 | 15 | /// 16 | /// 48x48 px 17 | /// 18 | ExtraLarge = 0x2, 19 | 20 | /// 21 | /// 256x256 px 22 | /// 23 | Jumbo = 0x4 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing.Interfaces; 2 | using System.Drawing.Structs; 3 | using System.Runtime.InteropServices; 4 | using System.Security; 5 | 6 | namespace System.Drawing 7 | { 8 | [SuppressUnmanagedCodeSecurity] 9 | internal static class NativeMethods 10 | { 11 | public const uint SHGFI_SYSICONINDEX = 0x4000; 12 | public const uint ILD_TRANSPARENT = 0x1; 13 | public const uint ILD_IMAGE = 0x20; 14 | public const uint FILE_ATTRIBUTE_NORMAL = 0x80; 15 | 16 | public const int RT_ICON = 3; 17 | public const int RT_GROUP_ICON = 14; 18 | 19 | [DllImport("shell32.dll", EntryPoint = "#727")] 20 | public static extern int SHGetImageList(int iImageList, ref Guid riid, ref IImageList ppv); 21 | 22 | [DllImport("shell32.dll", EntryPoint = "SHGetFileInfoW", CallingConvention = CallingConvention.StdCall)] 23 | public static extern int SHGetFileInfoW([MarshalAs(UnmanagedType.LPWStr)] string pszPath, uint dwFileAttributes, ref SHFILEINFOW psfi, int cbFileInfo, uint uFlags); 24 | 25 | [DllImport("user32.dll", EntryPoint = "DestroyIcon")] 26 | public static extern bool DestroyIcon(IntPtr hIcon); 27 | 28 | [DllImport("kernel32")] 29 | public static extern IntPtr BeginUpdateResource(string fileName, [MarshalAs(UnmanagedType.Bool)] bool deleteExistingResources); 30 | 31 | [DllImport("kernel32")] 32 | [return: MarshalAs(UnmanagedType.Bool)] 33 | public static extern bool UpdateResource(IntPtr hUpdate, IntPtr type, IntPtr name, short language, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] byte[] data, int dataSize); 34 | 35 | [DllImport("kernel32")] 36 | [return: MarshalAs(UnmanagedType.Bool)] 37 | public static extern bool EndUpdateResource(IntPtr hUpdate, [MarshalAs(UnmanagedType.Bool)] bool discard); 38 | 39 | [DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)] 40 | public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/RECT.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace System.Drawing.Structs 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | internal struct RECT 7 | { 8 | public int left; 9 | public int top; 10 | public int right; 11 | public int bottom; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Icon/SHFILEINFOW.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace System.Drawing.Structs 4 | { 5 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 6 | internal struct SHFILEINFOW 7 | { 8 | public IntPtr hIcon; 9 | public int iIcon; 10 | public uint dwAttributes; 11 | 12 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] 13 | public string szDisplayName; 14 | 15 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] 16 | public string szTypeName; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/NamespaceHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using MyComputerManager.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Drawing; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using Wpf.Ui.Controls; 13 | 14 | namespace MyComputerManager.Helpers 15 | { 16 | public static class NamespaceHelper 17 | { 18 | public static IEnumerable GetItems() 19 | { 20 | try 21 | { 22 | var tmp = NamespaceHelper.GetRawItems(); 23 | foreach (var t in tmp) 24 | { 25 | var p = t.IconPath.LastIndexOf(','); 26 | if (p != -1) 27 | t.IconPath = t.IconPath.Substring(0, p); 28 | 29 | t.Icon = IconHelper.ReadIcon(t.IconPath); 30 | } 31 | return tmp; 32 | } 33 | catch (Exception ex) 34 | { 35 | var m = new MessageBox(); 36 | m.Show("读取数据时发生异常", ex.Message); 37 | return null; 38 | } 39 | } 40 | 41 | public static IEnumerable GetRawItems() 42 | { 43 | var l1 = GetItemsInternal(Registry.CurrentUser, false, ItemType.MyComputer); 44 | var l2 = GetItemsInternal(Registry.LocalMachine, false, ItemType.MyComputer); 45 | var l3 = GetItemsInternal(Registry.CurrentUser, true, ItemType.MyComputer); 46 | var l4 = GetItemsInternal(Registry.LocalMachine, true, ItemType.MyComputer); 47 | var l5 = GetItemsInternal(Registry.CurrentUser, false, ItemType.Desktop); 48 | //var l6 = GetItemsInternal(Registry.LocalMachine, false, ItemType.Desktop); 49 | var l7 = GetItemsInternal(Registry.CurrentUser, true, ItemType.Desktop); 50 | //var l8 = GetItemsInternal(Registry.LocalMachine, true, ItemType.Desktop); 51 | return l1.Concat(l2).Concat(l3).Concat(l4).Concat(l5).Concat(l7); 52 | } 53 | 54 | public static List GetItemsInternal(RegistryKey rootkey, bool disabled, ItemType type) 55 | { 56 | var list = new List(); 57 | var LocalMachineNamespace = rootkey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + type.ToString() + @"\NameSpace" + (disabled ? "Disabled" : ""), false); 58 | if (LocalMachineNamespace == null) 59 | return new List(); 60 | foreach (var item in LocalMachineNamespace.GetSubKeyNames()) 61 | { 62 | var clsidrootkey = Registry.CurrentUser; 63 | var clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false); 64 | var itemkey = clsidkey.OpenSubKey(item, false); 65 | if (itemkey == null) 66 | { 67 | clsidrootkey = Registry.LocalMachine; 68 | clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false); 69 | itemkey = clsidkey.OpenSubKey(item, false); 70 | } 71 | if (itemkey == null) 72 | { 73 | clsidrootkey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32); 74 | clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false); 75 | itemkey = clsidkey.OpenSubKey(item, false); 76 | } 77 | if (itemkey == null) 78 | { 79 | clsidrootkey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); 80 | clsidkey = clsidrootkey.OpenSubKey(@"SOFTWARE\Classes\CLSID", false); 81 | itemkey = clsidkey.OpenSubKey(item, false); 82 | } 83 | if (itemkey != null) 84 | { 85 | var iconkey = itemkey.OpenSubKey("DefaultIcon"); 86 | var dllkey = itemkey.OpenSubKey("InProcServer32"); 87 | var exekey = itemkey.OpenSubKey(@"Shell\Open\Command"); 88 | string name = (string)itemkey.GetValue("", ""); 89 | string desc = (string)itemkey.GetValue("System.ItemAuthors", ""); 90 | string tip = (string)itemkey.GetValue("InfoTip", ""); 91 | 92 | string iconpath = (string)(iconkey?.GetValue("") ?? ""); 93 | string exepath = (string)(exekey?.GetValue("") ?? ""); 94 | 95 | if (name == "") continue; 96 | list.Add(new NamespaceItem(name, desc, tip, exepath, iconpath, rootkey, clsidrootkey, disabled, item, type)); 97 | } 98 | } 99 | return list; 100 | } 101 | 102 | public static CommonResult UpdateItem(NamespaceItem item) 103 | { 104 | try 105 | { 106 | var namespaceKey = item.RegKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" +item.Type.ToString()+ @"\NameSpace" + (item.IsEnabled ? "" : "Disabled"), true); 107 | if (namespaceKey == null) 108 | return new CommonResult(false, "找不到Namespace key"); 109 | var namespaceSubKey = namespaceKey.CreateSubKey(item.CLSID, true); 110 | if (namespaceSubKey == null) 111 | return new CommonResult(false, "找不到Namespace下的" + item.CLSID); 112 | var clsidKey = item.RegKey1.CreateSubKey(@"SOFTWARE\Classes\CLSID", true); 113 | if (clsidKey == null) 114 | return new CommonResult(false, "找不到CLSID key"); 115 | var clsidSubKey = clsidKey.CreateSubKey(item.CLSID, true); 116 | if (clsidSubKey == null) 117 | return new CommonResult(false, "找不到Classes下的" + item.CLSID); 118 | 119 | if (item.Name == "") 120 | return new CommonResult(false, "名称不能为空"); 121 | clsidSubKey.SetValue("", item.Name); 122 | if (clsidSubKey.GetValue("LocalizedString", true) != null) 123 | clsidSubKey.SetValue("LocalizedString", item.Name); 124 | 125 | if (item.Desc == "") 126 | clsidSubKey.DeleteValue("System.ItemAuthors", false); 127 | else 128 | clsidSubKey.SetValue("System.ItemAuthors", item.Desc); 129 | clsidSubKey.SetValue("TileInfo", "prop:System.ItemAuthors"); 130 | 131 | if (item.Tip != "") 132 | clsidSubKey.SetValue("InfoTip", item.Tip); 133 | else 134 | clsidSubKey.DeleteValue("InfoTip", false); 135 | 136 | if (item.IconPath != null) 137 | { 138 | var iconKey = clsidSubKey.CreateSubKey("DefaultIcon", true); 139 | if (iconKey == null) 140 | return new CommonResult(false, "创建Key:DefaultIcon失败"); 141 | 142 | iconKey.SetValue("", item.IconPath + ",0", RegistryValueKind.ExpandString); 143 | } 144 | 145 | if (item.ExePath == "") 146 | { 147 | clsidSubKey.DeleteSubKeyTree(@"Shell\Open", false); 148 | } 149 | else 150 | { 151 | var exeKey = clsidSubKey.CreateSubKey(@"Shell\Open\Command", true); 152 | if (exeKey == null) 153 | return new CommonResult(false, @"创建Key:Shell\Open\Command失败"); 154 | 155 | exeKey.SetValue("", item.ExePath); 156 | } 157 | 158 | return new CommonResult(true, "成功"); 159 | } 160 | catch (Exception ex) 161 | { 162 | return new CommonResult(false, ex.Message); 163 | } 164 | } 165 | 166 | public static CommonResult SetEnabled(NamespaceItem item, bool isEnabled) 167 | { 168 | try 169 | { 170 | if (isEnabled) 171 | { 172 | var namespacekey = item.RegKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + item.Type.ToString() + @"\NameSpace"); 173 | var namespacekey1 = item.RegKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + item.Type.ToString() + @"\NameSpaceDisabled"); 174 | var newkey = namespacekey.CreateSubKey(item.CLSID); 175 | namespacekey1.DeleteSubKey(item.CLSID); 176 | newkey.SetValue("", item.Name, RegistryValueKind.String); 177 | } 178 | else 179 | { 180 | var namespacekey = item.RegKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + item.Type.ToString() + @"\NameSpaceDisabled"); 181 | var namespacekey1 = item.RegKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + item.Type.ToString() + @"\NameSpace"); 182 | var newkey = namespacekey.CreateSubKey(item.CLSID); 183 | namespacekey1.DeleteSubKey(item.CLSID); 184 | newkey.SetValue("", item.Name, RegistryValueKind.String); 185 | } 186 | return new CommonResult(true, "成功"); 187 | } 188 | catch (Exception ex) 189 | { 190 | return new CommonResult(false, ex.Message); 191 | } 192 | } 193 | 194 | public static CommonResult DeleteItem(NamespaceItem item) 195 | { 196 | try 197 | { 198 | var namespaceKey = item.RegKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + item.Type.ToString() + @"\NameSpace" + (item.IsEnabled ? "" : "Disabled"), true); 199 | if (namespaceKey == null) 200 | return new CommonResult(false, "找不到Namespace key"); 201 | namespaceKey.DeleteSubKeyTree(item.CLSID, false); 202 | 203 | var clsidKey = item.RegKey1.OpenSubKey(@"SOFTWARE\Classes\CLSID", true); ; 204 | if (clsidKey == null) 205 | return new CommonResult(false, "找不到CLSID key"); 206 | clsidKey.DeleteSubKeyTree(item.CLSID, false); 207 | 208 | return new CommonResult(true, "成功"); 209 | } 210 | catch (Exception ex) 211 | { 212 | return new CommonResult(false, ex.Message); 213 | } 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Regedit/KeyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Win32; 3 | 4 | namespace DevTools.RegistryJump 5 | { 6 | public class KeyInfo 7 | { 8 | private const string HKCR = "HKCR"; 9 | private const string HKCU = "HKCU"; 10 | private const string HKLM = "HKLM"; 11 | private const string HKU = "HKU"; 12 | private const string HKCC = "HKCC"; 13 | 14 | private const string HKEY_CLASSES_ROOT = "HKEY_CLASSES_ROOT"; 15 | private const string HKEY_CURRENT_USER = "HKEY_CURRENT_USER"; 16 | private const string HKEY_LOCAL_MACHINE = "HKEY_LOCAL_MACHINE"; 17 | private const string HKEY_USERS = "HKEY_USERS"; 18 | private const string HKEY_CURRENT_CONFIG = "HKEY_CURRENT_CONFIG"; 19 | 20 | private string _hk; 21 | 22 | public readonly string Hkey; 23 | 24 | public string Name; 25 | 26 | private readonly RegistryKey _key; 27 | 28 | public string GetFullname() 29 | { 30 | string fullname = $@"{Hkey}"; 31 | if (Name.Length > 0) 32 | fullname += $@"\{Name}"; 33 | return fullname; 34 | } 35 | 36 | private KeyInfo(string hk, string hkey, string name, RegistryKey key) 37 | { 38 | _hk = hk; 39 | Hkey = hkey; 40 | Name = name; 41 | _key = key; 42 | } 43 | 44 | private static string GetName(string key, string desc) 45 | { 46 | return key.Length > desc.Length + 1 ? key.Substring(desc.Length + 1) : ""; 47 | } 48 | 49 | public static KeyInfo Parse(string key) 50 | { 51 | string name; 52 | 53 | // Remove spaces, square-brackets, and double-quotes from the beginning and the end of the key. 54 | char[] removeChars = { ' ', '[', ']', '"', '\\' }; 55 | key = key.Trim(removeChars); 56 | 57 | // Remove whitespace surrounding the back slashes in the key. 58 | key = System.Text.RegularExpressions.Regex.Replace(key, @"[\s]*\\[\s]*", @"\"); 59 | 60 | // Get an uppercase version of the key to use for comparison purposes. 61 | string ukey = key.ToUpper(); 62 | 63 | KeyInfo ki; 64 | if (ukey.StartsWith(HKCR)) 65 | { 66 | name = GetName(key, HKCR); 67 | ki = new KeyInfo(HKCR, HKEY_CLASSES_ROOT, name, Registry.ClassesRoot); 68 | } 69 | else if (ukey.StartsWith(HKCU)) 70 | { 71 | name = GetName(key, HKCU); 72 | ki = new KeyInfo(HKCU, HKEY_CURRENT_USER, name, Registry.CurrentUser); 73 | } 74 | else if (ukey.StartsWith(HKLM)) 75 | { 76 | name = GetName(key, HKLM); 77 | ki = new KeyInfo(HKLM, HKEY_LOCAL_MACHINE, name, Registry.LocalMachine); 78 | } 79 | else if (ukey.StartsWith(HKU)) 80 | { 81 | name = GetName(key, HKU); 82 | ki = new KeyInfo(HKU, HKEY_USERS, name, Registry.Users); 83 | } 84 | else if (ukey.StartsWith(HKCC)) 85 | { 86 | name = GetName(key, HKCC); 87 | ki = new KeyInfo(HKCC, HKEY_CURRENT_CONFIG, name, Registry.CurrentConfig); 88 | } 89 | else if (ukey.StartsWith(HKEY_CLASSES_ROOT)) 90 | { 91 | name = GetName(key, HKEY_CLASSES_ROOT); 92 | ki = new KeyInfo(HKCR, HKEY_CLASSES_ROOT, name, Registry.ClassesRoot); 93 | } 94 | else if (ukey.StartsWith(HKEY_LOCAL_MACHINE)) 95 | { 96 | name = GetName(key, HKEY_LOCAL_MACHINE); 97 | ki = new KeyInfo(HKLM, HKEY_LOCAL_MACHINE, name, Registry.LocalMachine); 98 | } 99 | else if (ukey.StartsWith(HKEY_CURRENT_USER)) 100 | { 101 | name = GetName(key, HKEY_CURRENT_USER); 102 | ki = new KeyInfo(HKCU, HKEY_CURRENT_USER, name, Registry.CurrentUser); 103 | } 104 | else if (ukey.StartsWith(HKEY_USERS)) 105 | { 106 | name = GetName(key, HKEY_USERS); 107 | ki = new KeyInfo(HKU, HKEY_USERS, name, Registry.Users); 108 | } 109 | else if (ukey.StartsWith(HKEY_CURRENT_CONFIG)) 110 | { 111 | name = GetName(key, HKEY_CURRENT_CONFIG); 112 | ki = new KeyInfo(HKCC, HKEY_CURRENT_CONFIG, name, Registry.CurrentConfig); 113 | } 114 | else 115 | { 116 | throw new Exception("That is not a valid registry key!"); 117 | } 118 | 119 | string subName = ki.Name; 120 | 121 | while (true) 122 | { 123 | RegistryKey subKey = ki._key.OpenSubKey(subName); 124 | if (subKey != null) 125 | break; 126 | 127 | int tokenLength = subName.LastIndexOf(@"\", StringComparison.Ordinal); 128 | if (tokenLength == -1) 129 | { 130 | subName = String.Empty; 131 | break; 132 | } 133 | subName = subName.Substring(0, tokenLength); 134 | } 135 | 136 | ki.Name = subName; 137 | 138 | ki._key.Close(); 139 | 140 | return ki; 141 | } 142 | } 143 | } -------------------------------------------------------------------------------- /MyComputerManager/Helpers/Regedit/RegistryEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.Win32; 3 | 4 | namespace DevTools.RegistryJump 5 | { 6 | public static class RegistryEditor 7 | { 8 | private const string SAVE_LAST_KEY = @"Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\"; 9 | public static string CurrentKey { get; private set; } 10 | 11 | public static void OpenRegistryEditor(string key) 12 | { 13 | // Quit running instance of regedit. 14 | Process[] process = Process.GetProcessesByName("regedit"); 15 | if (process.Length == 1) 16 | process[0].Kill(); 17 | 18 | // Convert the string into its KeyInfo equivalent. 19 | KeyInfo keyInfo = KeyInfo.Parse(key); 20 | 21 | // Concatenate the key name to the key root value. 22 | CurrentKey = $@"{keyInfo.Hkey}\{keyInfo.Name}"; 23 | 24 | // Save the current key. 25 | using (RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(SAVE_LAST_KEY, true)) 26 | registrykey?.SetValue("Lastkey", keyInfo.GetFullname()); 27 | 28 | // Launch the registry editor. 29 | StartRegistryEditor(); 30 | } 31 | 32 | public static void StartRegistryEditor() 33 | { 34 | Process.Start("regedit.exe"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /MyComputerManager/Helpers/StringHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MyComputerManager.Helpers 8 | { 9 | public static class StringHelper 10 | { 11 | public static string BuildFilter(string ext) 12 | { 13 | var exts = ext.Split(','); 14 | var res = new List(); 15 | var all = new List(); 16 | foreach (var i in exts) 17 | { 18 | res.Add($"{i} File|*.{i}"); 19 | all.Add($"*.{i}"); 20 | } 21 | res.Insert(0, $"All Supported Files|{string.Join(";", all)}"); 22 | return string.Join("|", res); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MyComputerManager/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 30 | 31 | 32 | 37 | 43 | 49 | 55 | 61 | 62 | 66 | 67 | 68 | 70 | 73 | 74 | 78 | 79 | 80 | 81 | 86 | 87 | 91 | 92 | 93 | 96 | 100 | 101 | 102 | 103 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /MyComputerManager/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Helpers; 2 | using MyComputerManager.Models; 3 | using MyComputerManager.Services.Contracts; 4 | using MyComputerManager.ViewModels; 5 | using MyComputerManager.Views; 6 | using System; 7 | using System.Collections.ObjectModel; 8 | using System.Drawing; 9 | using System.IO; 10 | using System.Threading.Tasks; 11 | using System.Windows; 12 | using System.Windows.Controls; 13 | using Wpf.Ui.Appearance; 14 | using Wpf.Ui.Controls; 15 | using Wpf.Ui.Controls.Interfaces; 16 | using Wpf.Ui.Mvvm.Contracts; 17 | using IDialogService = MyComputerManager.Services.Contracts.IDialogService; 18 | 19 | namespace MyComputerManager 20 | { 21 | /// 22 | /// MainWindow.xaml 的交互逻辑 23 | /// 24 | public partial class MainWindow : INavigationWindow 25 | { 26 | private readonly IDataService _dataService; 27 | private readonly INavigationService _navigationService; 28 | private readonly IThemeService _themeService; 29 | private readonly ISnackBarService _snackBarService; 30 | private readonly IDialogService _dialogService; 31 | public MainWindow(INavigationService navigationService, IPageService pageService, IDataService dataService, IThemeService themeService, ISnackBarService snackBarService, IDialogService dialogService) 32 | { 33 | InitializeComponent(); 34 | //Wpf.Ui.Appearance.Background.Apply(this, Wpf.Ui.Appearance.BackgroundType.Mica); 35 | //var c = Accent.GetColorizationColor(); 36 | //System.Windows.MessageBox.Show(c.ToString()); 37 | SetPageService(pageService); 38 | navigationService.SetNavigationControl(RootNavigation); 39 | snackBarService.SetSnackbar(RootSnackbar); 40 | dialogService.SetDialog(RootDialog); 41 | _dataService = dataService; 42 | _navigationService = navigationService; 43 | _themeService = themeService; 44 | _snackBarService = snackBarService; 45 | _dialogService = dialogService; 46 | 47 | WelcomeGrid.Visibility = Visibility.Visible; 48 | } 49 | 50 | private void Window_Loaded(object sender, RoutedEventArgs e) 51 | { 52 | _themeService.SetTheme(ThemeType.Light); 53 | RootNavigation.Frame = RootFrame; 54 | RootNavigation.Items.Add(new NavigationItem() { PageType = typeof(MainPage), Cache = false}); 55 | RootNavigation.Items.Add(new NavigationItem() { PageType = typeof(DetailPage), Cache = false}); 56 | //RootNavigation.Navigate("mainpage"); 57 | //RootNavigation.SelectedPageIndex = 0; 58 | 59 | Task.Run(async () => 60 | { 61 | var data = NamespaceHelper.GetItems(); 62 | await Task.Delay(1000); 63 | 64 | await Dispatcher.InvokeAsync(() => 65 | { 66 | WelcomeGrid.Visibility = Visibility.Collapsed; 67 | RootMainGrid.Visibility = Visibility.Visible; 68 | 69 | var o = new ObservableCollection(); 70 | foreach (var item in data) 71 | o.Add(item); 72 | _dataService.SetData(o); 73 | var res = _navigationService.Navigate(typeof(MainPage)); 74 | //var res = _navigationService.Navigate(typeof(Input)); 75 | }); 76 | 77 | return true; 78 | }); 79 | } 80 | 81 | private void MenuBack_Click(object sender, RoutedEventArgs e) 82 | { 83 | _navigationService.Navigate(typeof(MainPage)); 84 | } 85 | 86 | private void MenuAdd_Click(object sender, RoutedEventArgs e) 87 | { 88 | var item = new NamespaceItem("新建项目"); 89 | _dataService.SetData(item); 90 | _navigationService.Navigate(typeof(DetailPage)); 91 | } 92 | 93 | public Frame GetFrame() 94 | { 95 | return RootFrame; 96 | } 97 | 98 | public INavigation GetNavigation() 99 | { 100 | return RootNavigation; 101 | } 102 | 103 | public bool Navigate(Type pageType) 104 | { 105 | return RootNavigation.Navigate(pageType); 106 | } 107 | 108 | public void SetPageService(IPageService pageService) 109 | { 110 | RootNavigation.PageService = pageService; 111 | } 112 | 113 | public void ShowWindow() 114 | { 115 | Show(); 116 | } 117 | 118 | public void CloseWindow() 119 | { 120 | Close(); 121 | } 122 | 123 | private void MenuTheme_Click(object sender, RoutedEventArgs e) 124 | { 125 | _themeService.SetTheme(_themeService.GetTheme() == ThemeType.Dark ? ThemeType.Light : ThemeType.Dark); 126 | } 127 | 128 | private void MenuInfo_Click(object sender, RoutedEventArgs e) 129 | { 130 | _navigationService.Navigate(typeof(AboutPage)); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /MyComputerManager/Models/AppConfig.cs: -------------------------------------------------------------------------------- 1 | namespace Wpf.Ui.Demo.Models 2 | { 3 | public class AppConfig 4 | { 5 | public string ConfigurationsFolder { get; set; } 6 | 7 | public string AppPropertiesFileName { get; set; } 8 | } 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /MyComputerManager/Models/CommonResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MyComputerManager.Models 8 | { 9 | public class CommonResult 10 | { 11 | public bool success; 12 | public string result; 13 | 14 | public CommonResult() { } 15 | public CommonResult(bool success, string result) 16 | { 17 | this.success = success; 18 | this.result = result; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MyComputerManager/Models/DialogMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MyComputerManager.Models 8 | { 9 | public class DialogMessage 10 | { 11 | public DialogMessage(string title, string message) 12 | { 13 | Title = title; 14 | Message = message; 15 | } 16 | 17 | public string Title { get; set; } 18 | public string Message { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MyComputerManager/Models/NamespaceItem.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Diagnostics; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Imaging; 11 | 12 | namespace MyComputerManager.Models 13 | { 14 | public class NamespaceItem : INotifyPropertyChanged 15 | { 16 | public NamespaceItem() 17 | { 18 | 19 | } 20 | public NamespaceItem(string name, string desc, string tip, string exePath, string iconPath, RegistryKey key, RegistryKey key1, bool disabled, string cLSID, ItemType type) 21 | { 22 | Name = name; 23 | Desc = desc; 24 | Tip = tip; 25 | ExePath = exePath; 26 | IconPath = iconPath; 27 | RegKey = key; 28 | RegKey1 = key1; 29 | isEnabled = !disabled; 30 | CLSID = cLSID; 31 | Type = type; 32 | } 33 | 34 | public NamespaceItem(string name) 35 | { 36 | Name = name; 37 | RegKey = Registry.CurrentUser; 38 | RegKey1 = Registry.CurrentUser; 39 | isEnabled = true; 40 | CLSID = null; 41 | Desc = ""; 42 | Tip = ""; 43 | ExePath = ""; 44 | IconPath = ""; 45 | Type = ItemType.MyComputer; 46 | } 47 | 48 | private string cLSID; 49 | public string CLSID 50 | { 51 | get { return cLSID; } 52 | set 53 | { 54 | cLSID = value; 55 | this.RaisePropertyChanged("CLSID"); 56 | } 57 | } 58 | 59 | private string name; 60 | public string Name 61 | { 62 | get { return name; } 63 | set 64 | { 65 | name = value; 66 | this.RaisePropertyChanged("Name"); 67 | } 68 | } 69 | 70 | private string desc; 71 | public string Desc 72 | { 73 | get { return desc; } 74 | set 75 | { 76 | desc = value; 77 | this.RaisePropertyChanged("Desc"); 78 | } 79 | } 80 | 81 | private string tip; 82 | public string Tip 83 | { 84 | get { return tip; } 85 | set 86 | { 87 | tip = value; 88 | this.RaisePropertyChanged("Tip"); 89 | } 90 | } 91 | 92 | private string exePath; 93 | public string ExePath 94 | { 95 | get { return exePath; } 96 | set 97 | { 98 | exePath = value; 99 | this.RaisePropertyChanged("ExePath"); 100 | } 101 | } 102 | 103 | private string iconPath; 104 | public string IconPath 105 | { 106 | get { return iconPath; } 107 | set 108 | { 109 | iconPath = value; 110 | this.RaisePropertyChanged("IconPath"); 111 | } 112 | } 113 | 114 | private ImageSource icon; 115 | public ImageSource Icon 116 | { 117 | get { return icon; } 118 | set 119 | { 120 | icon = value; 121 | this.RaisePropertyChanged("Icon"); 122 | } 123 | } 124 | 125 | private bool isEnabled; 126 | public bool IsEnabled 127 | { 128 | get { return isEnabled; } 129 | set { 130 | isEnabled = value; 131 | this.RaisePropertyChanged("IsEnabled"); 132 | //if (value) 133 | // SetEnable(); 134 | //else 135 | // SetDisable(); 136 | } 137 | } 138 | 139 | private ItemType type; 140 | public ItemType Type 141 | { 142 | get { return type; } 143 | set 144 | { 145 | type = value; 146 | this.RaisePropertyChanged("Type"); 147 | } 148 | } 149 | 150 | 151 | public RegistryKey RegKey { get; set; } 152 | public RegistryKey RegKey1 { get; set; } 153 | 154 | public string RegKey_Namespace 155 | { 156 | get { 157 | return RegKey.Name + @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\" + Type.ToString() + @"\" + (IsEnabled ? "NameSpace" : "NameSpaceDisabled") + @"\" + CLSID; 158 | } 159 | } 160 | 161 | public string RegKey_CLSID 162 | { 163 | get 164 | { 165 | return RegKey1.Name + (RegKey1.View == RegistryView.Default ? @"\SOFTWARE\Classes\CLSID\" : @"\SOFTWARE\Classes\WOW6432Node\CLSID\") + CLSID; 166 | } 167 | } 168 | 169 | public NamespaceItem Clone() 170 | { 171 | return new NamespaceItem() 172 | { 173 | CLSID = CLSID, 174 | Name = Name, 175 | Desc = Desc, 176 | Tip = Tip, 177 | IconPath = IconPath, 178 | RegKey = RegKey, 179 | RegKey1 = RegKey1, 180 | IsEnabled = IsEnabled, 181 | Icon = Icon, 182 | ExePath = ExePath, 183 | Type = Type 184 | }; 185 | } 186 | 187 | #region INotifyPropertyChanged members 188 | 189 | public event PropertyChangedEventHandler PropertyChanged; 190 | 191 | protected void RaisePropertyChanged(string propertyName) 192 | { 193 | PropertyChangedEventHandler handler = this.PropertyChanged; 194 | if (handler != null) 195 | { 196 | var e = new PropertyChangedEventArgs(propertyName); 197 | handler(this, e); 198 | } 199 | } 200 | 201 | #endregion 202 | 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /MyComputerManager/Models/NamespaceItemType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MyComputerManager.Models 8 | { 9 | public enum ItemType 10 | { 11 | MyComputer,//此电脑 12 | Desktop,//侧边栏 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MyComputerManager/Mvvm/AsyncCommandBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | using System.Windows.Input; 5 | 6 | namespace MyComputerManager.Mvvm 7 | { 8 | public abstract class AsyncCommandBase : ICommand 9 | { 10 | public event EventHandler CanExecuteChanged 11 | { 12 | add => CommandManager.RequerySuggested += value; 13 | remove => CommandManager.RequerySuggested -= value; 14 | } 15 | 16 | public abstract Task ExecuteAsync(); 17 | 18 | public abstract bool CanExecuteTask(); 19 | 20 | [DebuggerStepThrough] 21 | bool ICommand.CanExecute(object parameter) 22 | { 23 | return this.CanExecute(); 24 | } 25 | 26 | void ICommand.Execute(object parameter) 27 | { 28 | this.Execute(); 29 | } 30 | 31 | protected void RaiseCanExecuteChanged() 32 | { 33 | CommandManager.InvalidateRequerySuggested(); 34 | } 35 | 36 | protected bool CanExecute() 37 | { 38 | return this.CanExecuteTask(); 39 | } 40 | 41 | protected async void Execute() 42 | { 43 | if (this.CanExecuteTask() == false) 44 | { 45 | return; 46 | } 47 | 48 | this.RaiseCanExecuteChanged(); 49 | 50 | try 51 | { 52 | await this.ExecuteAsync(); 53 | } 54 | finally 55 | { 56 | this.RaiseCanExecuteChanged(); 57 | } 58 | } 59 | } 60 | 61 | public abstract class AsyncCommandBase : ICommand 62 | { 63 | public event EventHandler CanExecuteChanged 64 | { 65 | add 66 | { 67 | CommandManager.RequerySuggested += value; 68 | } 69 | 70 | remove 71 | { 72 | CommandManager.RequerySuggested -= value; 73 | } 74 | } 75 | 76 | public abstract Task ExecuteAsync(T parameter); 77 | 78 | public abstract bool CanExecuteTask(T parameter); 79 | 80 | bool ICommand.CanExecute(object parameter) 81 | { 82 | if (typeof(T).IsValueType && parameter == null) 83 | { 84 | return false; 85 | } 86 | 87 | return this.CanExecute((T)parameter); 88 | } 89 | 90 | void ICommand.Execute(object parameter) 91 | { 92 | if (typeof(T).IsValueType && parameter == null) 93 | { 94 | return; 95 | } 96 | 97 | this.Execute((T)parameter); 98 | } 99 | 100 | protected bool CanExecute(T parameter) 101 | { 102 | return this.CanExecuteTask(parameter); 103 | } 104 | 105 | protected async void Execute(T parameter) 106 | { 107 | if (this.CanExecuteTask(parameter) == false) 108 | { 109 | return; 110 | } 111 | 112 | this.RaiseCanExecuteChanged(); 113 | 114 | try 115 | { 116 | await this.ExecuteAsync(parameter); 117 | } 118 | finally 119 | { 120 | this.RaiseCanExecuteChanged(); 121 | } 122 | } 123 | 124 | protected void RaiseCanExecuteChanged() 125 | { 126 | CommandManager.InvalidateRequerySuggested(); 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /MyComputerManager/Mvvm/AsyncRelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using System.Windows.Input; 4 | 5 | namespace MyComputerManager.Mvvm 6 | { 7 | public class AsyncRelayCommand : AsyncCommandBase 8 | { 9 | private readonly Func execute; 10 | 11 | private readonly Func canExecute; 12 | 13 | public AsyncRelayCommand(Func execute) 14 | : this(execute, () => true) 15 | { 16 | } 17 | 18 | public AsyncRelayCommand(Func execute, Func canExecute) 19 | { 20 | if (execute == null) 21 | { 22 | throw new ArgumentNullException(nameof(execute)); 23 | } 24 | 25 | this.execute = execute; 26 | this.canExecute = canExecute; 27 | } 28 | 29 | public override Task ExecuteAsync() 30 | { 31 | return this.execute(); 32 | } 33 | 34 | public override bool CanExecuteTask() 35 | { 36 | return this.canExecute(); 37 | } 38 | } 39 | 40 | public class AsyncRelayCommand : AsyncCommandBase 41 | { 42 | private readonly Func execute; 43 | 44 | private readonly Predicate canExecute; 45 | 46 | public AsyncRelayCommand(Func execute) 47 | : this(execute, param => true) 48 | { 49 | } 50 | 51 | public AsyncRelayCommand(Func execute, Predicate canExecute) 52 | { 53 | if (execute == null) 54 | { 55 | throw new ArgumentNullException(nameof(execute)); 56 | } 57 | 58 | this.execute = execute; 59 | this.canExecute = canExecute; 60 | } 61 | 62 | public override Task ExecuteAsync(TParameter parameter) 63 | { 64 | return this.execute(parameter); 65 | } 66 | 67 | public override bool CanExecuteTask(TParameter parameter) 68 | { 69 | return this.canExecute(parameter); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /MyComputerManager/Mvvm/RoutedEventTrigger.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xaml.Behaviors; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace MyComputerManager 10 | { 11 | public class RoutedEventTrigger : EventTriggerBase 12 | { 13 | RoutedEvent _routedEvent; 14 | public RoutedEvent RoutedEvent 15 | { 16 | get { return _routedEvent; } 17 | set { _routedEvent = value; } 18 | } 19 | 20 | public RoutedEventTrigger() { } 21 | 22 | protected override void OnAttached() 23 | { 24 | if (RoutedEvent != null) 25 | { 26 | Source.AddHandler(RoutedEvent, new RoutedEventHandler(this.OnRoutedEvent)); 27 | } 28 | } 29 | 30 | void OnRoutedEvent(object sender, RoutedEventArgs args) 31 | { 32 | base.OnEvent(args); 33 | } 34 | protected override string GetEventName() 35 | { 36 | return RoutedEvent.Name; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MyComputerManager/MyComputerManager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B606F8CF-6AEC-4DEC-9A8F-A0AF2750E28E} 8 | WinExe 9 | MyComputerManager 10 | MyComputerManager 11 | v4.7.2 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | true 17 | 18 | 19 | publish\ 20 | true 21 | Disk 22 | false 23 | Foreground 24 | 7 25 | Days 26 | false 27 | false 28 | true 29 | 0 30 | 1.0.0.%2a 31 | false 32 | false 33 | true 34 | 35 | 36 | x86 37 | true 38 | full 39 | false 40 | bin\Debug\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | 45 | 46 | AnyCPU 47 | pdbonly 48 | true 49 | bin\Release\ 50 | TRACE 51 | prompt 52 | 4 53 | 54 | 55 | true 56 | bin\x64\Debug\ 57 | DEBUG;TRACE 58 | full 59 | x64 60 | 7.3 61 | prompt 62 | true 63 | 64 | 65 | bin\x64\Release\ 66 | TRACE 67 | true 68 | pdbonly 69 | x64 70 | 7.3 71 | prompt 72 | true 73 | 74 | 75 | 76 | Resources\openbox.ico 77 | 78 | 79 | true 80 | bin\x86\Debug\ 81 | DEBUG;TRACE 82 | full 83 | x86 84 | 10.0 85 | prompt 86 | true 87 | 88 | 89 | bin\x86\Release\ 90 | TRACE 91 | true 92 | pdbonly 93 | x86 94 | 10.0 95 | prompt 96 | true 97 | 98 | 99 | 100 | ..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll 101 | 102 | 103 | ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll 104 | 105 | 106 | ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll 107 | 108 | 109 | ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll 110 | 111 | 112 | ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll 113 | 114 | 115 | ..\packages\Microsoft.Extensions.Configuration.6.0.0\lib\net461\Microsoft.Extensions.Configuration.dll 116 | 117 | 118 | ..\packages\Microsoft.Extensions.Configuration.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll 119 | 120 | 121 | ..\packages\Microsoft.Extensions.Configuration.Binder.6.0.0\lib\net461\Microsoft.Extensions.Configuration.Binder.dll 122 | 123 | 124 | ..\packages\Microsoft.Extensions.Configuration.CommandLine.6.0.0\lib\net461\Microsoft.Extensions.Configuration.CommandLine.dll 125 | 126 | 127 | ..\packages\Microsoft.Extensions.Configuration.EnvironmentVariables.6.0.1\lib\net461\Microsoft.Extensions.Configuration.EnvironmentVariables.dll 128 | 129 | 130 | ..\packages\Microsoft.Extensions.Configuration.FileExtensions.6.0.0\lib\net461\Microsoft.Extensions.Configuration.FileExtensions.dll 131 | 132 | 133 | ..\packages\Microsoft.Extensions.Configuration.Json.6.0.0\lib\net461\Microsoft.Extensions.Configuration.Json.dll 134 | 135 | 136 | ..\packages\Microsoft.Extensions.Configuration.UserSecrets.6.0.1\lib\net461\Microsoft.Extensions.Configuration.UserSecrets.dll 137 | 138 | 139 | ..\packages\Microsoft.Extensions.DependencyInjection.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll 140 | 141 | 142 | ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll 143 | 144 | 145 | ..\packages\Microsoft.Extensions.FileProviders.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.FileProviders.Abstractions.dll 146 | 147 | 148 | ..\packages\Microsoft.Extensions.FileProviders.Physical.6.0.0\lib\net461\Microsoft.Extensions.FileProviders.Physical.dll 149 | 150 | 151 | ..\packages\Microsoft.Extensions.FileSystemGlobbing.6.0.0\lib\net461\Microsoft.Extensions.FileSystemGlobbing.dll 152 | 153 | 154 | ..\packages\Microsoft.Extensions.Hosting.6.0.1\lib\net461\Microsoft.Extensions.Hosting.dll 155 | 156 | 157 | ..\packages\Microsoft.Extensions.Hosting.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Hosting.Abstractions.dll 158 | 159 | 160 | ..\packages\Microsoft.Extensions.Logging.6.0.0\lib\net461\Microsoft.Extensions.Logging.dll 161 | 162 | 163 | ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll 164 | 165 | 166 | ..\packages\Microsoft.Extensions.Logging.Configuration.6.0.0\lib\net461\Microsoft.Extensions.Logging.Configuration.dll 167 | 168 | 169 | ..\packages\Microsoft.Extensions.Logging.Console.6.0.0\lib\net461\Microsoft.Extensions.Logging.Console.dll 170 | 171 | 172 | ..\packages\Microsoft.Extensions.Logging.Debug.6.0.0\lib\net461\Microsoft.Extensions.Logging.Debug.dll 173 | 174 | 175 | ..\packages\Microsoft.Extensions.Logging.EventLog.6.0.0\lib\net461\Microsoft.Extensions.Logging.EventLog.dll 176 | 177 | 178 | ..\packages\Microsoft.Extensions.Logging.EventSource.6.0.0\lib\net461\Microsoft.Extensions.Logging.EventSource.dll 179 | 180 | 181 | ..\packages\Microsoft.Extensions.Options.6.0.0\lib\net461\Microsoft.Extensions.Options.dll 182 | 183 | 184 | ..\packages\Microsoft.Extensions.Options.ConfigurationExtensions.6.0.0\lib\net461\Microsoft.Extensions.Options.ConfigurationExtensions.dll 185 | 186 | 187 | ..\packages\Microsoft.Extensions.Primitives.6.0.0\lib\net461\Microsoft.Extensions.Primitives.dll 188 | 189 | 190 | ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll 191 | 192 | 193 | 194 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll 195 | 196 | 197 | 198 | 199 | 200 | ..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll 201 | 202 | 203 | 204 | ..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll 205 | 206 | 207 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll 208 | True 209 | True 210 | 211 | 212 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll 213 | 214 | 215 | 216 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll 217 | 218 | 219 | ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll 220 | True 221 | True 222 | 223 | 224 | ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll 225 | 226 | 227 | ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll 228 | True 229 | True 230 | 231 | 232 | ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll 233 | True 234 | True 235 | 236 | 237 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll 238 | True 239 | True 240 | 241 | 242 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll 243 | True 244 | True 245 | 246 | 247 | ..\packages\System.Text.Encodings.Web.6.0.0\lib\net461\System.Text.Encodings.Web.dll 248 | 249 | 250 | ..\packages\System.Text.Json.6.0.0\lib\net461\System.Text.Json.dll 251 | 252 | 253 | ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll 254 | 255 | 256 | ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll 257 | 258 | 259 | ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 4.0 269 | 270 | 271 | 272 | 273 | 274 | ..\packages\WPF-UI.2.0.2\lib\net47\Wpf.Ui.dll 275 | 276 | 277 | 278 | 279 | MSBuild:Compile 280 | Designer 281 | 282 | 283 | 284 | RegBox.xaml 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | AboutPage.xaml 323 | 324 | 325 | DetailPage.xaml 326 | 327 | 328 | MainPage.xaml 329 | 330 | 331 | PathBox.xaml 332 | 333 | 334 | MSBuild:Compile 335 | Designer 336 | 337 | 338 | Designer 339 | MSBuild:Compile 340 | 341 | 342 | Designer 343 | MSBuild:Compile 344 | 345 | 346 | Designer 347 | MSBuild:Compile 348 | 349 | 350 | MSBuild:Compile 351 | Designer 352 | 353 | 354 | App.xaml 355 | Code 356 | 357 | 358 | MainWindow.xaml 359 | Code 360 | 361 | 362 | Designer 363 | MSBuild:Compile 364 | 365 | 366 | Designer 367 | MSBuild:Compile 368 | 369 | 370 | Designer 371 | MSBuild:Compile 372 | 373 | 374 | MSBuild:Compile 375 | Designer 376 | 377 | 378 | 379 | 380 | Code 381 | 382 | 383 | True 384 | True 385 | Resources.resx 386 | 387 | 388 | True 389 | Settings.settings 390 | True 391 | 392 | 393 | ResXFileCodeGenerator 394 | Resources.Designer.cs 395 | 396 | 397 | 398 | SettingsSingleFileGenerator 399 | Settings.Designer.cs 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | False 411 | Microsoft .NET Framework 4.7.2 %28x86 和 x64%29 412 | true 413 | 414 | 415 | False 416 | .NET Framework 3.5 SP1 417 | false 418 | 419 | 420 | 421 | 422 | 423 | 424 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 425 | 426 | 427 | 428 | 429 | 430 | -------------------------------------------------------------------------------- /MyComputerManager/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("MyComputerManager")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("MyComputerManager")] 15 | [assembly: AssemblyCopyright("Copyright © 2022")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // 将 ComVisible 设置为 false 会使此程序集中的类型 20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请设置 25 | //.csproj 文件中的 CultureYouAreCodingWith 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(未在页面中找到资源时使用, 37 | //或应用程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(未在页面中找到资源时使用, 40 | //、应用程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 52 | //通过使用 "*",如下所示: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /MyComputerManager/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本: 4.0.30319.42000 5 | // 6 | // 对此文件的更改可能导致不正确的行为,如果 7 | // 重新生成代码,则所做更改将丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MyComputerManager.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 强类型资源类,用于查找本地化字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 返回此类使用的缓存 ResourceManager 实例。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyComputerManager.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 重写当前线程的 CurrentUICulture 属性,对 56 | /// 使用此强类型资源类的所有资源查找执行重写。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /MyComputerManager/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /MyComputerManager/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MyComputerManager.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MyComputerManager/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /MyComputerManager/Resources/addimage.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MyComputerManager/Resources/copy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MyComputerManager/Resources/folder.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MyComputerManager/Resources/openbox.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/MyComputerManager/Resources/openbox.ico -------------------------------------------------------------------------------- /MyComputerManager/Resources/openbox.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MyComputerManager/Resources/reg.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MyComputerManager/Resources/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/MyComputerManager/Resources/title.png -------------------------------------------------------------------------------- /MyComputerManager/Resources/title.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/MyComputerManager/Resources/title.psd -------------------------------------------------------------------------------- /MyComputerManager/Services/ApplicationHostService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using Microsoft.Extensions.Hosting; 8 | using Wpf.Ui.Mvvm.Contracts; 9 | 10 | namespace Wpf.Ui.Demo.Services 11 | { 12 | /// 13 | /// Managed host of the application. 14 | /// 15 | public class ApplicationHostService : IHostedService 16 | { 17 | private readonly IServiceProvider _serviceProvider; 18 | private readonly INavigationService _navigationService; 19 | private readonly IPageService _pageService; 20 | private readonly IThemeService _themeService; 21 | 22 | private INavigationWindow _navigationWindow; 23 | 24 | public ApplicationHostService(IServiceProvider serviceProvider, INavigationService navigationService, 25 | IPageService pageService, IThemeService themeService) 26 | { 27 | // If you want, you can do something with these services at the beginning of loading the application. 28 | _serviceProvider = serviceProvider; 29 | _navigationService = navigationService; 30 | _pageService = pageService; 31 | _themeService = themeService; 32 | } 33 | 34 | /// 35 | /// Triggered when the application host is ready to start the service. 36 | /// 37 | /// Indicates that the start process has been aborted. 38 | public async Task StartAsync(CancellationToken cancellationToken) 39 | { 40 | PrepareNavigation(); 41 | 42 | await HandleActivationAsync(); 43 | } 44 | 45 | /// 46 | /// Triggered when the application host is performing a graceful shutdown. 47 | /// 48 | /// Indicates that the shutdown process should no longer be graceful. 49 | public async Task StopAsync(CancellationToken cancellationToken) 50 | { 51 | await Task.CompletedTask; 52 | } 53 | 54 | /// 55 | /// Creates main window during activation. 56 | /// 57 | private async Task HandleActivationAsync() 58 | { 59 | await Task.CompletedTask; 60 | 61 | if (!Application.Current.Windows.OfType().Any()) 62 | { 63 | _navigationWindow = _serviceProvider.GetService(typeof(INavigationWindow)) as INavigationWindow; 64 | _navigationWindow.ShowWindow(); 65 | 66 | // NOTICE: You can set this service directly in the window 67 | // _navigationWindow.SetPageService(_pageService); 68 | 69 | // NOTICE: In the case of this window, we navigate to the Dashboard after loading with Container.InitializeUi() 70 | // _navigationWindow.Navigate(typeof(Views.Pages.Dashboard)); 71 | } 72 | 73 | await Task.CompletedTask; 74 | } 75 | 76 | private void PrepareNavigation() 77 | { 78 | _navigationService.SetPageService(_pageService); 79 | } 80 | } 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /MyComputerManager/Services/Contracts/IDataService.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MyComputerManager.Services.Contracts 9 | { 10 | public interface IDataService 11 | { 12 | void SetData(object data); 13 | 14 | object GetData(); 15 | 16 | MainPageViewModel GetVM(); 17 | 18 | void SetVM(MainPageViewModel data); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /MyComputerManager/Services/Contracts/IDialogService.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using Wpf.Ui.Common; 9 | using Wpf.Ui.Controls; 10 | 11 | namespace MyComputerManager.Services.Contracts 12 | { 13 | public interface IDialogService 14 | { 15 | void SetDialog(Dialog dialog); 16 | 17 | Task ShowDialog(DialogMessage content, double? dialogHeight, ControlAppearance buttonLeftAppearance, string buttonLeftText, ControlAppearance buttonRightAppearance, string buttonRightText); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MyComputerManager/Services/Contracts/ISnackBarService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Wpf.Ui.Common; 7 | using Wpf.Ui.Controls; 8 | 9 | namespace MyComputerManager.Services.Contracts 10 | { 11 | public interface ISnackBarService 12 | { 13 | void SetSnackbar(Snackbar snackbar); 14 | 15 | void Show(string title, string message, SymbolRegular icon = SymbolRegular.Info20, ControlAppearance appearance = ControlAppearance.Secondary, int timeout = 5000, bool showclosebutton = true); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MyComputerManager/Services/DataService.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Services.Contracts; 2 | using MyComputerManager.ViewModels; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace MyComputerManager.Services 10 | { 11 | public class DataService : IDataService 12 | { 13 | private object _data; 14 | 15 | public object GetData() 16 | { 17 | return _data; 18 | } 19 | 20 | public void SetData(object data) 21 | { 22 | _data = data; 23 | } 24 | 25 | private MainPageViewModel vm; 26 | 27 | public MainPageViewModel GetVM() 28 | { 29 | return vm; 30 | } 31 | 32 | public void SetVM(MainPageViewModel data) 33 | { 34 | vm = data; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /MyComputerManager/Services/DialogService.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Models; 2 | using MyComputerManager.Services.Contracts; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using Wpf.Ui.Common; 10 | using Wpf.Ui.Controls; 11 | using Wpf.Ui.Controls.Interfaces; 12 | 13 | namespace MyComputerManager.Services 14 | { 15 | public class DialogService : IDialogService 16 | { 17 | private Dialog _dialog; 18 | private TaskCompletionSource source; 19 | private bool buttonresult; 20 | public void SetDialog(Dialog dialog) 21 | { 22 | _dialog = dialog; 23 | _dialog.Closed += _dialog_Closed; 24 | _dialog.ButtonLeftClick += _dialog_ButtonLeftClick; 25 | _dialog.ButtonRightClick += _dialog_ButtonRightClick; 26 | } 27 | 28 | private void _dialog_ButtonRightClick(object sender, RoutedEventArgs e) 29 | { 30 | buttonresult = true; 31 | _dialog.Hide(); 32 | } 33 | 34 | private void _dialog_ButtonLeftClick(object sender, RoutedEventArgs e) 35 | { 36 | buttonresult = false; 37 | _dialog.Hide(); 38 | } 39 | 40 | private void _dialog_Closed(Dialog sender, RoutedEventArgs e) 41 | { 42 | if (source != null) 43 | source.SetResult(buttonresult); 44 | } 45 | 46 | public async Task ShowDialog(DialogMessage content, double? dialogHeight, ControlAppearance buttonLeftAppearance, string buttonLeftText, ControlAppearance buttonRightAppearance, string buttonRightText) 47 | { 48 | var res = await App.Current.Dispatcher.Invoke(async () => { 49 | _dialog.DataContext = content; 50 | if (dialogHeight != null) _dialog.DialogHeight = dialogHeight.Value; 51 | _dialog.ButtonLeftAppearance = buttonLeftAppearance; 52 | _dialog.ButtonRightAppearance = buttonRightAppearance; 53 | _dialog.ButtonLeftName = buttonLeftText; 54 | _dialog.ButtonRightName = buttonRightText; 55 | return await _dialog.ShowAndWaitAsync(); 56 | }); 57 | source = new TaskCompletionSource(); 58 | source.Task.Wait(); 59 | return buttonresult; 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MyComputerManager/Services/PageService.cs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the MIT License. 2 | // If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. 3 | // Copyright (C) Leszek Pomianowski and WPF UI Contributors. 4 | // All Rights Reserved. 5 | 6 | using System; 7 | using System.Windows; 8 | using Wpf.Ui.Mvvm.Contracts; 9 | 10 | namespace Wpf.Ui.Demo.Services 11 | { 12 | /// 13 | /// Service that provides pages for navigation. 14 | /// 15 | public class PageService : IPageService 16 | { 17 | /// 18 | /// Service which provides the instances of pages. 19 | /// 20 | private readonly IServiceProvider _serviceProvider; 21 | 22 | /// 23 | /// Creates new instance and attaches the . 24 | /// 25 | public PageService(IServiceProvider serviceProvider) 26 | { 27 | _serviceProvider = serviceProvider; 28 | } 29 | 30 | /// 31 | public T GetPage() where T : class 32 | { 33 | if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T))) 34 | throw new InvalidOperationException("The page should be a WPF control."); 35 | 36 | return (T)_serviceProvider.GetService(typeof(T)); 37 | } 38 | 39 | /// 40 | public FrameworkElement GetPage(Type pageType) 41 | { 42 | if (!typeof(FrameworkElement).IsAssignableFrom(pageType)) 43 | throw new InvalidOperationException("The page should be a WPF control."); 44 | 45 | return _serviceProvider.GetService(pageType) as FrameworkElement; 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /MyComputerManager/Services/SnackBarService.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Services.Contracts; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Wpf.Ui.Common; 8 | using Wpf.Ui.Controls; 9 | 10 | namespace MyComputerManager.Services 11 | { 12 | public class SnackBarService : ISnackBarService 13 | { 14 | private Snackbar _snackbar; 15 | public void SetSnackbar(Snackbar snackbar) 16 | { 17 | _snackbar = snackbar; 18 | } 19 | 20 | public void Show(string title, string message, SymbolRegular icon = SymbolRegular.Info20, ControlAppearance appearance = ControlAppearance.Secondary, int timeout = 5000, bool showclosebutton = true) 21 | { 22 | _snackbar.Icon = icon; 23 | _snackbar.Appearance = appearance; 24 | _snackbar.Timeout = timeout; 25 | _snackbar.CloseButtonEnabled = showclosebutton; 26 | _snackbar.Show(title, message); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MyComputerManager/Styles/ItemListStyle.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 10 | 11 | 12 | 15 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 62 | 105 | 106 | -------------------------------------------------------------------------------- /MyComputerManager/Styles/MenuButtonStyle.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 8 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 48 | -------------------------------------------------------------------------------- /MyComputerManager/Styles/PathBoxStyle.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 75 | 76 | 91 | 92 | 188 | -------------------------------------------------------------------------------- /MyComputerManager/ViewModels/DetailPageViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using Microsoft.Win32; 3 | using MyComputerManager.Controls; 4 | using MyComputerManager.Helpers; 5 | using MyComputerManager.Models; 6 | using MyComputerManager.Mvvm; 7 | using MyComputerManager.Services.Contracts; 8 | using MyComputerManager.Views; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Diagnostics; 12 | using System.Drawing; 13 | using System.IO; 14 | using System.Linq; 15 | using System.Text; 16 | using System.Threading.Tasks; 17 | using System.Windows; 18 | using System.Windows.Input; 19 | using Wpf.Ui.Common; 20 | using Wpf.Ui.Mvvm.Contracts; 21 | using IDialogService = MyComputerManager.Services.Contracts.IDialogService; 22 | 23 | namespace MyComputerManager.ViewModels 24 | { 25 | public class DetailPageViewModel : ViewModelBase 26 | { 27 | private readonly INavigationService _navigationService; 28 | private readonly IDataService _dataService; 29 | private readonly ISnackBarService _snackBarService; 30 | private readonly IDialogService _dialogService; 31 | public DetailPageViewModel(INavigationService navigationService, IDataService dataService, ISnackBarService snackbarService, IDialogService dialogService) 32 | { 33 | _navigationService = navigationService; 34 | _dataService = dataService; 35 | _snackBarService = snackbarService; 36 | _dialogService = dialogService; 37 | OriItem = (NamespaceItem)_dataService.GetData(); 38 | if (OriItem.CLSID == null) 39 | { 40 | Item = OriItem; 41 | var guid = Guid.NewGuid().ToString().ToUpper(); 42 | Item.CLSID = "{" + guid + "}"; 43 | OriItem = null; 44 | } 45 | else 46 | { 47 | Item = OriItem.Clone(); 48 | } 49 | OkCommand = new RelayCommand(ButtonOk_Click); 50 | CancelCommand = new RelayCommand(ButtonCancel_Click); 51 | ApplyCommand = new RelayCommand(ButtonApply_Click); 52 | OpenIconCommand = new RelayCommand(ButtonOpenIcon_Click); 53 | CopyCommand = new RelayCommand(ButtonCopy_Click); 54 | CopyIconPathCommand = new RelayCommand(ButtonCopyIconPath_Click); 55 | ClearIconCommand = new RelayCommand(ButtonClearIcon_Click); 56 | DropCommand = new RelayCommand(ImageDrop); 57 | DeleteCommand = new AsyncRelayCommand(ButtonDelete_Click); 58 | ExportCommand = new AsyncRelayCommand(ButtonExport_Click); 59 | } 60 | 61 | private NamespaceItem OriItem; 62 | private NamespaceItem item; 63 | public NamespaceItem Item 64 | { 65 | get { return item; } 66 | set 67 | { 68 | item = value; 69 | this.RaisePropertyChanged("Item"); 70 | } 71 | } 72 | 73 | public RelayCommand OkCommand { get; set; } 74 | public RelayCommand CancelCommand { get; set; } 75 | public RelayCommand ApplyCommand { get; set; } 76 | 77 | public void ButtonOk_Click() 78 | { 79 | var res = SaveToOrigin(); 80 | if (res.success) 81 | _navigationService.Navigate(typeof(MainPage)); 82 | else 83 | { 84 | _snackBarService.Show("操作失败", res.result, SymbolRegular.ShieldError16); 85 | } 86 | } 87 | 88 | public void ButtonCancel_Click() 89 | { 90 | _navigationService.Navigate(typeof(MainPage)); 91 | } 92 | 93 | public void ButtonApply_Click() 94 | { 95 | var res = SaveToOrigin(); 96 | if (res.success) 97 | _snackBarService.Show("操作成功", Item.Name, SymbolRegular.CheckmarkCircle16); 98 | else 99 | { 100 | _snackBarService.Show("操作失败", res.result, SymbolRegular.ShieldError16); 101 | } 102 | } 103 | 104 | public CommonResult SaveToOrigin() 105 | { 106 | var res = NamespaceHelper.UpdateItem(Item); 107 | if (res.success) 108 | { 109 | if (OriItem != null) 110 | { 111 | OriItem.Desc = Item.Desc; 112 | OriItem.Tip = Item.Tip; 113 | OriItem.Name = Item.Name; 114 | OriItem.Icon = Item.Icon; 115 | OriItem.ExePath = Item.ExePath; 116 | OriItem.IconPath = Item.IconPath; 117 | } 118 | else 119 | { 120 | var vm = _dataService.GetVM(); 121 | OriItem = Item.Clone(); 122 | vm.AddItem(OriItem); 123 | } 124 | } 125 | return res; 126 | } 127 | 128 | public RelayCommand OpenIconCommand { get; set; } 129 | public RelayCommand CopyCommand { get; set; } 130 | public RelayCommand CopyIconPathCommand { get; set; } 131 | public RelayCommand ClearIconCommand { get; set; } 132 | public RelayCommand DropCommand { get; set; } 133 | public AsyncRelayCommand DeleteCommand { get; set; } 134 | public AsyncRelayCommand ExportCommand { get; set; } 135 | 136 | public void ButtonOpenIcon_Click() 137 | { 138 | OpenFileDialog d = new OpenFileDialog(); 139 | d.Filter = StringHelper.BuildFilter("exe,ico,dll"); 140 | if (d.ShowDialog() ?? false) 141 | Item.IconPath = d.FileName; 142 | 143 | Item.Icon = IconHelper.ReadIcon(Item.IconPath); 144 | if (Item.Icon == null) 145 | Item.IconPath = ""; 146 | } 147 | 148 | public void ButtonCopy_Click(object content) 149 | { 150 | System.Windows.Clipboard.SetText(content.ToString()); 151 | _snackBarService.Show("已复制到剪切板", content.ToString(), SymbolRegular.Info16, ControlAppearance.Secondary, 3000); 152 | } 153 | 154 | public void ButtonCopyIconPath_Click() 155 | { 156 | System.Windows.Clipboard.SetText(Item.IconPath); 157 | if (Item.IconPath != "") 158 | _snackBarService.Show("已复制到剪切板", Item.IconPath, SymbolRegular.Info16, ControlAppearance.Secondary, 3000); 159 | } 160 | 161 | public void ButtonClearIcon_Click() 162 | { 163 | Item.Icon = null; 164 | Item.IconPath = ""; 165 | } 166 | 167 | public void ImageDrop(object obj) 168 | { 169 | DragEventArgs e = (DragEventArgs)obj; 170 | var filelist = e.Data.GetData("FileDrop"); 171 | if (filelist == null) 172 | { 173 | _snackBarService.Show("不支持的操作", "拖放exe/ico/dll文件到此以打开图标", SymbolRegular.Info16, ControlAppearance.Secondary, 5000); 174 | return; 175 | } 176 | string filepath = ((string[])filelist).First(); 177 | FileInfo fileInfo = new FileInfo(filepath); 178 | 179 | if (!fileInfo.Exists) 180 | { 181 | _snackBarService.Show("操作失败", "文件不存在或无法访问", SymbolRegular.Info16, ControlAppearance.Secondary, 5000); 182 | return; 183 | } 184 | 185 | if (!new List() { ".exe", ".ico", ".dll" }.Contains(fileInfo.Extension.ToLower())) 186 | { 187 | _snackBarService.Show("不支持的文件类型", "拖放exe/ico/dll文件到此以打开图标", SymbolRegular.Info16, ControlAppearance.Secondary, 5000); 188 | return; 189 | } 190 | 191 | Item.IconPath = filepath; 192 | Item.Icon = IconHelper.ReadIcon(Item.IconPath); 193 | if (Item.Icon == null) 194 | Item.IconPath = ""; 195 | } 196 | 197 | public async Task ButtonDelete_Click() 198 | { 199 | if (OriItem == null) 200 | { 201 | _navigationService.Navigate(typeof(MainPage)); 202 | return; 203 | } 204 | var res1 = await Task.Run(() => 205 | { 206 | var res = _dialogService.ShowDialog(new DialogMessage("警告", $"此操作将删除项目\"{OriItem?.Name ?? "未命名项目"}\",且无法恢复!"), null, ControlAppearance.Danger, "确认删除", ControlAppearance.Transparent, "取消操作"); 207 | return res; 208 | }); 209 | if (!res1) 210 | { 211 | var res2 = NamespaceHelper.DeleteItem(Item); 212 | if (res2.success) 213 | { 214 | var vm = _dataService.GetVM(); 215 | vm.DeleteItem(OriItem); 216 | _navigationService.Navigate(typeof(MainPage)); 217 | if (OriItem?.Name != null) 218 | _snackBarService.Show("操作成功", $"已删除{OriItem?.Name}", SymbolRegular.Info16); 219 | } 220 | else 221 | { 222 | _snackBarService.Show("操作失败", res2.result, SymbolRegular.ShieldError16); 223 | item.IsEnabled = !item.IsEnabled; 224 | } 225 | } 226 | } 227 | 228 | public async Task ButtonExport_Click() 229 | { 230 | var dialog = new SaveFileDialog(); 231 | dialog.Filter = "registry file|*.reg"; 232 | if (dialog.ShowDialog() != true) 233 | return; 234 | var res1 = await Task.Run(() => 235 | { 236 | var filename1 = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); 237 | var filename2 = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); 238 | ProcessStartInfo psi1 = new ProcessStartInfo("regedit", $"-e {filename1} {Item.RegKey_CLSID}"); 239 | ProcessStartInfo psi2 = new ProcessStartInfo("regedit", $"-e {filename2} {Item.RegKey_Namespace}"); 240 | Process p1 = Process.Start(psi1); 241 | p1.WaitForExit(); 242 | Process p2 = Process.Start(psi2); 243 | p2.WaitForExit(); 244 | 245 | try 246 | { 247 | var text1 = File.ReadAllText(filename1); 248 | var text2 = File.ReadAllText(filename2); 249 | text2 = text2.Replace("Windows Registry Editor Version 5.00", ""); 250 | File.WriteAllText(dialog.FileName, text1 + text2, Encoding.Unicode); 251 | return 0; 252 | } 253 | catch(Exception ex) 254 | { 255 | return 1; 256 | } 257 | }); 258 | if (res1 == 0) 259 | { 260 | _snackBarService.Show("已导出到", dialog.FileName, SymbolRegular.Info16, ControlAppearance.Secondary, 3000); 261 | } 262 | else 263 | { 264 | _snackBarService.Show("操作失败", "原因未知", SymbolRegular.ShieldError16); 265 | } 266 | } 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /MyComputerManager/ViewModels/MainPageViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using MyComputerManager.Helpers; 3 | using MyComputerManager.Models; 4 | using MyComputerManager.Services.Contracts; 5 | using MyComputerManager.Views; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Collections.ObjectModel; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using Wpf.Ui.Appearance; 13 | using Wpf.Ui.Common; 14 | using Wpf.Ui.Mvvm.Contracts; 15 | 16 | namespace MyComputerManager.ViewModels 17 | { 18 | public class MainPageViewModel : ViewModelBase 19 | { 20 | private readonly INavigationService _navigationService; 21 | private readonly IDataService _dataService; 22 | private readonly ISnackBarService _snackBarService; 23 | public MainPageViewModel(INavigationService navigationService, IDataService dataService, ISnackBarService snackBarService) 24 | { 25 | _navigationService = navigationService; 26 | _dataService = dataService; 27 | _snackBarService = snackBarService; 28 | Items = (ObservableCollection)_dataService.GetData(); 29 | dataService.SetVM(this); 30 | GoDetailCommand = new RelayCommand(GoDetail); 31 | ToggleCommand = new RelayCommand(ToggleEnabled); 32 | } 33 | 34 | private ObservableCollection items; 35 | 36 | public ObservableCollection Items 37 | { 38 | get { return items; } 39 | set 40 | { 41 | items = value; 42 | this.RaisePropertyChanged("Items"); 43 | } 44 | } 45 | 46 | public void GoDetail(object item) 47 | { 48 | _dataService.SetData(item); 49 | _navigationService.Navigate(typeof(DetailPage)); 50 | //_navigationService.Navigate(typeof(Input)); 51 | } 52 | 53 | public RelayCommand GoDetailCommand { get; set; } 54 | public RelayCommand ToggleCommand { get; set; } 55 | 56 | public void ToggleEnabled(object obj) 57 | { 58 | NamespaceItem item = (NamespaceItem)obj; 59 | var res = NamespaceHelper.SetEnabled(item, item.IsEnabled); 60 | if (!res.success) 61 | { 62 | _snackBarService.Show("操作失败", res.result, SymbolRegular.ShieldError16); 63 | item.IsEnabled = !item.IsEnabled; 64 | } 65 | } 66 | 67 | public void DeleteItem(NamespaceItem item) 68 | { 69 | if (item != null) 70 | if (Items.Contains(item)) 71 | Items.Remove(item); 72 | } 73 | 74 | public void AddItem(NamespaceItem item) 75 | { 76 | Items.Add(item); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /MyComputerManager/Views/AboutPage.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 50 | 54 | 60 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /MyComputerManager/Views/AboutPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace MyComputerManager.Views 18 | { 19 | /// 20 | /// AboutPage.xaml 的交互逻辑 21 | /// 22 | public partial class AboutPage : Page 23 | { 24 | public AboutPage() 25 | { 26 | InitializeComponent(); 27 | } 28 | 29 | private void TextBlock_MouseUp(object sender, MouseButtonEventArgs e) 30 | { 31 | Process.Start("explorer", "https://github.com/1357310795/MyComputerManager"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MyComputerManager/Views/DetailPage.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 84 | 89 | 90 | 95 | 99 | 100 | 105 | 109 | 110 | 111 | 115 | 116 | 117 | 118 | 119 | 125 | 131 | 137 | 142 | 143 | 144 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /MyComputerManager/Views/DetailPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Extensions; 2 | using MyComputerManager.ViewModels; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Data; 11 | using System.Windows.Documents; 12 | using System.Windows.Input; 13 | using System.Windows.Media; 14 | using System.Windows.Media.Imaging; 15 | using System.Windows.Navigation; 16 | using System.Windows.Shapes; 17 | using Wpf.Ui.Controls; 18 | 19 | namespace MyComputerManager.Views 20 | { 21 | /// 22 | /// DetailPage.xaml 的交互逻辑 23 | /// 24 | public partial class DetailPage 25 | { 26 | public DetailPage(DetailPageViewModel vm) 27 | { 28 | InitializeComponent(); 29 | this.DataContext = vm; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /MyComputerManager/Views/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /MyComputerManager/Views/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using MyComputerManager.Helpers; 2 | using MyComputerManager.Models; 3 | using MyComputerManager.ViewModels; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Drawing; 7 | using System.IO; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using Wpf.Ui.Common; 13 | using Wpf.Ui.Mvvm.Contracts; 14 | 15 | namespace MyComputerManager.Views 16 | { 17 | /// 18 | /// MainPage.xaml 的交互逻辑 19 | /// 20 | public partial class MainPage : Page 21 | { 22 | public MainPage(MainPageViewModel vm) 23 | { 24 | InitializeComponent(); 25 | this.DataContext = vm; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MyComputerManager/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 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 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![title.png](https://s2.loli.net/2022/07/07/o9rWHAm6fiZS4pQ.png) 2 | 3 | ## 背景 4 | 国内流氓软件经常为了某些目的无所不用其极,竟然想到通过Shell Extension在“此电脑”里面塞快捷方式,用户无法轻易删除。除了在这些流氓软件本身的设置里取消这个快捷方式,还有没有更优雅的办法?百度给出的答案无一例外都是修改注册表,这对于电脑小白极不友好,又非常危险。万一误删了系统关键条目,麻烦可就大了。 5 | 6 | 于是,我萌生了开发这个小工具的念头。4天时间,查了大量资料,终于把这个写完了,又弥补了一片空白! 7 | 8 | ## 功能介绍 9 | ![intro-p1.png](https://s2.loli.net/2022/07/07/IULqP6W3crB4Vxk.png) 10 | ![intro-p3.png](https://s2.loli.net/2022/07/07/49FYxJUWj5l6Z8a.png) 11 | ![intro-p2.png](https://s2.loli.net/2022/07/07/mC9lh4SvHUIrD1W.png) 12 | 13 | ## 使用方法 14 | 在[Github Releases](https://github.com/1357310795/MyComputerManager/releases)下载最新版程序,双击直接运行 15 | 16 | ## 开发者相关 17 | 项目基于 .NET Framework 4.7.2 开发(为了兼容性就用老版本啦😓),又是一个极好的 WPF 学习材料。程序涉及到了: 18 | - 自定义控件(基于xaml/基于cs代码) 19 | - 重写控件样式 20 | - 数据绑定(绑定到其他控件/DataContext,设置RelativeSource) 21 | - Mvvm模式(PropertyChanged/Command,DataTemplate) 22 | - 附加事件+控件行为(Microsoft.Xaml.Behaviors库) 23 | - 异步方法 24 | - 依赖注入(Dependency Injection)模式 25 | - 页面导航 26 | 27 | ## 开源许可 28 | 本程序通过 GNU General Public License v3.0 许可在 [GitHub](https://github.com/1357310795/MyComputerManager) 开源,如果您觉得软件好用,请不要吝惜您的 Star 哦,这会对我有非常大的帮助! 29 | 30 | ## 致谢 31 | 感谢 @lepoco 的 [wpf-ui](https://github.com/lepoco/wpfui) 项目,Win11风格的控件来自于此。 32 | 33 | 感谢 @walterlv 和 @XIU2 [在 TileTool 下的讨论](https://github.com/XIU2/TileTool/pull/4),本程序部分 UI 设计参考了这里。 34 | -------------------------------------------------------------------------------- /ReadmeItems/intro-p1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/ReadmeItems/intro-p1.png -------------------------------------------------------------------------------- /ReadmeItems/intro-p1.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/ReadmeItems/intro-p1.psd -------------------------------------------------------------------------------- /ReadmeItems/intro-p2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/ReadmeItems/intro-p2.png -------------------------------------------------------------------------------- /ReadmeItems/intro-p2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/ReadmeItems/intro-p2.psd -------------------------------------------------------------------------------- /ReadmeItems/intro-p3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/ReadmeItems/intro-p3.png -------------------------------------------------------------------------------- /ReadmeItems/intro-p3.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/MyComputerManager/adc7e22c62733572fb9bad460453a7ff0e151533/ReadmeItems/intro-p3.psd -------------------------------------------------------------------------------- /Settings.XamlStyler: -------------------------------------------------------------------------------- 1 | { 2 | // ==========[属性格式化]========== 3 | "AttributesTolerance": 2, // 单行最大属性数,2[默认],如果元素属性数不大于此数就不会换行 4 | "KeepFirstAttributeOnSameLine": true, // 第一个属性是否与开始标记在同一行,false[默认] 5 | "MaxAttributeCharactersPerLine": 60, // 多个属性大于多少个字符就该换行,0[默认] 6 | "MaxAttributesPerLine": 2, // 大于几个属性就该换行,1[默认] 7 | // 无需换行的元素(比较短的),"RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter"[默认] 8 | "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter", 9 | "AttributeIndentation": 0, // 属性缩进空格字符数(-1不缩进;0[默认]缩进4个空格;其它个数则指定) 10 | "AttributeIndentationStyle": 1, // 属性缩进风格(0混合,视情况使用制表符和空格;1[默认]使用空格) 11 | "RemoveDesignTimeReferences": false, // 是否移除自动添加的控件和设计时参考内容,false[默认] 12 | // 13 | // ==========[属性排序]========== 14 | "EnableAttributeReordering": true, // 是否启用属性的自动排序,true[默认] 15 | "SeparateByGroups": true, // 是否应该按照属性的分组进行分隔,false[默认] 16 | /* 属性排序和分组规则 17 | */ 18 | "AttributeOrderingRuleGroups": [ 19 | "x:Class", 20 | "xmlns, xmlns:x", 21 | "xmlns:*", 22 | "x:Key, Key, x:Name, Name, x:Uid, Uid, Title", 23 | "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight,MaxLength", 24 | "HorizontalAlignment, VerticalAlignment", 25 | "TextWrapping, Margin, Padding", 26 | "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom", 27 | "Background, Foreground", 28 | "Content,Text,IsChecked", 29 | "Command,CommandParameter", 30 | "HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex", 31 | "*:*, *", 32 | "FontSize, FontFamily", 33 | "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint", 34 | "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText", 35 | "Storyboard.*, From, To, Duration" 36 | ], 37 | "FirstLineAttributes": "x:Name", // 应该在第一行的属性,例如Name、x:Name和x:Uid等等,None[默认] 38 | "OrderAttributesByName": false, // 是否按照属性名称进行排序 39 | // 40 | // ==========[元素格式化]========== 41 | "PutEndingBracketOnNewLine": false, // 结束括号是否独占一行,false[默认] 42 | "RemoveEndingTagOfEmptyElement": true, // 是否移除空元素的结束标签,true[默认] 43 | "SpaceBeforeClosingSlash": true, // 自闭合元素的末尾斜杠前是否要有空格,true[默认] 44 | "RootElementLineBreakRule": 0, // 是否将根元素的属性分成多行(0[默认]默认;1始终;2从不) 45 | // 46 | // ==========[元素排序]========== 47 | "ReorderVSM": 2, // 是否重新排序Visual State Manager(0未定义;1[默认]移到最后;2移到最前) 48 | "ReorderGridChildren": false, // 是否重新排序Grid的子元素,false[默认] 49 | "ReorderCanvasChildren": false, // 是否重新排序Canvas的子元素,false[默认] 50 | "ReorderSetters": 0, // 是否重新排序Setter(0[默认]不排序;1按属性名;2按目标名;3先按目标名再按属性名) 51 | // 52 | // ==========[标记扩展]========== 53 | "FormatMarkupExtension": true, // 是否格式化标记扩展的属性,true[默认] 54 | // 始终放在一行上的标记扩展,"x:Bind, Binding"[默认] 55 | "NoNewLineMarkupExtensions": "x:Bind, Binding", 56 | // 57 | // ==========[属性排序]========== 58 | "ThicknessSeparator": 2, // Thickness类型的属性应该用哪种分隔符(0不格式化;1空格;2[默认]逗号) 59 | // 被认定为Thickness的元素应该是哪些,"Margin, Padding, BorderThickness, ThumbnailClipMargin"[默认] 60 | "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin", 61 | // 62 | // ==========[杂项]========== 63 | "FormatOnSave": false, // 是否在保存时进行格式化,true[默认] 64 | "CommentPadding": 2, // 注释的间距应该是几个空格,2[默认] 65 | // 66 | // ==========[覆盖VS配置]========== 67 | "IndentSize": 4, // 缩进空格数,4[VS默认] 68 | "IndentWithTabs": false // 是否使用制表符进行缩进,false[VS默认] 69 | } --------------------------------------------------------------------------------