├── .gitignore ├── README.md ├── res ├── windchart.ico ├── windchart.png └── windchart.psd └── src ├── BilibiliTutorial ├── Mel20220827.Toolkit.WeChart.sln ├── Tutorial.md ├── WindChart.Lesson1 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson1.csproj ├── WindChart.Lesson10 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainViewModel.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson10.csproj ├── WindChart.Lesson11 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainViewModel.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson11.csproj ├── WindChart.Lesson12 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson12.csproj ├── WindChart.Lesson13 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson13.csproj ├── WindChart.Lesson14 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson14.csproj ├── WindChart.Lesson2 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson2.csproj ├── WindChart.Lesson3 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson3.csproj ├── WindChart.Lesson4 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson4.csproj ├── WindChart.Lesson5 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson5.csproj ├── WindChart.Lesson6 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson6.csproj ├── WindChart.Lesson7 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainViewModel.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson7.csproj ├── WindChart.Lesson8 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainViewModel.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson8.csproj ├── WindChart.Lesson9 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── MainViewModel.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── WindChart.Lesson9.csproj └── WindChart │ ├── BarGram.cs │ ├── Gram.cs │ ├── LineGram.cs │ └── WindChart.csproj ├── Melphi220603.WeChart.sln ├── Samples ├── MeiMvvm │ ├── Binder.cs │ ├── ExpressionHelpers.cs │ ├── IBinder.cs │ ├── IModule.cs │ ├── MeiMvvm.csproj │ ├── NotifyPropertyChanged.cs │ ├── RelayCommand.cs │ └── ServiceProvider.cs └── WindChart.ApplyDemo │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── Data │ ├── MainModule.cs │ └── ServiceLocator.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── PageModels │ ├── BargramPageModel.cs │ ├── DotgramPageModel.cs │ ├── LinegramPageModel.cs │ └── WelcomePageModel.cs │ ├── Pages │ ├── BargramPage.xaml │ ├── BargramPage.xaml.cs │ ├── Bargrams │ │ ├── CodebehindDemo0Page.xaml │ │ ├── CodebehindDemo0Page.xaml.cs │ │ ├── CodebehindDemo1Page.xaml │ │ └── CodebehindDemo1Page.xaml.cs │ ├── DotgramPage.xaml │ ├── DotgramPage.xaml.cs │ ├── GramPage.xaml │ ├── GramPage.xaml.cs │ ├── LinegramPage.xaml │ ├── LinegramPage.xaml.cs │ ├── Linegrams │ │ ├── CodebehindDemo0Page.xaml │ │ ├── CodebehindDemo0Page.xaml.cs │ │ ├── CodebehindDemo1Page.xaml │ │ ├── CodebehindDemo1Page.xaml.cs │ │ ├── CodebehindDemo2Page.xaml │ │ └── CodebehindDemo2Page.xaml.cs │ ├── WelcomePage.xaml │ └── WelcomePage.xaml.cs │ ├── WindChart.ApplyDemo.csproj │ ├── WindChart.ApplyDemo.csproj.user │ └── windchart.ico └── WindChart ├── AxisEnums.cs ├── Bargram.cs ├── Dotgram.cs ├── Gram.cs ├── Linegram.cs ├── WindChart.csproj └── windchart.ico /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | 154 | # Windows Azure Build Output 155 | csx/ 156 | *.build.csdef 157 | 158 | # Windows Azure Emulator 159 | efc/ 160 | rfc/ 161 | 162 | # Windows Store app package directory 163 | AppPackages/ 164 | 165 | # Visual Studio cache files 166 | # files ending in .cache can be ignored 167 | *.[Cc]ache 168 | # but keep track of directories ending in .cache 169 | !*.[Cc]ache/ 170 | 171 | # Others 172 | ClientBin/ 173 | [Ss]tyle[Cc]op.* 174 | ~$* 175 | *~ 176 | *.dbmdl 177 | *.dbproj.schemaview 178 | *.pfx 179 | *.publishsettings 180 | node_modules/ 181 | orleans.codegen.cs 182 | 183 | # RIA/Silverlight projects 184 | Generated_Code/ 185 | 186 | # Backup & report files from converting an old project file 187 | # to a newer Visual Studio version. Backup files are not needed, 188 | # because we have git ;-) 189 | _UpgradeReport_Files/ 190 | Backup*/ 191 | UpgradeLog*.XML 192 | UpgradeLog*.htm 193 | 194 | # SQL Server files 195 | *.mdf 196 | *.ldf 197 | 198 | # Business Intelligence projects 199 | *.rdl.data 200 | *.bim.layout 201 | *.bim_*.settings 202 | 203 | # Microsoft Fakes 204 | FakesAssemblies/ 205 | 206 | # GhostDoc plugin setting file 207 | *.GhostDoc.xml 208 | 209 | # Node.js Tools for Visual Studio 210 | .ntvs_analysis.dat 211 | 212 | # Visual Studio 6 build log 213 | *.plg 214 | 215 | # Visual Studio 6 workspace options file 216 | *.opt 217 | 218 | # Visual Studio LightSwitch build output 219 | **/*.HTMLClient/GeneratedArtifacts 220 | **/*.DesktopClient/GeneratedArtifacts 221 | **/*.DesktopClient/ModelManifest.xml 222 | **/*.Server/GeneratedArtifacts 223 | **/*.Server/ModelManifest.xml 224 | _Pvt_Extensions 225 | 226 | # Paket dependency manager 227 | .paket/paket.exe 228 | 229 | # FAKE - F# Make 230 | .fake/ 231 | *.binlog 232 | /.dotnet 233 | -------------------------------------------------------------------------------- /res/windchart.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mefdeamon/Toolkit-WeChart/f7a40245bd5f7395ac39ed6fb2d333414b90772f/res/windchart.ico -------------------------------------------------------------------------------- /res/windchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mefdeamon/Toolkit-WeChart/f7a40245bd5f7395ac39ed6fb2d333414b90772f/res/windchart.png -------------------------------------------------------------------------------- /res/windchart.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mefdeamon/Toolkit-WeChart/f7a40245bd5f7395ac39ed6fb2d333414b90772f/res/windchart.psd -------------------------------------------------------------------------------- /src/BilibiliTutorial/Mel20220827.Toolkit.WeChart.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32421.90 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson1", "WindChart.Lesson1\WindChart.Lesson1.csproj", "{9FDD57ED-FC3A-4876-B96D-8711B7D69B3D}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson2", "WindChart.Lesson2\WindChart.Lesson2.csproj", "{83CE8F31-DE9D-4D10-A3D5-679BCB5659B8}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart", "WindChart\WindChart.csproj", "{C73CE2BA-EBF9-4068-99D8-18FC98C32BE5}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson3", "WindChart.Lesson3\WindChart.Lesson3.csproj", "{B35A3E97-FB01-48CA-BDBE-F81FE76FF321}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson4", "WindChart.Lesson4\WindChart.Lesson4.csproj", "{FB149CDB-3119-463B-AE70-AB3F125F2E14}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson5", "WindChart.Lesson5\WindChart.Lesson5.csproj", "{5CC246E0-2AAF-4E4C-9632-5B462050DF68}" 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson6", "WindChart.Lesson6\WindChart.Lesson6.csproj", "{DAB3C257-6B4D-4858-B601-906831DD6DD4}" 19 | EndProject 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson7", "WindChart.Lesson7\WindChart.Lesson7.csproj", "{D8DFBA38-F69A-43DD-BD8A-1DC42E0CDE03}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson8", "WindChart.Lesson8\WindChart.Lesson8.csproj", "{73A7E9FE-F704-4FB7-BE03-01BA6635FAAB}" 23 | EndProject 24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson9", "WindChart.Lesson9\WindChart.Lesson9.csproj", "{4231BC5D-3DF1-44E6-BABE-AE4CE74BD69F}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson10", "WindChart.Lesson10\WindChart.Lesson10.csproj", "{C9795C3A-11E0-4EBE-8E46-8A65EB4B3E37}" 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson11", "WindChart.Lesson11\WindChart.Lesson11.csproj", "{B5997C23-EE42-4AB0-897B-B3289FFEAA5C}" 29 | EndProject 30 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson12", "WindChart.Lesson12\WindChart.Lesson12.csproj", "{EC2BB83D-4DC2-4B0D-8CE6-CA7F29579B2E}" 31 | EndProject 32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.Lesson13", "WindChart.Lesson13\WindChart.Lesson13.csproj", "{739FEADD-156C-4436-A046-E805D67E7BE7}" 33 | EndProject 34 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindChart.Lesson14", "WindChart.Lesson14\WindChart.Lesson14.csproj", "{10580BC0-C3C1-4095-82FF-460380EEF2EA}" 35 | EndProject 36 | Global 37 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 38 | Debug|Any CPU = Debug|Any CPU 39 | Release|Any CPU = Release|Any CPU 40 | EndGlobalSection 41 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 42 | {9FDD57ED-FC3A-4876-B96D-8711B7D69B3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {9FDD57ED-FC3A-4876-B96D-8711B7D69B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {9FDD57ED-FC3A-4876-B96D-8711B7D69B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {9FDD57ED-FC3A-4876-B96D-8711B7D69B3D}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {83CE8F31-DE9D-4D10-A3D5-679BCB5659B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {83CE8F31-DE9D-4D10-A3D5-679BCB5659B8}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {83CE8F31-DE9D-4D10-A3D5-679BCB5659B8}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {83CE8F31-DE9D-4D10-A3D5-679BCB5659B8}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {C73CE2BA-EBF9-4068-99D8-18FC98C32BE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {C73CE2BA-EBF9-4068-99D8-18FC98C32BE5}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {C73CE2BA-EBF9-4068-99D8-18FC98C32BE5}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {C73CE2BA-EBF9-4068-99D8-18FC98C32BE5}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {B35A3E97-FB01-48CA-BDBE-F81FE76FF321}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {B35A3E97-FB01-48CA-BDBE-F81FE76FF321}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {B35A3E97-FB01-48CA-BDBE-F81FE76FF321}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {B35A3E97-FB01-48CA-BDBE-F81FE76FF321}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {FB149CDB-3119-463B-AE70-AB3F125F2E14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {FB149CDB-3119-463B-AE70-AB3F125F2E14}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {FB149CDB-3119-463B-AE70-AB3F125F2E14}.Release|Any CPU.ActiveCfg = Release|Any CPU 61 | {FB149CDB-3119-463B-AE70-AB3F125F2E14}.Release|Any CPU.Build.0 = Release|Any CPU 62 | {5CC246E0-2AAF-4E4C-9632-5B462050DF68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 63 | {5CC246E0-2AAF-4E4C-9632-5B462050DF68}.Debug|Any CPU.Build.0 = Debug|Any CPU 64 | {5CC246E0-2AAF-4E4C-9632-5B462050DF68}.Release|Any CPU.ActiveCfg = Release|Any CPU 65 | {5CC246E0-2AAF-4E4C-9632-5B462050DF68}.Release|Any CPU.Build.0 = Release|Any CPU 66 | {DAB3C257-6B4D-4858-B601-906831DD6DD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 67 | {DAB3C257-6B4D-4858-B601-906831DD6DD4}.Debug|Any CPU.Build.0 = Debug|Any CPU 68 | {DAB3C257-6B4D-4858-B601-906831DD6DD4}.Release|Any CPU.ActiveCfg = Release|Any CPU 69 | {DAB3C257-6B4D-4858-B601-906831DD6DD4}.Release|Any CPU.Build.0 = Release|Any CPU 70 | {D8DFBA38-F69A-43DD-BD8A-1DC42E0CDE03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 71 | {D8DFBA38-F69A-43DD-BD8A-1DC42E0CDE03}.Debug|Any CPU.Build.0 = Debug|Any CPU 72 | {D8DFBA38-F69A-43DD-BD8A-1DC42E0CDE03}.Release|Any CPU.ActiveCfg = Release|Any CPU 73 | {D8DFBA38-F69A-43DD-BD8A-1DC42E0CDE03}.Release|Any CPU.Build.0 = Release|Any CPU 74 | {73A7E9FE-F704-4FB7-BE03-01BA6635FAAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 75 | {73A7E9FE-F704-4FB7-BE03-01BA6635FAAB}.Debug|Any CPU.Build.0 = Debug|Any CPU 76 | {73A7E9FE-F704-4FB7-BE03-01BA6635FAAB}.Release|Any CPU.ActiveCfg = Release|Any CPU 77 | {73A7E9FE-F704-4FB7-BE03-01BA6635FAAB}.Release|Any CPU.Build.0 = Release|Any CPU 78 | {4231BC5D-3DF1-44E6-BABE-AE4CE74BD69F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 79 | {4231BC5D-3DF1-44E6-BABE-AE4CE74BD69F}.Debug|Any CPU.Build.0 = Debug|Any CPU 80 | {4231BC5D-3DF1-44E6-BABE-AE4CE74BD69F}.Release|Any CPU.ActiveCfg = Release|Any CPU 81 | {4231BC5D-3DF1-44E6-BABE-AE4CE74BD69F}.Release|Any CPU.Build.0 = Release|Any CPU 82 | {C9795C3A-11E0-4EBE-8E46-8A65EB4B3E37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {C9795C3A-11E0-4EBE-8E46-8A65EB4B3E37}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {C9795C3A-11E0-4EBE-8E46-8A65EB4B3E37}.Release|Any CPU.ActiveCfg = Release|Any CPU 85 | {C9795C3A-11E0-4EBE-8E46-8A65EB4B3E37}.Release|Any CPU.Build.0 = Release|Any CPU 86 | {B5997C23-EE42-4AB0-897B-B3289FFEAA5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 87 | {B5997C23-EE42-4AB0-897B-B3289FFEAA5C}.Debug|Any CPU.Build.0 = Debug|Any CPU 88 | {B5997C23-EE42-4AB0-897B-B3289FFEAA5C}.Release|Any CPU.ActiveCfg = Release|Any CPU 89 | {B5997C23-EE42-4AB0-897B-B3289FFEAA5C}.Release|Any CPU.Build.0 = Release|Any CPU 90 | {EC2BB83D-4DC2-4B0D-8CE6-CA7F29579B2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 91 | {EC2BB83D-4DC2-4B0D-8CE6-CA7F29579B2E}.Debug|Any CPU.Build.0 = Debug|Any CPU 92 | {EC2BB83D-4DC2-4B0D-8CE6-CA7F29579B2E}.Release|Any CPU.ActiveCfg = Release|Any CPU 93 | {EC2BB83D-4DC2-4B0D-8CE6-CA7F29579B2E}.Release|Any CPU.Build.0 = Release|Any CPU 94 | {739FEADD-156C-4436-A046-E805D67E7BE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 95 | {739FEADD-156C-4436-A046-E805D67E7BE7}.Debug|Any CPU.Build.0 = Debug|Any CPU 96 | {739FEADD-156C-4436-A046-E805D67E7BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU 97 | {739FEADD-156C-4436-A046-E805D67E7BE7}.Release|Any CPU.Build.0 = Release|Any CPU 98 | {10580BC0-C3C1-4095-82FF-460380EEF2EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 99 | {10580BC0-C3C1-4095-82FF-460380EEF2EA}.Debug|Any CPU.Build.0 = Debug|Any CPU 100 | {10580BC0-C3C1-4095-82FF-460380EEF2EA}.Release|Any CPU.ActiveCfg = Release|Any CPU 101 | {10580BC0-C3C1-4095-82FF-460380EEF2EA}.Release|Any CPU.Build.0 = Release|Any CPU 102 | EndGlobalSection 103 | GlobalSection(SolutionProperties) = preSolution 104 | HideSolutionNode = FALSE 105 | EndGlobalSection 106 | GlobalSection(ExtensibilityGlobals) = postSolution 107 | SolutionGuid = {C3D4ED59-462F-4345-BFD6-5E556CC5FA54} 108 | EndGlobalSection 109 | EndGlobal 110 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson1/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson1/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson1 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson1/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/BilibiliTutorial/WindChart.Lesson1/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson1/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson1 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | // Create a host visual derived from the FrameworkElement class. 29 | // This class provides layout, event handling, and container support for 30 | // the child visual objects. 31 | public class MyVisualHost : FrameworkElement 32 | { 33 | // Create a collection of child visual objects. 34 | private VisualCollection _children; 35 | 36 | public MyVisualHost() 37 | { 38 | _children = new VisualCollection(this); 39 | _children.Add(CreateDrawingVisualRectangle()); 40 | _children.Add(CreateDrawingVisualText()); 41 | _children.Add(CreateDrawingVisualEllipses()); 42 | 43 | // Add the event handler for MouseLeftButtonUp. 44 | this.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(MyVisualHost_MouseLeftButtonUp); 45 | } 46 | 47 | private Visual CreateDrawingVisualEllipses() 48 | { 49 | DrawingVisual drawingVisual = new DrawingVisual(); 50 | DrawingContext drawingContext = drawingVisual.RenderOpen(); 51 | 52 | drawingContext.DrawEllipse(Brushes.Purple, new Pen(Brushes.Blue, 1), new Point(50, 50), 20, 20); 53 | drawingContext.Close(); 54 | 55 | return drawingVisual; 56 | } 57 | 58 | private Visual CreateDrawingVisualText() 59 | { 60 | DrawingVisual drawingVisual = new DrawingVisual(); 61 | DrawingContext drawingContext = drawingVisual.RenderOpen(); 62 | 63 | FormattedText formattedText = new FormattedText("hello world", System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("微软雅黑"), 12, Brushes.Red); 64 | 65 | drawingContext.DrawText(formattedText, new Point(50, 50)); 66 | drawingContext.Close(); 67 | 68 | return drawingVisual; 69 | } 70 | 71 | // Create a DrawingVisual that contains a rectangle. 72 | private DrawingVisual CreateDrawingVisualRectangle() 73 | { 74 | DrawingVisual drawingVisual = new DrawingVisual(); 75 | 76 | // Retrieve the DrawingContext in order to create new drawing content. 77 | DrawingContext drawingContext = drawingVisual.RenderOpen(); 78 | 79 | // Create a rectangle and draw it in the DrawingContext. 80 | Rect rect = new Rect(new System.Windows.Point(160, 100), new System.Windows.Size(320, 80)); 81 | drawingContext.DrawRectangle(System.Windows.Media.Brushes.LightBlue, (System.Windows.Media.Pen)null, rect); 82 | 83 | // Persist the drawing content. 84 | drawingContext.Close(); 85 | 86 | return drawingVisual; 87 | } 88 | 89 | // Provide a required override for the VisualChildrenCount property. 90 | protected override int VisualChildrenCount 91 | { 92 | get { return _children.Count; } 93 | } 94 | 95 | // Provide a required override for the GetVisualChild method. 96 | protected override Visual GetVisualChild(int index) 97 | { 98 | if (index < 0 || index >= _children.Count) 99 | { 100 | throw new ArgumentOutOfRangeException(); 101 | } 102 | 103 | return _children[index]; 104 | } 105 | 106 | // Capture the mouse event and hit test the coordinate point value against 107 | // the child visual objects. 108 | void MyVisualHost_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) 109 | { 110 | // Retrieve the coordinates of the mouse button event. 111 | System.Windows.Point pt = e.GetPosition((UIElement)sender); 112 | 113 | // Initiate the hit test by setting up a hit test result callback method. 114 | VisualTreeHelper.HitTest(this, null, new HitTestResultCallback(myCallback), new PointHitTestParameters(pt)); 115 | } 116 | 117 | // If a child visual object is hit, toggle its opacity to visually indicate a hit. 118 | public HitTestResultBehavior myCallback(HitTestResult result) 119 | { 120 | if (result.VisualHit.GetType() == typeof(DrawingVisual)) 121 | { 122 | if (((DrawingVisual)result.VisualHit).Opacity == 1.0) 123 | { 124 | ((DrawingVisual)result.VisualHit).Opacity = 0.4; 125 | } 126 | else 127 | { 128 | ((DrawingVisual)result.VisualHit).Opacity = 1.0; 129 | } 130 | } 131 | 132 | // Stop the hit test enumeration of objects in the visual tree. 133 | return HitTestResultBehavior.Stop; 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson1/WindChart.Lesson1.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson10/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson10/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson10 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson10/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/BilibiliTutorial/WindChart.Lesson10/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson10 10 | { 11 | public class MainViewModel : INotifyPropertyChanged 12 | { 13 | public event PropertyChangedEventHandler PropertyChanged; 14 | 15 | public MainViewModel() 16 | { 17 | LinePoints = new ObservableCollection(); 18 | 19 | 20 | // 模拟 21 | Task.Delay(1000).ContinueWith((Action)(t => 22 | { 23 | 24 | Application.Current.Dispatcher.Invoke(() => 25 | { 26 | LinePoints = new ObservableCollection(); 27 | }); 28 | 29 | double x = 0; 30 | double y = 0; 31 | 32 | Random random = new Random(); 33 | 34 | y = 50; 35 | 36 | 37 | // while (true) 38 | { 39 | List points = new List(); 40 | while (true) 41 | { 42 | 43 | Application.Current.Dispatcher.Invoke((Action)(() => 44 | { 45 | points.Add(new Point(x, y)); 46 | })); 47 | 48 | x++; 49 | y = random.Next() % 2 == 0 ? ++y : --y; 50 | 51 | Application.Current.Dispatcher.Invoke(() => 52 | { 53 | LinePoints = new ObservableCollection(points); 54 | }); 55 | 56 | Thread.Sleep(20); 57 | 58 | } 59 | Application.Current.Dispatcher.Invoke(() => 60 | { 61 | LinePoints = new ObservableCollection(points); 62 | x = 0; 63 | y = 50; 64 | }); 65 | 66 | Thread.Sleep(2000); 67 | } 68 | 69 | })); 70 | 71 | 72 | 73 | } 74 | 75 | private Boolean isGraph; 76 | 77 | public Boolean IsGraph 78 | { 79 | get { return isGraph; } 80 | set 81 | { 82 | isGraph = value; 83 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsGraph))); 84 | } 85 | } 86 | 87 | private ObservableCollection linePoints; 88 | 89 | public ObservableCollection LinePoints 90 | { 91 | get { return linePoints; } 92 | set 93 | { 94 | linePoints = value; 95 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LinePoints))); 96 | } 97 | } 98 | 99 | 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson10/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson10/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson10 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson10/WindChart.Lesson10.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson11/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson11/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson11 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson11/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/BilibiliTutorial/WindChart.Lesson11/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson11 10 | { 11 | 12 | public class MainViewModel : INotifyPropertyChanged 13 | { 14 | public event PropertyChangedEventHandler PropertyChanged; 15 | 16 | public MainViewModel() 17 | { 18 | LinePoints = new ObservableCollection(); 19 | 20 | 21 | // 模拟 22 | Task.Delay(1000).ContinueWith((Action)(t => 23 | { 24 | 25 | Application.Current.Dispatcher.Invoke(() => 26 | { 27 | LinePoints = new ObservableCollection(); 28 | }); 29 | 30 | double x = 0; 31 | double y = 0; 32 | 33 | Random random = new Random(); 34 | 35 | y = 50; 36 | 37 | 38 | // while (true) 39 | { 40 | List points = new List(); 41 | while (true) 42 | { 43 | 44 | Application.Current.Dispatcher.Invoke((Action)(() => 45 | { 46 | points.Add(new Point(x, y)); 47 | })); 48 | 49 | x++; 50 | y = random.Next() % 2 == 0 ? ++y : --y; 51 | 52 | Application.Current.Dispatcher.Invoke(() => 53 | { 54 | LinePoints = new ObservableCollection(points); 55 | }); 56 | 57 | Thread.Sleep(20); 58 | 59 | } 60 | Application.Current.Dispatcher.Invoke(() => 61 | { 62 | LinePoints = new ObservableCollection(points); 63 | x = 0; 64 | y = 50; 65 | }); 66 | 67 | Thread.Sleep(2000); 68 | } 69 | 70 | })); 71 | 72 | 73 | 74 | } 75 | 76 | private Boolean isGraph; 77 | 78 | public Boolean IsGraph 79 | { 80 | get { return isGraph; } 81 | set 82 | { 83 | isGraph = value; 84 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsGraph))); 85 | } 86 | } 87 | 88 | private ObservableCollection linePoints; 89 | 90 | public ObservableCollection LinePoints 91 | { 92 | get { return linePoints; } 93 | set 94 | { 95 | linePoints = value; 96 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LinePoints))); 97 | } 98 | } 99 | 100 | 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson11/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson11/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 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 WindChart.Lesson11 18 | { 19 | /// 20 | /// Interaction logic for MainWindow.xaml 21 | /// 22 | public partial class MainWindow : Window 23 | { 24 | public MainWindow() 25 | { 26 | InitializeComponent(); 27 | 28 | 29 | 30 | } 31 | 32 | private void FlashEveryPoint() 33 | { 34 | // 设置X轴开始显示范围 35 | line.XMin = DateTime.Now.ToOADate(); 36 | line.XMax = DateTime.Now.AddSeconds(60).ToOADate(); 37 | // 设置X轴刻度文本格式 38 | line.XAxisTextFormatString = "HH: mm:ss"; 39 | // X轴刻度按照日期显示 40 | line.IsXAxisTextDateTimeFormat = true; 41 | line.IsGraph = false; 42 | 43 | // 轴跟随数据变化 44 | line.IsAxisFollowData = true; 45 | // Y轴范围 46 | line.YMin = 0; 47 | line.YMax = 80; 48 | 49 | // 实时数据模拟 50 | Task.Run(() => 51 | { 52 | Random rand = new Random(); 53 | double y = 10; 54 | while (true) 55 | { 56 | var ran = rand.Next(-150, 150); 57 | if (ran > 0) 58 | { 59 | y -= 1; 60 | } 61 | else 62 | { 63 | y += 1; 64 | } 65 | this.Dispatcher.Invoke(() => 66 | { 67 | line.Add(new Point(DateTime.Now.ToOADate(), y)); 68 | }); 69 | Thread.Sleep(30); 70 | } 71 | }); 72 | } 73 | 74 | 75 | private void FlashOnce() 76 | { 77 | // 设置X轴开始显示范围 78 | DateTime dtStart = DateTime.Now.AddMinutes(-3); 79 | line.XMin = dtStart.ToOADate(); 80 | line.XMax = DateTime.Now.AddSeconds(60).ToOADate(); 81 | // 设置X轴刻度文本格式 82 | line.XAxisTextFormatString = "HH:mm:ss"; 83 | // X轴刻度按照日期显示 84 | line.IsXAxisTextDateTimeFormat = true; 85 | 86 | // 轴跟随数据变化 87 | line.IsAxisFollowData = true; 88 | // Y轴范围 89 | line.YMin = 0; 90 | line.YMax = 80; 91 | 92 | // 数据模拟 93 | Random rand = new Random(); 94 | List points = new List(); 95 | double y = 10; 96 | while (dtStart < DateTime.Now) 97 | { 98 | var ran = rand.Next(-150, 150); 99 | if (ran > 0) 100 | { 101 | y -= 1; 102 | } 103 | else 104 | { 105 | y += 1; 106 | } 107 | points.Add(new Point(dtStart.ToOADate(), y)); 108 | dtStart = dtStart.AddMilliseconds(500); 109 | } 110 | line.DrawLine(points); 111 | } 112 | 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson11/WindChart.Lesson11.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson12/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson12/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson12 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson12/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/BilibiliTutorial/WindChart.Lesson12/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson12/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson12 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | 27 | 28 | Task.Delay(1000).ContinueWith(t => 29 | { 30 | bar.Draw(new List() 31 | { 32 | new Bar (){ Fill=Brushes.Purple, Label="星期天", Value=8}, 33 | new Bar (){ Fill=Brushes.PaleGoldenrod , Label="星期一", Value=8.35}, 34 | new Bar (){ Fill=Brushes.Green, Label="星期二", Value=9.35} 35 | }); 36 | }); 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson12/WindChart.Lesson12.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson13/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson13/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson13 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson13/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/BilibiliTutorial/WindChart.Lesson13/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson13/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson13 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | 27 | 28 | Task.Delay(1000).ContinueWith(t => 29 | { 30 | bar.Draw(new List() 31 | { 32 | new Bar (){ Fill=Brushes.Purple, Label="星期天", Value=8}, 33 | new Bar (){ Fill=Brushes.PaleGoldenrod , Label="星期一", Value=8.35}, 34 | new Bar (){ Fill=Brushes.Green, Label="星期二", Value=9.35} 35 | }); 36 | }); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson13/WindChart.Lesson13.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson14/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson14/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson14 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson14/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/BilibiliTutorial/WindChart.Lesson14/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson14/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Media; 15 | using System.Windows.Media.Imaging; 16 | using System.Windows.Navigation; 17 | using System.Windows.Shapes; 18 | 19 | namespace WindChart.Lesson14 20 | { 21 | /// 22 | /// Interaction logic for MainWindow.xaml 23 | /// 24 | public partial class MainWindow : Window 25 | { 26 | public MainWindow() 27 | { 28 | InitializeComponent(); 29 | 30 | DataContext = new MainWindowModel(); 31 | 32 | //// Y轴范围 33 | //bar.YMin = 0; 34 | //bar.YMax = 24; 35 | 36 | //bar.ValueLabelLocation = BarValueLocation.None; 37 | 38 | //// 实时数据模拟 39 | //Task.Run(() => 40 | //{ 41 | // Random rand = new Random(); 42 | // double y = 10; 43 | // List bars = new List(); 44 | // DateTime dt = DateTime.Now.AddMonths(-2); 45 | // while (true) 46 | // { 47 | // y = rand.Next(5, 16); 48 | 49 | // this.Dispatcher.Invoke(() => 50 | // { 51 | // bars.Add(new Bar() { Fill = y > 8 ? Brushes.CornflowerBlue : Brushes.OrangeRed, Label = dt.Day.ToString(), Value = y }); 52 | // bar.DrawBar(bars); 53 | // }); 54 | // dt = dt.AddDays(1); 55 | // if (dt > DateTime.Now) 56 | // { 57 | // break; 58 | // } 59 | // } 60 | //}); 61 | } 62 | } 63 | 64 | 65 | public class MainWindowModel : ObservableObject 66 | { 67 | public MainWindowModel() 68 | { 69 | 70 | // 实时数据模拟 71 | Random rand = new Random(); 72 | double y = 10; 73 | List bars = new List(); 74 | DateTime dt = DateTime.Now.AddMonths(-2); 75 | while (true) 76 | { 77 | y = rand.Next(5, 16); 78 | 79 | bars.Add(new Bar() { Fill = y > 8 ? Brushes.CornflowerBlue : Brushes.OrangeRed, Label = dt.Day.ToString(), Value = y }); 80 | dt = dt.AddDays(1); 81 | if (dt > DateTime.Now) 82 | { 83 | break; 84 | } 85 | } 86 | 87 | Bars = new ObservableCollection(bars); 88 | } 89 | 90 | 91 | public ObservableCollection Bars { get; set; } 92 | 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson14/WindChart.Lesson14.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson2/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson2/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson2 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson2/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/BilibiliTutorial/WindChart.Lesson2/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson2/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson2 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | 29 | 30 | public class Gram : FrameworkElement 31 | { 32 | protected VisualCollection _children; 33 | 34 | public Gram() 35 | { 36 | _children = new VisualCollection(this); 37 | 38 | axisVisual = new DrawingVisual(); 39 | _children.Add(axisVisual); 40 | } 41 | 42 | private DrawingVisual axisVisual; 43 | 44 | 45 | /// 46 | /// 绘制原点 47 | /// 48 | private void DrawAxis() 49 | { 50 | var drawingContext = axisVisual.RenderOpen(); 51 | 52 | Point org = new Point(0, 0); 53 | org = ConvertToPixcel(org); 54 | 55 | drawingContext.DrawEllipse(Brushes.Black, new Pen(Brushes.OrangeRed, 1), org, 5, 5); 56 | 57 | drawingContext.Close(); 58 | } 59 | 60 | #region 场景大小 61 | 62 | public double XMin { get; set; } = -10; 63 | public double YMin { get; set; } = -10; 64 | public double XMax { get; set; } = 100; 65 | public double YMax { get; set; } = 100; 66 | 67 | protected double XWidth => XMax - XMin; 68 | protected double YHeight => YMax - YMin; 69 | 70 | #endregion 71 | 72 | #region 像素比 73 | 74 | public double xPixelRatio => RenderSize.Width / XWidth; 75 | public double yPixelRatio => RenderSize.Height / YHeight; 76 | 77 | #endregion 78 | 79 | #region 坐标点转换 80 | 81 | public double ConvertYToPixcel(double y) 82 | { 83 | double distY = y - YMin; 84 | return RenderSize.Height - distY * yPixelRatio; 85 | } 86 | 87 | public double ConvertXToPixcel(double x) 88 | { 89 | double distX = x - XMin; 90 | return distX * xPixelRatio; 91 | } 92 | 93 | public Point ConvertToPixcel(Point p) 94 | { 95 | p.X = ConvertXToPixcel((double)p.X); 96 | p.Y = ConvertYToPixcel((double)p.Y); 97 | return p; 98 | } 99 | 100 | #endregion 101 | 102 | protected override int VisualChildrenCount 103 | { 104 | get { return _children.Count; } 105 | } 106 | 107 | protected override Visual GetVisualChild(int index) 108 | { 109 | if (index < 0 || index >= _children.Count) 110 | { 111 | throw new ArgumentOutOfRangeException(); 112 | } 113 | 114 | return _children[index]; 115 | } 116 | 117 | protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) 118 | { 119 | base.OnRenderSizeChanged(sizeInfo); 120 | DrawAxis(); 121 | } 122 | 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson2/WindChart.Lesson2.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson3/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson3/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson3 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson3/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/BilibiliTutorial/WindChart.Lesson3/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson3/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson3 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson3/WindChart.Lesson3.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson4/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson4/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson4 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson4/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/BilibiliTutorial/WindChart.Lesson4/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson4/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 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 WindChart.Lesson4 18 | { 19 | /// 20 | /// Interaction logic for MainWindow.xaml 21 | /// 22 | public partial class MainWindow : Window 23 | { 24 | public MainWindow() 25 | { 26 | InitializeComponent(); 27 | 28 | // 模拟 29 | Task.Delay(1000).ContinueWith((Action)(t => 30 | { 31 | 32 | this.Dispatcher.Invoke(() => 33 | { 34 | lineGram.InitLine(Brushes.Red); 35 | }); 36 | 37 | double x = 0; 38 | double y = 0; 39 | 40 | Random random = new Random(); 41 | 42 | y = 50; 43 | 44 | while (true) 45 | { 46 | 47 | this.Dispatcher.Invoke((Action)(() => 48 | { 49 | lineGram.DrawLine(new Point(x, y)); 50 | })); 51 | 52 | x++; 53 | y = random.Next() % 2 == 0 ? ++y : --y; 54 | 55 | if (x > 500) 56 | { 57 | this.Dispatcher.Invoke(() => 58 | { 59 | lineGram.InitLine(Brushes.DarkOliveGreen); 60 | y = 50; 61 | x = 0; 62 | }); 63 | } 64 | 65 | //Thread.Sleep(100); 66 | } 67 | 68 | 69 | 70 | })); 71 | 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson4/WindChart.Lesson4.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson5/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson5/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson5 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson5/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/BilibiliTutorial/WindChart.Lesson5/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson5/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson5 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | 27 | 28 | // 模拟 29 | Task.Delay(1000).ContinueWith((Action)(t => 30 | { 31 | 32 | this.Dispatcher.Invoke(() => 33 | { 34 | lineGram.InitLine(Brushes.Red); 35 | }); 36 | 37 | double x = 0; 38 | double y = 0; 39 | 40 | Random random = new Random(); 41 | 42 | y = 50; 43 | 44 | while (true) 45 | { 46 | 47 | this.Dispatcher.Invoke((Action)(() => 48 | { 49 | lineGram.DrawLine(new Point(x, y)); 50 | })); 51 | 52 | x++; 53 | y = random.Next() % 2 == 0 ? ++y : --y; 54 | 55 | if (x > 500) 56 | { 57 | this.Dispatcher.Invoke(() => 58 | { 59 | lineGram.InitLine(Brushes.DarkOliveGreen); 60 | y = 50; 61 | x = 0; 62 | }); 63 | } 64 | 65 | //Thread.Sleep(100); 66 | } 67 | 68 | 69 | 70 | })); 71 | 72 | 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson5/WindChart.Lesson5.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson6/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson6/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson6 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson6/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/BilibiliTutorial/WindChart.Lesson6/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson6/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 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.Threading; 17 | 18 | namespace WindChart.Lesson6 19 | { 20 | /// 21 | /// Interaction logic for MainWindow.xaml 22 | /// 23 | public partial class MainWindow : Window 24 | { 25 | public MainWindow() 26 | { 27 | InitializeComponent(); 28 | 29 | } 30 | } 31 | 32 | public class MainViewModel : INotifyPropertyChanged 33 | { 34 | public event PropertyChangedEventHandler PropertyChanged; 35 | 36 | public MainViewModel() 37 | { 38 | LinePoints = new ObservableCollection(); 39 | 40 | 41 | // 模拟 42 | Task.Delay(1000).ContinueWith((Action)(t => 43 | { 44 | 45 | Application.Current.Dispatcher.Invoke(() => 46 | { 47 | LinePoints = new ObservableCollection(); 48 | }); 49 | 50 | double x = 0; 51 | double y = 0; 52 | 53 | Random random = new Random(); 54 | 55 | y = 50; 56 | 57 | 58 | while (true) 59 | { 60 | List points = new List(); 61 | while (true) 62 | { 63 | 64 | Application.Current.Dispatcher.Invoke((Action)(() => 65 | { 66 | points.Add(new Point(x, y)); 67 | })); 68 | 69 | x++; 70 | y = random.Next() % 2 == 0 ? ++y : --y; 71 | 72 | if (x > 500) 73 | { 74 | break; 75 | } 76 | } 77 | Application.Current.Dispatcher.Invoke(() => 78 | { 79 | LinePoints = new ObservableCollection(points); 80 | x = 0; 81 | y = 50; 82 | }); 83 | 84 | Thread.Sleep(2000); 85 | } 86 | 87 | })); 88 | 89 | 90 | 91 | } 92 | 93 | private Boolean isGraph; 94 | 95 | public Boolean IsGraph 96 | { 97 | get { return isGraph; } 98 | set 99 | { 100 | isGraph = value; 101 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsGraph))); 102 | } 103 | } 104 | 105 | private ObservableCollection linePoints; 106 | 107 | public ObservableCollection LinePoints 108 | { 109 | get { return linePoints; } 110 | set 111 | { 112 | linePoints = value; 113 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LinePoints))); 114 | } 115 | } 116 | 117 | 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson6/WindChart.Lesson6.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson7/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson7/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson7 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson7/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/BilibiliTutorial/WindChart.Lesson7/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson7 10 | { 11 | public class MainViewModel : INotifyPropertyChanged 12 | { 13 | public event PropertyChangedEventHandler PropertyChanged; 14 | 15 | public MainViewModel() 16 | { 17 | LinePoints = new ObservableCollection(); 18 | 19 | 20 | // 模拟 21 | Task.Delay(1000).ContinueWith((Action)(t => 22 | { 23 | 24 | Application.Current.Dispatcher.Invoke(() => 25 | { 26 | LinePoints = new ObservableCollection(); 27 | }); 28 | 29 | double x = 0; 30 | double y = 0; 31 | 32 | Random random = new Random(); 33 | 34 | y = 50; 35 | 36 | 37 | // while (true) 38 | { 39 | List points = new List(); 40 | while (true) 41 | { 42 | 43 | Application.Current.Dispatcher.Invoke((Action)(() => 44 | { 45 | points.Add(new Point(x, y)); 46 | })); 47 | 48 | x++; 49 | y = random.Next() % 2 == 0 ? ++y : --y; 50 | 51 | if (x > 500) 52 | { 53 | break; 54 | } 55 | } 56 | Application.Current.Dispatcher.Invoke(() => 57 | { 58 | LinePoints = new ObservableCollection(points); 59 | x = 0; 60 | y = 50; 61 | }); 62 | 63 | Thread.Sleep(2000); 64 | } 65 | 66 | })); 67 | 68 | 69 | 70 | } 71 | 72 | private Boolean isGraph; 73 | 74 | public Boolean IsGraph 75 | { 76 | get { return isGraph; } 77 | set 78 | { 79 | isGraph = value; 80 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsGraph))); 81 | } 82 | } 83 | 84 | private ObservableCollection linePoints; 85 | 86 | public ObservableCollection LinePoints 87 | { 88 | get { return linePoints; } 89 | set 90 | { 91 | linePoints = value; 92 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LinePoints))); 93 | } 94 | } 95 | 96 | 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson7/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson7/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Text; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Data; 6 | using System.Windows.Documents; 7 | using System.Windows.Input; 8 | using System.Windows.Media; 9 | using System.Windows.Media.Imaging; 10 | using System.Windows.Navigation; 11 | using System.Windows.Shapes; 12 | 13 | namespace WindChart.Lesson7 14 | { 15 | /// 16 | /// Interaction logic for MainWindow.xaml 17 | /// 18 | public partial class MainWindow : Window 19 | { 20 | public MainWindow() 21 | { 22 | InitializeComponent(); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson7/WindChart.Lesson7.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson8/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson8/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson8 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson8/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/BilibiliTutorial/WindChart.Lesson8/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson8 10 | { 11 | public class MainViewModel : INotifyPropertyChanged 12 | { 13 | public event PropertyChangedEventHandler PropertyChanged; 14 | 15 | public MainViewModel() 16 | { 17 | LinePoints = new ObservableCollection(); 18 | 19 | 20 | // 模拟 21 | Task.Delay(1000).ContinueWith((Action)(t => 22 | { 23 | 24 | Application.Current.Dispatcher.Invoke(() => 25 | { 26 | LinePoints = new ObservableCollection(); 27 | }); 28 | 29 | double x = 0; 30 | double y = 0; 31 | 32 | Random random = new Random(); 33 | 34 | y = 50; 35 | 36 | 37 | // while (true) 38 | { 39 | List points = new List(); 40 | while (true) 41 | { 42 | 43 | Application.Current.Dispatcher.Invoke((Action)(() => 44 | { 45 | points.Add(new Point(x, y)); 46 | })); 47 | 48 | x++; 49 | y = random.Next() % 2 == 0 ? ++y : --y; 50 | 51 | Application.Current.Dispatcher.Invoke(() => 52 | { 53 | LinePoints = new ObservableCollection(points); 54 | }); 55 | 56 | Thread.Sleep(20); 57 | 58 | } 59 | Application.Current.Dispatcher.Invoke(() => 60 | { 61 | LinePoints = new ObservableCollection(points); 62 | x = 0; 63 | y = 50; 64 | }); 65 | 66 | Thread.Sleep(2000); 67 | } 68 | 69 | })); 70 | 71 | 72 | 73 | } 74 | 75 | private Boolean isGraph; 76 | 77 | public Boolean IsGraph 78 | { 79 | get { return isGraph; } 80 | set 81 | { 82 | isGraph = value; 83 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsGraph))); 84 | } 85 | } 86 | 87 | private ObservableCollection linePoints; 88 | 89 | public ObservableCollection LinePoints 90 | { 91 | get { return linePoints; } 92 | set 93 | { 94 | linePoints = value; 95 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LinePoints))); 96 | } 97 | } 98 | 99 | 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson8/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson8/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson8 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson8/WindChart.Lesson8.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson9/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson9/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson9 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson9/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/BilibiliTutorial/WindChart.Lesson9/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.Lesson9 10 | { 11 | public class MainViewModel : INotifyPropertyChanged 12 | { 13 | public event PropertyChangedEventHandler PropertyChanged; 14 | 15 | public MainViewModel() 16 | { 17 | LinePoints = new ObservableCollection(); 18 | 19 | 20 | // 模拟 21 | Task.Delay(1000).ContinueWith((Action)(t => 22 | { 23 | 24 | Application.Current.Dispatcher.Invoke(() => 25 | { 26 | LinePoints = new ObservableCollection(); 27 | }); 28 | 29 | double x = 0; 30 | double y = 0; 31 | 32 | Random random = new Random(); 33 | 34 | y = 50; 35 | 36 | 37 | // while (true) 38 | { 39 | List points = new List(); 40 | while (true) 41 | { 42 | 43 | Application.Current.Dispatcher.Invoke((Action)(() => 44 | { 45 | points.Add(new Point(x, y)); 46 | })); 47 | 48 | x++; 49 | y = random.Next() % 2 == 0 ? ++y : --y; 50 | 51 | Application.Current.Dispatcher.Invoke(() => 52 | { 53 | LinePoints = new ObservableCollection(points); 54 | }); 55 | 56 | Thread.Sleep(20); 57 | 58 | } 59 | Application.Current.Dispatcher.Invoke(() => 60 | { 61 | LinePoints = new ObservableCollection(points); 62 | x = 0; 63 | y = 50; 64 | }); 65 | 66 | Thread.Sleep(2000); 67 | } 68 | 69 | })); 70 | 71 | 72 | 73 | } 74 | 75 | private Boolean isGraph; 76 | 77 | public Boolean IsGraph 78 | { 79 | get { return isGraph; } 80 | set 81 | { 82 | isGraph = value; 83 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsGraph))); 84 | } 85 | } 86 | 87 | private ObservableCollection linePoints; 88 | 89 | public ObservableCollection LinePoints 90 | { 91 | get { return linePoints; } 92 | set 93 | { 94 | linePoints = value; 95 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LinePoints))); 96 | } 97 | } 98 | 99 | 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson9/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson9/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.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.Lesson9 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart.Lesson9/WindChart.Lesson9.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart/BarGram.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace WindChart 6 | { 7 | 8 | public class BarGram : Gram 9 | { 10 | private DrawingVisual barVisual; 11 | 12 | public BarGram() 13 | { 14 | barVisual = new DrawingVisual(); 15 | _children.Add(barVisual); 16 | 17 | XMin = 0; 18 | YMin = 0; 19 | YMax = 100; 20 | XMax = 200; 21 | NeedXAxisText = false; 22 | NeedXAxisLine = false; 23 | DrawAxis(); 24 | } 25 | 26 | 27 | public void Draw(List bars) 28 | { 29 | _bars = bars; 30 | Draw(); 31 | } 32 | 33 | public bool NeedInternal { get; set; } = true; 34 | 35 | public BarDirection Direction { get; set; } = BarDirection.Horizontal; 36 | 37 | private List _bars = new List(); 38 | 39 | private void Draw() 40 | { 41 | switch (Direction) 42 | { 43 | case BarDirection.Vertical: 44 | NeedXAxisText = false; 45 | NeedXAxisLine = false; 46 | NeedYAxisLine = true; 47 | NeedYAxisText = true; 48 | DrawAxis(); 49 | 50 | DrawVertical(); 51 | break; 52 | case BarDirection.Horizontal: 53 | NeedXAxisText = true; 54 | NeedXAxisLine = true; 55 | NeedYAxisLine = false; 56 | NeedYAxisText = false; 57 | DrawAxis(); 58 | 59 | DrawHorizontal(); 60 | break; 61 | default: 62 | break; 63 | } 64 | } 65 | 66 | 67 | 68 | private void DrawVertical() 69 | { 70 | this.Dispatcher.Invoke(() => 71 | { 72 | var dc = barVisual.RenderOpen(); 73 | 74 | if (_bars.Count > 0) 75 | { 76 | double barWidth = RenderSize.Width / _bars.Count; 77 | double barLocation = 0; 78 | 79 | if (NeedInternal) 80 | { 81 | barWidth = barWidth / 2; 82 | barLocation = barWidth / 2; 83 | } 84 | 85 | for (int i = 0; i < _bars.Count; i++) 86 | { 87 | var item = _bars[i]; 88 | 89 | 90 | var barHeight = ConvertYToPixcel(item.Value); 91 | 92 | dc.DrawRectangle(item.Fill, null, new System.Windows.Rect(barLocation, barHeight, barWidth, RenderSize.Height - barHeight)); 93 | 94 | 95 | FormattedText text = new FormattedText(item.Value.ToString(), 96 | System.Globalization.CultureInfo.CurrentCulture, 97 | System.Windows.FlowDirection.LeftToRight, 98 | new Typeface("Microsoft Yahei"), 99 | 12, 100 | item.Fill, VisualTreeHelper.GetDpi(this).PixelsPerDip); 101 | 102 | var x = barLocation + barWidth / 2 - text.Width / 2; 103 | dc.DrawText(text, new System.Windows.Point(x, barHeight - text.Height)); 104 | 105 | 106 | FormattedText label = new FormattedText(item.Label.ToString(), 107 | System.Globalization.CultureInfo.CurrentCulture, 108 | System.Windows.FlowDirection.LeftToRight, 109 | new Typeface("Microsoft Yahei"), 110 | 12, 111 | Brushes.Black, VisualTreeHelper.GetDpi(this).PixelsPerDip); 112 | 113 | x = barLocation + barWidth / 2 - label.Width / 2; 114 | dc.DrawText(label, new System.Windows.Point(x, RenderSize.Height)); 115 | 116 | 117 | 118 | barLocation += barWidth; 119 | if (NeedInternal) 120 | { 121 | barLocation += barWidth; 122 | } 123 | } 124 | } 125 | 126 | dc.Close(); 127 | }); 128 | } 129 | 130 | 131 | /// 132 | /// 绘制水平 133 | /// 134 | private void DrawHorizontal() 135 | { 136 | this.Dispatcher.Invoke(() => 137 | { 138 | var dc = barVisual.RenderOpen(); 139 | 140 | if (_bars.Count > 0) 141 | { 142 | double barHeight = RenderSize.Height / _bars.Count; 143 | double barLocation = 0; 144 | 145 | if (NeedInternal) 146 | { 147 | barHeight = barHeight / 2; 148 | barLocation = barHeight / 2; 149 | } 150 | 151 | for (int i = 0; i < _bars.Count; i++) 152 | { 153 | var item = _bars[i]; 154 | 155 | 156 | var barWidth = ConvertXToPixcel(item.Value); 157 | 158 | dc.DrawRectangle(item.Fill, new Pen(Brushes.Black, 1), new System.Windows.Rect(0, barLocation, barWidth, barHeight)); 159 | 160 | 161 | FormattedText text = new FormattedText(item.Value.ToString(), 162 | System.Globalization.CultureInfo.CurrentCulture, 163 | System.Windows.FlowDirection.LeftToRight, 164 | new Typeface("Microsoft Yahei"), 165 | 12, 166 | item.Fill, VisualTreeHelper.GetDpi(this).PixelsPerDip); 167 | double y = barLocation + barHeight / 2 - text.Height / 2; 168 | dc.DrawText(text, new System.Windows.Point(barWidth, y)); 169 | 170 | 171 | FormattedText label = new FormattedText(item.Label.ToString(), 172 | System.Globalization.CultureInfo.CurrentCulture, 173 | System.Windows.FlowDirection.LeftToRight, 174 | new Typeface("Microsoft Yahei"), 175 | 12, 176 | Brushes.Black, VisualTreeHelper.GetDpi(this).PixelsPerDip); 177 | 178 | 179 | dc.DrawText(label, new System.Windows.Point(0 - label.Width, y)); 180 | 181 | barLocation += barHeight; 182 | if (NeedInternal) 183 | { 184 | barLocation += barHeight; 185 | } 186 | } 187 | } 188 | 189 | dc.Close(); 190 | }); 191 | } 192 | 193 | protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) 194 | { 195 | base.OnRenderSizeChanged(sizeInfo); 196 | Draw(); 197 | } 198 | 199 | } 200 | 201 | 202 | public enum BarDirection 203 | { 204 | Vertical, 205 | Horizontal 206 | } 207 | 208 | 209 | /// 210 | /// 条形 211 | /// 212 | public class Bar 213 | { 214 | /// 215 | /// 标签 216 | /// 217 | public string Label { get; set; } 218 | 219 | private double _value; 220 | /// 221 | /// 值 222 | /// 223 | public double Value 224 | { 225 | get { return _value; } 226 | set 227 | { 228 | _value = value; 229 | } 230 | } 231 | /// 232 | /// 填充颜色 233 | /// 234 | public Brush Fill { get; set; } = Brushes.CornflowerBlue; 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart/Gram.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace WindChart 6 | { 7 | public class Gram : FrameworkElement 8 | { 9 | protected VisualCollection _children; 10 | 11 | public Gram() 12 | { 13 | _children = new VisualCollection(this); 14 | 15 | xAxisVisual = new DrawingVisual(); 16 | _children.Add(xAxisVisual); 17 | yAxisVisual = new DrawingVisual(); 18 | _children.Add(yAxisVisual); 19 | } 20 | 21 | private DrawingVisual xAxisVisual; 22 | private DrawingVisual yAxisVisual; 23 | 24 | 25 | /// 26 | /// 获取X轴刻度上的文本格式化 27 | /// 28 | protected Func GetXAxisTextFormat = new Func(oaDatetime => oaDatetime.ToString()); 29 | 30 | 31 | /// 32 | /// 绘制原点 33 | /// 34 | protected void DrawAxis() 35 | { 36 | DrawXAxis(); 37 | DrawYAxis(); 38 | } 39 | 40 | 41 | public int XAxisScaleCount { get; set; } = 10; 42 | public int YAxisScaleCount { get; set; } = 10; 43 | 44 | public Boolean NeedXAxisLine { get; set; } = true; 45 | public Boolean NeedXAxisText { get; set; } = true; 46 | 47 | 48 | public Boolean NeedYAxisLine { get; set; } = true; 49 | public Boolean NeedYAxisText { get; set; } = true; 50 | 51 | /// 52 | /// 绘制原点 53 | /// 54 | protected void DrawXAxis() 55 | { 56 | this.Dispatcher.Invoke(() => 57 | { 58 | var drawingContext = xAxisVisual.RenderOpen(); 59 | 60 | Point org = new Point(0, 0); 61 | ConvertToPixcel(ref org); 62 | drawingContext.DrawEllipse(Brushes.Black, new Pen(Brushes.OrangeRed, 1), org, 5, 5); 63 | 64 | Pen pen = new Pen(Brushes.Black, 1); 65 | // X轴 66 | Point xStart = new Point(XMin, 0); 67 | Point xEnd = new Point(XMax, 0); 68 | ConvertToPixcel(ref xStart); 69 | ConvertToPixcel(ref xEnd); 70 | drawingContext.DrawLine(pen, xStart, xEnd); 71 | int interval = (int)(XWidth / XAxisScaleCount); 72 | for (double i = XMin; i <= XMax; i += interval) 73 | { 74 | Point xPstart = new Point(i, 0); 75 | ConvertToPixcel(ref xPstart); 76 | 77 | if (NeedXAxisLine) 78 | { 79 | Point xPend = new Point(xPstart.X, xPstart.Y - 5); 80 | drawingContext.DrawLine(pen, xPstart, xPend); 81 | } 82 | 83 | if (NeedXAxisText) 84 | { 85 | FormattedText text = new FormattedText(GetXAxisTextFormat.Invoke(i), 86 | System.Globalization.CultureInfo.CurrentCulture, 87 | FlowDirection.LeftToRight, 88 | new Typeface("Microsoft Yahei"), 89 | 12, 90 | Brushes.Black, VisualTreeHelper.GetDpi(this).PixelsPerDip); 91 | 92 | Point loca = new Point(xPstart.X - text.Width / 2, xPstart.Y); 93 | drawingContext.DrawText(text, loca); 94 | } 95 | } 96 | 97 | drawingContext.Close(); 98 | }); 99 | } 100 | 101 | 102 | 103 | /// 104 | /// 绘制原点 105 | /// 106 | protected void DrawYAxis() 107 | { 108 | this.Dispatcher.Invoke(() => 109 | { 110 | var drawingContext = yAxisVisual.RenderOpen(); 111 | 112 | Point org = new Point(0, 0); 113 | ConvertToPixcel(ref org); 114 | drawingContext.DrawEllipse(Brushes.Black, new Pen(Brushes.OrangeRed, 1), org, 5, 5); 115 | 116 | Pen pen = new Pen(Brushes.Black, 1); 117 | // Y轴 118 | Point yStart = new Point(XMin, YMin); 119 | Point yEnd = new Point(XMin, YMax); 120 | ConvertToPixcel(ref yStart); 121 | ConvertToPixcel(ref yEnd); 122 | drawingContext.DrawLine(pen, yStart, yEnd); 123 | var interval = (int)(YHeight / YAxisScaleCount); 124 | for (double i = YMin; i <= YMax; i += interval) 125 | { 126 | Point yPstart = new Point(XMin, i); 127 | ConvertToPixcel(ref yPstart); 128 | if (NeedYAxisLine) 129 | { 130 | Point yPend = new Point(yPstart.X + 5, yPstart.Y); 131 | drawingContext.DrawLine(pen, yPstart, yPend); 132 | } 133 | 134 | if (NeedYAxisText) 135 | { 136 | FormattedText text = new FormattedText(i.ToString(), 137 | System.Globalization.CultureInfo.CurrentCulture, 138 | FlowDirection.LeftToRight, 139 | new Typeface("Microsoft Yahei"), 140 | 12, 141 | Brushes.Black, VisualTreeHelper.GetDpi(this).PixelsPerDip); 142 | 143 | Point loca = new Point(yPstart.X - text.Width - 2, yPstart.Y - text.Height / 2); 144 | drawingContext.DrawText(text, loca); 145 | } 146 | } 147 | 148 | drawingContext.Close(); 149 | }); 150 | } 151 | 152 | 153 | #region 场景大小 154 | 155 | /// 156 | /// Y轴最小值 157 | /// 158 | public double YMin { get; set; } = -100; 159 | /// 160 | /// Y轴最大值 161 | /// 162 | public double YMax { get; set; } = 100; 163 | /// 164 | /// X轴最小值 165 | /// 166 | public double XMin { get; set; } = -100; 167 | /// 168 | /// X轴最大值 169 | /// 170 | public double XMax { get; set; } = 100; 171 | 172 | protected double XWidth => XMax - XMin; 173 | protected double YHeight => YMax - YMin; 174 | 175 | #endregion 176 | 177 | #region 像素比 178 | 179 | public double xPixelRatio => RenderSize.Width / XWidth; 180 | public double yPixelRatio => RenderSize.Height / YHeight; 181 | 182 | #endregion 183 | 184 | #region 坐标点转换 185 | 186 | public double ConvertYToPixcel(double y) 187 | { 188 | double distY = y - YMin; 189 | return RenderSize.Height - distY * yPixelRatio; 190 | } 191 | 192 | public double ConvertXToPixcel(double x) 193 | { 194 | double distX = x - XMin; 195 | return distX * xPixelRatio; 196 | } 197 | 198 | public Point ConvertToPixcel(ref Point p) 199 | { 200 | p.X = ConvertXToPixcel((double)p.X); 201 | p.Y = ConvertYToPixcel((double)p.Y); 202 | return p; 203 | } 204 | 205 | public Point ConvertToPixcel(Point p) 206 | { 207 | p.X = ConvertXToPixcel((double)p.X); 208 | p.Y = ConvertYToPixcel((double)p.Y); 209 | return p; 210 | } 211 | 212 | #endregion 213 | 214 | protected override int VisualChildrenCount 215 | { 216 | get { return _children.Count; } 217 | } 218 | 219 | protected override Visual GetVisualChild(int index) 220 | { 221 | if (index < 0 || index >= _children.Count) 222 | { 223 | throw new ArgumentOutOfRangeException(); 224 | } 225 | 226 | return _children[index]; 227 | } 228 | 229 | protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) 230 | { 231 | base.OnRenderSizeChanged(sizeInfo); 232 | DrawAxis(); 233 | } 234 | 235 | protected override void OnRender(DrawingContext drawingContext) 236 | { 237 | base.OnRender(drawingContext); 238 | drawingContext.DrawRectangle(Brushes.White, null, new Rect(0, 0, RenderSize.Width, RenderSize.Height)); 239 | } 240 | 241 | } 242 | 243 | } 244 | -------------------------------------------------------------------------------- /src/BilibiliTutorial/WindChart/WindChart.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | true 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Melphi220603.WeChart.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32505.173 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart", "WindChart\WindChart.csproj", "{99F53915-EFDD-4348-9220-80305B6A5C40}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{EBE9CDCD-BE95-43CE-801A-A604BD982C4E}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindChart.ApplyDemo", "Samples\WindChart.ApplyDemo\WindChart.ApplyDemo.csproj", "{36FD1AB4-E94A-4139-BEF4-EA51C501B87F}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeiMvvm", "Samples\MeiMvvm\MeiMvvm.csproj", "{0F7F449E-508E-4D6E-8B4A-7CA6332A4413}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {99F53915-EFDD-4348-9220-80305B6A5C40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {99F53915-EFDD-4348-9220-80305B6A5C40}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {99F53915-EFDD-4348-9220-80305B6A5C40}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {99F53915-EFDD-4348-9220-80305B6A5C40}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {36FD1AB4-E94A-4139-BEF4-EA51C501B87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {36FD1AB4-E94A-4139-BEF4-EA51C501B87F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {36FD1AB4-E94A-4139-BEF4-EA51C501B87F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {36FD1AB4-E94A-4139-BEF4-EA51C501B87F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {0F7F449E-508E-4D6E-8B4A-7CA6332A4413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {0F7F449E-508E-4D6E-8B4A-7CA6332A4413}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {0F7F449E-508E-4D6E-8B4A-7CA6332A4413}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {0F7F449E-508E-4D6E-8B4A-7CA6332A4413}.Release|Any CPU.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(NestedProjects) = preSolution 37 | {36FD1AB4-E94A-4139-BEF4-EA51C501B87F} = {EBE9CDCD-BE95-43CE-801A-A604BD982C4E} 38 | {0F7F449E-508E-4D6E-8B4A-7CA6332A4413} = {EBE9CDCD-BE95-43CE-801A-A604BD982C4E} 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {7AB67895-0A79-4337-B8A1-E4F4C0592F31} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/Binder.cs: -------------------------------------------------------------------------------- 1 | using Ninject.Modules; 2 | using System.Collections.Generic; 3 | 4 | namespace MeiMvvm 5 | { 6 | 7 | public class Binder : NinjectModule, IBinder 8 | { 9 | private readonly IModule module; 10 | 11 | public Binder(IModule module) 12 | { 13 | this.module = module; 14 | } 15 | 16 | /// 17 | /// Binding of singleton type. 18 | /// 19 | /// The singleton type 20 | public void BindSingleton() 21 | { 22 | Bind().ToSelf().InSingletonScope(); 23 | } 24 | 25 | /// 26 | /// Binding a specified implementation type to the service interface it inherits. 27 | /// 28 | /// the specified service type (generally it's an Interface) 29 | /// the specified implementation type (generally it inherits from the specified service) 30 | /// 31 | public void Bind(bool singleton = true) where TTarget : TFrom 32 | { 33 | var binding = Bind().To(); 34 | 35 | if (singleton) 36 | binding.InSingletonScope(); 37 | } 38 | 39 | /// 40 | /// Gets an instance of the specified service 41 | /// 42 | /// The service to resolve 43 | /// An instance of the service 44 | public T Get() => ServiceProvider.Get(); 45 | 46 | public override void Load() 47 | { 48 | module.OnLoad(this); 49 | } 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/ExpressionHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace MeiMvvm 8 | { 9 | 10 | /// 11 | /// A helper for expressions 12 | /// 13 | public static class ExpressionHelpers 14 | { 15 | /// 16 | /// Compiles an expression and gets the functions return value 17 | /// 18 | /// The type of return value 19 | /// The expression to compile 20 | /// 21 | public static T GetPropertyValue(this Expression> lambda) 22 | { 23 | return lambda.Compile().Invoke(); 24 | } 25 | 26 | /// 27 | /// Sets the underlying properties value to the given value 28 | /// from an expression that contains the property 29 | /// 30 | /// The type of value to set 31 | /// The expression 32 | /// The value to set the property to 33 | public static void SetPropertyValue(this Expression> lambda, T value) 34 | { 35 | // Converts a lambda () => some.Property, to some.Property 36 | var expression = (lambda as LambdaExpression).Body as MemberExpression; 37 | 38 | // Get the property information so we can set it 39 | var propertyInfo = (PropertyInfo)expression.Member; 40 | var target = System.Linq.Expressions.Expression.Lambda(expression.Expression).Compile().DynamicInvoke(); 41 | 42 | // Set the property value 43 | propertyInfo.SetValue(target, value); 44 | } 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/IBinder.cs: -------------------------------------------------------------------------------- 1 | namespace MeiMvvm 2 | { 3 | 4 | public interface IBinder 5 | { 6 | /// 7 | /// Binding of singleton type. 8 | /// 9 | /// The singleton type 10 | void BindSingleton(); 11 | 12 | /// 13 | /// Binding a specified implementation type to the service interface it inherits. 14 | /// 15 | /// the specified service type (generally it's an Interface) 16 | /// the specified implementation type (generally it inherits from the specified service) 17 | /// 18 | void Bind(bool Singleton = true) where TTarget : TFrom; 19 | 20 | /// 21 | /// Gets an instance of the specified service 22 | /// 23 | /// The service to resolve 24 | /// An instance of the service 25 | T Get(); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/IModule.cs: -------------------------------------------------------------------------------- 1 | namespace MeiMvvm 2 | { 3 | /// 4 | /// The module will register into kernel 5 | /// 6 | public interface IModule 7 | { 8 | void OnLoad(IBinder binder); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/MeiMvvm.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/NotifyPropertyChanged.cs: -------------------------------------------------------------------------------- 1 | #region MeiMvvm 2 | // The base class of WPF desktop software products power by melphily 3 | #endregion 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.ComponentModel; 8 | using System.Linq.Expressions; 9 | using System.Runtime.CompilerServices; 10 | using System.Threading.Tasks; 11 | 12 | namespace MeiMvvm 13 | { 14 | /// 15 | /// A base class for objects of which the properties must be observable. 16 | /// 17 | public abstract class NotifyPropertyChanged : INotifyPropertyChanged 18 | { 19 | /// 20 | /// Occurs after a property value changes. 21 | /// 22 | public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { }; 23 | 24 | /// 25 | /// Verifies that a property name exists in this ViewModel. 26 | /// This method can be called before the property is used, for instance before calling RaisePropertyChanged. 27 | /// It avoids errors when a property name is changed but some places are missed. 28 | /// 29 | /// (optional) The name of the property that changed. 30 | protected void RaisePropertyChanged(string propertyName) 31 | { 32 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 33 | } 34 | 35 | /// 36 | /// Assigns a new value to the property. 37 | /// Then, raises the PropertyChanged event if needed. 38 | /// 39 | /// The type of the property that changed. 40 | /// The field storing the property's value. 41 | /// The property's value after the change occurred. 42 | /// (optional) The name of the property that changed. 43 | /// 44 | protected bool Set(ref T field, T Value, [CallerMemberName] string PropertyName = null) 45 | { 46 | if (EqualityComparer.Default.Equals(field, Value)) 47 | return false; 48 | 49 | field = Value; 50 | 51 | RaisePropertyChanged(PropertyName); 52 | 53 | return true; 54 | } 55 | 56 | /// 57 | /// Raises the PropertyChanged event if needed. 58 | /// 59 | /// (optional) The name of the property that changed. 60 | public void OnPropertyChanged([CallerMemberName] string propertyName = null) 61 | { 62 | RaisePropertyChanged(propertyName); 63 | } 64 | 65 | /// 66 | /// Raises all of propertys PropertyChanged event if needed. 67 | /// 68 | protected void RaiseAllChanged() 69 | { 70 | RaisePropertyChanged(""); 71 | } 72 | 73 | protected object mPropertyValueCheckLock = new object(); 74 | 75 | protected async Task RunCommandAsync(Expression> updatingFlag, Func action) 76 | { 77 | // Lock to ensure single access to check 78 | lock (mPropertyValueCheckLock) 79 | { 80 | // Check if the flag property is true (meaning the function is already running) 81 | if (updatingFlag.GetPropertyValue()) 82 | return; 83 | 84 | // Set the property flag to true to indicate we are running 85 | updatingFlag.SetPropertyValue(true); 86 | } 87 | 88 | try 89 | { 90 | // Run the passed in action 91 | await action(); 92 | } 93 | finally 94 | { 95 | // Set the property flag back to false now it's finished 96 | updatingFlag.SetPropertyValue(false); 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/Samples/MeiMvvm/ServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using Ninject; 2 | using Ninject.Modules; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace MeiMvvm 8 | { 9 | public class ServiceProvider 10 | { 11 | static IKernel Kernel { get; } = new StandardKernel(); 12 | 13 | 14 | public static void LoadModule(IModule module) 15 | { 16 | Kernel.Load(new Binder(module)); 17 | } 18 | public static T Get() => Kernel.Get(); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/App.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 | 26 | 27 | 38 | 39 | 43 | 44 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WindChart.ApplyDemo 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | protected override void OnStartup(StartupEventArgs e) 17 | { 18 | base.OnStartup(e); 19 | MeiMvvm.ServiceProvider.LoadModule(new Data.MainModule()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/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/Samples/WindChart.ApplyDemo/Data/MainModule.cs: -------------------------------------------------------------------------------- 1 | using MeiMvvm; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using WindChart.ApplyDemo.PageModels; 8 | 9 | namespace WindChart.ApplyDemo.Data 10 | { 11 | internal class MainModule : IModule 12 | { 13 | public void OnLoad(IBinder binder) 14 | { 15 | binder.BindSingleton(); 16 | binder.BindSingleton(); 17 | binder.BindSingleton(); 18 | binder.BindSingleton(); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Data/ServiceLocator.cs: -------------------------------------------------------------------------------- 1 | using MeiMvvm; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using WindChart.ApplyDemo.PageModels; 8 | 9 | namespace WindChart.ApplyDemo.Data 10 | { 11 | internal class ServiceLocator 12 | { 13 | public WelcomePageModel WelcomePageModel => ServiceProvider.Get(); 14 | public LinegramPageModel LinegramPageModel => ServiceProvider.Get(); 15 | public BargramPageModel BargramPageModel => ServiceProvider.Get(); 16 | public DotgramPageModel DotgramPageModel => ServiceProvider.Get(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/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.Controls.Primitives; 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 WindChart.ApplyDemo 18 | { 19 | /// 20 | /// Interaction logic for MainWindow.xaml 21 | /// 22 | public partial class MainWindow : Window 23 | { 24 | public MainWindow() 25 | { 26 | InitializeComponent(); 27 | } 28 | 29 | private void NaviClick(object sender, RoutedEventArgs e) 30 | { 31 | var el = (ToggleButton)sender; 32 | if (el.IsChecked == true) 33 | { 34 | var att = el.Tag.ToString(); 35 | if (att != null) 36 | { 37 | frame.Navigate(new Uri(att, UriKind.Relative)); 38 | } 39 | else 40 | { 41 | frame.Content = null; 42 | } 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/PageModels/BargramPageModel.cs: -------------------------------------------------------------------------------- 1 | using MeiMvvm; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows.Media; 8 | 9 | namespace WindChart.ApplyDemo.PageModels 10 | { 11 | internal class BargramPageModel : NotifyPropertyChanged 12 | { 13 | private readonly Random random = new Random(); 14 | 15 | private ObservableCollection bars = new ObservableCollection(); 16 | 17 | public ObservableCollection Bars 18 | { 19 | get { return bars; } 20 | set { Set(ref bars, value); } 21 | } 22 | 23 | public BargramPageModel() 24 | { 25 | var lis = new List() { 26 | new Bar() {Value = 8, Label= "Sunday" }, 27 | new Bar() {Value = 7.5, Label= "Monday"}, 28 | new Bar() {Value = 8.6, Label = "Tuesday"}, 29 | new Bar() {Value = 8.2, Label = "Wednesday"}, 30 | new Bar() {Value = 7.6, Label = "Thursday"}, 31 | new Bar() {Value = 7.1, Label = "Friday"}, 32 | new Bar() {Value = 7.1, Label = "Saturday" } }; 33 | Bars = new ObservableCollection(lis); 34 | 35 | ValueLabelBrush = Brushes.Black; 36 | BarBorderBrush = Brushes.Black; 37 | } 38 | 39 | 40 | 41 | private bool needInterval = true; 42 | 43 | public bool NeedInterval 44 | { 45 | get { return needInterval; } 46 | set { Set(ref needInterval, value); } 47 | } 48 | 49 | private BarDirection direction = BarDirection.Vertical; 50 | 51 | public BarDirection Direction 52 | { 53 | get { return direction; } 54 | set { Set(ref direction, value); } 55 | } 56 | 57 | private BarValueLocation valueLabelLocation = BarValueLocation.Follow; 58 | 59 | public BarValueLocation ValueLabelLocation 60 | { 61 | get { return valueLabelLocation; } 62 | set { Set(ref valueLabelLocation, value); } 63 | } 64 | 65 | private Brush valueLabelBrush; 66 | 67 | public Brush ValueLabelBrush 68 | { 69 | get { return valueLabelBrush; } 70 | set { Set(ref valueLabelBrush, value); } 71 | } 72 | 73 | private Brush barBorderBrush; 74 | public Brush BarBorderBrush 75 | { 76 | get { return barBorderBrush; } 77 | set { Set(ref barBorderBrush, value); } 78 | } 79 | 80 | 81 | 82 | private bool isSimulating = false; 83 | /// 84 | /// 是否处于模拟状态 85 | /// 86 | public bool IsSimulating 87 | { 88 | get { return isSimulating; } 89 | set 90 | { 91 | Set(ref isSimulating, value); 92 | RaisePropertyChanged(nameof(CanSimulate)); 93 | } 94 | } 95 | /// 96 | /// 是否可以再次模拟 97 | /// 98 | public bool CanSimulate => !IsSimulating; 99 | 100 | private int sleepTime = 0; 101 | /// 102 | /// 模拟,点与点绘制间隔时间 103 | /// 单位毫秒 104 | /// 105 | public int SleepTime 106 | { 107 | get { return sleepTime; } 108 | set { Set(ref sleepTime, value); } 109 | } 110 | /// 111 | /// 数据模拟 112 | /// 113 | public RelayCommand SimulateCommand => new RelayCommand(Simulate); 114 | 115 | /// 116 | /// 数据模拟 117 | /// 118 | private void Simulate() 119 | { 120 | if (IsSimulating) 121 | { 122 | IsSimulating = false; 123 | return; 124 | } 125 | IsSimulating = true; 126 | var lis = new List() { 127 | new Bar() {Value = 8, Label= "Sunday" }, 128 | new Bar() {Value = 7.5, Label= "Monday"}, 129 | new Bar() {Value = 8.6, Label = "Tuesday"}, 130 | new Bar() {Value = 8.2, Label = "Wednesday"}, 131 | new Bar() {Value = 7.6, Label = "Thursday"}, 132 | new Bar() {Value = 7.1, Label = "Friday"}, 133 | new Bar() {Value = 7.1, Label = "Saturday" } }; 134 | Bars = new ObservableCollection(lis); 135 | Task.Delay(10).ContinueWith(t => 136 | { 137 | 138 | while (IsSimulating) 139 | { 140 | foreach (var item in lis) 141 | { 142 | var baseValue = random.Next(6, 9); 143 | item.Value = Math.Round(baseValue % 2 == 0 ? baseValue + random.NextDouble() : baseValue - random.NextDouble(), 1); 144 | 145 | if (item.Value < 7.5) 146 | { 147 | item.Fill = Brushes.OrangeRed; 148 | } 149 | else 150 | { 151 | item.Fill = Brushes.CornflowerBlue; 152 | } 153 | } 154 | 155 | if (SleepTime > 0) 156 | { 157 | // 延迟效果 158 | Thread.Sleep(SleepTime); 159 | } 160 | 161 | Bars = new ObservableCollection(lis); 162 | } 163 | 164 | IsSimulating = false; 165 | }); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/PageModels/DotgramPageModel.cs: -------------------------------------------------------------------------------- 1 | using MeiMvvm; 2 | using System; 3 | using System.Collections.ObjectModel; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace WindChart.ApplyDemo.PageModels 9 | { 10 | /// 11 | /// 单线图示例页面数据模型 12 | /// 13 | public class DotgramPageModel : NotifyPropertyChanged 14 | { 15 | private readonly Random random = new Random(); 16 | 17 | public DotgramPageModel() 18 | { 19 | DotSource = new ObservableCollection(); 20 | FlashFrame(); 21 | } 22 | 23 | private bool isUpdatedDot; 24 | 25 | public bool IsUpdatedDot 26 | { 27 | get { return isUpdatedDot; } 28 | set { Set(ref isUpdatedDot, value); } 29 | } 30 | 31 | 32 | 33 | private ObservableCollection dotSource = new ObservableCollection(); 34 | /// 35 | /// 线点数据 36 | /// 37 | public ObservableCollection DotSource 38 | { 39 | get { return dotSource; } 40 | set { Set(ref dotSource, value); } 41 | } 42 | 43 | 44 | private bool isSimulating = false; 45 | /// 46 | /// 是否处于模拟状态 47 | /// 48 | public bool IsSimulating 49 | { 50 | get { return isSimulating; } 51 | set 52 | { 53 | Set(ref isSimulating, value); 54 | RaisePropertyChanged(nameof(CanSimulate)); 55 | } 56 | } 57 | /// 58 | /// 是否可以再次模拟 59 | /// 60 | public bool CanSimulate => !IsSimulating; 61 | 62 | private int sleepTime = 1000; 63 | /// 64 | /// 模拟,点与点绘制间隔时间 65 | /// 单位毫秒 66 | /// 67 | public int SleepTime 68 | { 69 | get { return sleepTime; } 70 | set { Set(ref sleepTime, value); } 71 | } 72 | 73 | /// 74 | /// 数据模拟 75 | /// 76 | public RelayCommand SimulateCommand => new RelayCommand(Simulate); 77 | 78 | /// 79 | /// 数据模拟 80 | /// 81 | private void Simulate() 82 | { 83 | if (IsSimulating) 84 | { 85 | IsSimulating = false; 86 | return; 87 | } 88 | IsSimulating = true; 89 | DotSource = new ObservableCollection(); 90 | 91 | Task.Delay(10).ContinueWith(t => 92 | { 93 | while (IsSimulating) 94 | { 95 | FlashFrame(); 96 | Thread.Sleep(SleepTime); 97 | } 98 | IsSimulating = false; 99 | }); 100 | } 101 | 102 | 103 | private int dotCount = 40; 104 | 105 | public int DotCount 106 | { 107 | get { return dotCount; } 108 | set { Set(ref dotCount, value); } 109 | } 110 | 111 | private Double dotSize = 5; 112 | 113 | public Double DotSize 114 | { 115 | get { return dotSize; } 116 | set { Set(ref dotSize, value); } 117 | } 118 | 119 | private void FlashFrame() 120 | { 121 | double x = 0; 122 | double y = 0; 123 | 124 | int count = 0; 125 | var ss = new ObservableCollection(); 126 | while (count < DotCount) 127 | { 128 | y = random.Next(-50, 50); 129 | x = random.Next(-50, 50); 130 | var size = random.Next(1, (int)DotSize); 131 | ss.Add(new EllipseDot() { X = x, Y = y, Type = random.Next(0, 3), Height = size, Width = size }); 132 | 133 | count++; 134 | } 135 | DotSource = new ObservableCollection(ss); 136 | } 137 | 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/PageModels/LinegramPageModel.cs: -------------------------------------------------------------------------------- 1 | using MeiMvvm; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace WindChart.ApplyDemo.PageModels 11 | { 12 | /// 13 | /// 单线图示例页面数据模型 14 | /// 15 | public class LinegramPageModel : NotifyPropertyChanged 16 | { 17 | private readonly Random random = new Random(); 18 | 19 | public LinegramPageModel() 20 | { 21 | LinePoints = new ObservableCollection(); 22 | FillBrush = FillBrushes[6]; 23 | 24 | // 初始化 25 | double x = 0; 26 | double y = 0; 27 | List list = new List(); 28 | while (x < 100) 29 | { 30 | var ran = random.Next(-150, 150); 31 | 32 | if (ran > 0) 33 | { 34 | y -= Math.Abs(ran) / 10; 35 | } 36 | else 37 | { 38 | y += Math.Abs(ran) / 10; 39 | } 40 | var p = new Point(x, y); 41 | 42 | list.Add(p); 43 | x++; 44 | } 45 | LinePoints = new ObservableCollection(list); 46 | } 47 | 48 | private Boolean needAiming = true; 49 | /// 50 | /// 显示瞄点 51 | /// 52 | public Boolean NeedAiming 53 | { 54 | get { return needAiming; } 55 | set { Set(ref needAiming, value); } 56 | } 57 | 58 | private Boolean isAxisFollowData = true; 59 | /// 60 | /// 界面是否跟随数据(保留所有数据) 61 | /// 62 | public Boolean IsAxisFollowData 63 | { 64 | get { return isAxisFollowData; } 65 | set { Set(ref isAxisFollowData, value); } 66 | } 67 | 68 | private Boolean isFlashRange = false; 69 | /// 70 | /// 是否刷新最新最大范围 71 | /// 72 | public Boolean IsFlashRange 73 | { 74 | get { return isFlashRange; } 75 | set { Set(ref isFlashRange, value); } 76 | } 77 | 78 | private int flashRangePointCount = 200; 79 | /// 80 | /// 刷新范围点个数 81 | /// 82 | public int FlashRangePointCount 83 | { 84 | get { return flashRangePointCount; } 85 | set { Set(ref flashRangePointCount, value); } 86 | } 87 | 88 | 89 | private Boolean isXAxisTextDateTimeFormat; 90 | /// 91 | /// X轴刻度是否格式化成日期 92 | /// 93 | public Boolean IsXAxisTextDateTimeFormat 94 | { 95 | get { return isXAxisTextDateTimeFormat; } 96 | set { Set(ref isXAxisTextDateTimeFormat, value); } 97 | } 98 | 99 | private string xAxisTextFormat; 100 | /// 101 | /// X轴刻度日期格式化 字符 102 | /// 103 | public string XAxisTextFormat 104 | { 105 | get { return xAxisTextFormat; } 106 | set { Set(ref xAxisTextFormat, value); } 107 | } 108 | 109 | 110 | 111 | private Boolean isGraph = true; 112 | /// 113 | /// 是否是面积图 114 | /// 115 | public Boolean IsGraph 116 | { 117 | get { return isGraph; } 118 | set { Set(ref isGraph, value); } 119 | } 120 | 121 | private Brush lineBrush = Brushes.Black; 122 | /// 123 | /// 线颜色 124 | /// 125 | public Brush LineBrush 126 | { 127 | get { return lineBrush; } 128 | set { Set(ref lineBrush, value); } 129 | } 130 | 131 | private double lineThinkness = 1; 132 | /// 133 | /// 线宽 134 | /// 135 | public double LineThinkness 136 | { 137 | get { return lineThinkness; } 138 | set { Set(ref lineThinkness, value); } 139 | } 140 | 141 | private Brush fillBrush = Brushes.DarkSeaGreen; 142 | /// 143 | /// 填充颜色 144 | /// 145 | public Brush FillBrush 146 | { 147 | get { return fillBrush; } 148 | set { Set(ref fillBrush, value); } 149 | } 150 | /// 151 | /// 面积区域填充颜色选择项 152 | /// 153 | public List FillBrushes => new List() { Brushes.Black, Brushes.OrangeRed, Brushes.DarkSeaGreen, Brushes.CornflowerBlue, 154 | new LinearGradientBrush() { EndPoint = new Point(0, 1), 155 | GradientStops=new GradientStopCollection (){new GradientStop() { Color= Colors.OrangeRed, Offset=0} , 156 | new GradientStop() { Color= Color.FromArgb(0x40,0xFF,0x45,0x00), Offset=1} }}, 157 | new LinearGradientBrush() { EndPoint = new Point(0, 1), 158 | GradientStops=new GradientStopCollection (){new GradientStop() { Color= Colors.DarkSeaGreen, Offset=0} , 159 | new GradientStop() { Color= Color.FromArgb(0x40,0x8F,0xBC,0x8F), Offset=1} } }, 160 | new LinearGradientBrush() { EndPoint = new Point(0, 1), 161 | GradientStops=new GradientStopCollection (){new GradientStop() { Color= Colors.CornflowerBlue, Offset=0} , 162 | new GradientStop() { Color= Color.FromArgb(0x40,0x64,0x95,0xED), Offset=1} } } 163 | }; 164 | 165 | private ObservableCollection linePoints = new ObservableCollection(); 166 | /// 167 | /// 线点数据 168 | /// 169 | public ObservableCollection LinePoints 170 | { 171 | get { return linePoints; } 172 | set { Set(ref linePoints, value); } 173 | } 174 | 175 | private bool isSimulating = false; 176 | /// 177 | /// 是否处于模拟状态 178 | /// 179 | public bool IsSimulating 180 | { 181 | get { return isSimulating; } 182 | set 183 | { 184 | Set(ref isSimulating, value); 185 | RaisePropertyChanged(nameof(CanSimulate)); 186 | } 187 | } 188 | /// 189 | /// 是否可以再次模拟 190 | /// 191 | public bool CanSimulate => !IsSimulating; 192 | 193 | private int sleepTime = 30; 194 | /// 195 | /// 模拟,点与点绘制间隔时间 196 | /// 单位毫秒 197 | /// 198 | public int SleepTime 199 | { 200 | get { return sleepTime; } 201 | set { Set(ref sleepTime, value); } 202 | } 203 | 204 | /// 205 | /// 数据模拟 206 | /// 207 | public RelayCommand SimulateCommand => new RelayCommand(Simulate); 208 | 209 | /// 210 | /// 数据模拟 211 | /// 212 | private void Simulate() 213 | { 214 | if (IsSimulating) 215 | { 216 | IsSimulating = false; 217 | return; 218 | } 219 | IsSimulating = true; 220 | LinePoints = new ObservableCollection(); 221 | 222 | Task.Delay(10).ContinueWith(t => 223 | { 224 | double x = 0; 225 | double y = 0; 226 | List list = new List(); 227 | while (IsSimulating) 228 | { 229 | var ran = random.Next(-150, 150); 230 | 231 | if (ran > 0) 232 | { 233 | y -= Math.Abs(ran) / 10; 234 | } 235 | else 236 | { 237 | y += Math.Abs(ran) / 10; 238 | } 239 | var p = new Point(x, y); 240 | 241 | list.Add(p); 242 | if (SleepTime > 0) 243 | { 244 | LinePoints.Add(p); 245 | 246 | // 延迟效果 247 | Thread.Sleep(SleepTime); 248 | } 249 | 250 | x++; 251 | } 252 | 253 | IsSimulating = false; 254 | }); 255 | } 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/PageModels/WelcomePageModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Threading.Tasks; 5 | using System.Windows; 6 | using System.Windows.Media; 7 | 8 | namespace WindChart.ApplyDemo.PageModels 9 | { 10 | /// 11 | /// 欢迎页面数据模型 12 | /// 13 | internal class WelcomePageModel : MeiMvvm.NotifyPropertyChanged 14 | { 15 | private readonly Random random = new Random(); 16 | 17 | //private ObservableCollection linePoints = new ObservableCollection(); 18 | ///// 19 | ///// 单线图的点 20 | ///// 21 | //public ObservableCollection LinePoints 22 | //{ 23 | // get { return linePoints; } 24 | // set { Set(ref linePoints, value); } 25 | //} 26 | 27 | /// 28 | /// 单线图的点 29 | /// 30 | public ObservableCollection LinePoints { get; set; } = new ObservableCollection(); 31 | 32 | private ObservableCollection bars = new ObservableCollection(); 33 | /// 34 | /// 条形图的信息 35 | /// 36 | public ObservableCollection Bars 37 | { 38 | get { return bars; } 39 | set { Set(ref bars, value); } 40 | } 41 | 42 | private Uri theme; 43 | 44 | public Uri Theme 45 | { 46 | get { return theme; } 47 | set 48 | { 49 | Set(ref theme, value); 50 | var themeDict = new ResourceDictionary { Source = theme }; 51 | Application.Current.Resources.MergedDictionaries.Add(themeDict); 52 | } 53 | } 54 | 55 | public Dictionary Sources { get; set; } 56 | 57 | private Boolean isDark; 58 | public Boolean IsDark 59 | { 60 | get { return isDark; } 61 | set { Set(ref isDark, value); 62 | if (isDark) 63 | { 64 | Theme = Sources["幽暗"]; 65 | } 66 | else 67 | { 68 | Theme = Sources["明亮"]; 69 | } 70 | } 71 | } 72 | 73 | 74 | public WelcomePageModel() 75 | { 76 | Sources = new Dictionary(); 77 | Sources.Add("明亮", new Uri("/FirstDraft;component/Themes/Ui.Light.xaml", UriKind.Relative)); 78 | Sources.Add("幽暗", new Uri("/FirstDraft;component/Themes/Ui.Dark.xaml", UriKind.Relative)); 79 | Theme = Sources["明亮"]; 80 | 81 | double x = 0; 82 | double y = 50; 83 | while (x < 500) 84 | { 85 | var ran = random.Next(-150, 150); 86 | 87 | if (ran > 0) 88 | { 89 | y -= Math.Abs(ran) / 10; 90 | } 91 | else 92 | { 93 | y += Math.Abs(ran) / 10; 94 | } 95 | var p = new Point(x, y); 96 | 97 | LinePoints.Add(p); 98 | x++; 99 | } 100 | 101 | 102 | var lis = new List() { 103 | new Bar() {Value = 8, Label= "Sunday" }, 104 | new Bar() {Value = 7.5, Label= "Monday"}, 105 | new Bar() {Value = 8.6, Label = "Tuesday"}, 106 | new Bar() {Value = 8.2, Label = "Wednesday"}, 107 | new Bar() {Value = 7.6, Label = "Thursday"}, 108 | new Bar() {Value = 7.1, Label = "Friday"}, 109 | new Bar() {Value = 7.1, Label = "Saturday" } }; 110 | Bars = new ObservableCollection(lis); 111 | 112 | 113 | Task.Delay(10).ContinueWith(t => 114 | { 115 | double x = 0; 116 | double y = 0; 117 | 118 | int count = 0; 119 | var ss = new ObservableCollection(); 120 | while (count < 50) 121 | { 122 | y = random.Next(-50, 50); 123 | x = random.Next(0, 350); 124 | var size = random.Next(1, 5); 125 | ss.Add(new EllipseDot() { X = x, Y = y, Type = random.Next(0, 3), Height = size, Width = size }); 126 | 127 | count++; 128 | } 129 | DotSource = new ObservableCollection(ss); 130 | }); 131 | } 132 | 133 | private ObservableCollection dotSource = new ObservableCollection(); 134 | /// 135 | /// 线点数据 136 | /// 137 | public ObservableCollection DotSource 138 | { 139 | get { return dotSource; } 140 | set { Set(ref dotSource, value); } 141 | } 142 | 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Pages/BargramPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Data; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Imaging; 11 | using System.Windows.Navigation; 12 | using System.Windows.Shapes; 13 | 14 | namespace WindChart.ApplyDemo.Pages 15 | { 16 | /// 17 | /// BargramPage.xaml 的交互逻辑 18 | /// 19 | public partial class BargramPage : Page 20 | { 21 | public BargramPage() 22 | { 23 | InitializeComponent(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Pages/Bargrams/CodebehindDemo0Page.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 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 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Pages/Bargrams/CodebehindDemo0Page.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading; 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.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace WindChart.ApplyDemo.Pages.Bargrams 17 | { 18 | /// 19 | /// CodebehindDemo0Page.xaml 的交互逻辑 20 | /// 21 | public partial class CodebehindDemo0Page : Page 22 | { 23 | public CodebehindDemo0Page() 24 | { 25 | InitializeComponent(); 26 | 27 | // Y轴范围 28 | bar.YMin = 0; 29 | bar.YMax = 24; 30 | 31 | bar.NeedInterval = true; 32 | bar.ValueLabelLocation = BarValueLocation.None; 33 | 34 | // 实时数据模拟 35 | Task.Run(() => 36 | { 37 | Random rand = new Random(); 38 | double y = 10; 39 | List bars = new List(); 40 | DateTime dt = DateTime.Now.AddMonths(-2); 41 | while (true) 42 | { 43 | y = rand.Next(5, 16); 44 | 45 | this.Dispatcher.Invoke(() => 46 | { 47 | bars.Add(new Bar() { Fill = y > 8 ? Brushes.CornflowerBlue : Brushes.OrangeRed, Label = dt.Day.ToString(), Value = y }); 48 | bar.Draw(bars); 49 | }); 50 | dt = dt.AddDays(1); 51 | if (dt > DateTime.Now) 52 | { 53 | break; 54 | } 55 | } 56 | }); 57 | 58 | code.Text = @" // Y轴范围 59 | bar.YMin = 0; 60 | bar.YMax = 24; 61 | 62 | bar.NeedInterval = true; 63 | bar.ValueLabelLocation = BarValueLocation.None; 64 | 65 | // 实时数据模拟 66 | Task.Run(() => 67 | { 68 | Random rand = new Random(); 69 | double y = 10; 70 | List bars = new List(); 71 | DateTime dt = DateTime.Now.AddMonths(-2); 72 | while (true) 73 | { 74 | y = rand.Next(5, 16); 75 | 76 | this.Dispatcher.Invoke(() => 77 | { 78 | bars.Add(new Bar() { Fill = y > 8 ? Brushes.CornflowerBlue : Brushes.OrangeRed, Label = dt.Day.ToString(), Value = y }); 79 | bar.Draw(bars); 80 | }); 81 | Thread.Sleep(30); 82 | dt = dt.AddDays(1); 83 | if (dt > DateTime.Now) 84 | { 85 | break; 86 | } 87 | } 88 | });"; 89 | 90 | xaml.Text = @" 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 111 | 112 | 113 | 114 | "; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Pages/Bargrams/CodebehindDemo1Page.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Pages/Bargrams/CodebehindDemo1Page.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace WindChart.ApplyDemo.Pages.Bargrams 16 | { 17 | /// 18 | /// CodebehindDemo1Page.xaml 的交互逻辑 19 | /// 20 | public partial class CodebehindDemo1Page : Page 21 | { 22 | public CodebehindDemo1Page() 23 | { 24 | InitializeComponent(); 25 | 26 | // Y轴范围 27 | bar.YMin = 0; 28 | bar.XMax = 100; 29 | bar.YMax = 100; 30 | 31 | bar.NeedInterval = true; 32 | bar.ValueLabelLocation = BarValueLocation.Follow; 33 | bar.Direction = BarDirection.Horizontal; 34 | 35 | // 实时数据模拟 36 | List bars = new List(); 37 | 38 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "C#", Value = 54 }); 39 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "C++", Value = 46 }); 40 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "JavaScript", Value = 84 }); 41 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "Java", Value = 16 }); 42 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "Go", Value = 25 }); 43 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "Rust", Value = 26 }); 44 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "C", Value = 49 }); 45 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "Ruby", Value = 83 }); 46 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "TypeScript", Value = 41 }); 47 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "Node.js", Value = 12 }); 48 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "SQL", Value = 45 }); 49 | bars.Add(new Bar() { Fill = Brushes.CornflowerBlue, Label = "Python", Value = 23 }); 50 | 51 | bar.Draw(bars); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Samples/WindChart.ApplyDemo/Pages/DotgramPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 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 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |