├── .gitignore ├── License ├── README.md └── src └── DivergenceMeter ├── DivergenceMeter.sln └── DivergenceMeter ├── .editorconfig ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── DivergenceMeter.csproj ├── Images ├── 0.png ├── 1.png ├── 10.png ├── 11.png ├── 12.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── 9.png └── favicon.ico ├── Models └── Settings.cs ├── ViewModels ├── MainWindowViewModel.cs └── SettingsWindowViewModel.cs ├── Views ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── SettingsWindow.xaml └── SettingsWindow.xaml.cs └── favicon.ico /.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 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Coverlet is a free, cross platform Code Coverage Tool 141 | coverage*[.json, .xml, .info] 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | 355 | ## 356 | ## Visual studio for Mac 357 | ## 358 | 359 | 360 | # globs 361 | Makefile.in 362 | *.userprefs 363 | *.usertasks 364 | config.make 365 | config.status 366 | aclocal.m4 367 | install-sh 368 | autom4te.cache/ 369 | *.tar.gz 370 | tarballs/ 371 | test-results/ 372 | 373 | # Mac bundle stuff 374 | *.dmg 375 | *.app 376 | 377 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 378 | # General 379 | .DS_Store 380 | .AppleDouble 381 | .LSOverride 382 | 383 | # Icon must end with two \r 384 | Icon 385 | 386 | 387 | # Thumbnails 388 | ._* 389 | 390 | # Files that might appear in the root of a volume 391 | .DocumentRevisions-V100 392 | .fseventsd 393 | .Spotlight-V100 394 | .TemporaryItems 395 | .Trashes 396 | .VolumeIcon.icns 397 | .com.apple.timemachine.donotpresent 398 | 399 | # Directories potentially created on remote AFP share 400 | .AppleDB 401 | .AppleDesktop 402 | Network Trash Folder 403 | Temporary Items 404 | .apdisk 405 | 406 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 407 | # Windows thumbnail cache files 408 | Thumbs.db 409 | ehthumbs.db 410 | ehthumbs_vista.db 411 | 412 | # Dump file 413 | *.stackdump 414 | 415 | # Folder config file 416 | [Dd]esktop.ini 417 | 418 | # Recycle Bin used on file shares 419 | $RECYCLE.BIN/ 420 | 421 | # Windows Installer files 422 | *.cab 423 | *.msi 424 | *.msix 425 | *.msm 426 | *.msp 427 | 428 | # Windows shortcuts 429 | *.lnk 430 | 431 | # JetBrains Rider 432 | .idea/ 433 | *.sln.iml 434 | 435 | ## 436 | ## Visual Studio Code 437 | ## 438 | .vscode/* 439 | !.vscode/settings.json 440 | !.vscode/tasks.json 441 | !.vscode/launch.json 442 | !.vscode/extensions.json 443 | -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 sanshiliuxiao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 命运石之门时钟挂件 2 | 3 | 使用 .NET 6、WPF 和 Prism 8 制作的桌面时钟挂件 4 | 5 | 6 | ### 实现功能 7 | - 辉光时钟 8 | - 世界线变动仪效果 9 | - 窗体置顶效果 10 | - 窗体拖拽 11 | - 窗体穿透效果 12 | - 任务栏隐藏 13 | - 系统托盘 14 | - 边缘吸附 15 | - 开机自启 16 | 17 | ### 食用 18 | 19 | #### 方式一 20 | 21 | * 下载源代码自行编译 22 | 23 | #### 方式二 24 | 25 | * 前往 [DivergenceMeter](https://github.com/sanshiliuxiao/DivergenceMeter/releases) 下载 exe 文件 26 | 27 | 28 | * 如果电脑上不存在 .NET 6 环境,需要前往微软官网下载。 [Download .NET6](https://dotnet.microsoft.com/download) 29 | 30 | ## 文档 31 | 32 | [[WPF] 命运石之门效果时钟](https://www.yuque.com/zxlt/yg65uh) 33 | 34 | ## 视频 35 | 36 | [命运石之门效果时钟初学教程](https://www.bilibili.com/video/bv1qy4y1n7xE) 37 | 38 | 39 | ### 补充说明 40 | 41 | 欢迎 PR,欢迎 Issues。 42 | 43 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DivergenceMeter", "DivergenceMeter\DivergenceMeter.csproj", "{7C593A0B-681E-4259-8321-2A0D41D535F5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7C593A0B-681E-4259-8321-2A0D41D535F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7C593A0B-681E-4259-8321-2A0D41D535F5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7C593A0B-681E-4259-8321-2A0D41D535F5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7C593A0B-681E-4259-8321-2A0D41D535F5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {21B059B5-59E5-42FD-832E-9BEE3BFE0D0C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/.editorconfig: -------------------------------------------------------------------------------- 1 | # 若要了解有关 .editorconfig 的详细信息,请参阅 https://aka.ms/editorconfigdocs 2 | ############################### 3 | # Core EditorConfig Options # 4 | ############################### 5 | root = true 6 | # All files 7 | [*] 8 | indent_style = space 9 | # Code files 10 | [*.{cs,csx,vb,vbx}] 11 | indent_size = 4 12 | insert_final_newline = true 13 | charset = utf-8 14 | ############################### 15 | # .NET Coding Conventions # 16 | ############################### 17 | [*.{cs,vb}] 18 | # Organize usings 19 | dotnet_sort_system_directives_first = true 20 | # this. preferences 21 | dotnet_style_qualification_for_field = false:silent 22 | dotnet_style_qualification_for_property = false:silent 23 | dotnet_style_qualification_for_method = false:silent 24 | dotnet_style_qualification_for_event = false:silent 25 | # Language keywords vs BCL types preferences 26 | dotnet_style_predefined_type_for_locals_parameters_members = true:silent 27 | dotnet_style_predefined_type_for_member_access = true:silent 28 | # Parentheses preferences 29 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent 30 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent 31 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent 32 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent 33 | # Modifier preferences 34 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent 35 | dotnet_style_readonly_field = true:suggestion 36 | # Expression-level preferences 37 | dotnet_style_object_initializer = true:suggestion 38 | dotnet_style_collection_initializer = true:suggestion 39 | dotnet_style_explicit_tuple_names = true:suggestion 40 | dotnet_style_null_propagation = true:suggestion 41 | dotnet_style_coalesce_expression = true:suggestion 42 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent 43 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 44 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion 45 | dotnet_style_prefer_auto_properties = true:silent 46 | dotnet_style_prefer_conditional_expression_over_assignment = true:silent 47 | dotnet_style_prefer_conditional_expression_over_return = true:silent 48 | ############################### 49 | # Naming Conventions # 50 | ############################### 51 | # Style Definitions 52 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case 53 | # Use PascalCase for constant fields 54 | dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion 55 | dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields 56 | dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style 57 | dotnet_naming_symbols.constant_fields.applicable_kinds = field 58 | dotnet_naming_symbols.constant_fields.applicable_accessibilities = * 59 | dotnet_naming_symbols.constant_fields.required_modifiers = const 60 | ############################### 61 | # C# Coding Conventions # 62 | ############################### 63 | [*.cs] 64 | # var preferences 65 | csharp_style_var_for_built_in_types = true:silent 66 | csharp_style_var_when_type_is_apparent = true:silent 67 | csharp_style_var_elsewhere = true:silent 68 | # Expression-bodied members 69 | csharp_style_expression_bodied_methods = false:silent 70 | csharp_style_expression_bodied_constructors = false:silent 71 | csharp_style_expression_bodied_operators = false:silent 72 | csharp_style_expression_bodied_properties = true:silent 73 | csharp_style_expression_bodied_indexers = true:silent 74 | csharp_style_expression_bodied_accessors = true:silent 75 | # Pattern matching preferences 76 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 77 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 78 | # Null-checking preferences 79 | csharp_style_throw_expression = true:suggestion 80 | csharp_style_conditional_delegate_call = true:suggestion 81 | # Modifier preferences 82 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion 83 | # Expression-level preferences 84 | csharp_prefer_braces = true:silent 85 | csharp_style_deconstructed_variable_declaration = true:suggestion 86 | csharp_prefer_simple_default_expression = true:suggestion 87 | csharp_style_pattern_local_over_anonymous_function = true:suggestion 88 | csharp_style_inlined_variable_declaration = true:suggestion 89 | ############################### 90 | # C# Formatting Rules # 91 | ############################### 92 | # New line preferences 93 | csharp_new_line_before_open_brace = all 94 | csharp_new_line_before_else = true 95 | csharp_new_line_before_catch = true 96 | csharp_new_line_before_finally = true 97 | csharp_new_line_before_members_in_object_initializers = true 98 | csharp_new_line_before_members_in_anonymous_types = true 99 | csharp_new_line_between_query_expression_clauses = true 100 | # Indentation preferences 101 | csharp_indent_case_contents = true 102 | csharp_indent_switch_labels = true 103 | csharp_indent_labels = flush_left 104 | # Space preferences 105 | csharp_space_after_cast = false 106 | csharp_space_after_keywords_in_control_flow_statements = true 107 | csharp_space_between_method_call_parameter_list_parentheses = false 108 | csharp_space_between_method_declaration_parameter_list_parentheses = false 109 | csharp_space_between_parentheses = false 110 | csharp_space_before_colon_in_inheritance_clause = true 111 | csharp_space_after_colon_in_inheritance_clause = true 112 | csharp_space_around_binary_operators = before_and_after 113 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 114 | csharp_space_between_method_call_name_and_opening_parenthesis = false 115 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 116 | # Wrapping preferences 117 | csharp_preserve_single_line_statements = true 118 | csharp_preserve_single_line_blocks = true 119 | ############################### 120 | # VB Coding Conventions # 121 | ############################### 122 | [*.vb] 123 | # Modifier preferences 124 | visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion 125 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using DivergenceMeter.Models; 2 | using DivergenceMeter.Views; 3 | using Prism.Ioc; 4 | using Prism.Unity; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Configuration; 8 | using System.Data; 9 | using System.Linq; 10 | using System.Threading.Tasks; 11 | using System.Windows; 12 | 13 | namespace DivergenceMeter 14 | { 15 | /// 16 | /// Interaction logic for App.xaml 17 | /// 18 | public partial class App : PrismApplication 19 | { 20 | protected override Window CreateShell() 21 | { 22 | // 在 .NET 4.5 以上, TextBox 无法输入 浮动数 需要做如下修改 23 | FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false; 24 | var w = Container.Resolve(); 25 | return w; 26 | } 27 | 28 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 29 | { 30 | // 全局单例注入 31 | // 把 设置 和 prism 都注入进去 32 | // 稍微改造一些 各种的 Viemodel 33 | containerRegistry.RegisterSingleton(() => SettingsFactory()); 34 | containerRegistry.RegisterSingleton(() => this); 35 | 36 | 37 | 38 | } 39 | 40 | private Settings SettingsFactory() 41 | { 42 | var path = $@"{AppDomain.CurrentDomain.BaseDirectory}Settings.json"; 43 | var settings = Settings.LoadSettings(path); 44 | 45 | if (settings != null) 46 | { 47 | return settings; 48 | } 49 | settings = new Settings(); 50 | 51 | var width = settings.Width; 52 | var height = settings.Height; 53 | 54 | var workAreaWidth = SystemParameters.WorkArea.Width; 55 | var workAreaHeight = SystemParameters.WorkArea.Height; 56 | settings.Left = workAreaWidth / 2 - width / 2; 57 | settings.Top = workAreaHeight / 2 - height / 2; 58 | 59 | Settings.SaveSettings(path, settings); 60 | 61 | return settings; 62 | 63 | 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/DivergenceMeter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | true 7 | favicon.ico 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 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/0.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/1.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/10.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/11.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/12.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/2.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/3.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/4.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/5.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/6.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/7.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/8.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/9.png -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/Images/favicon.ico -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Models/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Text.Json; 7 | using System.Threading.Tasks; 8 | using Prism.Mvvm; 9 | 10 | namespace DivergenceMeter.Models 11 | { 12 | public class Settings: BindableBase 13 | { 14 | // 优化 Settings 类 15 | private double _radio = 8.0 / 3; 16 | private bool _canLockRadio; 17 | public bool CanLockRadio 18 | { 19 | get => _canLockRadio; 20 | set => SetProperty(ref _canLockRadio, value); 21 | } 22 | private double _left; 23 | public double Left 24 | { 25 | get => _left; 26 | set => SetProperty(ref _left, value); 27 | } 28 | private double _top; 29 | public double Top 30 | { 31 | get => _top; 32 | set => SetProperty(ref _top, value); 33 | } 34 | 35 | private bool _ifWidthChanged; 36 | private double _width; 37 | public double Width 38 | { 39 | get => _width; 40 | set 41 | { 42 | _ifWidthChanged = true; 43 | SetProperty(ref _width, value); 44 | OnWidthChanged(value); 45 | _ifWidthChanged = false; 46 | } 47 | } 48 | private bool _ifHeightChanged; 49 | private double _height; 50 | public double Height 51 | { 52 | get => _height; 53 | set 54 | { 55 | _ifHeightChanged = true; 56 | SetProperty(ref _height, value); 57 | OnHeightChanged(value); 58 | _ifHeightChanged = false; 59 | } 60 | } 61 | 62 | private double _opacity; 63 | public double Opacity 64 | { 65 | get => _opacity; 66 | set 67 | { 68 | if (value < 0) 69 | { 70 | SetProperty(ref _opacity, 0); 71 | } 72 | else if (value > 1) 73 | { 74 | SetProperty(ref _opacity, 1); 75 | } 76 | else 77 | { 78 | SetProperty(ref _opacity, value); 79 | } 80 | } 81 | } 82 | private bool _canTopmost; 83 | public bool CanTopmost 84 | { 85 | get => _canTopmost; 86 | set => SetProperty(ref _canTopmost, value); 87 | } 88 | // 无需与 xmal 元素关联 89 | public bool CanDragMove { get; set; } 90 | public bool CanAttachEdge { get; set; } 91 | // CanClickThrough 需要一个事件 92 | public event Action CanClickThroughChangedEvent; 93 | private bool _canClickThrough; 94 | public bool CanClickThrough 95 | { 96 | get => _canClickThrough; 97 | set 98 | { 99 | SetProperty(ref _canClickThrough, value); 100 | CanClickThroughChangedEvent?.Invoke(value); 101 | } 102 | } 103 | public event Action CanStartupChangedEvent; 104 | private bool _canStartup; 105 | public bool CanStartup 106 | { 107 | get => _canStartup; 108 | set 109 | { 110 | SetProperty(ref _canStartup, value); 111 | CanStartupChangedEvent?.Invoke(value); 112 | } 113 | } 114 | 115 | public Settings() 116 | { 117 | // 八张图片,一张图片宽高比为 1:3,最终为 8:3 118 | CanLockRadio = true; 119 | Width = 288; 120 | Opacity = 1; 121 | CanDragMove = true; 122 | CanTopmost = true; 123 | CanAttachEdge = true; 124 | } 125 | 126 | private void OnWidthChanged(double width) 127 | { 128 | // 进行检测, 使用 _ifWidthChanged 和 _ifHeightChanged 来阻止循环变化 129 | 130 | if (CanLockRadio && !_ifHeightChanged) 131 | { 132 | Height = width / _radio; 133 | } 134 | } 135 | private void OnHeightChanged(double height) 136 | { 137 | if (CanLockRadio && !_ifWidthChanged) 138 | { 139 | Width = Height * _radio; 140 | } 141 | } 142 | 143 | public static bool SaveSettings(string path, Settings settings) 144 | { 145 | try 146 | { 147 | var options = new JsonSerializerOptions 148 | { 149 | WriteIndented = true 150 | }; 151 | 152 | var json = JsonSerializer.Serialize(settings, options); 153 | File.WriteAllText(path, json); 154 | 155 | return true; 156 | } 157 | catch(Exception e) 158 | { 159 | return false; 160 | } 161 | } 162 | 163 | public static Settings LoadSettings(string path) 164 | { 165 | if (!File.Exists(path)) 166 | { 167 | return null; 168 | } 169 | 170 | try 171 | { 172 | var jsonString = File.ReadAllText(path); 173 | 174 | var options = new JsonSerializerOptions 175 | { 176 | AllowTrailingCommas = true, 177 | ReadCommentHandling = JsonCommentHandling.Skip 178 | }; 179 | var settings = JsonSerializer.Deserialize(jsonString, options); 180 | return settings; 181 | 182 | } 183 | catch (Exception e) 184 | { 185 | return null; 186 | } 187 | 188 | } 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Timers; 8 | using System.Windows; 9 | using System.Windows.Input; 10 | using System.Windows.Media.Imaging; 11 | using DivergenceMeter.Models; 12 | using Prism.Commands; 13 | using Prism.Mvvm; 14 | using PInvoke; 15 | using Prism.Unity; 16 | using DivergenceMeter.Views; 17 | using System.Diagnostics; 18 | using System.IO; 19 | 20 | namespace DivergenceMeter.ViewModels 21 | { 22 | public class MainWindowViewModel: BindableBase 23 | { 24 | private PrismApplication _app; 25 | // 加载所有图片 26 | private BitmapImage[] _allImages = new BitmapImage[13]; 27 | private Window _mainWindow = Application.Current.MainWindow; 28 | private IntPtr _mainWindowHandle = IntPtr.Zero; 29 | // Settings 30 | private Settings _settings; 31 | public Settings Settings 32 | { 33 | get => _settings; 34 | set => SetProperty(ref _settings, value); 35 | } 36 | // 动态时钟 37 | // 与 xaml 关联的图片 38 | public ObservableCollection ClockImages { get; set; } = new ObservableCollection(); 39 | private int[] _clockImagesIndex = new int[8]; 40 | private Timer _clockTimer; 41 | private Timer _worldLineTimer; 42 | private int _maxWorldLineChangedCount = 50; 43 | private int _currentWorldLineChangedCount; 44 | // DelegateCommand 45 | public DelegateCommand DragMoveCommand { get; set; } 46 | public DelegateCommand OpenSettingsWindowCommand { get; set; } 47 | public DelegateCommand ExitTheAppCommand { get; set; } 48 | public MainWindowViewModel(PrismApplication app, Settings settings) 49 | { 50 | _app = app; 51 | Settings = settings; 52 | 53 | Settings.CanClickThroughChangedEvent += SetTheClickThrough; 54 | Settings.CanStartupChangedEvent += SetStartup; 55 | 56 | IninialClockImages(); 57 | 58 | DragMoveCommand = new DelegateCommand(DragMove); 59 | OpenSettingsWindowCommand = new DelegateCommand(OpenSettingsWindow); 60 | ExitTheAppCommand = new DelegateCommand(ExitTheApp); 61 | 62 | var task = new Action(async () => 63 | { 64 | // 时钟效果 65 | InitialClockTimer(); 66 | 67 | // 世界线效果 68 | InitialWorldLineTimer(); 69 | 70 | StartWorldLineTimer(); 71 | await Task.Delay(1000); 72 | StartClockTimer(); 73 | }); 74 | task.Invoke(); 75 | 76 | // 窗体穿透效果 会 阻止 双击 和 窗体拖拽 77 | 78 | // 需要借助 User32.dll 需要获取 Window Handle 79 | 80 | } 81 | 82 | public void SetStartup() 83 | { 84 | SetStartup(Settings.CanStartup); 85 | } 86 | private void SetStartup(bool canStartup) 87 | { 88 | string startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); 89 | var appPath = Process.GetCurrentProcess().MainModule.FileName; 90 | var workPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; 91 | 92 | var shortcutName = System.IO.Path.GetFileNameWithoutExtension(appPath); 93 | 94 | var linkPath = $@"{startupPath}\{shortcutName}.lnk"; 95 | 96 | if (canStartup) 97 | { 98 | if (!File.Exists(linkPath)) 99 | { 100 | var shellType = Type.GetTypeFromProgID("WScript.shell"); 101 | dynamic shell = Activator.CreateInstance(shellType); 102 | var shortcut = shell.CreateShortcut(linkPath); 103 | shortcut.TargetPath = appPath; 104 | shortcut.WorkingDirectory = workPath; 105 | shortcut.Save(); 106 | 107 | } 108 | } 109 | 110 | else 111 | { 112 | if (File.Exists(linkPath)) 113 | { 114 | File.Delete(linkPath); 115 | } 116 | } 117 | 118 | } 119 | 120 | 121 | private void ExitTheApp() 122 | { 123 | var path = $@"{AppDomain.CurrentDomain.BaseDirectory}Settings.json"; 124 | Settings.SaveSettings(path, this.Settings); 125 | Application.Current.Shutdown(); 126 | } 127 | 128 | private void OpenSettingsWindow() 129 | { 130 | // 开启设置窗口 131 | // 这里可以选择直接创建窗体,绑定 ViewModel, 也能够交由 Prism 托管 132 | 133 | // 选择使用 Prism 134 | 135 | var sw = (SettingsWindow)_app.Container.Resolve(typeof(SettingsWindow)); 136 | // 应该是 Show 137 | sw.Show(); 138 | } 139 | 140 | public void SetTheClickThrough(IntPtr handle) 141 | { 142 | if (handle == IntPtr.Zero) return; 143 | _mainWindowHandle = handle; 144 | SetTheClickThrough(Settings.CanClickThrough); 145 | 146 | } 147 | private void SetTheClickThrough(bool canClickThrough) 148 | { 149 | if (_mainWindowHandle == IntPtr.Zero) return; 150 | // 函数重载 151 | if (canClickThrough) 152 | { 153 | // 设置穿透效果 154 | User32.SetWindowLong(_mainWindowHandle, User32.WindowLongIndexFlags.GWL_EXSTYLE, User32.SetWindowLongFlags.WS_EX_TRANSPARENT); 155 | } 156 | else 157 | { 158 | // 回复到正常效果 159 | User32.SetWindowLong(_mainWindowHandle, User32.WindowLongIndexFlags.GWL_EXSTYLE, User32.SetWindowLongFlags.WS_EX_LAYERED); 160 | } 161 | } 162 | #region 163 | private void StartWorldLineTimer() 164 | { 165 | _worldLineTimer?.Start(); 166 | } 167 | private void StopWorldLineTimer() 168 | { 169 | _worldLineTimer?.Stop(); 170 | } 171 | private void TheWorldLine(object sender, ElapsedEventArgs e) 172 | { 173 | if (_currentWorldLineChangedCount > _maxWorldLineChangedCount && (_clockImagesIndex[0] == 0 || _clockImagesIndex[0] == 1)) 174 | { 175 | // stop and reset 176 | StopWorldLineTimer(); 177 | _currentWorldLineChangedCount = 0; 178 | return; 179 | 180 | } 181 | 182 | _currentWorldLineChangedCount++; 183 | Random rd = new Random(); 184 | _clockImagesIndex[0] = rd.Next(0, 9); 185 | _clockImagesIndex[1] = 11; // 不变 186 | _clockImagesIndex[2] = rd.Next(0, 9); 187 | _clockImagesIndex[3] = rd.Next(0, 9); 188 | _clockImagesIndex[4] = rd.Next(0, 9); 189 | _clockImagesIndex[5] = rd.Next(0, 9); 190 | _clockImagesIndex[6] = rd.Next(0, 9); 191 | _clockImagesIndex[7] = rd.Next(0, 9); 192 | 193 | for(var i=0; i<_clockImagesIndex.Length; ++i) 194 | { 195 | ClockImages[i] = _allImages[_clockImagesIndex[i]]; 196 | } 197 | } 198 | 199 | private void InitialWorldLineTimer() 200 | { 201 | 202 | _worldLineTimer = new Timer(); 203 | _worldLineTimer.Interval = 20; 204 | _worldLineTimer.Elapsed += TheWorldLine; 205 | } 206 | #endregion 207 | 208 | #region 动态时钟 209 | private void InitialClockTimer() 210 | { 211 | _clockTimer = new Timer();// System.Timers 212 | _clockTimer.Interval = 100; // 毫秒 213 | _clockTimer.Elapsed += TheClock; 214 | } 215 | private void StartClockTimer() 216 | { 217 | _clockTimer?.Start(); 218 | 219 | } 220 | private void StopClockTimer() 221 | { 222 | _clockTimer?.Stop(); 223 | } 224 | 225 | private void TheClock(object sender, ElapsedEventArgs e) 226 | { 227 | var nowTime = DateTime.Now; 228 | var hour = nowTime.Hour; 229 | var min = nowTime.Minute; 230 | var sec = nowTime.Second; 231 | var millis = nowTime.Millisecond; 232 | 233 | _clockImagesIndex[0] = hour < 10 ? 0 : hour / 10; 234 | _clockImagesIndex[1] = hour < 10 ? hour : hour % 10; 235 | _clockImagesIndex[2] = millis < 500 ? 11 : 12; 236 | _clockImagesIndex[3] = min < 10 ? 0 : min / 10; 237 | _clockImagesIndex[4] = min < 10 ? min : min % 10; 238 | _clockImagesIndex[5] = millis < 500 ? 11 : 12; 239 | _clockImagesIndex[6] = sec < 10 ? 0 : sec / 10; 240 | _clockImagesIndex[7] = sec < 10 ? sec : sec % 10; 241 | 242 | for (var i=0; i<_clockImagesIndex.Length; ++i) 243 | { 244 | ClockImages[i] = _allImages[_clockImagesIndex[i]]; 245 | } 246 | } 247 | #endregion 248 | private void IninialClockImages() 249 | { 250 | _allImages = LoadAllImage(); 251 | var clockImages = new BitmapImage[8]; 252 | for(int i=0; i<_clockImagesIndex.Length; ++i) 253 | { 254 | _clockImagesIndex[i] = 0; 255 | clockImages[i] = _allImages[_clockImagesIndex[i]]; 256 | } 257 | ClockImages.AddRange(clockImages); 258 | } 259 | 260 | private async void DragMove(object obj) 261 | { 262 | var e = obj as MouseButtonEventArgs; 263 | if (e != null && e.LeftButton == MouseButtonState.Pressed && Settings.CanDragMove) 264 | { 265 | _mainWindow.DragMove(); 266 | 267 | if (Settings.CanAttachEdge) 268 | { 269 | var workArea = SystemParameters.WorkArea; 270 | if (Settings.Left - 10 < 0) 271 | { 272 | Settings.Left = 0; 273 | } 274 | else if (Settings.Left + Settings.Width - 10 > workArea.Width) 275 | { 276 | Settings.Left = workArea.Width - Settings.Width; 277 | } 278 | 279 | if (Settings.Top - 10 < 0) 280 | { 281 | Settings.Top = 0; 282 | } 283 | else if(Settings.Top + Settings.Height - 10 > workArea.Height) 284 | { 285 | Settings.Top = workArea.Height - Settings.Height; 286 | } 287 | } 288 | 289 | } 290 | 291 | if (e.ClickCount == 2) 292 | { 293 | // 双击效果 294 | StopClockTimer(); 295 | await Task.Delay(1000); 296 | StartWorldLineTimer(); 297 | await Task.Delay(2000); 298 | StartClockTimer(); 299 | } 300 | } 301 | 302 | private BitmapImage[] LoadAllImage() 303 | { 304 | var allImages = new BitmapImage[13]; 305 | for(var i=0; i _settings; 18 | set => SetProperty(ref _settings, value); 19 | } 20 | 21 | public DelegateCommand SaveSettingsCommand { get; set; } 22 | 23 | public SettingsWindowViewModel(Settings settings) 24 | { 25 | Settings = settings; 26 | SaveSettingsCommand = new DelegateCommand(SaveSettings); 27 | } 28 | 29 | private void SaveSettings() 30 | { 31 | var path = $@"{AppDomain.CurrentDomain.BaseDirectory}Settings.json"; 32 | Settings.SaveSettings(path, this.Settings); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Views/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  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 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Views/MainWindow.xaml.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.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Interop; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | using DivergenceMeter.ViewModels; 17 | 18 | namespace DivergenceMeter.Views 19 | { 20 | /// 21 | /// Interaction logic for MainWindow.xaml 22 | /// 23 | public partial class MainWindow : Window 24 | { 25 | public MainWindow() 26 | { 27 | InitializeComponent(); 28 | } 29 | protected override void OnSourceInitialized(EventArgs e) 30 | { 31 | base.OnSourceInitialized(e); 32 | // 重写此函数,得到 Handle 33 | 34 | var vm = this.DataContext as MainWindowViewModel; 35 | 36 | var window = Window.GetWindow(this); 37 | if (window == null) return; 38 | var handle = new WindowInteropHelper(window).Handle; 39 | 40 | if (handle != IntPtr.Zero) 41 | { 42 | vm.SetTheClickThrough(handle); 43 | 44 | vm.HiddenWindowTaskbar(handle); 45 | 46 | } 47 | 48 | // 开启启动实现:往开机启动文件夹里写入快捷方式(无需管理员权限) 49 | vm.SetStartup(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Views/SettingsWindow.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 17 | 18 | 19 | 20 | 时钟坐标: 21 | 22 | 23 | 24 | 25 | 时钟宽高: 26 | 27 | 28 | 29 | 30 | 31 | 32 | 不透明度: 33 | 34 | 范围 [0, 1] 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 说明: 47 | 坐标和宽高单位基于 WPF 单位 48 | 点击穿透效果会阻止拖动和双击效果 49 | 边缘吸附效果只针对主屏幕(如果存在多屏) 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/Views/SettingsWindow.xaml.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.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.Shapes; 14 | 15 | namespace DivergenceMeter.Views 16 | { 17 | /// 18 | /// SettingsWindow.xaml 的交互逻辑 19 | /// 20 | public partial class SettingsWindow : Window 21 | { 22 | public SettingsWindow() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/DivergenceMeter/DivergenceMeter/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/z-xl-t/DivergenceMeter/c81f9ca3532b95fd0d1497c578f666aa4e75fb92/src/DivergenceMeter/DivergenceMeter/favicon.ico --------------------------------------------------------------------------------