├── .gitignore ├── LICENSE └── PrismMetroSample └── PrismMetroSample ├── PrismMetroSample.Infrastructure ├── ApplicationCommands.cs ├── Assets │ ├── Fonts │ │ └── iconfont.ttf │ └── Photos │ │ ├── Home, homepage, menu.png │ │ ├── alter.png │ │ ├── success.png │ │ └── 按钮.png ├── Constants │ ├── FlyoutNames.cs │ ├── Global.cs │ └── RegionNames.cs ├── Converters │ ├── BoolToVisibilityConverter.cs │ └── PasswordConverter.cs ├── CustomerRegionAdapters │ └── UniformGridRegionAdapter.cs ├── Events │ ├── MedicineSentEvent.cs │ └── PatientSentEvent.cs ├── Helpers │ └── WindowHelp.cs ├── Interceptor │ ├── HandlerAttributes │ │ └── LogHandlerAttribute.cs │ └── Handlers │ │ └── LogHandler.cs ├── Models │ ├── Medicine.cs │ ├── Patient.cs │ ├── Recipe.cs │ └── User.cs ├── PrismMetroSample.Infrastructure.csproj ├── PrismMetroSample.Infrastructure.csproj.user └── Services │ ├── FlyoutService.cs │ ├── IFlyoutService.cs │ ├── IFlyoutView.cs │ ├── IMedicineSerivce.cs │ ├── IPatientService.cs │ ├── IUserService.cs │ ├── MedicineSerivce .cs │ ├── PatientService.cs │ └── UserService.cs ├── PrismMetroSample.MedicineModule ├── MedicineModule.cs ├── PrismMetroSample.MedicineModule.csproj ├── PrismMetroSample.MedicineModule.csproj.user ├── ViewModels │ ├── MedicineMainContentViewModel.cs │ ├── SearchMedicineViewModel.cs │ └── ShowSearchPatientViewModel.cs └── Views │ ├── MedicineMainContent.xaml │ ├── MedicineMainContent.xaml.cs │ ├── SearchMedicine.xaml │ ├── SearchMedicine.xaml.cs │ ├── ShowSearchPatient.xaml │ └── ShowSearchPatient.xaml.cs ├── PrismMetroSample.PatientModule ├── PatientModule.cs ├── PrismMetroSample.PatientModule.csproj ├── PrismMetroSample.PatientModule.csproj.user ├── ViewModels │ ├── PatientDetailViewModel.cs │ └── PatientListViewModel.cs └── Views │ ├── PatientDetail.xaml │ ├── PatientDetail.xaml.cs │ ├── PatientList.xaml │ └── PatientList.xaml.cs ├── PrismMetroSample.Shell ├── App.config ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Configurations │ └── Settings.cs ├── PrismMetroSample.Shell.csproj ├── PrismMetroSample.Shell.csproj.user ├── Properties │ ├── PublishProfiles │ │ ├── FolderProfile.pubxml │ │ └── FolderProfile.pubxml.user │ └── launchSettings.json ├── ShellSwitcher.cs ├── ViewModels │ ├── Dialogs │ │ ├── AlertDialogViewModel.cs │ │ ├── SuccessDialogViewModel.cs │ │ └── WarningDialogViewModel.cs │ ├── Login │ │ ├── CreateAccountViewModel.cs │ │ ├── LoginMainContentViewModel.cs │ │ └── LoginWindowViewModel.cs │ └── MainWindowViewModel.cs └── Views │ ├── Dialogs │ ├── AlertDialog.xaml │ ├── AlertDialog.xaml.cs │ ├── DialogWindow.xaml │ ├── DialogWindow.xaml.cs │ ├── SuccessDialog.xaml │ ├── SuccessDialog.xaml.cs │ ├── WarningDialog.xaml │ └── WarningDialog.xaml.cs │ ├── Login │ ├── CreateAccount.xaml │ ├── CreateAccount.xaml.cs │ ├── LoginMainContent.xaml │ ├── LoginMainContent.xaml.cs │ ├── LoginWindow.xaml │ └── LoginWindow.xaml.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── RegionAdapterViews │ ├── RegionAdapterView1.xaml │ ├── RegionAdapterView1.xaml.cs │ ├── RegionAdapterView2.xaml │ └── RegionAdapterView2.xaml.cs ├── PrismMetroSample.Styling ├── PrismMetroSample.Styling.csproj ├── PrismMetroSample.Styling.csproj.user └── Styles │ └── ButtonStyle.xaml └── PrismMetroSample.sln /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb 341 | .vscode 342 | *.apk 343 | *.unitypackage 344 | 345 | # webapi appsettings 346 | /AccessControl.Api/appsettings.json 347 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 王政道 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/ApplicationCommands.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | 3 | namespace PrismMetroSample.Infrastructure 4 | { 5 | public interface IApplicationCommands 6 | { 7 | public CompositeCommand ShowCommand { get; } 8 | } 9 | 10 | public class ApplicationCommands : IApplicationCommands 11 | { 12 | private CompositeCommand _showCommand=new CompositeCommand(); 13 | 14 | public CompositeCommand ShowCommand 15 | { 16 | get { return _showCommand; } 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Fonts/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhengDaoWang/PrismMetroSample/cf54a70f613130884828432ef993de89199eefed/PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Fonts/iconfont.ttf -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/Home, homepage, menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhengDaoWang/PrismMetroSample/cf54a70f613130884828432ef993de89199eefed/PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/Home, homepage, menu.png -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/alter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhengDaoWang/PrismMetroSample/cf54a70f613130884828432ef993de89199eefed/PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/alter.png -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhengDaoWang/PrismMetroSample/cf54a70f613130884828432ef993de89199eefed/PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/success.png -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/按钮.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhengDaoWang/PrismMetroSample/cf54a70f613130884828432ef993de89199eefed/PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Assets/Photos/按钮.png -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Constants/FlyoutNames.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace PrismMetroSample.Infrastructure.Constants 6 | { 7 | public static class FlyoutNames 8 | { 9 | public static string PatientDetailFlyout = "PatientDetailFlyout"; 10 | 11 | public static string SearchMedicineFlyout = "SearchMedicineFlyout"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Constants/Global.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace PrismMetroSample.Infrastructure.Constants 7 | { 8 | public static class Global 9 | { 10 | private static List _allUsers; 11 | public static List AllUsers 12 | { 13 | get { return _allUsers; } 14 | set { _allUsers = value; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Constants/RegionNames.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace PrismMetroSample.Infrastructure.Constants 6 | { 7 | public static class RegionNames 8 | { 9 | public static string MedicineMainContentRegion = "MedicineMainContentRegion"; 10 | 11 | public static string FlyoutRegion = "FlyoutRegion"; 12 | 13 | public static string ShowSearchPatientRegion = "ShowSearchPatientRegion"; 14 | 15 | public static string PatientListRegion = "PatientListRegion"; 16 | 17 | public static string UniformContentRegion = "UniformContentRegion"; 18 | 19 | public static string LoginContentRegion = "LoginContentRegion"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Converters/BoolToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | 8 | namespace PrismMetroSample.Infrastructure.Converters 9 | { 10 | public class BoolToVisibilityConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (value==null) 15 | { 16 | return DependencyProperty.UnsetValue; 17 | } 18 | var isCanExcute = (bool)value; 19 | if (isCanExcute) 20 | { 21 | return Visibility.Visible; 22 | } 23 | else 24 | { 25 | return Visibility.Hidden; 26 | } 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Converters/PasswordConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using System.Windows.Controls; 6 | using System.Windows.Data; 7 | 8 | namespace PrismMetroSample.Infrastructure.Converters 9 | { 10 | public class PasswordConverter : IMultiValueConverter 11 | { 12 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | Dictionary keyValues = new Dictionary(); 15 | foreach (var item in values) 16 | { 17 | var password = (PasswordBox)item; 18 | keyValues.Add(password.Name, password); 19 | } 20 | return keyValues; 21 | } 22 | 23 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/CustomerRegionAdapters/UniformGridRegionAdapter.cs: -------------------------------------------------------------------------------- 1 | using Prism.Regions; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls.Primitives; 7 | 8 | namespace PrismMetroSample.Infrastructure.CustomerRegionAdapters 9 | { 10 | public class UniformGridRegionAdapter : RegionAdapterBase 11 | { 12 | public UniformGridRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory) 13 | { 14 | 15 | } 16 | 17 | protected override void Adapt(IRegion region, UniformGrid regionTarget) 18 | { 19 | region.Views.CollectionChanged += (s, e) => 20 | { 21 | if (e.Action==System.Collections.Specialized.NotifyCollectionChangedAction.Add) 22 | { 23 | foreach (FrameworkElement element in e.NewItems) 24 | { 25 | regionTarget.Children.Add(element); 26 | } 27 | } 28 | }; 29 | } 30 | 31 | protected override IRegion CreateRegion() 32 | { 33 | return new AllActiveRegion(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Events/MedicineSentEvent.cs: -------------------------------------------------------------------------------- 1 | using Prism.Events; 2 | using PrismMetroSample.Infrastructure.Models; 3 | 4 | namespace PrismMetroSample.Infrastructure.Events 5 | { 6 | public class MedicineSentEvent: PubSubEvent 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Events/PatientSentEvent.cs: -------------------------------------------------------------------------------- 1 | using Prism.Events; 2 | using PrismMetroSample.Infrastructure.Models; 3 | 4 | namespace PrismMetroSample.Infrastructure.Events 5 | { 6 | public class PatientSentEvent: PubSubEvent 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Helpers/WindowHelp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Interop; 7 | 8 | namespace PrismMetroSample.Infrastructure.Helpers 9 | { 10 | public static class WindowHelp 11 | { 12 | [DllImport("user32.dll")] 13 | static extern int GetWindowLong(IntPtr hwnd, int index); 14 | 15 | [DllImport("user32.dll")] 16 | static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle); 17 | 18 | [DllImport("user32.dll")] 19 | static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, 20 | int x, int y, int width, int height, uint flags); 21 | 22 | [DllImport("user32.dll")] 23 | static extern IntPtr SendMessage(IntPtr hwnd, uint msg, 24 | IntPtr wParam, IntPtr lParam); 25 | 26 | const int GWL_EXSTYLE = -20; 27 | const int WS_EX_DLGMODALFRAME = 0x0001; 28 | const int SWP_NOSIZE = 0x0001; 29 | const int SWP_NOMOVE = 0x0002; 30 | const int SWP_NOZORDER = 0x0004; 31 | const int SWP_FRAMECHANGED = 0x0020; 32 | const uint WM_SETICON = 0x0080; 33 | 34 | public static void RemoveIcon(Window window) 35 | { 36 | //获取窗体的句柄 37 | IntPtr hwnd = new WindowInteropHelper(window).Handle; 38 | 39 | //改变窗体的样式 40 | int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE); 41 | SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME); 42 | 43 | //更新窗口的非客户区,以反映变化 44 | SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | 45 | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Interceptor/HandlerAttributes/LogHandlerAttribute.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Interceptor.Handlers; 2 | using Unity; 3 | using Unity.Interception.PolicyInjection.Pipeline; 4 | using Unity.Interception.PolicyInjection.Policies; 5 | 6 | namespace PrismMetroSample.Infrastructure.Interceptor.HandlerAttributes 7 | { 8 | public class LogHandlerAttribute : HandlerAttribute 9 | { 10 | public override ICallHandler CreateHandler(IUnityContainer container) 11 | { 12 | return new LogHandler() { Order = this.Order }; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Interceptor/Handlers/LogHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Unity.Interception.PolicyInjection.Pipeline; 8 | 9 | namespace PrismMetroSample.Infrastructure.Interceptor.Handlers 10 | { 11 | public class LogHandler : ICallHandler 12 | { 13 | public int Order { get ; set ; } 14 | 15 | public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) 16 | { 17 | Debug.WriteLine("-------------Method Excute Befored-------------"); 18 | Debug.WriteLine($"Method Name:{input.MethodBase.Name}"); 19 | if (input.Arguments.Count>0) 20 | { 21 | Debug.WriteLine("Arguments:"); 22 | for (int i = 0; i < input.Arguments.Count; i++) 23 | { 24 | Debug.WriteLine($"parameterName:{input.Arguments.ParameterName(i)},parameterValue:{input.Arguments[i]}"); 25 | } 26 | } 27 | var methodReturn = getNext()(input, getNext); 28 | Debug.WriteLine("-------------Method Excute After-------------"); 29 | if (methodReturn.Exception!=null) 30 | { 31 | Debug.WriteLine($"Exception:{methodReturn.Exception.Message} \n"); 32 | } 33 | else 34 | { 35 | Debug.WriteLine($"Excuted Successed \n"); 36 | } 37 | return methodReturn; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Models/Medicine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace PrismMetroSample.Infrastructure.Models 6 | { 7 | public class Medicine 8 | { 9 | public int Id { get; set; } 10 | 11 | public string Name { get; set; } 12 | 13 | public string Type { get; set; } 14 | 15 | public string Unit { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Models/Patient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace PrismMetroSample.Infrastructure.Models 6 | { 7 | public class Patient 8 | { 9 | public int Id { get; set; } 10 | 11 | public string Name { get; set; } 12 | 13 | public int Age { get; set; } 14 | 15 | public string Sex { get; set; } 16 | 17 | public string RoomNo { get; set; } 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Models/Recipe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace PrismMetroSample.Infrastructure.Models 6 | { 7 | public class Recipe 8 | { 9 | public int Id { get; set; } 10 | 11 | public int PatientId { get; set; } 12 | 13 | public List LstMedicines { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Models/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace PrismMetroSample.Infrastructure.Models 6 | { 7 | public class User 8 | { 9 | public int Id { get; set; } 10 | 11 | public string LoginId { get; set; } 12 | 13 | public string PassWord { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/PrismMetroSample.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Library 5 | net5.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/PrismMetroSample.Infrastructure.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/FlyoutService.cs: -------------------------------------------------------------------------------- 1 | using MahApps.Metro.Controls; 2 | using Prism.Commands; 3 | using Prism.Regions; 4 | using PrismMetroSample.Infrastructure.Constants; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Windows.Input; 10 | 11 | namespace PrismMetroSample.Infrastructure.Services 12 | { 13 | public class FlyoutService : IFlyoutService 14 | { 15 | IRegionManager _regionManager; 16 | IApplicationCommands _applicationCommands; 17 | 18 | public ICommand ShowFlyoutCommand { get; private set; } 19 | public FlyoutService(IRegionManager regionManager, IApplicationCommands applicationCommands) 20 | { 21 | _regionManager = regionManager; 22 | _applicationCommands = applicationCommands; 23 | 24 | this.ShowFlyoutCommand = new DelegateCommand(ShowFlyout); 25 | //注册子命令给全局复合命令 26 | _applicationCommands.ShowCommand.RegisterCommand(this.ShowFlyoutCommand); 27 | 28 | } 29 | public void ShowFlyout(string flyoutName) 30 | { 31 | var region = _regionManager.Regions[RegionNames.FlyoutRegion]; 32 | 33 | if (region != null) 34 | { 35 | var flyout = region.Views.Where(v => v is IFlyoutView && ((IFlyoutView)v).FlyoutName.Equals(flyoutName)).FirstOrDefault() as Flyout; 36 | 37 | if (flyout != null) 38 | { 39 | flyout.IsOpen = !flyout.IsOpen; 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/IFlyoutService.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Interceptor.HandlerAttributes; 2 | 3 | namespace PrismMetroSample.Infrastructure.Services 4 | { 5 | public interface IFlyoutService 6 | { 7 | void ShowFlyout(string flyoutName); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/IFlyoutView.cs: -------------------------------------------------------------------------------- 1 | namespace PrismMetroSample.Infrastructure.Services 2 | { 3 | public interface IFlyoutView 4 | { 5 | string FlyoutName { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/IMedicineSerivce.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Interceptor.HandlerAttributes; 2 | using PrismMetroSample.Infrastructure.Models; 3 | using System.Collections.Generic; 4 | 5 | namespace PrismMetroSample.Infrastructure.Services 6 | { 7 | [LogHandler] 8 | public interface IMedicineSerivce 9 | { 10 | List GetAllMedicines(); 11 | 12 | List GetRecipesByPatientId(int patientId); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/IPatientService.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Interceptor.HandlerAttributes; 2 | using PrismMetroSample.Infrastructure.Models; 3 | using System.Collections.Generic; 4 | 5 | namespace PrismMetroSample.Infrastructure.Services 6 | { 7 | [LogHandler] 8 | public interface IPatientService 9 | { 10 | List GetAllPatients(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/IUserService.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Interceptor.HandlerAttributes; 2 | using PrismMetroSample.Infrastructure.Models; 3 | using System.Collections.Generic; 4 | 5 | namespace PrismMetroSample.Infrastructure.Services 6 | { 7 | [LogHandler] 8 | public interface IUserService 9 | { 10 | List GetAllUsers(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/MedicineSerivce .cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Models; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace PrismMetroSample.Infrastructure.Services 6 | { 7 | public class MedicineSerivce : IMedicineSerivce 8 | { 9 | public List GetAllMedicines() 10 | { 11 | var allMedicines = new List() 12 | { 13 | new Medicine(){Id=1,Name="当归",Type="中药",Unit="克"}, 14 | new Medicine(){Id=2,Name="人参",Type="中药",Unit="克"}, 15 | new Medicine(){Id=3,Name="枸杞",Type="中药",Unit="克"}, 16 | new Medicine(){Id=4,Name="青霉素",Type="西药",Unit="瓶"}, 17 | new Medicine(){Id=5,Name="琼浆玉露",Type="仙药",Unit="滴"} 18 | }; 19 | return allMedicines; 20 | } 21 | 22 | public List GetRecipesByPatientId(int patientId) 23 | { 24 | var allMedicines = GetAllMedicines(); 25 | var allRecipe = new List() 26 | { 27 | new Recipe() {Id=1,LstMedicines=allMedicines.Where(t=>t.Id>2).ToList(),PatientId=2}, 28 | new Recipe() {Id=1,LstMedicines=allMedicines.Where(t=>t.Id==2||t.Id==3).ToList(),PatientId=1}, 29 | new Recipe() {Id=1,LstMedicines=allMedicines.Where(t=>t.Id<4).ToList(),PatientId=3}, 30 | new Recipe() {Id=1,LstMedicines=allMedicines.Where(t=>t.Id==5).ToList(),PatientId=4}, 31 | }; 32 | return allRecipe.Where(t => t.PatientId == patientId).ToList(); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/PatientService.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace PrismMetroSample.Infrastructure.Services 7 | { 8 | public class PatientService : IPatientService 9 | { 10 | public List GetAllPatients() 11 | { 12 | var allPatient = new List() 13 | { 14 | new Patient(){Id=1,Name="Lina",Age=18,Sex="女",RoomNo="A-501"}, 15 | new Patient(){Id=2,Name="Ryzen",Age=24,Sex="男",RoomNo="B-610"}, 16 | new Patient(){Id=3,Name="Joy",Age=20,Sex="男",RoomNo="C-620"}, 17 | new Patient(){Id=4,Name="Jack",Age=40,Sex="男",RoomNo="D-520"}, 18 | }; 19 | return allPatient; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.Infrastructure/Services/UserService.cs: -------------------------------------------------------------------------------- 1 | using PrismMetroSample.Infrastructure.Models; 2 | using System.Collections.Generic; 3 | 4 | namespace PrismMetroSample.Infrastructure.Services 5 | { 6 | public class UserService : IUserService 7 | { 8 | public List GetAllUsers() 9 | { 10 | var allUsers = new List() 11 | { 12 | new User(){Id=1,LoginId="Admin",PassWord="Admin123"}, 13 | new User(){Id=1,LoginId="Ryzen",PassWord="123456"}, 14 | new User(){Id=1,LoginId="Test",PassWord="Test123"}, 15 | }; 16 | return allUsers; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/MedicineModule.cs: -------------------------------------------------------------------------------- 1 | using Prism.Ioc; 2 | using Prism.Modularity; 3 | using Prism.Regions; 4 | using PrismMetroSample.MedicineModule.Views; 5 | using PrismMetroSample.Infrastructure.Constants; 6 | using System; 7 | using System.Windows.Controls; 8 | 9 | namespace PrismMetroSample.MedicineModule 10 | { 11 | [Module(ModuleName = "MedicineModule", OnDemand =true)] 12 | public class MedicineModule : IModule 13 | { 14 | public void OnInitialized(IContainerProvider containerProvider) 15 | { 16 | var regionManager = containerProvider.Resolve(); 17 | 18 | 19 | //MedicineMainContent 20 | regionManager.RegisterViewWithRegion(RegionNames.MedicineMainContentRegion, typeof(MedicineMainContent)); 21 | 22 | //SearchMedicine-Flyout 23 | regionManager.RegisterViewWithRegion(RegionNames.FlyoutRegion, typeof(SearchMedicine)); 24 | 25 | //rightWindowCommandsRegion 26 | regionManager.RegisterViewWithRegion(RegionNames.ShowSearchPatientRegion, typeof(ShowSearchPatient)); 27 | 28 | } 29 | 30 | public void RegisterTypes(IContainerRegistry containerRegistry) 31 | { 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/PrismMetroSample.MedicineModule.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Library 5 | net5.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/PrismMetroSample.MedicineModule.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Code 7 | 8 | 9 | Code 10 | 11 | 12 | Code 13 | 14 | 15 | 16 | 17 | Designer 18 | 19 | 20 | Designer 21 | 22 | 23 | Designer 24 | 25 | 26 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/ViewModels/MedicineMainContentViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Mvvm; 2 | using PrismMetroSample.Infrastructure.Models; 3 | using PrismMetroSample.Infrastructure.Services; 4 | using System.Collections.ObjectModel; 5 | using Prism.Events; 6 | using PrismMetroSample.Infrastructure.Events; 7 | using System; 8 | using Prism; 9 | using System.Windows; 10 | using Prism.Services.Dialogs; 11 | using Prism.Commands; 12 | using System.Threading.Tasks; 13 | using System.Diagnostics; 14 | 15 | namespace PrismMetroSample.MedicineModule.ViewModels 16 | { 17 | public class MedicineMainContentViewModel : BindableBase,IActiveAware 18 | { 19 | #region Fields 20 | 21 | private readonly IMedicineSerivce _medicineSerivce; 22 | private readonly IEventAggregator _ea; 23 | private readonly IDialogService _dialogService; 24 | 25 | public event EventHandler IsActiveChanged; 26 | 27 | #endregion 28 | 29 | #region Properties 30 | 31 | 32 | private ObservableCollection _allMedicines=new ObservableCollection(); 33 | 34 | public ObservableCollection AllMedicines 35 | { 36 | get { return _allMedicines; } 37 | set { _allMedicines = value; } 38 | } 39 | 40 | 41 | 42 | bool _isActive; 43 | public bool IsActive 44 | { 45 | get { return _isActive; } 46 | set 47 | { 48 | _isActive = value; 49 | if (_isActive) 50 | { 51 | _dialogService.ShowDialog("SuccessDialog", new DialogParameters($"message={"视图被激活了"}"), null); 52 | } 53 | else 54 | { 55 | _dialogService.ShowDialog("WarningDialog", new DialogParameters($"message={"视图失效了"}"), null); 56 | } 57 | IsActiveChanged?.Invoke(this, new EventArgs()); 58 | } 59 | } 60 | 61 | #endregion 62 | 63 | #region Commands 64 | 65 | private DelegateCommand _loadCommand; 66 | public DelegateCommand LoadCommand => 67 | _loadCommand ?? (_loadCommand = new DelegateCommand(ExecuteLoadCommand)); 68 | 69 | void ExecuteLoadCommand() 70 | { 71 | //TaskExtension for async void Command 72 | ALongTask().Await( completedCallback:() => 73 | { 74 | this.AllMedicines.AddRange(_medicineSerivce.GetAllMedicines()); 75 | }, errorCallback:null,configureAwait:true); 76 | 77 | 78 | } 79 | 80 | private async Task ALongTask() 81 | { 82 | await Task.Delay(3000);//模拟耗时操作 83 | Debug.WriteLine("耗时操作完成"); 84 | } 85 | 86 | #endregion 87 | 88 | #region Excutes 89 | 90 | 91 | 92 | #endregion 93 | 94 | 95 | 96 | public MedicineMainContentViewModel(IMedicineSerivce medicineSerivce,IEventAggregator ea,IDialogService dialogService) 97 | { 98 | _medicineSerivce = medicineSerivce; 99 | _ea = ea; 100 | _dialogService = dialogService; 101 | _ea.GetEvent().Subscribe(MedicineMessageReceived);//订阅事件 102 | this.AllMedicines = new ObservableCollection(); 103 | } 104 | 105 | /// 106 | /// 事件消息接受函数 107 | /// 108 | private void MedicineMessageReceived(Medicine medicine) 109 | { 110 | this.AllMedicines?.Add(medicine); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/ViewModels/SearchMedicineViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using PrismMetroSample.Infrastructure.Services; 4 | using PrismMetroSample.Infrastructure.Models; 5 | using Prism.Events; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using PrismMetroSample.Infrastructure.Events; 9 | 10 | namespace PrismMetroSample.MedicineModule.ViewModels 11 | { 12 | public class SearchMedicineViewModel : BindableBase 13 | { 14 | #region Fields 15 | 16 | private readonly IMedicineSerivce _medicineSerivce; 17 | private readonly IEventAggregator _ea; 18 | 19 | #endregion 20 | 21 | #region Properties 22 | 23 | private List _allMedicines; 24 | public List AllMedicines 25 | { 26 | get { return _allMedicines; } 27 | set { SetProperty(ref _allMedicines, value); } 28 | } 29 | 30 | private List _currentMedicines; 31 | public List CurrentMedicines 32 | { 33 | get { return _currentMedicines; } 34 | set { SetProperty(ref _currentMedicines, value); } 35 | } 36 | 37 | private string _searchCondition; 38 | public string SearchCondition 39 | { 40 | get { return _searchCondition; } 41 | set { SetProperty(ref _searchCondition, value); } 42 | } 43 | 44 | #endregion 45 | 46 | #region Commands 47 | 48 | private DelegateCommand _searchCommand; 49 | public DelegateCommand SearchCommand => 50 | _searchCommand ?? (_searchCommand = new DelegateCommand(ExecuteSearchCommand)); 51 | 52 | private DelegateCommand _addMedicineCommand; 53 | public DelegateCommand AddMedicineCommand => 54 | _addMedicineCommand ?? (_addMedicineCommand = new DelegateCommand(ExecuteAddMedicineCommand)); 55 | 56 | #endregion 57 | 58 | #region Excutes 59 | 60 | void ExecuteSearchCommand() 61 | { 62 | this.CurrentMedicines = this.AllMedicines.Where(t => t.Name.Contains(this.SearchCondition) || t.Type.Contains(this.SearchCondition) 63 | || t.Unit.Contains(this.SearchCondition)).ToList(); 64 | } 65 | 66 | void ExecuteAddMedicineCommand(Medicine currentMedicine) 67 | { 68 | _ea.GetEvent().Publish(currentMedicine); 69 | } 70 | 71 | #endregion 72 | 73 | 74 | 75 | public SearchMedicineViewModel(IMedicineSerivce medicineSerivce, IEventAggregator ea) 76 | { 77 | _ea = ea; 78 | _medicineSerivce = medicineSerivce; 79 | this.CurrentMedicines = this.AllMedicines = _medicineSerivce.GetAllMedicines(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/ViewModels/ShowSearchPatientViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Mvvm; 2 | using Prism.Regions; 3 | using PrismMetroSample.Infrastructure; 4 | using PrismMetroSample.MedicineModule.Views; 5 | using PrismMetroSample.Infrastructure.Constants; 6 | using System.Linq; 7 | using Prism.Commands; 8 | using System.Threading.Tasks; 9 | 10 | namespace PrismMetroSample.MedicineModule.ViewModels 11 | { 12 | 13 | public class ShowSearchPatientViewModel : BindableBase 14 | { 15 | #region Fields 16 | 17 | private readonly IRegionManager _regionManager; 18 | private ShowSearchPatient _showSearchPatientView; 19 | private IRegion _region; 20 | 21 | #endregion 22 | 23 | #region Properties 24 | 25 | private bool _isShow = true; 26 | public bool IsShow 27 | { 28 | get { return _isShow = true; } 29 | set 30 | { 31 | SetProperty(ref _isShow, value); 32 | if (_isShow) 33 | { 34 | ActiveShowSearchPatient(); 35 | } 36 | else 37 | { 38 | DeactiveShowSearchPaitent(); 39 | } 40 | } 41 | } 42 | 43 | private IApplicationCommands _applicationCommands; 44 | public IApplicationCommands ApplicationCommands 45 | { 46 | get { return _applicationCommands; } 47 | set { SetProperty(ref _applicationCommands, value); } 48 | } 49 | 50 | #endregion 51 | 52 | #region Commands 53 | 54 | private DelegateCommand _showSearchLoadingCommand; 55 | public DelegateCommand ShowSearchLoadingCommand => 56 | _showSearchLoadingCommand ?? (_showSearchLoadingCommand = new DelegateCommand(ExecuteShowSearchLoadingCommand)); 57 | 58 | #endregion 59 | 60 | #region Excutes 61 | 62 | void ExecuteShowSearchLoadingCommand() 63 | { 64 | _region = _regionManager.Regions[RegionNames.ShowSearchPatientRegion]; 65 | _showSearchPatientView = (ShowSearchPatient)_region.Views.Where(t => t.GetType() == typeof(ShowSearchPatient)).FirstOrDefault(); 66 | } 67 | 68 | #endregion 69 | 70 | 71 | public ShowSearchPatientViewModel(IApplicationCommands applicationCommands,IRegionManager regionManager) 72 | { 73 | this.ApplicationCommands = applicationCommands; 74 | _regionManager = regionManager; 75 | } 76 | 77 | private void ActiveShowSearchPatient() 78 | { 79 | if (!_region.ActiveViews.Contains(_showSearchPatientView)) 80 | { 81 | _region.Add(_showSearchPatientView); 82 | } 83 | } 84 | 85 | private async void DeactiveShowSearchPaitent() 86 | { 87 | _region.Remove(_showSearchPatientView); 88 | await Task.Delay(2000); 89 | IsShow = true; 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/Views/MedicineMainContent.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 31 | 32 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/Views/MedicineMainContent.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace PrismMetroSample.MedicineModule.Views 4 | { 5 | /// 6 | /// Interaction logic for MedicineMainContent 7 | /// 8 | public partial class MedicineMainContent : UserControl 9 | { 10 | public MedicineMainContent() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/Views/SearchMedicine.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 21 | 22 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.MedicineModule/Views/ShowSearchPatient.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace PrismMetroSample.MedicineModule.Views 4 | { 5 | /// 6 | /// Interaction logic for ShowSearchPatient 7 | /// 8 | public partial class ShowSearchPatient : StackPanel 9 | { 10 | public ShowSearchPatient() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.PatientModule/PatientModule.cs: -------------------------------------------------------------------------------- 1 | using Prism.Ioc; 2 | using Prism.Modularity; 3 | using Prism.Regions; 4 | using PrismMetroSample.PatientModule.Views; 5 | using PrismMetroSample.Infrastructure.Constants; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | 10 | namespace PrismMetroSample.PatientModule 11 | { 12 | public class PatientModule : IModule 13 | { 14 | public void OnInitialized(IContainerProvider containerProvider) 15 | { 16 | var regionManager = containerProvider.Resolve(); 17 | 18 | //PatientList 19 | //regionManager.RegisterViewWithRegion(RegionNames.PatientListRegion, typeof(PatientList)); 20 | //PatientDetail-Flyout 21 | regionManager.RegisterViewWithRegion(RegionNames.FlyoutRegion, typeof(PatientDetail)); 22 | 23 | 24 | } 25 | 26 | public void RegisterTypes(IContainerRegistry containerRegistry) 27 | { 28 | 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.PatientModule/PrismMetroSample.PatientModule.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Library 5 | net5.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.PatientModule/PrismMetroSample.PatientModule.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Code 7 | 8 | 9 | Code 10 | 11 | 12 | 13 | 14 | Designer 15 | 16 | 17 | Designer 18 | 19 | 20 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.PatientModule/ViewModels/PatientDetailViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Events; 3 | using Prism.Mvvm; 4 | using PrismMetroSample.Infrastructure.Events; 5 | using PrismMetroSample.Infrastructure.Models; 6 | using PrismMetroSample.Infrastructure.Services; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Collections.ObjectModel; 10 | 11 | namespace PrismMetroSample.PatientModule.ViewModels 12 | { 13 | public class PatientDetailViewModel : BindableBase 14 | { 15 | 16 | #region Fields 17 | 18 | private readonly IMedicineSerivce _medicineSerivce; 19 | private readonly IEventAggregator _ea; 20 | 21 | #endregion 22 | 23 | #region Properties 24 | 25 | private Patient _currentPatient; 26 | public Patient CurrentPatient 27 | { 28 | get { return _currentPatient; } 29 | set { SetProperty(ref _currentPatient, value); } 30 | } 31 | 32 | private ObservableCollection _lstMedicines; 33 | public ObservableCollection lstMedicines 34 | { 35 | get { return _lstMedicines; } 36 | set { SetProperty(ref _lstMedicines, value); } 37 | } 38 | 39 | #endregion 40 | 41 | #region Commands 42 | 43 | private DelegateCommand _cancleSubscribeCommand; 44 | public DelegateCommand CancleSubscribeCommand => 45 | _cancleSubscribeCommand ?? (_cancleSubscribeCommand = new DelegateCommand(ExecuteCancleSubscribeCommand)); 46 | 47 | #endregion 48 | 49 | #region Excutes 50 | 51 | void ExecuteCancleSubscribeCommand() 52 | { 53 | _ea.GetEvent().Unsubscribe(MedicineMessageReceived); 54 | } 55 | 56 | #endregion 57 | 58 | 59 | 60 | public PatientDetailViewModel(IEventAggregator ea, IMedicineSerivce medicineSerivce) 61 | { 62 | _medicineSerivce = medicineSerivce; 63 | _ea = ea; 64 | _ea.GetEvent().Subscribe(PatientMessageReceived); 65 | _ea.GetEvent().Subscribe(MedicineMessageReceived,ThreadOption.PublisherThread,false, 66 | medicine=>medicine.Name=="当归"|| medicine.Name== "琼浆玉露"); 67 | } 68 | 69 | /// 70 | /// 接受事件消息函数 71 | /// 72 | private void MedicineMessageReceived(Medicine medicine) 73 | { 74 | this.lstMedicines?.Add(medicine); 75 | } 76 | 77 | private void PatientMessageReceived(Patient patient) 78 | { 79 | this.CurrentPatient = patient; 80 | this.lstMedicines = new ObservableCollection(_medicineSerivce.GetRecipesByPatientId(this.CurrentPatient.Id).FirstOrDefault().LstMedicines); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.PatientModule/ViewModels/PatientListViewModel.cs: -------------------------------------------------------------------------------- 1 | using Prism.Commands; 2 | using Prism.Mvvm; 3 | using PrismMetroSample.Infrastructure.Services; 4 | using PrismMetroSample.Infrastructure.Models; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using Prism.Regions; 9 | using PrismMetroSample.Infrastructure; 10 | using Prism.Events; 11 | using PrismMetroSample.Infrastructure.Events; 12 | using PrismMetroSample.Infrastructure.Constants; 13 | using PrismMetroSample.PatientModule.Views; 14 | 15 | namespace PrismMetroSample.PatientModule.ViewModels 16 | { 17 | public class PatientListViewModel : BindableBase, IRegionMemberLifetime 18 | { 19 | 20 | #region Fields 21 | 22 | private readonly IEventAggregator _ea; 23 | private readonly IRegionManager _regionManager; 24 | private readonly IPatientService _patientService; 25 | private IRegion _region; 26 | private PatientList _patientListView; 27 | 28 | #endregion 29 | 30 | #region Properties 31 | 32 | private IApplicationCommands _applicationCommands; 33 | public IApplicationCommands ApplicationCommands 34 | { 35 | get { return _applicationCommands; } 36 | set { SetProperty(ref _applicationCommands, value); } 37 | } 38 | 39 | private List _allPatients; 40 | public List AllPatients 41 | { 42 | get { return _allPatients; } 43 | set { SetProperty(ref _allPatients, value); } 44 | } 45 | 46 | 47 | public bool KeepAlive => true; 48 | 49 | #endregion 50 | 51 | #region Commands 52 | 53 | private DelegateCommand _mouseDoubleClickCommand; 54 | public DelegateCommand MouseDoubleClickCommand => 55 | _mouseDoubleClickCommand ?? (_mouseDoubleClickCommand = new DelegateCommand(ExecuteMouseDoubleClickCommand)); 56 | 57 | #endregion 58 | 59 | #region Excutes 60 | 61 | /// 62 | /// DataGrid 双击按钮命令方法 63 | /// 64 | void ExecuteMouseDoubleClickCommand(Patient patient) 65 | { 66 | this.ApplicationCommands.ShowCommand.Execute(FlyoutNames.PatientDetailFlyout);//打开窗体 67 | _ea.GetEvent().Publish(patient);//发布消息 68 | } 69 | 70 | #endregion 71 | 72 | 73 | /// 74 | /// 构造函数 75 | /// 76 | public PatientListViewModel(IPatientService patientService, IEventAggregator ea, IApplicationCommands applicationCommands) 77 | { 78 | _ea = ea; 79 | this.ApplicationCommands = applicationCommands; 80 | _patientService = patientService; 81 | this.AllPatients = _patientService.GetAllPatients(); 82 | } 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /PrismMetroSample/PrismMetroSample/PrismMetroSample.PatientModule/Views/PatientDetail.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 |