├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── ModernUIIcons-License.txt
├── ModernWPF.sln
├── README.markdown
├── icons
├── icon-128.png
├── icon-16.png
├── icon-24.png
├── icon-256.png
├── icon-32.png
├── icon-48.png
├── icon-512.png
├── icon-64.png
└── icon.ico
├── images
├── textbox-clearbtn.png
├── textbox-leading.png
├── textbox-watermark.png
├── window-blank-red.png
├── window-blank.png
├── window-modern.png
├── xaml-app-basic.png
├── xaml-chrome-markup-custom.png
├── xaml-chrome-markup.png
└── xaml-window-basic.png
├── samples
└── ModernWPF.Sample
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── DialogWindow.xaml
│ ├── DialogWindow.xaml.cs
│ ├── InWindowDialog.xaml
│ ├── InWindowDialog.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── ModernWPF.Sample.csproj
│ ├── MsgWindow.xaml
│ ├── MsgWindow.xaml.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ ├── Settings.settings
│ └── VersionInfo.cs
│ ├── VM
│ ├── AccentVM.cs
│ ├── CultureInfoVM.cs
│ ├── HierarchyVM.cs
│ ├── ItemVM.cs
│ └── SampleAppVM.cs
│ ├── app.config
│ ├── icon.ico
│ └── packages.config
├── src
├── ModernWPF.Mvvm.Net4
│ ├── ModernWPF.Mvvm.Net4.csproj
│ ├── Sign.snk
│ ├── app.config
│ └── packages.config
├── ModernWPF.Mvvm
│ ├── AutoCleanupObservableCollection.cs
│ ├── AutoDisposeObservableCollection.cs
│ ├── CustomDictionary.xml
│ ├── Messages
│ │ └── MessageRoutine.cs
│ ├── ModernWPF.Mvvm.csproj
│ ├── ModernWPF.Mvvm.nuspec
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── VersionInfo.cs
│ ├── Sign.snk
│ ├── ViewModels
│ │ ├── AsyncPagerViewModel.cs
│ │ ├── DisposableViewModel.cs
│ │ ├── PagedCollectionViewModel.cs
│ │ ├── PagerViewModel.cs
│ │ ├── ProgressViewModel.cs
│ │ ├── SelectableViewModel.cs
│ │ └── StatusViewModel.cs
│ ├── app.config
│ └── packages.config
└── ModernWPF
│ ├── Accent.cs
│ ├── Animation.cs
│ ├── Assets
│ ├── error.png
│ ├── info.png
│ ├── question.png
│ └── warning.png
│ ├── Chrome.cs
│ ├── Controls
│ ├── AnimatedScrollViewer.cs
│ ├── AppButton.cs
│ ├── BorderSide.cs
│ ├── BorderWindow.cs
│ ├── ControlBox.cs
│ ├── DialogControl.cs
│ ├── DialogControlContainer.cs
│ ├── LegacyBorderWindow.cs
│ ├── MessageBoxControl.cs
│ ├── ModernContentControl.cs
│ ├── ModernMessageBox.xaml
│ ├── ModernMessageBox.xaml.cs
│ └── TileView.cs
│ ├── Converters
│ ├── AppIconImageConverter.cs
│ ├── BoolNotConverter.cs
│ ├── BoolVisibleConverter.cs
│ ├── EnumValueConverter.cs
│ ├── FileIconConverter.cs
│ ├── IsSmallFontConverter.cs
│ ├── MultiBoolVisibleConverter.cs
│ ├── NullEmptyCollapsedConverter.cs
│ ├── SingleToEnumerableConverter.cs
│ ├── TextCaseConverter.cs
│ ├── ThicknessToDoubleConverter.cs
│ ├── ThicknessZeroSideConverter.cs
│ ├── TreeDepthLeftMarginConverter.cs
│ └── WindowCaptionHeightConverter.cs
│ ├── CustomDictionary.xml
│ ├── DpiEvents.cs
│ ├── GlobalSuppressions.cs
│ ├── GridViewSortParameter.cs
│ ├── HSLColor.cs
│ ├── Internal
│ ├── BorderManager.cs
│ ├── EventUtil.cs
│ ├── LegacyBorderManager.cs
│ └── RelayCommand.cs
│ ├── ListViewUI.cs
│ ├── MenuItemUI.cs
│ ├── Messages
│ ├── AppCloseMessage.cs
│ ├── AppClosingMessage.cs
│ ├── ChooseFileMessage.cs
│ ├── ChooseFolderMessage.cs
│ ├── MessageBase.cs
│ ├── MessageBoxMessage.cs
│ ├── OpenExplorerMessage.cs
│ └── RefreshCommandsMessage.cs
│ ├── ModernExtensions.cs
│ ├── ModernTheme.cs
│ ├── ModernWPF.csproj
│ ├── ModernWPF.nuspec
│ ├── MouseEvents.cs
│ ├── Native
│ └── User32Ex.cs
│ ├── PlatformInfo.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ └── VersionInfo.cs
│ ├── Resources
│ ├── CommandText.Designer.cs
│ ├── CommandText.ja.resx
│ ├── CommandText.resx
│ ├── CommandText.zh-Hans.resx
│ ├── CommandText.zh-Hant.resx
│ └── CommandTextBinder.cs
│ ├── ScrollViewerUI.cs
│ ├── Sign.snk
│ ├── TextBoxUI.cs
│ ├── TextCommands.cs
│ ├── Themes
│ ├── Animations.xaml
│ ├── Generic.xaml
│ ├── ModernBase.xaml
│ ├── ModernBaseDesktop.xaml
│ ├── ModernDark.xaml
│ ├── ModernLight.xaml
│ ├── ModernStyles.xaml
│ ├── ModernStylesExplicit.cs
│ ├── ModernStylesExplicit.xaml
│ └── References
│ │ ├── Readme.txt
│ │ ├── winrt
│ │ ├── generic.xaml
│ │ └── themeresources.xaml
│ │ └── wpf
│ │ ├── aero.normalcolor.xaml
│ │ └── aero2.normalcolor.xaml
│ └── packages.config
└── tests
├── ModernWPF.Mvvm.Tests
├── AutoCleanupObservableCollectionTests.cs
├── AutoDisposeObservableCollectionTests.cs
├── ModernWPF.Mvvm.Tests.csproj
├── PagerViewModelTests.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
└── ModernWPF.Tests
├── AppIconImageConverterTest.cs
├── BoolVisibleConverterTest.cs
├── IsSmallFontConverterTest.cs
├── ModernWPF.Tests.csproj
├── MultiBoolVisibleConverterTest.cs
├── NullEmptyCollapsedConverterTest.cs
├── Properties
└── AssemblyInfo.cs
├── TextCaseConverterTest.cs
├── ThicknessZeroSideConverterTest.cs
└── packages.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 |
18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19 | !packages/*/build/
20 |
21 | # MSTest test Results
22 | [Tt]est[Rr]esult*/
23 | [Bb]uild[Ll]og.*
24 |
25 | *_i.c
26 | *_p.c
27 | *.ilk
28 | *.meta
29 | *.obj
30 | *.pch
31 | *.pdb
32 | *.pgc
33 | *.pgd
34 | *.rsp
35 | *.sbr
36 | *.tlb
37 | *.tli
38 | *.tlh
39 | *.tmp
40 | *.tmp_proj
41 | *.log
42 | *.vspscc
43 | *.vssscc
44 | .builds
45 | *.pidb
46 | *.log
47 | *.scc
48 |
49 | # Visual C++ cache files
50 | ipch/
51 | *.aps
52 | *.ncb
53 | *.opensdf
54 | *.sdf
55 | *.cachefile
56 |
57 | # Visual Studio profiler
58 | *.psess
59 | *.vsp
60 | *.vspx
61 |
62 | # Guidance Automation Toolkit
63 | *.gpState
64 |
65 | # ReSharper is a .NET coding add-in
66 | _ReSharper*/
67 | *.[Rr]e[Ss]harper
68 |
69 | # TeamCity is a build add-in
70 | _TeamCity*
71 |
72 | # DotCover is a Code Coverage Tool
73 | *.dotCover
74 |
75 | # NCrunch
76 | *.ncrunch*
77 | .*crunch*.local.xml
78 |
79 | # Installshield output folder
80 | [Ee]xpress/
81 |
82 | # DocProject is a documentation generator add-in
83 | DocProject/buildhelp/
84 | DocProject/Help/*.HxT
85 | DocProject/Help/*.HxC
86 | DocProject/Help/*.hhc
87 | DocProject/Help/*.hhk
88 | DocProject/Help/*.hhp
89 | DocProject/Help/Html2
90 | DocProject/Help/html
91 |
92 | # Click-Once directory
93 | publish/
94 |
95 | # Publish Web Output
96 | *.Publish.xml
97 |
98 | # NuGet Packages Directory
99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
100 | #packages/
101 |
102 | # Windows Azure Build Output
103 | csx
104 | *.build.csdef
105 |
106 | # Windows Store app package directory
107 | AppPackages/
108 |
109 | # Others
110 | sql/
111 | *.Cache
112 | ClientBin/
113 | [Ss]tyle[Cc]op.*
114 | ~$*
115 | *~
116 | *.dbmdl
117 | *.[Pp]ublish.xml
118 | *.pfx
119 | *.publishsettings
120 |
121 | # RIA/Silverlight projects
122 | Generated_Code/
123 |
124 | # Backup & report files from converting an old project file to a newer
125 | # Visual Studio version. Backup files are not needed, because we have git ;-)
126 | _UpgradeReport_Files/
127 | Backup*/
128 | UpgradeLog*.XML
129 | UpgradeLog*.htm
130 |
131 | # SQL Server files
132 | App_Data/*.mdf
133 | App_Data/*.ldf
134 |
135 |
136 | #LightSwitch generated files
137 | GeneratedArtifacts/
138 | _Pvt_Extensions/
139 | ModelManifest.xml
140 |
141 | # =========================
142 | # Windows detritus
143 | # =========================
144 |
145 | # Windows image file caches
146 | Thumbs.db
147 | ehthumbs.db
148 |
149 | # Folder config file
150 | Desktop.ini
151 |
152 | # Recycle Bin used on file shares
153 | $RECYCLE.BIN/
154 |
155 | # Mac desktop service store files
156 | .DS_Store
157 | /packages
158 | *.nupkg
159 | *.jtconfig
160 | /.vs/config
161 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2013 Yin-Chun Wang
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights to
7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 | of the Software, and to permit persons to whom the Software is furnished
9 | to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included
12 | in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 | OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/ModernUIIcons-License.txt:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | Please carefully understand the license and download the latest icons at ModernUIIcons.com.
4 |
5 | ## Understand Your Rights
6 | No Attribution and No Derived Works
7 | http://creativecommons.org/licenses/by-nd/3.0/ *
8 |
9 | - If your project is open source include this license file in the source.
10 | - Nothing is needed in the front facing project (UNLESS you
11 | are using any of the icons listed below in the attribution section).
12 | - Commercial use is not only allowed but encouraged. If it is an icon
13 | in the attribution list below, you still need to attribute those!
14 | - Do not distribute the entire package (I've allowed this dozens of
15 | times for open source projects, but email me first).
16 |
17 | ## Creator
18 | - Austin Andrews (@templarian)
19 |
20 | ## Contributor**
21 | - Jay Zawrotny (@JayZawrotny)
22 | - A Bunch
23 | - Oren Nachman
24 | - appbar.chevron.down
25 | - appbar.chevron.up
26 | - appbar.chevron.left
27 | - appbar.chevron.right
28 |
29 | ## Derived Works
30 | - Alex Peattie
31 | - Social: http://www.alexpeattie.com/projects/justvector_icons/
32 |
33 | ## Attribution***
34 | - Kris Vandermotten (@kvandermotten)
35 | - appbar.medical.pulse
36 | - Constantin Kichinsky (@kichinsky)
37 | - appbar.currency.rubles
38 | - appbar.currency.grivna
39 | - Massimo Savazzi (@msavazzi)
40 | - List of missing exported icons
41 | - Proletkult Graphik, from The Noun Project
42 | - appbar.draw.pen (inspired)
43 | - Olivier Guin, from The Noun Project
44 | - appbar.draw.marker
45 | - Gibran Bisio, from The Noun Project
46 | - appbar.draw.bucket
47 | Andrew Forrester, from The Noun Project
48 | - appbar.fingerprint
49 |
50 | * The license is for attribution, but this is not required.
51 | ** Developers and designers that emailed Templarian the source .design icons to be added into the package. PNGs also accepted, but may take longer to be added.
52 | *** Icons I've copied so closely you want to attribute them and are also under the CC license.
53 |
54 | Contact
55 | - http://templarian.com/
56 | - admin[@]templarian[.]com
57 |
58 | * Does not apply to copyrighted logos
59 | - Skype
60 | - Facebook
61 | - Twitter
62 | - etc...
--------------------------------------------------------------------------------
/ModernWPF.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30723.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWPF", "src\ModernWPF\ModernWPF.csproj", "{77D86B3D-EE36-4E4F-951D-A220DE7FBCCB}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{D41E34D6-9D5E-40AE-BA89-2EFC75023605}"
9 | ProjectSection(SolutionItems) = preProject
10 | LICENSE.txt = LICENSE.txt
11 | ModernUIIcons-License.txt = ModernUIIcons-License.txt
12 | README.markdown = README.markdown
13 | EndProjectSection
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWPF.Sample", "samples\ModernWPF.Sample\ModernWPF.Sample.csproj", "{816E78C7-1709-4586-A59D-B52D3495DE26}"
16 | EndProject
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWPF.Tests", "tests\ModernWPF.Tests\ModernWPF.Tests.csproj", "{312EC5C2-E085-4434-AFD2-86EADBC5DD32}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWPF.Mvvm.Tests", "tests\ModernWPF.Mvvm.Tests\ModernWPF.Mvvm.Tests.csproj", "{6B588EFA-5231-4312-B50C-5E5EC0A5B1CA}"
20 | EndProject
21 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0278F598-E288-4CF9-80FC-E1EBA2891A5E}"
22 | EndProject
23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWPF.Mvvm.Net4", "src\ModernWPF.Mvvm.Net4\ModernWPF.Mvvm.Net4.csproj", "{71FFB214-7239-48E1-BF7C-986E9EE870D4}"
24 | EndProject
25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWPF.Mvvm", "src\ModernWPF.Mvvm\ModernWPF.Mvvm.csproj", "{92496A6F-31C4-4EFA-B64D-688C1EF32B6B}"
26 | EndProject
27 | Global
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|Any CPU = Debug|Any CPU
30 | Release|Any CPU = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {77D86B3D-EE36-4E4F-951D-A220DE7FBCCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {77D86B3D-EE36-4E4F-951D-A220DE7FBCCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {77D86B3D-EE36-4E4F-951D-A220DE7FBCCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {77D86B3D-EE36-4E4F-951D-A220DE7FBCCB}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {816E78C7-1709-4586-A59D-B52D3495DE26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {816E78C7-1709-4586-A59D-B52D3495DE26}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {816E78C7-1709-4586-A59D-B52D3495DE26}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {816E78C7-1709-4586-A59D-B52D3495DE26}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {312EC5C2-E085-4434-AFD2-86EADBC5DD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {312EC5C2-E085-4434-AFD2-86EADBC5DD32}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {312EC5C2-E085-4434-AFD2-86EADBC5DD32}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {312EC5C2-E085-4434-AFD2-86EADBC5DD32}.Release|Any CPU.Build.0 = Release|Any CPU
45 | {6B588EFA-5231-4312-B50C-5E5EC0A5B1CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {6B588EFA-5231-4312-B50C-5E5EC0A5B1CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {6B588EFA-5231-4312-B50C-5E5EC0A5B1CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {6B588EFA-5231-4312-B50C-5E5EC0A5B1CA}.Release|Any CPU.Build.0 = Release|Any CPU
49 | {71FFB214-7239-48E1-BF7C-986E9EE870D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50 | {71FFB214-7239-48E1-BF7C-986E9EE870D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
51 | {71FFB214-7239-48E1-BF7C-986E9EE870D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 | {71FFB214-7239-48E1-BF7C-986E9EE870D4}.Release|Any CPU.Build.0 = Release|Any CPU
53 | {92496A6F-31C4-4EFA-B64D-688C1EF32B6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {92496A6F-31C4-4EFA-B64D-688C1EF32B6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {92496A6F-31C4-4EFA-B64D-688C1EF32B6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
56 | {92496A6F-31C4-4EFA-B64D-688C1EF32B6B}.Release|Any CPU.Build.0 = Release|Any CPU
57 | EndGlobalSection
58 | GlobalSection(SolutionProperties) = preSolution
59 | HideSolutionNode = FALSE
60 | EndGlobalSection
61 | GlobalSection(NestedProjects) = preSolution
62 | {312EC5C2-E085-4434-AFD2-86EADBC5DD32} = {0278F598-E288-4CF9-80FC-E1EBA2891A5E}
63 | {6B588EFA-5231-4312-B50C-5E5EC0A5B1CA} = {0278F598-E288-4CF9-80FC-E1EBA2891A5E}
64 | EndGlobalSection
65 | EndGlobal
66 |
--------------------------------------------------------------------------------
/README.markdown:
--------------------------------------------------------------------------------
1 | ModernWPF
2 | ==============================
3 |
4 | Project Info
5 | --------------------------------------
6 | This is a small lib for creating modern-style
7 | Windows application in WPF 4. This was formerly
8 | the MetroWPF lib.
9 |
10 | Some Features
11 | --------------------------------------
12 | + Easily create border-less window with resizing drop-shadows like VS 2012 or Office 2013 without using WindowStyle="None" property.
13 |
14 | + All standard chrome behaviors are supported (caption area, icon area, aero snap, etc.).
15 |
16 | + Does NOT require inheriting from a custom Window class.
17 |
18 | + Modern theme in this lib is optional. The border-less windows is a blank canvas so developers can use other theming lib.
19 |
20 | + Chrome only applies to one window (unless set in styles) so different windows in a single process can have different border colors.
21 |
--------------------------------------------------------------------------------
/icons/icon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-128.png
--------------------------------------------------------------------------------
/icons/icon-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-16.png
--------------------------------------------------------------------------------
/icons/icon-24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-24.png
--------------------------------------------------------------------------------
/icons/icon-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-256.png
--------------------------------------------------------------------------------
/icons/icon-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-32.png
--------------------------------------------------------------------------------
/icons/icon-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-48.png
--------------------------------------------------------------------------------
/icons/icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-512.png
--------------------------------------------------------------------------------
/icons/icon-64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon-64.png
--------------------------------------------------------------------------------
/icons/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/icons/icon.ico
--------------------------------------------------------------------------------
/images/textbox-clearbtn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/textbox-clearbtn.png
--------------------------------------------------------------------------------
/images/textbox-leading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/textbox-leading.png
--------------------------------------------------------------------------------
/images/textbox-watermark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/textbox-watermark.png
--------------------------------------------------------------------------------
/images/window-blank-red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/window-blank-red.png
--------------------------------------------------------------------------------
/images/window-blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/window-blank.png
--------------------------------------------------------------------------------
/images/window-modern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/window-modern.png
--------------------------------------------------------------------------------
/images/xaml-app-basic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/xaml-app-basic.png
--------------------------------------------------------------------------------
/images/xaml-chrome-markup-custom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/xaml-chrome-markup-custom.png
--------------------------------------------------------------------------------
/images/xaml-chrome-markup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/xaml-chrome-markup.png
--------------------------------------------------------------------------------
/images/xaml-window-basic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/images/xaml-window-basic.png
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using CommonWin32;
2 | using CommonWin32.API;
3 | using CommonWin32.HighDPI;
4 | using ModernWPF.Resources;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using System.Configuration;
9 | using System.Data;
10 | using System.Linq;
11 | using System.Runtime.InteropServices;
12 | using System.Threading;
13 | using System.Windows;
14 |
15 | namespace ModernWPF.Sample
16 | {
17 | ///
18 | /// Interaction logic for App.xaml
19 | ///
20 | public partial class App : Application
21 | {
22 | public App()
23 | {
24 | this.DispatcherUnhandledException += App_DispatcherUnhandledException;
25 | }
26 |
27 | void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
28 | {
29 | MessageBox.Show("Global Exception: " + e.Exception.ToString());
30 | }
31 |
32 | protected override void OnStartup(StartupEventArgs e)
33 | {
34 | var test = Shcore.SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE);
35 | if (!test)
36 | {
37 | var err = new Win32Exception();
38 | }
39 |
40 | base.OnStartup(e);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/DialogWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | Just a dialog showing a different ModernWindow style
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/DialogWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
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.Shapes;
13 |
14 | namespace ModernWPF.Sample
15 | {
16 | ///
17 | /// Interaction logic for DialogWindow.xaml
18 | ///
19 | public partial class DialogWindow : Window
20 | {
21 | public DialogWindow()
22 | {
23 | InitializeComponent();
24 |
25 | List items = new List();
26 | for (int i = 0; i < 50; i++)
27 | {
28 | items.Add(string.Format("Item {0:00}", i));
29 | }
30 | list.ItemsSource = items;
31 | }
32 |
33 | private void Button_Click(object sender, RoutedEventArgs e)
34 | {
35 | DialogResult = true;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/InWindowDialog.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | TBD
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/InWindowDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using ModernWPF.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace ModernWPF.Sample
17 | {
18 | ///
19 | /// Interaction logic for InWindowDialog.xaml
20 | ///
21 | public partial class InWindowDialog : DialogControl
22 | {
23 | public InWindowDialog()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | public string Message { get { return infolabel.Text; } set { infolabel.Text = value; } }
29 |
30 | protected override void OnFocus()
31 | {
32 | mybox.Focus();
33 | }
34 |
35 | private void btnOk_Click(object sender, RoutedEventArgs e)
36 | {
37 | this.DialogResult = true;
38 | }
39 |
40 | private void btnCancel_Click(object sender, RoutedEventArgs e)
41 | {
42 | this.DialogResult = false;
43 | }
44 |
45 | private void btnTop_Click(object sender, RoutedEventArgs e)
46 | {
47 | VerticalAlignment = System.Windows.VerticalAlignment.Top;
48 | }
49 |
50 | private void btnCenter_Click(object sender, RoutedEventArgs e)
51 | {
52 | VerticalAlignment = System.Windows.VerticalAlignment.Center;
53 | }
54 |
55 | private void btnBottom_Click(object sender, RoutedEventArgs e)
56 | {
57 | VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
58 | }
59 |
60 | private void btnStretch_Click(object sender, RoutedEventArgs e)
61 | {
62 | VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
63 | }
64 |
65 | private void mybox_KeyDown(object sender, KeyEventArgs e)
66 | {
67 | //if (e.Key == Key.Escape) { e.Handled = true; }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/MsgWindow.xaml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/MsgWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using CommonWin32.Windows;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Interop;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Shapes;
15 |
16 | namespace ModernWPF.Sample
17 | {
18 | ///
19 | /// Interaction logic for MsgWindow.xaml
20 | ///
21 | public partial class MsgWindow : Window
22 | {
23 | public MsgWindow()
24 | {
25 | InitializeComponent();
26 | this.SourceInitialized += MsgWindow_SourceInitialized;
27 | }
28 |
29 | void MsgWindow_SourceInitialized(object sender, EventArgs e)
30 | {
31 | var hwnd = new WindowInteropHelper(this).Handle;
32 | var src = HwndSource.FromHwnd(hwnd);
33 | src.AddHook(WndProc);
34 |
35 | }
36 |
37 | IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
38 | {
39 | IntPtr retVal = IntPtr.Zero;
40 | var wmsg = (WindowMessage)msg;
41 | msgBox.AppendText(string.Format("{0}\n", wmsg));
42 | msgBox.ScrollToEnd();
43 | return retVal;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 | using System.Windows.Media;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("ModernWPF.Sample")]
12 | [assembly: AssemblyDescription("")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyProduct("ModernWPF.Sample")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | //In order to begin building localizable applications, set
24 | //CultureYouAreCodingWith in your .csproj file
25 | //inside a . For example, if you are using US english
26 | //in your source files, set the to en-US. Then uncomment
27 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
28 | //the line below to match the UICulture setting in the project file.
29 |
30 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
31 |
32 |
33 | [assembly: ThemeInfo(
34 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
35 | //(used if a resource is not found in the page,
36 | // or application resource dictionaries)
37 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
38 | //(used if a resource is not found in the page,
39 | // app, or any theme specific resource dictionaries)
40 | )]
41 |
42 | [assembly: DisableDpiAwareness]
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34003
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ModernWPF.Sample.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModernWPF.Sample.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34003
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ModernWPF.Sample.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/Properties/VersionInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyCompany("Yin-Chun Wang")]
4 | [assembly: AssemblyCopyright("Copyright © Yin-Chun Wang 2014")]
5 |
6 | [assembly: AssemblyVersion("1.0.0.0")]
7 | [assembly: AssemblyFileVersion("1.0.0")]
8 | [assembly: AssemblyInformationalVersion("1.0.0")]
9 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/VM/AccentVM.cs:
--------------------------------------------------------------------------------
1 | using ModernWPF.ViewModels;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ModernWPF.Sample.VM
8 | {
9 | class AccentVM : SelectableViewModel
10 | {
11 | public AccentVM(Accent a)
12 | : base(a)
13 | {
14 |
15 | }
16 |
17 | protected override void OnSelectedChanged()
18 | {
19 | if (IsSelected)
20 | {
21 | ModernTheme.ApplyTheme(ModernTheme.CurrentTheme.GetValueOrDefault(), Model);
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/VM/CultureInfoVM.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight.Messaging;
2 | using ModernWPF.Resources;
3 | using ModernWPF.ViewModels;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Collections.ObjectModel;
7 | using System.Globalization;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading;
11 |
12 | namespace ModernWPF.Sample.VM
13 | {
14 | class CultureInfoVM : SelectableViewModel
15 | {
16 | public CultureInfoVM(CultureInfo info)
17 | : base(info)
18 | {
19 |
20 | }
21 |
22 | protected override void OnSelectedChanged()
23 | {
24 | if (IsSelected)
25 | {
26 | Thread.CurrentThread.CurrentUICulture = Model;
27 | CommandTextBinder.Instance.UpdateCulture(Model);
28 | }
29 | }
30 |
31 | public override string ToString()
32 | {
33 | return Model.NativeName;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/VM/HierarchyVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ModernWPF.Sample.VM
8 | {
9 | class HierarchyVM
10 | {
11 | public HierarchyVM(int children)
12 | {
13 | Children = new ObservableCollection();
14 | for (int i = 0; i < children; i++)
15 | {
16 | Children.Add(new HierarchyVM(children - 1));
17 | }
18 | Name = string.Format("has {0} nodes", children);
19 | }
20 |
21 | public string Name { get; set; }
22 |
23 | public ObservableCollection Children { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/VM/ItemVM.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ModernWPF.Sample.VM
7 | {
8 | class ItemVM
9 | {
10 | public bool Boolean { get; set; }
11 |
12 | public string String { get; set; }
13 |
14 | public int Number { get; set; }
15 |
16 |
17 | public DateTime Date { get { return DateTime.Now; } }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/samples/ModernWPF.Sample/icon.ico
--------------------------------------------------------------------------------
/samples/ModernWPF.Sample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm.Net4/Sign.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF.Mvvm.Net4/Sign.snk
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm.Net4/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm.Net4/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/AutoCleanupObservableCollection.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace ModernWPF
9 | {
10 | ///
11 | /// An observable collection that will cleanup items when they are removed.
12 | ///
13 | /// A type that implements .
14 | public class AutoCleanupObservableCollection : ObservableCollection where T : ICleanup
15 | {
16 | ///
17 | /// Replaces the element at the specified index.
18 | ///
19 | /// The index.
20 | /// The item.
21 | protected override void SetItem(int index, T item)
22 | {
23 | T it = this[index];
24 | try
25 | {
26 | base.SetItem(index, item);
27 | }
28 | finally
29 | {
30 | if (it != null) { it.Cleanup(); }
31 | }
32 | }
33 |
34 | ///
35 | /// Removes all items from the collection.
36 | ///
37 | protected override void ClearItems()
38 | {
39 | // use a handle since the items may still be in UI.
40 | var handle = new List(this);
41 | try
42 | {
43 | base.ClearItems();
44 | }
45 | finally
46 | {
47 | foreach (var it in handle) { it.Cleanup(); }
48 | }
49 | }
50 |
51 | ///
52 | /// Removes the item at the specified index of the collection.
53 | ///
54 | /// The index.
55 | protected override void RemoveItem(int index)
56 | {
57 | T it = this[index];
58 | try
59 | {
60 | base.RemoveItem(index);
61 | }
62 | finally
63 | {
64 | if (it != null) { it.Cleanup(); }
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/AutoDisposeObservableCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ModernWPF
8 | {
9 | ///
10 | /// An observable collection that will dispose items when they are removed.
11 | ///
12 | /// A type that implements .
13 | public class AutoDisposeObservableCollection : ObservableCollection where T : IDisposable
14 | {
15 | ///
16 | /// Replaces the element at the specified index.
17 | ///
18 | /// The index.
19 | /// The item.
20 | protected override void SetItem(int index, T item)
21 | {
22 | T it = this[index];
23 | try
24 | {
25 | base.SetItem(index, item);
26 | }
27 | finally
28 | {
29 | if (it != null) { it.Dispose(); }
30 | }
31 | }
32 |
33 | ///
34 | /// Removes all items from the collection.
35 | ///
36 | protected override void ClearItems()
37 | {
38 | // use a handle since the items may still be in UI.
39 | var handle = new List(this);
40 | try
41 | {
42 | base.ClearItems();
43 | }
44 | finally
45 | {
46 | foreach (var it in handle) { it.Dispose(); }
47 | }
48 | }
49 |
50 | ///
51 | /// Removes the item at the specified index of the collection.
52 | ///
53 | /// The index.
54 | protected override void RemoveItem(int index)
55 | {
56 | T it = this[index];
57 | try
58 | {
59 | base.RemoveItem(index);
60 | }
61 | finally
62 | {
63 | if (it != null) { it.Dispose(); }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/CustomDictionary.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Prev
6 | Mvvm
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | WPF
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/Messages/MessageRoutine.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight.Messaging;
2 | using Microsoft.Win32;
3 | using Microsoft.WindowsAPICodePack.Dialogs;
4 | using Microsoft.WindowsAPICodePack.Shell;
5 | using ModernWPF.Controls;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Diagnostics;
9 | using System.Globalization;
10 | using System.Linq;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 | using System.Windows;
14 | using System.Windows.Input;
15 |
16 | namespace ModernWPF.Messages
17 | {
18 | ///
19 | /// Contains common routines for handling messages on a view.
20 | ///
21 | public static class MessageRoutine
22 | {
23 | ///
24 | /// Handles the on a window by showing a folder dialog based on the message options.
25 | ///
26 | /// The owner.
27 | /// The message.
28 | ///
29 | /// message
30 | ///
31 | public static void HandleChooseFolder(this Window owner, ChooseFolderMessage message)
32 | {
33 | //if (owner == null) { throw new ArgumentNullException("owner"); }
34 | if (message == null) { throw new ArgumentNullException("message"); }
35 |
36 | if (CommonOpenFileDialog.IsPlatformSupported)
37 | {
38 | using (var diag = new CommonOpenFileDialog())
39 | {
40 | diag.InitialDirectory = message.InitialFolder;
41 | diag.IsFolderPicker = true;
42 | diag.Title = message.Caption;
43 | diag.Multiselect = false;
44 | // allow this for desktop, but now opens other locations up so need to check those
45 | diag.AllowNonFileSystemItems = true;
46 |
47 | REOPEN:
48 |
49 | var result = owner == null ? diag.ShowDialog() : diag.ShowDialog(owner);
50 |
51 | if (result == CommonFileDialogResult.Ok)
52 | {
53 | ShellObject selectedSO = null;
54 |
55 | try
56 | {
57 | // Try to get a valid selected item
58 | selectedSO = diag.FileAsShellObject as ShellObject;
59 | }
60 | catch (Exception ex)
61 | {
62 | MessageBox.Show("Could not create a ShellObject from the selected item: " + ex.Message);
63 | }
64 | if (selectedSO != null)
65 | {
66 | string name = selectedSO.Name;
67 | string path = selectedSO.ParsingName;
68 | bool notReal = selectedSO is ShellNonFileSystemFolder;
69 | selectedSO.Dispose();
70 | if (notReal)
71 | {
72 | if (path.EndsWith(".library-ms", StringComparison.OrdinalIgnoreCase))
73 | {
74 | using (var lib = ShellLibrary.Load(name, true))
75 | {
76 | if (lib != null)
77 | path = lib.DefaultSaveFolder;
78 | }
79 | }
80 | else
81 | {
82 | if (MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "The location \"{0}\" is not valid, please select another.", name),
83 | "Invalid Location", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK)
84 | {
85 | goto REOPEN;
86 | }
87 | else
88 | {
89 | return;
90 | }
91 | }
92 | }
93 |
94 | if (owner == null || owner.Dispatcher.CheckAccess())
95 | {
96 | message.DoCallback(path);
97 | }
98 | else
99 | {
100 | owner.Dispatcher.BeginInvoke(new Action(() =>
101 | {
102 | message.DoCallback(path);
103 | }));
104 | }
105 | }
106 | }
107 | }
108 | }
109 | else
110 | {
111 | message.HandleWithPlatform(owner);
112 | }
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/ModernWPF.Mvvm.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | $title$
7 | $author$
8 | $author$
9 | https://github.com/soukoku/ModernWPF
10 | https://github.com/soukoku/ModernWPF/blob/master/LICENSE.txt
11 | http://i.imgur.com/WAYKszr.png
12 | false
13 | $description$
14 |
15 | $copyright$
16 | metro modern wpf mvvm
17 |
18 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Resources;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 | using System.Windows;
7 | using System.Windows.Markup;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("ModernWPF.Mvvm")]
13 | [assembly: AssemblyDescription("Contains some useful view models, messages, and handler routines using ModernWPF and MvvmLight.")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyProduct("ModernWPF.Mvvm")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 | [assembly: ComVisible(false)]
19 | [assembly: CLSCompliant(true)]
20 |
21 |
22 | //In order to begin building localizable applications, set
23 | //CultureYouAreCodingWith in your .csproj file
24 | //inside a . For example, if you are using US english
25 | //in your source files, set the to en-US. Then uncomment
26 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
27 | //the line below to match the UICulture setting in the project file.
28 |
29 | [assembly: NeutralResourcesLanguage("en", UltimateResourceFallbackLocation.MainAssembly)]
30 |
31 |
32 | [assembly: ThemeInfo(
33 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
34 | //(used if a resource is not found in the page,
35 | // or application resource dictionaries)
36 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
37 | //(used if a resource is not found in the page,
38 | // app, or any theme specific resource dictionaries)
39 | )]
40 |
41 | //[assembly: XmlnsDefinition("http://modernwpf", "ModernWPF")]
42 | [assembly: XmlnsDefinition("http://modernwpf", "ModernWPF")]
43 | [assembly: XmlnsDefinition("http://modernwpf", "ModernWPF.ViewModels")]
44 | //[assembly: XmlnsDefinition("http://modernwpf", "ModernWPF.Controls")]
45 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/Properties/VersionInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyCompany("Yin-Chun Wang")]
4 | [assembly: AssemblyCopyright("Copyright © Yin-Chun Wang 2014")]
5 |
6 | [assembly: AssemblyVersion(ModernWPF.Mvvm.Version.Release)]
7 | [assembly: AssemblyFileVersion(ModernWPF.Mvvm.Version.Build)]
8 | [assembly: AssemblyInformationalVersion(ModernWPF.Mvvm.Version.Build)]
9 |
10 | namespace ModernWPF.Mvvm
11 | {
12 | static class Version
13 | {
14 | // change this only for major releases
15 | public const string Release = "0.7.0.0";
16 | // change this for each nuget release
17 | public const string Build = "0.7.5";
18 | }
19 | }
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/Sign.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF.Mvvm/Sign.snk
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/ViewModels/DisposableViewModel.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ModernWPF.ViewModels
8 | {
9 | ///
10 | /// A view model base class that also implements .
11 | ///
12 | public class DisposableViewModel : ViewModelBase, IDisposable
13 | {
14 |
15 | ///
16 | /// Gets a value indicating whether this instance is disposed.
17 | ///
18 | ///
19 | /// true if this instance is disposed; otherwise, false.
20 | ///
21 | public bool IsDisposed { get; private set; }
22 |
23 | ///
24 | /// Throws exception if this instance is disposed.
25 | ///
26 | ///
27 | protected void VerifyNotDisposed()
28 | {
29 | if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); }
30 | }
31 |
32 | ///
33 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
34 | ///
35 | public void Dispose()
36 | {
37 | Dispose(true);
38 | GC.SuppressFinalize(this);
39 | }
40 | ///
41 | /// Finalizes an instance of the class.
42 | ///
43 | ~DisposableViewModel()
44 | {
45 | Dispose(false);
46 | }
47 |
48 | private void Dispose(bool disposing)
49 | {
50 | IsDisposed = true;
51 | if (disposing)
52 | {
53 | OnDisposingManaged();
54 | }
55 | OnDisposingNative();
56 | }
57 |
58 | ///
59 | /// Called when disposing managed resources.
60 | ///
61 | protected virtual void OnDisposingManaged()
62 | {
63 | Cleanup();
64 | }
65 |
66 | ///
67 | /// Called when disposing native resources.
68 | ///
69 | protected virtual void OnDisposingNative() { }
70 |
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/ViewModels/ProgressViewModel.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Shell;
8 |
9 | namespace ModernWPF.ViewModels
10 | {
11 | ///
12 | /// A view-model for reporting progress. This is also suitable for databinding to
13 | /// in a wpf window.
14 | ///
15 | public class ProgressViewModel : ViewModelBase
16 | {
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | public ProgressViewModel()
21 | {
22 | Info = new StatusViewModel();
23 | }
24 |
25 | ///
26 | /// Updates the progress state.
27 | ///
28 | /// The state.
29 | public void UpdateState(TaskbarItemProgressState state)
30 | {
31 | UpdateState(state, 0, null, StatusType.Info);
32 | }
33 | ///
34 | /// Updates the progress state.
35 | ///
36 | /// The state.
37 | /// The progress percent (0 to 1).
38 | public void UpdateState(TaskbarItemProgressState state, double progressPercent)
39 | {
40 | UpdateState(state, progressPercent, null, StatusType.Info);
41 | }
42 | ///
43 | /// Updates the progress state.
44 | ///
45 | /// The state.
46 | /// The progress percent (0 to 1).
47 | /// The extra information.
48 | public void UpdateState(TaskbarItemProgressState state, double progressPercent, string info)
49 | {
50 | UpdateState(state, progressPercent, info, StatusType.Info);
51 | }
52 |
53 | ///
54 | /// Updates the progress state.
55 | ///
56 | /// The state.
57 | /// The progress percent (0 to 1).
58 | /// The extra information.
59 | /// Type of the information.
60 | public void UpdateState(TaskbarItemProgressState state, double progressPercent, string info, StatusType infoType)
61 | {
62 | Info.Update(info, infoType);
63 | State = state;
64 |
65 | var val = progressPercent * Maximum;
66 | if (val < Minimum) { val = Minimum; }
67 | else if (val > Maximum) { val = Maximum; }
68 | Value = val;
69 |
70 | RaisePropertyChanged(() => State);
71 | RaisePropertyChanged(() => IsIndeterminate);
72 | RaisePropertyChanged(() => IsBusy);
73 | RaisePropertyChanged(() => Info);
74 | RaisePropertyChanged(() => Value);
75 | }
76 |
77 |
78 | ///
79 | /// Gets the progress state.
80 | ///
81 | ///
82 | /// The state.
83 | ///
84 | public TaskbarItemProgressState State { get; private set; }
85 |
86 | ///
87 | /// Gets a value indicating whether the is indeterminate.
88 | ///
89 | ///
90 | /// true if the is indeterminate; otherwise, false.
91 | ///
92 | public bool IsIndeterminate { get { return State == TaskbarItemProgressState.Indeterminate; } }
93 |
94 | ///
95 | /// Gets a value indicating whether the is reporting progress.
96 | ///
97 | ///
98 | /// true if the is reporting progress; otherwise, false.
99 | ///
100 | public bool IsBusy { get { return State != TaskbarItemProgressState.None; } }
101 |
102 | ///
103 | /// Gets the extra information.
104 | ///
105 | ///
106 | /// The information.
107 | ///
108 | public StatusViewModel Info { get; private set; }
109 |
110 | ///
111 | /// Gets the maximum for data-binding purposes.
112 | ///
113 | ///
114 | /// The maximum.
115 | ///
116 | public static double Maximum { get { return 1; } }
117 | ///
118 | /// Gets the minimum for data-binding purposes.
119 | ///
120 | ///
121 | /// The minimum.
122 | ///
123 | public static double Minimum { get { return 0; } }
124 | ///
125 | /// Gets the current progress value.
126 | ///
127 | ///
128 | /// The value.
129 | ///
130 | public double Value { get; private set; }
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/ViewModels/SelectableViewModel.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ModernWPF.ViewModels
10 | {
11 | ///
12 | /// A view-model for something that can be selected.
13 | ///
14 | public abstract class SelectableViewModel : ViewModelBase
15 | {
16 | private bool _isSelected;
17 |
18 | ///
19 | /// Gets or sets a value indicating whether this instance is selected.
20 | ///
21 | ///
22 | /// true if this instance is selected; otherwise, false.
23 | ///
24 | public bool IsSelected
25 | {
26 | get { return _isSelected; }
27 | set
28 | {
29 | _isSelected = value;
30 | OnSelectedChanged();
31 | RaisePropertyChanged(() => this.IsSelected);
32 | }
33 | }
34 |
35 | ///
36 | /// Called when IsSelected has changed.
37 | ///
38 | protected virtual void OnSelectedChanged()
39 | {
40 | }
41 |
42 | }
43 |
44 | ///
45 | /// A selectable view-model wrapper for another model.
46 | ///
47 | /// The type of the model.
48 | public class SelectableViewModel : SelectableViewModel
49 | {
50 | ///
51 | /// Initializes a new instance of the class.
52 | ///
53 | /// The model.
54 | protected SelectableViewModel(TModel model)
55 | {
56 | Model = model;
57 | }
58 |
59 | ///
60 | /// Gets the model.
61 | ///
62 | ///
63 | /// The model.
64 | ///
65 | public TModel Model { get; private set; }
66 |
67 |
68 | ///
69 | /// Raises property changed event on the model.
70 | ///
71 | public void UpdateModelProperties()
72 | {
73 | RaisePropertyChanged(() => this.Model);
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/ViewModels/StatusViewModel.cs:
--------------------------------------------------------------------------------
1 | using GalaSoft.MvvmLight;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ModernWPF.ViewModels
9 | {
10 | ///
11 | /// A view model for status string.
12 | ///
13 | public class StatusViewModel : ViewModelBase
14 | {
15 | ///
16 | /// Updates status with the specified text.
17 | ///
18 | /// The text.
19 | public void Update(string text)
20 | {
21 | Update(text, StatusType.Info);
22 | }
23 |
24 | ///
25 | /// Updates status with the specified text.
26 | ///
27 | /// The text.
28 | /// The type.
29 | public void Update(string text, StatusType type)
30 | {
31 | Text = text;
32 | StatusType = type;
33 | RaisePropertyChanged(() => Text);
34 | RaisePropertyChanged(() => StatusType);
35 | RaisePropertyChanged(() => IsError);
36 | RaisePropertyChanged(() => IsWarning);
37 | RaisePropertyChanged(() => IsSuccess);
38 | RaisePropertyChanged(() => IsInfo);
39 | }
40 |
41 | ///
42 | /// Gets the status type.
43 | ///
44 | ///
45 | /// The type.
46 | ///
47 | public StatusType StatusType { get; private set; }
48 |
49 | ///
50 | /// Gets the status text.
51 | ///
52 | ///
53 | /// The text.
54 | ///
55 | public string Text { get; private set; }
56 |
57 | ///
58 | /// Gets a value indicating whether current status is error.
59 | ///
60 | ///
61 | /// true if current status is error; otherwise, false.
62 | ///
63 | public bool IsError { get { return StatusType == StatusType.Error; } }
64 | ///
65 | /// Gets a value indicating whether current status is warning.
66 | ///
67 | ///
68 | /// true if current status is warning; otherwise, false.
69 | ///
70 | public bool IsWarning { get { return StatusType == StatusType.Warning; } }
71 | ///
72 | /// Gets a value indicating whether current status is success.
73 | ///
74 | ///
75 | /// true if current status is success; otherwise, false.
76 | ///
77 | public bool IsSuccess { get { return StatusType == StatusType.Success; } }
78 | ///
79 | /// Gets a value indicating whether current status is info.
80 | ///
81 | ///
82 | /// true if current status is info; otherwise, false.
83 | ///
84 | public bool IsInfo { get { return StatusType == StatusType.Info; } }
85 |
86 | ///
87 | /// Returns a that represents this instance.
88 | ///
89 | ///
90 | /// A that represents this instance.
91 | ///
92 | public override string ToString()
93 | {
94 | return Text;
95 | }
96 | }
97 |
98 | ///
99 | /// Indicates the status type.
100 | ///
101 | public enum StatusType
102 | {
103 | ///
104 | /// The information type.
105 | ///
106 | Info,
107 | ///
108 | /// The success type.
109 | ///
110 | Success,
111 | ///
112 | /// The warning type.
113 | ///
114 | Warning,
115 | ///
116 | /// The error type.
117 | ///
118 | Error
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/ModernWPF.Mvvm/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/ModernWPF/Assets/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF/Assets/error.png
--------------------------------------------------------------------------------
/src/ModernWPF/Assets/info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF/Assets/info.png
--------------------------------------------------------------------------------
/src/ModernWPF/Assets/question.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF/Assets/question.png
--------------------------------------------------------------------------------
/src/ModernWPF/Assets/warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF/Assets/warning.png
--------------------------------------------------------------------------------
/src/ModernWPF/Controls/BorderSide.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ModernWPF.Controls
7 | {
8 | enum BorderSide
9 | {
10 | Left = 180,
11 | Top = 90,
12 | Right = 0,
13 | Bottom = 270
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/ModernWPF/Controls/ModernContentControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Media;
7 | using System.Windows.Media.Animation;
8 |
9 | namespace ModernWPF.Controls
10 | {
11 | // originally from http://xamlcoder.com/blog/2010/11/04/creating-a-metro-ui-style-control/
12 | // but no longer resembles it
13 |
14 | ///
15 | /// A that animates content in.
16 | ///
17 | //[TemplatePart(Name = PARTContent, Type = typeof(ContentPresenter))]
18 | public class ModernContentControl : ContentControl
19 | {
20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
21 | static ModernContentControl()
22 | {
23 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ModernContentControl), new FrameworkPropertyMetadata(typeof(ModernContentControl)));
24 | }
25 |
26 | //const string PARTContent = "PART_Content";
27 |
28 | //ContentPresenter _presenter;
29 |
30 | ///
31 | /// Initializes a new instance of the class.
32 | ///
33 | public ModernContentControl()
34 | {
35 | if (!DesignerProperties.GetIsInDesignMode(this))
36 | {
37 | this.Loaded += (s, e) =>
38 | {
39 | AnimateIn();
40 | };
41 | this.DataContextChanged += (s, e) =>
42 | {
43 | AnimateIn();
44 | };
45 | //this.Unloaded += (s, e) =>
46 | //{
47 | // AnimateOut();
48 | //};
49 | }
50 | }
51 |
52 | /////
53 | ///// Animates the content out.
54 | /////
55 | //public void AnimateOut()
56 | //{
57 | // if (Animation.ShouldAnimate)
58 | // {
59 | // Animation.FadeOut(this, Animation.TypicalDuration);
60 | // }
61 | //}
62 |
63 | ///
64 | /// Animates the content in.
65 | ///
66 | public void AnimateIn()
67 | {
68 | if (Animation.ShouldAnimate)
69 | {
70 | Animation.FadeIn(this, Animation.TypicalDuration);
71 | Animation.SlideIn(this, SlideFromDirection, TimeSpan.FromMilliseconds((double)AnimationSpeed.Slow));
72 | }
73 | }
74 |
75 | /////
76 | ///// When overridden in a derived class, is invoked whenever application code or internal processes call .
77 | /////
78 | //public override void OnApplyTemplate()
79 | //{
80 | // base.OnApplyTemplate();
81 | // _presenter = GetTemplateChild(PARTContent) as ContentPresenter;
82 | //}
83 |
84 |
85 | ///
86 | /// Gets or sets the slide from animation direction.
87 | ///
88 | ///
89 | /// The slide from direction.
90 | ///
91 | public SlideFromDirection SlideFromDirection
92 | {
93 | get { return (SlideFromDirection)GetValue(SlideFromDirectionProperty); }
94 | set { SetValue(SlideFromDirectionProperty, value); }
95 | }
96 |
97 |
98 | ///
99 | /// The DP for .
100 | ///
101 | public static readonly DependencyProperty SlideFromDirectionProperty =
102 | DependencyProperty.Register("SlideFromDirection", typeof(SlideFromDirection), typeof(ModernContentControl), new PropertyMetadata(SlideFromDirection.Right));
103 |
104 |
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/ModernWPF/Controls/ModernMessageBox.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/src/ModernWPF/Controls/TileView.cs:
--------------------------------------------------------------------------------
1 | //using System;
2 | //using System.Collections.Generic;
3 | //using System.Linq;
4 | //using System.Text;
5 | //using System.Windows.Controls;
6 |
7 | //namespace ModernWPF.Controls
8 | //{
9 | // ///
10 | // /// Tile view for a control.
11 | // ///
12 | // public class TileView : ViewBase
13 | // {
14 |
15 | // }
16 | //}
17 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/AppIconImageConverter.cs:
--------------------------------------------------------------------------------
1 | using CommonWin32.API;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Reflection;
9 | using System.Text;
10 | using System.Windows;
11 | using System.Windows.Data;
12 | using System.Windows.Interop;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 |
16 | namespace ModernWPF.Converters
17 | {
18 | ///
19 | /// A converter for the property that if not set, will return the application's icon (i.e. from the exe file).
20 | ///
21 | [ValueConversion(typeof(ImageSource), typeof(ImageSource))]
22 | public class AppIconImageConverter : IValueConverter
23 | {
24 | static readonly AppIconImageConverter _instance = new AppIconImageConverter();
25 |
26 | ///
27 | /// Gets the singleton instance for this converter.
28 | ///
29 | ///
30 | /// The instance.
31 | ///
32 | public static AppIconImageConverter Instance { get { return _instance; } }
33 |
34 | static readonly ImageSource __appIcon = TryGetAppIcon();
35 | ///
36 | /// Gets the extracted large application icon image.
37 | ///
38 | ///
39 | /// The application icon.
40 | ///
41 | public static ImageSource AppIcon { get { return __appIcon; } }
42 |
43 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
44 | private static ImageSource TryGetAppIcon()
45 | {
46 | IntPtr iconPtr = IntPtr.Zero;
47 | try
48 | {
49 | var exe = Assembly.GetEntryAssembly().Location;
50 | int r = 0;
51 | // use direct pinvoke to work with unc paths
52 | iconPtr = Shell32.ExtractAssociatedIcon(IntPtr.Zero, exe, ref r);
53 | var img = Imaging.CreateBitmapSourceFromHIcon(iconPtr, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
54 | if (img.CanFreeze)
55 | {
56 | img.Freeze();
57 | }
58 | return img;
59 | }
60 | catch (Exception ex)
61 | {
62 | Trace.TraceError("AppIconImageConverter failed to extract icon: {0}", ex);
63 | }
64 | finally
65 | {
66 | if (iconPtr != IntPtr.Zero)
67 | {
68 | User32.DestroyIcon(iconPtr);
69 | }
70 | }
71 | return null;
72 | }
73 |
74 | #region IValueConverter Members
75 |
76 | ///
77 | /// Converts a value.
78 | ///
79 | /// The value produced by the binding source.
80 | /// The type of the binding target property.
81 | /// The converter parameter to use.
82 | /// The culture to use in the converter.
83 | ///
84 | /// A converted value. If the method returns null, the valid null value is used.
85 | ///
86 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
87 | {
88 | if (value == null)
89 | {
90 | return __appIcon;
91 | }
92 | return value;
93 | }
94 |
95 | ///
96 | /// Not supported.
97 | ///
98 | /// The value that is produced by the binding target.
99 | /// The type to convert to.
100 | /// The converter parameter to use.
101 | /// The culture to use in the converter.
102 | ///
103 | /// A converted value. If the method returns null, the valid null value is used.
104 | ///
105 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
106 | {
107 | return DependencyProperty.UnsetValue;
108 | }
109 |
110 | #endregion
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/BoolNotConverter.cs:
--------------------------------------------------------------------------------
1 | using CommonWin32.API;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Data;
8 | using System.Windows.Media;
9 |
10 | namespace ModernWPF.Converters
11 | {
12 | ///
13 | /// Inverts a boolean value.
14 | ///
15 | [ValueConversion(typeof(bool), typeof(bool))]
16 | public class BoolNotConverter : IValueConverter
17 | {
18 | static readonly BoolNotConverter _instance = new BoolNotConverter();
19 |
20 | ///
21 | /// Gets the singleton instance for this converter.
22 | ///
23 | ///
24 | /// The instance.
25 | ///
26 | public static BoolNotConverter Instance { get { return _instance; } }
27 |
28 | #region IValueConverter Members
29 |
30 | ///
31 | /// Converts a value.
32 | ///
33 | /// The value produced by the binding source.
34 | /// The type of the binding target property.
35 | /// The converter parameter to use.
36 | /// The culture to use in the converter.
37 | ///
38 | /// A converted value. If the method returns null, the valid null value is used.
39 | ///
40 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
41 | {
42 | if (value is bool)
43 | {
44 | return !(bool)value;
45 | }
46 | return value;
47 | }
48 |
49 | ///
50 | /// Converts a value.
51 | ///
52 | /// The value that is produced by the binding target.
53 | /// The type to convert to.
54 | /// The converter parameter to use.
55 | /// The culture to use in the converter.
56 | ///
57 | /// A converted value. If the method returns null, the valid null value is used.
58 | ///
59 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
60 | {
61 | if (value is bool)
62 | {
63 | return !(bool)value;
64 | }
65 | return value;
66 | }
67 |
68 | #endregion
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/BoolVisibleConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace ModernWPF.Converters
10 | {
11 | ///
12 | /// Provides conversion of bool values to visibility.
13 | ///
14 | [ValueConversion(typeof(bool), typeof(Visibility))]
15 | public class BoolVisibleConverter : IValueConverter
16 | {
17 | static readonly BoolVisibleConverter _instance = new BoolVisibleConverter();
18 |
19 | ///
20 | /// Gets the singleton instance for this converter.
21 | ///
22 | ///
23 | /// The instance.
24 | ///
25 | public static BoolVisibleConverter Instance { get { return _instance; } }
26 |
27 | #region IValueConverter Members
28 |
29 | ///
30 | /// Converts a value to the string representation.
31 | ///
32 | /// The value produced by the binding source.
33 | /// The type of the binding target property.
34 | /// The converter parameter to use.
35 | /// The culture to use in the converter.
36 | ///
37 | /// A converted value. If the method returns null, the valid null value is used.
38 | ///
39 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
40 | {
41 | var visible = value as bool?;
42 |
43 | if (parameter != null && string.Equals("not", parameter.ToString(), StringComparison.OrdinalIgnoreCase))
44 | {
45 | visible = !visible.GetValueOrDefault();
46 | }
47 | return visible.GetValueOrDefault() ? Visibility.Visible : Visibility.Collapsed;
48 | }
49 |
50 | ///
51 | /// Not supported.
52 | ///
53 | /// The value that is produced by the binding target.
54 | /// The type to convert to.
55 | /// The converter parameter to use.
56 | /// The culture to use in the converter.
57 | ///
58 | /// A converted value. If the method returns null, the valid null value is used.
59 | ///
60 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
61 | {
62 | return DependencyProperty.UnsetValue;
63 | }
64 |
65 | #endregion
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/EnumValueConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace ModernWPF.Converters
10 | {
11 | ///
12 | /// Converts an enum to its underlying integer value.
13 | ///
14 | [ValueConversion(typeof(Enum), typeof(int))]
15 | public class EnumValueConverter : IValueConverter
16 | {
17 | static readonly EnumValueConverter _instance = new EnumValueConverter();
18 |
19 | ///
20 | /// Gets the singleton instance for this converter.
21 | ///
22 | ///
23 | /// The instance.
24 | ///
25 | public static EnumValueConverter Instance { get { return _instance; } }
26 |
27 | ///
28 | /// Converts the enum to integer value.
29 | ///
30 | /// The value.
31 | /// Type of the target.
32 | /// The parameter.
33 | /// The culture.
34 | ///
35 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
36 | {
37 | if (value == null) { return value; }
38 | var type = value.GetType();
39 | return System.Convert.ChangeType(value, Type.GetTypeCode(type));
40 | }
41 |
42 | ///
43 | /// Converts the value back to enum.
44 | ///
45 | /// The value.
46 | /// Type of the target.
47 | /// The parameter.
48 | /// The culture.
49 | ///
50 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
51 | {
52 | if (value == null) { return value; }
53 | return Enum.Parse(targetType, Enum.GetName(targetType, value));
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/FileIconConverter.cs:
--------------------------------------------------------------------------------
1 | using CommonWin32.API;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Data;
8 | using System.Windows.Media;
9 |
10 | namespace ModernWPF.Converters
11 | {
12 | ///
13 | /// Parse databound value as file path and converts to file icon image.
14 | ///
15 | [ValueConversion(typeof(object), typeof(ImageSource))]
16 | public class FileIconConverter : IValueConverter
17 | {
18 | static readonly FileIconConverter _instance = new FileIconConverter();
19 |
20 | ///
21 | /// Gets the singleton instance for this converter.
22 | ///
23 | ///
24 | /// The instance.
25 | ///
26 | public static FileIconConverter Instance { get { return _instance; } }
27 |
28 | #region IValueConverter Members
29 |
30 | ///
31 | /// Converts a value.
32 | ///
33 | /// The value produced by the binding source.
34 | /// The type of the binding target property.
35 | /// The converter parameter to use.
36 | /// The culture to use in the converter.
37 | ///
38 | /// A converted value. If the method returns null, the valid null value is used.
39 | ///
40 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
41 | {
42 | var para = parameter == null ? string.Empty : parameter.ToString();
43 | bool large = para.IndexOf("large", StringComparison.OrdinalIgnoreCase) > -1;
44 |
45 | return GetFileIconCore(value, large);
46 | }
47 |
48 | ///
49 | /// Not supported.
50 | ///
51 | /// The value that is produced by the binding target.
52 | /// The type to convert to.
53 | /// The converter parameter to use.
54 | /// The culture to use in the converter.
55 | ///
56 | /// A converted value. If the method returns null, the valid null value is used.
57 | ///
58 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
59 | {
60 | return DependencyProperty.UnsetValue;
61 | }
62 |
63 | #endregion
64 |
65 | ///
66 | /// Real method to get the file icon after parsing the parameter.
67 | ///
68 | /// The databound value.
69 | /// if set to true return large icon.
70 | ///
71 | protected virtual ImageSource GetFileIconCore(object value, bool large)
72 | {
73 | if (value == null) { return null; }
74 | return IconReader.GetFileIconWpf(value.ToString(), large ? IconReader.IconSize.Large : IconReader.IconSize.Small, false);
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/IsSmallFontConverter.cs:
--------------------------------------------------------------------------------
1 | using CommonWin32.API;
2 | using System;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Data;
6 | using System.Windows.Interop;
7 | using System.Globalization;
8 |
9 | namespace ModernWPF.Converters
10 | {
11 | ///
12 | /// A converter that tests if a TextBlock's font size is considered a small font size to allow changing TextOptions.
13 | ///
14 | public class IsSmallFontConverter : IMultiValueConverter
15 | {
16 | static readonly IsSmallFontConverter _instance = new IsSmallFontConverter();
17 |
18 | ///
19 | /// Gets the singleton instance for this converter.
20 | ///
21 | ///
22 | /// The instance.
23 | ///
24 | public static IsSmallFontConverter Instance { get { return _instance; } }
25 |
26 | static double _threshold = 14;
27 |
28 | ///
29 | /// Gets or sets the threshold size for small.
30 | ///
31 | ///
32 | /// The threshold.
33 | ///
34 | public static double Threshold { get { return _threshold; } set { _threshold = value; } }
35 |
36 |
37 | ///
38 | /// Converts a TextBlock value to boolean true if too small.
39 | ///
40 | /// The values.
41 | /// Type of the target.
42 | /// The parameter.
43 | /// The culture.
44 | ///
45 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
46 | {
47 | var tooSmall = false;
48 | if (values != null)
49 | {
50 | foreach (var value in values)
51 | {
52 | var tb = value as TextBlock;
53 | if (tb != null)
54 | {
55 | var dpi = DpiEvents.GetWindowDpi(tb);
56 |
57 | tooSmall = dpi <= 96 && tb.FontSize <= Threshold;
58 | break;
59 | }
60 | }
61 | }
62 | return tooSmall;
63 | }
64 |
65 | ///
66 | /// Not supported.
67 | ///
68 | /// The value.
69 | /// The target types.
70 | /// The parameter.
71 | /// The culture.
72 | ///
73 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
74 | {
75 | return null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/MultiBoolVisibleConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace ModernWPF.Converters
9 | {
10 | ///
11 | /// Converts multiple or values into a single .
12 | ///
13 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")]
14 | public class MultiBoolVisibleConverter : IMultiValueConverter
15 | {
16 | static readonly MultiBoolVisibleConverter _instance = new MultiBoolVisibleConverter();
17 |
18 | ///
19 | /// Gets the singleton instance for this converter.
20 | ///
21 | ///
22 | /// The instance.
23 | ///
24 | public static MultiBoolVisibleConverter Instance { get { return _instance; } }
25 |
26 | #region IMultiValueConverter Members
27 |
28 | ///
29 | /// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
30 | ///
31 | /// The array of values that the source bindings in the produces. The value indicates that the source binding has no value to provide for conversion.
32 | /// The type of the binding target property.
33 | /// The converter parameter to use.
34 | /// The culture to use in the converter.
35 | ///
36 | /// A converted value.If the method returns null, the valid null value is used.A return value of . indicates that the converter did not produce a value, and that the binding will use the if it is available, or else will use the default value.A return value of . indicates that the binding does not transfer the value or use the or the default value.
37 | ///
38 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
39 | {
40 | bool? retVal = null;
41 | if (values != null)
42 | {
43 | foreach (var val in values)
44 | {
45 | var asBool = val as bool?;
46 | if (asBool != null)
47 | {
48 | if (retVal.HasValue) { retVal = retVal.Value && asBool.Value; }
49 | else { retVal = asBool.Value; }
50 | }
51 | else
52 | {
53 | var asVis = val as Visibility?;
54 | if (asVis != null)
55 | {
56 | if (retVal.HasValue) { retVal = retVal.Value && (asVis.Value == Visibility.Visible); }
57 | else { retVal = asVis.Value == Visibility.Visible; }
58 | }
59 | }
60 | }
61 | }
62 | if (parameter != null && string.Equals("not", parameter.ToString(), StringComparison.OrdinalIgnoreCase))
63 | {
64 | retVal = !retVal.GetValueOrDefault();
65 | }
66 | return retVal.GetValueOrDefault() ? Visibility.Visible : Visibility.Collapsed;
67 | }
68 |
69 | ///
70 | /// Not supported.
71 | ///
72 | /// The value that the binding target produces.
73 | /// The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.
74 | /// The converter parameter to use.
75 | /// The culture to use in the converter.
76 | ///
77 | /// An array of values that have been converted from the target value back to the source values.
78 | ///
79 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
80 | {
81 | return null;
82 | }
83 |
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/NullEmptyCollapsedConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace ModernWPF.Converters
9 | {
10 | ///
11 | /// Converts to if the value is null or empty string.
12 | ///
13 | [ValueConversion(typeof(object), typeof(Visibility))]
14 | public class NullEmptyCollapsedConverter : IValueConverter
15 | {
16 | static readonly NullEmptyCollapsedConverter _instance = new NullEmptyCollapsedConverter();
17 |
18 | ///
19 | /// Gets the singleton instance for this converter.
20 | ///
21 | ///
22 | /// The instance.
23 | ///
24 | public static NullEmptyCollapsedConverter Instance { get { return _instance; } }
25 |
26 | #region IValueConverter Members
27 |
28 | ///
29 | /// Converts a value.
30 | ///
31 | /// The value produced by the binding source.
32 | /// The type of the binding target property.
33 | /// The converter parameter to use.
34 | /// The culture to use in the converter.
35 | ///
36 | /// A converted value. If the method returns null, the valid null value is used.
37 | ///
38 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
39 | {
40 | var visible = value != null && !string.IsNullOrEmpty(value.ToString());
41 | if (parameter != null && string.Equals("not", parameter.ToString(), StringComparison.OrdinalIgnoreCase))
42 | {
43 | visible = !visible;
44 | }
45 | return visible ? Visibility.Visible : Visibility.Collapsed;
46 | }
47 |
48 | ///
49 | /// Not supported.
50 | ///
51 | /// The value that is produced by the binding target.
52 | /// The type to convert to.
53 | /// The converter parameter to use.
54 | /// The culture to use in the converter.
55 | ///
56 | /// A converted value. If the method returns null, the valid null value is used.
57 | ///
58 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
59 | {
60 | return DependencyProperty.UnsetValue;
61 | }
62 |
63 | #endregion
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/SingleToEnumerableConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace ModernWPF.Converters
10 | {
11 | ///
12 | /// Converts a single object to an for list binding purposes when you only have one.
13 | /// Useful for 's ItemsSources binding.
14 | ///
15 | [ValueConversion(typeof(object), typeof(IEnumerable))]
16 | public class SingleToEnumerableConverter : IValueConverter
17 | {
18 | static readonly SingleToEnumerableConverter _instance = new SingleToEnumerableConverter();
19 |
20 | ///
21 | /// Gets the singleton instance for this converter.
22 | ///
23 | ///
24 | /// The instance.
25 | ///
26 | public static SingleToEnumerableConverter Instance { get { return _instance; } }
27 |
28 | #region IValueConverter Members
29 |
30 | ///
31 | /// Converts a value.
32 | ///
33 | /// The value produced by the binding source.
34 | /// The type of the binding target property.
35 | /// The converter parameter to use.
36 | /// The culture to use in the converter.
37 | ///
38 | /// A converted value. If the method returns null, the valid null value is used.
39 | ///
40 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
41 | {
42 | if (value != null)
43 | {
44 | return AsEnumerable(value);
45 | }
46 | return value;
47 | }
48 |
49 | ///
50 | /// Not supported.
51 | ///
52 | /// The value that is produced by the binding target.
53 | /// The type to convert to.
54 | /// The converter parameter to use.
55 | /// The culture to use in the converter.
56 | ///
57 | /// A converted value. If the method returns null, the valid null value is used.
58 | ///
59 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
60 | {
61 | return DependencyProperty.UnsetValue;
62 | }
63 |
64 | #endregion
65 |
66 | private IEnumerable AsEnumerable(object value)
67 | {
68 | yield return value;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/TextCaseConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace ModernWPF.Converters
10 | {
11 | ///
12 | /// Provides conversion of text to upper (default), lower, or title cases.
13 | ///
14 | [ValueConversion(typeof(object), typeof(string))]
15 | public class TextCaseConverter : IValueConverter
16 | {
17 | static readonly TextCaseConverter _instance = new TextCaseConverter();
18 |
19 | ///
20 | /// Gets the singleton instance for this converter.
21 | ///
22 | ///
23 | /// The instance.
24 | ///
25 | public static TextCaseConverter Instance { get { return _instance; } }
26 |
27 | #region IValueConverter Members
28 |
29 | ///
30 | /// Converts a value to the string representation.
31 | ///
32 | /// The value produced by the binding source.
33 | /// The type of the binding target property.
34 | /// The converter parameter to use.
35 | /// The culture to use in the converter.
36 | ///
37 | /// A converted value. If the method returns null, the valid null value is used.
38 | ///
39 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
40 | {
41 | if (value != null)
42 | {
43 | if (culture == null) { culture = System.Globalization.CultureInfo.CurrentCulture; }
44 | if (parameter != null)
45 | {
46 | if (string.Equals("lower", parameter.ToString(), StringComparison.OrdinalIgnoreCase))
47 | {
48 | return culture.TextInfo.ToLower(value.ToString());
49 | }
50 | if (string.Equals("title", parameter.ToString(), StringComparison.OrdinalIgnoreCase))
51 | {
52 | return culture.TextInfo.ToTitleCase(value.ToString());
53 | }
54 | }
55 | return culture.TextInfo.ToUpper(value.ToString());
56 | }
57 | return value;
58 | }
59 |
60 | ///
61 | /// Not supported.
62 | ///
63 | /// The value that is produced by the binding target.
64 | /// The type to convert to.
65 | /// The converter parameter to use.
66 | /// The culture to use in the converter.
67 | ///
68 | /// A converted value. If the method returns null, the valid null value is used.
69 | ///
70 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
71 | {
72 | return DependencyProperty.UnsetValue;
73 | }
74 |
75 | #endregion
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/ThicknessToDoubleConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls.Primitives;
7 | using System.Windows.Data;
8 |
9 | namespace ModernWPF.Converters
10 | {
11 | ///
12 | /// Convert in a property to single double value for those pesky shape bindings.
13 | ///
14 | [ValueConversion(typeof(Thickness), typeof(double))]
15 | public class ThicknessToDoubleConverter : IValueConverter
16 | {
17 | static readonly ThicknessToDoubleConverter _instance = new ThicknessToDoubleConverter();
18 |
19 | ///
20 | /// Gets the singleton instance for this converter.
21 | ///
22 | ///
23 | /// The instance.
24 | ///
25 | public static ThicknessToDoubleConverter Instance { get { return _instance; } }
26 |
27 | #region IValueConverter Members
28 |
29 | ///
30 | /// Converts a value.
31 | ///
32 | /// The value produced by the binding source.
33 | /// The type of the binding target property.
34 | /// The converter parameter to use.
35 | /// The culture to use in the converter.
36 | ///
37 | /// A converted value. If the method returns null, the valid null value is used.
38 | ///
39 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
40 | {
41 | if (value is Thickness)
42 | {
43 | var t = ((Thickness)value);
44 |
45 | string para = parameter == null ? string.Empty : parameter.ToString().ToLowerInvariant();
46 | switch (para)
47 | {
48 | case "left":
49 | return t.Left;
50 | case "top":
51 | return t.Top;
52 | case "right":
53 | return t.Right;
54 | case "bottom":
55 | return t.Bottom;
56 | default:
57 | // default is avg
58 | return (t.Left + t.Right + t.Bottom + t.Top) / 4;
59 | }
60 | }
61 | return 0;
62 | }
63 |
64 | ///
65 | /// Not supported.
66 | ///
67 | /// The value that is produced by the binding target.
68 | /// The type to convert to.
69 | /// The converter parameter to use.
70 | /// The culture to use in the converter.
71 | ///
72 | /// A converted value. If the method returns null, the valid null value is used.
73 | ///
74 | ///
75 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
76 | {
77 | return DependencyProperty.UnsetValue;
78 | }
79 |
80 | #endregion
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/ThicknessZeroSideConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace ModernWPF.Converters
9 | {
10 | ///
11 | /// Converts a or number to another with the specified sides to 0.
12 | /// Side parameters can be top, left, right, or bottom.
13 | ///
14 | [ValueConversion(typeof(Thickness), typeof(Thickness))]
15 | [ValueConversion(typeof(double), typeof(Thickness))]
16 | public class ThicknessZeroSideConverter : IValueConverter
17 | {
18 | static readonly char[] __splitChars = new char[] { ',', ' ' };
19 |
20 | static readonly ThicknessZeroSideConverter _instance = new ThicknessZeroSideConverter();
21 |
22 | ///
23 | /// Gets the singleton instance for this converter.
24 | ///
25 | ///
26 | /// The instance.
27 | ///
28 | public static ThicknessZeroSideConverter Instance { get { return _instance; } }
29 |
30 | #region IValueConverter Members
31 |
32 | ///
33 | /// Converts a value.
34 | ///
35 | /// The value produced by the binding source.
36 | /// The type of the binding target property.
37 | /// The converter parameter to use.
38 | /// The culture to use in the converter.
39 | ///
40 | /// A converted value. If the method returns null, the valid null value is used.
41 | ///
42 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
43 | {
44 | Thickness target = default(Thickness);
45 |
46 | var thickTest = value as Thickness?;
47 | if (thickTest != null)
48 | {
49 | target = thickTest.Value;
50 | }
51 | else if (value != null)
52 | {
53 | double test = 0;
54 | if (double.TryParse(value.ToString(), out test))
55 | {
56 | target = new Thickness(test);
57 | }
58 | }
59 | if (parameter != null)
60 | {
61 | foreach (var para in parameter.ToString().Split(__splitChars, StringSplitOptions.RemoveEmptyEntries))
62 | {
63 | if (string.Equals(para, "top", StringComparison.OrdinalIgnoreCase))
64 | {
65 | target.Top = 0;
66 | }
67 | else if (string.Equals(para, "left", StringComparison.OrdinalIgnoreCase))
68 | {
69 | target.Left = 0;
70 | }
71 | else if (string.Equals(para, "right", StringComparison.OrdinalIgnoreCase))
72 | {
73 | target.Right = 0;
74 | }
75 | else if (string.Equals(para, "bottom", StringComparison.OrdinalIgnoreCase))
76 | {
77 | target.Bottom = 0;
78 | }
79 | }
80 | }
81 | return target;
82 | }
83 |
84 | ///
85 | /// Not supported.
86 | ///
87 | /// The value that is produced by the binding target.
88 | /// The type to convert to.
89 | /// The converter parameter to use.
90 | /// The culture to use in the converter.
91 | ///
92 | /// A converted value. If the method returns null, the valid null value is used.
93 | ///
94 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
95 | {
96 | return DependencyProperty.UnsetValue;
97 | }
98 |
99 | #endregion
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/TreeDepthLeftMarginConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Media;
10 |
11 | namespace ModernWPF.Converters
12 | {
13 | // this is from http://stackoverflow.com/questions/664632/highlight-whole-treeviewitem-line-in-wpf
14 |
15 | ///
16 | /// Used to calculate left margin of a tree node to achieve full row select.
17 | ///
18 | [ValueConversion(typeof(TreeViewItem), typeof(Thickness))]
19 | public class TreeDepthLeftMarginConverter : IValueConverter
20 | {
21 | ///
22 | /// Gets or sets the length to indent for each level.
23 | ///
24 | ///
25 | /// The length.
26 | ///
27 | public double Length { get; set; }
28 |
29 | ///
30 | /// Converts a value.
31 | ///
32 | /// The value produced by the binding source.
33 | /// The type of the binding target property.
34 | /// The converter parameter to use.
35 | /// The culture to use in the converter.
36 | ///
37 | /// A converted value. If the method returns null, the valid null value is used.
38 | ///
39 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
40 | {
41 | var item = value as TreeViewItem;
42 | if (item == null)
43 | return new Thickness(0);
44 |
45 | return new Thickness(Length * GetDepth(item), 0, 0, 0);
46 | }
47 |
48 | ///
49 | /// Not supported.
50 | ///
51 | /// The value that is produced by the binding target.
52 | /// The type to convert to.
53 | /// The converter parameter to use.
54 | /// The culture to use in the converter.
55 | ///
56 | /// A converted value. If the method returns null, the valid null value is used.
57 | ///
58 | ///
59 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
60 | {
61 | return DependencyProperty.UnsetValue;
62 | }
63 |
64 | static int GetDepth(TreeViewItem item)
65 | {
66 | TreeViewItem parent;
67 | while ((parent = GetParent(item)) != null)
68 | {
69 | return GetDepth(parent) + 1;
70 | }
71 | return 0;
72 | }
73 | static TreeViewItem GetParent(TreeViewItem item)
74 | {
75 | var parent = VisualTreeHelper.GetParent(item);
76 | while (parent != null)
77 | {
78 | var test = parent as TreeViewItem;
79 | if (test != null) { return test; }
80 |
81 | parent = VisualTreeHelper.GetParent(parent);
82 | }
83 |
84 | return (TreeViewItem)parent;
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/ModernWPF/Converters/WindowCaptionHeightConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace ModernWPF.Converters
9 | {
10 | ///
11 | /// Converts invalid caption height to system caption height for modern windows.
12 | ///
13 | [ValueConversion(typeof(double), typeof(double))]
14 | public class WindowCaptionHeightConverter : IValueConverter
15 | {
16 | static readonly WindowCaptionHeightConverter _instance = new WindowCaptionHeightConverter();
17 |
18 | ///
19 | /// Gets the singleton instance for this converter.
20 | ///
21 | ///
22 | /// The instance.
23 | ///
24 | public static WindowCaptionHeightConverter Instance { get { return _instance; } }
25 |
26 | #region IValueConverter Members
27 |
28 | ///
29 | /// Converts a value.
30 | ///
31 | /// The value produced by the binding source.
32 | /// The type of the binding target property.
33 | /// The converter parameter to use.
34 | /// The culture to use in the converter.
35 | ///
36 | /// A converted value. If the method returns null, the valid null value is used.
37 | ///
38 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
39 | {
40 | if (value is double)
41 | {
42 | var pendingH = (double)value;
43 | if (pendingH < 0)
44 | {
45 | // use system current
46 | return SystemParameters.WindowCaptionHeight + SystemParameters.ResizeFrameHorizontalBorderHeight;
47 | }
48 | return pendingH;
49 | }
50 | return 0d;
51 | }
52 |
53 | ///
54 | /// Not supported.
55 | ///
56 | /// The value that is produced by the binding target.
57 | /// The type to convert to.
58 | /// The converter parameter to use.
59 | /// The culture to use in the converter.
60 | ///
61 | /// A converted value. If the method returns null, the valid null value is used.
62 | ///
63 | ///
64 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
65 | {
66 | return DependencyProperty.UnsetValue; ;
67 | }
68 |
69 | #endregion
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/ModernWPF/CustomDictionary.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | FadeOut
9 |
10 |
11 |
12 |
13 | WPF
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/ModernWPF/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/soukoku/ModernWPF/261d30ced04caa51ee2e8e018462062961592797/src/ModernWPF/GlobalSuppressions.cs
--------------------------------------------------------------------------------
/src/ModernWPF/GridViewSortParameter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Controls;
7 |
8 | namespace ModernWPF
9 | {
10 | ///
11 | /// The parameter passed to .
12 | ///
13 | public class GridViewSortParameter
14 | {
15 | public GridViewSortParameter(GridViewColumnHeader header, ListSortDirection? newDirection)
16 | {
17 | Header = header;
18 | NewSortDirection = newDirection;
19 | }
20 |
21 | ///
22 | /// Gets the header that was clicked.
23 | ///
24 | ///
25 | /// The header.
26 | ///
27 | public GridViewColumnHeader Header { get; private set; }
28 |
29 | ///
30 | /// Gets the new sort direction. If this is null then no sort should happen.
31 | ///
32 | ///
33 | /// The new sort direction.
34 | ///
35 | public ListSortDirection? NewSortDirection { get; private set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/ModernWPF/HSLColor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Text;
5 | using System.Windows.Media;
6 |
7 | namespace ModernWPF
8 | {
9 | // modified from Rich Newman's HSLColor class for wpf
10 | // http://richnewman.wordpress.com/about/code-listings-and-diagrams/hslcolor-class/
11 |
12 | class HSLColor
13 | {
14 | // Private data members below are on scale 0-1
15 | // They are scaled for use externally based on scale
16 | private double hue = 1.0;
17 | private double saturation = 1.0;
18 | private double luminosity = 1.0;
19 |
20 | private const double scale = 1.0;//240.0;
21 |
22 | public double Hue
23 | {
24 | get { return hue * scale; }
25 | //set { hue = CheckRange(value / scale); }
26 | }
27 | public double Saturation
28 | {
29 | get { return saturation * scale; }
30 | //set { saturation = CheckRange(value / scale); }
31 | }
32 | public double Luminosity
33 | {
34 | get { return luminosity * scale; }
35 | set { luminosity = CheckRange(value / scale); }
36 | }
37 |
38 | static double CheckRange(double value)
39 | {
40 | if (value < 0.0)
41 | value = 0.0;
42 | else if (value > 1.0)
43 | value = 1.0;
44 | return value;
45 | }
46 |
47 | public override string ToString()
48 | {
49 | return string.Format(CultureInfo.CurrentCulture, "H: {0:#0.##}\tS: {1:#0.##}\tL: {2:#0.##}", Hue, Saturation, Luminosity);
50 | }
51 |
52 | //public string ToRGBString()
53 | //{
54 | // Color color = (Color)this;
55 | // return string.Format(CultureInfo.CurrentCulture, "R: {0:#0.##}\tG: {1:#0.##}\tB: {2:#0.##}", color.R, color.G, color.B);
56 | //}
57 |
58 | #region Casts to/from System.Drawing.Color
59 | public static implicit operator Color(HSLColor hslColor)
60 | {
61 | double r = 0, g = 0, b = 0;
62 | if (hslColor.luminosity != 0)
63 | {
64 | if (hslColor.saturation == 0)
65 | r = g = b = hslColor.luminosity;
66 | else
67 | {
68 | double temp2 = GetTemp2(hslColor);
69 | double temp1 = 2.0 * hslColor.luminosity - temp2;
70 |
71 | r = GetColorComponent(temp1, temp2, hslColor.hue + 1.0 / 3.0);
72 | g = GetColorComponent(temp1, temp2, hslColor.hue);
73 | b = GetColorComponent(temp1, temp2, hslColor.hue - 1.0 / 3.0);
74 | }
75 | }
76 | return Color.FromRgb((byte)(255 * r), (byte)(255 * g), (byte)(255 * b));
77 | }
78 |
79 | private static double GetColorComponent(double temp1, double temp2, double temp3)
80 | {
81 | temp3 = MoveIntoRange(temp3);
82 | if (temp3 < 1.0 / 6.0)
83 | return temp1 + (temp2 - temp1) * 6.0 * temp3;
84 | else if (temp3 < 0.5)
85 | return temp2;
86 | else if (temp3 < 2.0 / 3.0)
87 | return temp1 + ((temp2 - temp1) * ((2.0 / 3.0) - temp3) * 6.0);
88 | else
89 | return temp1;
90 | }
91 | private static double MoveIntoRange(double temp3)
92 | {
93 | if (temp3 < 0.0)
94 | temp3 += 1.0;
95 | else if (temp3 > 1.0)
96 | temp3 -= 1.0;
97 | return temp3;
98 | }
99 | private static double GetTemp2(HSLColor hslColor)
100 | {
101 | double temp2;
102 | if (hslColor.luminosity < 0.5) //<=??
103 | temp2 = hslColor.luminosity * (1.0 + hslColor.saturation);
104 | else
105 | temp2 = hslColor.luminosity + hslColor.saturation - (hslColor.luminosity * hslColor.saturation);
106 | return temp2;
107 | }
108 |
109 | public static implicit operator HSLColor(Color color)
110 | {
111 | System.Drawing.Color dummy = System.Drawing.Color.FromArgb(color.R, color.G, color.B);
112 |
113 | HSLColor hslColor = new HSLColor();
114 | hslColor.hue = dummy.GetHue() / 360.0; // we store hue as 0-1 as opposed to 0-360
115 | hslColor.luminosity = dummy.GetBrightness();
116 | hslColor.saturation = dummy.GetSaturation();
117 | return hslColor;
118 | }
119 | #endregion
120 |
121 | //public void SetRGB(byte red, byte green, byte blue)
122 | //{
123 | // HSLColor hslColor = Color.FromRgb(red, green, blue);
124 | // this.hue = hslColor.hue;
125 | // this.saturation = hslColor.saturation;
126 | // this.luminosity = hslColor.luminosity;
127 | //}
128 |
129 | public HSLColor() { }
130 | //public HSLColor(Color color)
131 | //{
132 | // SetRGB(color.R, color.G, color.B);
133 | //}
134 | //public HSLColor(byte red, byte green, byte blue)
135 | //{
136 | // SetRGB(red, green, blue);
137 | //}
138 | //public HSLColor(double hue, double saturation, double luminosity)
139 | //{
140 | // this.Hue = hue;
141 | // this.Saturation = saturation;
142 | // this.Luminosity = luminosity;
143 | //}
144 |
145 | }
146 |
147 | }
148 |
--------------------------------------------------------------------------------
/src/ModernWPF/Internal/EventUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 |
8 | namespace ModernWPF.Internal
9 | {
10 | static class EventUtil
11 | {
12 |
13 | public static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
14 | {
15 | if (element == null) { throw new ArgumentNullException("element"); }
16 |
17 | var uie = element as UIElement;
18 | if (uie != null)
19 | {
20 | uie.AddHandler(routedEvent, handler);
21 | }
22 | else
23 | {
24 | var ce = element as ContentElement;
25 | if (ce != null)
26 | {
27 | ce.AddHandler(routedEvent, handler);
28 | }
29 | else
30 | {
31 | var u3d = element as UIElement3D;
32 | if (u3d != null)
33 | u3d.AddHandler(routedEvent, handler);
34 | else
35 | throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid element {0}.", element.GetType()));
36 | }
37 | }
38 | }
39 | public static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
40 | {
41 | if (element == null) { throw new ArgumentNullException("element"); }
42 |
43 | var uie = element as UIElement;
44 | if (uie != null)
45 | {
46 | uie.RemoveHandler(routedEvent, handler);
47 | }
48 | else
49 | {
50 | var ce = element as ContentElement;
51 | if (ce != null)
52 | {
53 | ce.RemoveHandler(routedEvent, handler);
54 | }
55 | else
56 | {
57 | var u3d = element as UIElement3D;
58 | if (u3d != null)
59 | u3d.RemoveHandler(routedEvent, handler);
60 | else
61 | throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid element {0}.", element.GetType()));
62 | }
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/ModernWPF/Internal/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Input;
7 |
8 | namespace ModernWPF.Internal
9 | {
10 | ///
11 | /// Simple relay command for internal use only.
12 | ///
13 | class RelayCommand : ICommand
14 | {
15 | #region Fields
16 |
17 | readonly Action _execute;
18 | readonly Func _canExecute;
19 |
20 | #endregion // Fields
21 |
22 | #region Constructors
23 |
24 | public RelayCommand(Action execute)
25 | : this(execute, null)
26 | {
27 | }
28 |
29 | public RelayCommand(Action execute, Func canExecute)
30 | {
31 | if (execute == null)
32 | throw new ArgumentNullException("execute");
33 |
34 | _execute = execute;
35 | _canExecute = canExecute;
36 | }
37 | #endregion // Constructors
38 |
39 | #region ICommand Members
40 |
41 | [DebuggerStepThrough]
42 | public bool CanExecute(object parameter)
43 | {
44 | return _canExecute == null ? true : _canExecute();
45 | }
46 |
47 | public event EventHandler CanExecuteChanged
48 | {
49 | add { CommandManager.RequerySuggested += value; }
50 | remove { CommandManager.RequerySuggested -= value; }
51 | }
52 |
53 | public void Execute(object parameter)
54 | {
55 | _execute();
56 | }
57 |
58 | #endregion // ICommand Members
59 | }
60 |
61 | ///
62 | /// Simple relay command for internal use only.
63 | ///
64 | ///
65 | class RelayCommand : ICommand where T : class
66 | {
67 | #region Fields
68 |
69 | readonly Action _execute;
70 | readonly Predicate _canExecute;
71 |
72 | #endregion // Fields
73 |
74 | #region Constructors
75 |
76 | public RelayCommand(Action execute)
77 | : this(execute, null)
78 | {
79 | }
80 |
81 | public RelayCommand(Action execute, Predicate canExecute)
82 | {
83 | if (execute == null)
84 | throw new ArgumentNullException("execute");
85 |
86 | _execute = execute;
87 | _canExecute = canExecute;
88 | }
89 | #endregion // Constructors
90 |
91 | #region ICommand Members
92 |
93 | [DebuggerStepThrough]
94 | public bool CanExecute(object parameter)
95 | {
96 | return _canExecute == null ? true : _canExecute(parameter as T);
97 | }
98 |
99 | public event EventHandler CanExecuteChanged
100 | {
101 | add { CommandManager.RequerySuggested += value; }
102 | remove { CommandManager.RequerySuggested -= value; }
103 | }
104 |
105 | public void Execute(object parameter)
106 | {
107 | _execute(parameter as T);
108 | }
109 |
110 | #endregion // ICommand Members
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/ModernWPF/MenuItemUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 |
8 | namespace ModernWPF
9 | {
10 | ///
11 | /// Contains various attached properties for .
12 | ///
13 | public class MenuItemUI : DependencyObject
14 | {
15 |
16 | #region group name extension
17 | // from http://stackoverflow.com/questions/3652688/mutually-exclusive-checkable-menu-items
18 |
19 | static Dictionary