├── .gitattributes
├── .gitignore
├── README.md
├── RuntimeThemeSwitchingDemo.sln
├── RuntimeThemeSwitchingDemo
├── App.xaml
├── App.xaml.cs
├── Assets
│ ├── LockScreenLogo.scale-200.png
│ ├── SplashScreen.scale-200.png
│ ├── Square150x150Logo.scale-200.png
│ ├── Square44x44Logo.scale-200.png
│ ├── Square44x44Logo.targetsize-24_altform-unplated.png
│ ├── StoreLogo.png
│ ├── Visual Studio for Mac Logo.png
│ └── Wide310x150Logo.scale-200.png
├── MainPage.xaml
├── MainPage.xaml.cs
├── Package.appxmanifest
├── Properties
│ ├── AssemblyInfo.cs
│ └── Default.rd.xml
├── RuntimeThemeSwitchingDemo.csproj
├── Theme.cs
├── ThemeManager.cs
├── WindowShotOverlay.cs
└── project.json
└── runtimethemeswitching.gif
/.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 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RuntimeThemeSwitchingDemo
2 | A UWP demo of runtime theme switching with fake VS for Mac UI.
3 |
4 | 
5 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuntimeThemeSwitchingDemo", "RuntimeThemeSwitchingDemo\RuntimeThemeSwitchingDemo.csproj", "{B84E5DBD-1979-4C7D-ABE9-87359016B4F8}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|ARM = Debug|ARM
11 | Debug|x64 = Debug|x64
12 | Debug|x86 = Debug|x86
13 | Release|ARM = Release|ARM
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|ARM.ActiveCfg = Debug|ARM
19 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|ARM.Build.0 = Debug|ARM
20 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|ARM.Deploy.0 = Debug|ARM
21 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|x64.ActiveCfg = Debug|x64
22 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|x64.Build.0 = Debug|x64
23 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|x64.Deploy.0 = Debug|x64
24 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|x86.ActiveCfg = Debug|x86
25 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|x86.Build.0 = Debug|x86
26 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Debug|x86.Deploy.0 = Debug|x86
27 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|ARM.ActiveCfg = Release|ARM
28 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|ARM.Build.0 = Release|ARM
29 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|ARM.Deploy.0 = Release|ARM
30 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|x64.ActiveCfg = Release|x64
31 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|x64.Build.0 = Release|x64
32 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|x64.Deploy.0 = Release|x64
33 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|x86.ActiveCfg = Release|x86
34 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|x86.Build.0 = Release|x86
35 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}.Release|x86.Deploy.0 = Release|x86
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | EndGlobal
41 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | namespace RuntimeThemeSwitchingDemo
19 | {
20 | ///
21 | /// Provides application-specific behavior to supplement the default Application class.
22 | ///
23 | sealed partial class App : Application
24 | {
25 | ///
26 | /// Initializes the singleton application object. This is the first line of authored code
27 | /// executed, and as such is the logical equivalent of main() or WinMain().
28 | ///
29 | public App()
30 | {
31 | this.InitializeComponent();
32 | this.Suspending += OnSuspending;
33 | }
34 |
35 | ///
36 | /// Invoked when the application is launched normally by the end user. Other entry points
37 | /// will be used such as when the application is launched to open a specific file.
38 | ///
39 | /// Details about the launch request and process.
40 | protected override void OnLaunched(LaunchActivatedEventArgs e)
41 | {
42 | #if DEBUG
43 | if (System.Diagnostics.Debugger.IsAttached)
44 | {
45 | this.DebugSettings.EnableFrameRateCounter = true;
46 | }
47 | #endif
48 | Frame rootFrame = Window.Current.Content as Frame;
49 |
50 | // Do not repeat app initialization when the Window already has content,
51 | // just ensure that the window is active
52 | if (rootFrame == null)
53 | {
54 | // Create a Frame to act as the navigation context and navigate to the first page
55 | rootFrame = new Frame();
56 |
57 | rootFrame.NavigationFailed += OnNavigationFailed;
58 |
59 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
60 | {
61 | //TODO: Load state from previously suspended application
62 | }
63 |
64 | // Place the frame in the current Window
65 | Window.Current.Content = rootFrame;
66 | }
67 |
68 | if (e.PrelaunchActivated == false)
69 | {
70 | if (rootFrame.Content == null)
71 | {
72 | // When the navigation stack isn't restored navigate to the first page,
73 | // configuring the new page by passing required information as a navigation
74 | // parameter
75 | rootFrame.Navigate(typeof(MainPage), e.Arguments);
76 | }
77 | // Ensure the current window is active
78 | Window.Current.Activate();
79 | }
80 | }
81 |
82 | ///
83 | /// Invoked when Navigation to a certain page fails
84 | ///
85 | /// The Frame which failed navigation
86 | /// Details about the navigation failure
87 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
88 | {
89 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
90 | }
91 |
92 | ///
93 | /// Invoked when application execution is being suspended. Application state is saved
94 | /// without knowing whether the application will be terminated or resumed with the contents
95 | /// of memory still intact.
96 | ///
97 | /// The source of the suspend request.
98 | /// Details about the suspend request.
99 | private void OnSuspending(object sender, SuspendingEventArgs e)
100 | {
101 | var deferral = e.SuspendingOperation.GetDeferral();
102 | //TODO: Save application state and stop any background activity
103 | deferral.Complete();
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/Visual Studio for Mac Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/Visual Studio for Mac Logo.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/RuntimeThemeSwitchingDemo/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using System.Threading.Tasks;
7 | using Windows.ApplicationModel.Core;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI;
11 | using Windows.UI.ViewManagement;
12 | using Windows.UI.Xaml;
13 | using Windows.UI.Xaml.Controls;
14 | using Windows.UI.Xaml.Controls.Primitives;
15 | using Windows.UI.Xaml.Data;
16 | using Windows.UI.Xaml.Input;
17 | using Windows.UI.Xaml.Media;
18 | using Windows.UI.Xaml.Navigation;
19 |
20 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
21 |
22 | namespace RuntimeThemeSwitchingDemo
23 | {
24 | ///
25 | /// An empty page that can be used on its own or navigated to within a Frame.
26 | ///
27 | public sealed partial class MainPage : Page
28 | {
29 | public MainPage()
30 | {
31 | this.InitializeComponent();
32 |
33 | if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop")
34 | {
35 | var view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
36 | ApplicationViewTitleBar titleBar = view.TitleBar;
37 | if (titleBar != null)
38 | {
39 | titleBar.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
40 | titleBar.ForegroundColor = Colors.White;
41 | titleBar.ButtonBackgroundColor = Color.FromArgb(0, 0, 0, 0);
42 | titleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 0, 0, 0);
43 | titleBar.ButtonForegroundColor = Color.FromArgb(0xff, 0xaf, 0xaf, 0xaf);
44 | }
45 |
46 | CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
47 |
48 | //Window.Current.SetTitleBar(UIElement);
49 | }
50 | }
51 |
52 | private async void toggleSwitch_Toggled(object sender, RoutedEventArgs e)
53 | {
54 | if (tgsFade.IsOn)
55 | {
56 | await Task.Delay(200);
57 | var overlay = new WindowShotOverlay();
58 | await overlay.PrepareShot();
59 | overlay.ShowOverlay();
60 | ThemeManager.SwitchTheme(tgsNightMode.IsOn ? 1 : 0);
61 | overlay.FadeIntoTheme();
62 |
63 | }
64 | else
65 | {
66 | ThemeManager.SwitchTheme(tgsNightMode.IsOn ? 1 : 0);
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
15 |
16 |
17 | RuntimeThemeSwitchingDemo
18 | validvoid
19 | Assets\StoreLogo.png
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("RuntimeThemeSwitchingDemo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("RuntimeThemeSwitchingDemo")]
13 | [assembly: AssemblyCopyright("Copyright © 2016 validvoid")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Properties/Default.rd.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/RuntimeThemeSwitchingDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x86
7 | {B84E5DBD-1979-4C7D-ABE9-87359016B4F8}
8 | AppContainerExe
9 | Properties
10 | RuntimeThemeSwitchingDemo
11 | RuntimeThemeSwitchingDemo
12 | en-US
13 | UAP
14 | 10.0.14393.0
15 | 10.0.10586.0
16 | 14
17 | 512
18 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
19 | RuntimeThemeSwitchingDemo_TemporaryKey.pfx
20 |
21 |
22 | true
23 | bin\x86\Debug\
24 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
25 | ;2008
26 | full
27 | x86
28 | false
29 | prompt
30 | true
31 |
32 |
33 | bin\x86\Release\
34 | TRACE;NETFX_CORE;WINDOWS_UWP
35 | true
36 | ;2008
37 | pdbonly
38 | x86
39 | false
40 | prompt
41 | true
42 | true
43 |
44 |
45 | true
46 | bin\ARM\Debug\
47 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
48 | ;2008
49 | full
50 | ARM
51 | false
52 | prompt
53 | true
54 |
55 |
56 | bin\ARM\Release\
57 | TRACE;NETFX_CORE;WINDOWS_UWP
58 | true
59 | ;2008
60 | pdbonly
61 | ARM
62 | false
63 | prompt
64 | true
65 | true
66 |
67 |
68 | true
69 | bin\x64\Debug\
70 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
71 | ;2008
72 | full
73 | x64
74 | false
75 | prompt
76 | true
77 |
78 |
79 | bin\x64\Release\
80 | TRACE;NETFX_CORE;WINDOWS_UWP
81 | true
82 | ;2008
83 | pdbonly
84 | x64
85 | false
86 | prompt
87 | true
88 | true
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | App.xaml
97 |
98 |
99 | MainPage.xaml
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | Designer
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | MSBuild:Compile
126 | Designer
127 |
128 |
129 | MSBuild:Compile
130 | Designer
131 |
132 |
133 |
134 |
135 | Windows Mobile Extensions for the UWP
136 |
137 |
138 |
139 | 14.0
140 |
141 |
142 |
149 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/Theme.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI;
7 | using Windows.UI.Xaml.Media;
8 |
9 | namespace RuntimeThemeSwitchingDemo
10 | {
11 | public class Theme
12 | {
13 | public String ThemeName { get; set; }
14 |
15 | public Color AccentColor { get; set; }
16 | public SolidColorBrush AccentBrush => new SolidColorBrush(AccentColor);
17 |
18 | public Color HeadTextColor { get; set; }
19 | public SolidColorBrush HeadTextBrush => new SolidColorBrush(HeadTextColor);
20 |
21 | public Color PrimaryTextColor { get; set; }
22 | public SolidColorBrush PrimaryTextBrush => new SolidColorBrush(PrimaryTextColor);
23 |
24 | public Color SecondaryTextColor { get; set; }
25 | public SolidColorBrush SecondaryTextBrush => new SolidColorBrush(SecondaryTextColor);
26 |
27 | public Color PrimaryButtonBackgroundColor { get; set; }
28 | public SolidColorBrush PrimaryButtonBackgroundBrush => new SolidColorBrush(PrimaryButtonBackgroundColor);
29 |
30 | public Color PrimaryButtonForegroundColor { get; set; }
31 | public SolidColorBrush PrimaryButtonForegroundBrush => new SolidColorBrush(PrimaryButtonForegroundColor);
32 |
33 | public Color PrimaryButtonBorderColor { get; set; }
34 | public SolidColorBrush PrimaryButtonBorderBrush => new SolidColorBrush(PrimaryButtonBorderColor);
35 |
36 | public Color SecondaryButtonBackgroundColor { get; set; }
37 | public SolidColorBrush SecondaryButtonBackgroundBrush => new SolidColorBrush(SecondaryButtonBackgroundColor);
38 |
39 | public Color SecondaryButtonForegroundColor { get; set; }
40 | public SolidColorBrush SecondaryButtonForegroundBrush => new SolidColorBrush(SecondaryButtonForegroundColor);
41 |
42 | public Color SecondaryButtonBorderColor { get; set; }
43 | public SolidColorBrush SecondaryButtonBorderBrush => new SolidColorBrush(SecondaryButtonBorderColor);
44 |
45 | public Color PageBackgroundColor { get; set; }
46 | public SolidColorBrush PageBackgroundBrush => new SolidColorBrush(PageBackgroundColor);
47 |
48 | public Color RightPanelBackgroundColor { get; set; }
49 | public SolidColorBrush RightPanelBackgroundBrush => new SolidColorBrush(RightPanelBackgroundColor);
50 |
51 | public Color DividerColor { get; set; }
52 | public SolidColorBrush DividerBrush => new SolidColorBrush(DividerColor);
53 |
54 | public LinearGradientBrush DividerShadowBrush { get; set; }
55 |
56 | public double PrimaryTextSize { get; set; }
57 |
58 | public double SecondaryTextSize { get; set; }
59 |
60 | public double Head1TextSize { get; set; }
61 |
62 | public double Head2TextSize { get; set; }
63 |
64 | public double Head3TextSize { get; set; }
65 |
66 | public FontFamily PrimaryTextFontFamily { get; set; }
67 |
68 | public FontFamily SecondaryTextFontFamily { get; set; }
69 |
70 | public LinearGradientBrush TopToolbarBrush { get; set; }
71 |
72 | public Color TopToolbarBorderColor { get; set; }
73 |
74 | public SolidColorBrush TopToolbarBorderBrush => new SolidColorBrush(TopToolbarBorderColor);
75 |
76 | public Color TopToolbarButtonBackgroundColor { get; set; }
77 | public SolidColorBrush TopToolbarButtonBackgroundBrush => new SolidColorBrush(TopToolbarButtonBackgroundColor);
78 |
79 | public Color TopToolbarButtonForegroundColor { get; set; }
80 | public SolidColorBrush TopToolbarButtonForegroundBrush => new SolidColorBrush(TopToolbarButtonForegroundColor);
81 |
82 | public Color TopToolbarButtonBorderColor { get; set; }
83 | public SolidColorBrush TopToolbarButtonBorderBrush => new SolidColorBrush(TopToolbarButtonBorderColor);
84 | }
85 |
86 | public class ThemeCollection : List { }
87 | }
88 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/ThemeManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Windows.UI.Xaml;
9 |
10 | namespace RuntimeThemeSwitchingDemo
11 | {
12 | public class ThemeManager
13 | {
14 | public static void SwitchTheme(int themenum)
15 | {
16 | var controller = App.Current.Resources["ThemeController"] as ThemeController;
17 | if (controller == null)
18 | return;
19 |
20 | switch (themenum)
21 | {
22 | case 0:
23 | controller.ActiveTheme = controller.Themes[0];
24 | break;
25 | case 1:
26 | controller.ActiveTheme = controller.Themes[1];
27 | break;
28 | default:
29 | controller.ActiveTheme = controller.Themes[0];
30 | break;
31 | }
32 | }
33 | }
34 |
35 | public class ThemeController : INotifyPropertyChanged
36 | {
37 | public event PropertyChangedEventHandler PropertyChanged;
38 |
39 | private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
40 | {
41 | if (PropertyChanged != null)
42 | {
43 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
44 | }
45 | }
46 |
47 | public ThemeCollection Themes
48 | {
49 | get
50 | {
51 | return (ThemeCollection)Application.Current.Resources["Themes"];
52 | }
53 | }
54 |
55 | [DefaultValue("Default")]
56 | public String DefaultTheme { get; set; }
57 |
58 | private Theme activeTheme;
59 |
60 | public Theme ActiveTheme
61 | {
62 | get
63 | {
64 | if (activeTheme == null)
65 | {
66 | activeTheme = Themes.FirstOrDefault(t => t.ThemeName == DefaultTheme);
67 | }
68 |
69 | return activeTheme;
70 | }
71 | set
72 | {
73 | if (activeTheme != value)
74 | {
75 | activeTheme = value;
76 | NotifyPropertyChanged();
77 | }
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/WindowShotOverlay.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml;
7 | using Windows.UI.Xaml.Controls;
8 | using Windows.UI.Xaml.Controls.Primitives;
9 | using Windows.UI.Xaml.Media.Animation;
10 | using Windows.UI.Xaml.Media.Imaging;
11 |
12 | namespace RuntimeThemeSwitchingDemo
13 | {
14 | public class WindowShotOverlay
15 | {
16 | private readonly RenderTargetBitmap _bitmap = new RenderTargetBitmap();
17 | private Popup _pop = new Popup();
18 | private Storyboard _sbFade = new Storyboard();
19 | private readonly Image _imgShot = new Image();
20 |
21 | public async Task PrepareShot()
22 | {
23 | double statusbarHeight = 0;
24 | if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
25 | {
26 | var sb = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
27 | statusbarHeight = sb.OccludedRect.Height;
28 | }
29 |
30 |
31 | _pop.Width = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;
32 | _pop.Height = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Height;
33 | _pop.HorizontalAlignment = HorizontalAlignment.Stretch;
34 | _pop.VerticalAlignment = VerticalAlignment.Stretch;
35 |
36 | _pop.VerticalOffset = statusbarHeight;
37 |
38 | _imgShot.Width = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;
39 | _imgShot.Height = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Height;
40 | _imgShot.VerticalAlignment = VerticalAlignment.Stretch;
41 | _imgShot.HorizontalAlignment = HorizontalAlignment.Stretch;
42 |
43 | await _bitmap.RenderAsync(Window.Current.Content);
44 | _imgShot.Source = _bitmap;
45 |
46 | _pop.Child = _imgShot;
47 |
48 | DoubleAnimationUsingKeyFrames daukfFade = new DoubleAnimationUsingKeyFrames();
49 |
50 | daukfFade.KeyFrames.Add(new EasingDoubleKeyFrame()
51 | {
52 | KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300)),
53 | Value = 0,
54 | EasingFunction = new QuinticEase() { EasingMode = EasingMode.EaseIn }
55 | });
56 |
57 | Storyboard.SetTarget(daukfFade, _imgShot);
58 | Storyboard.SetTargetProperty(daukfFade, "(UIElement.Opacity)");
59 | _sbFade.Children.Add(daukfFade);
60 |
61 | _sbFade.Completed += (sender, o) =>
62 | {
63 | _pop.IsOpen = false;
64 | _pop.Child = null;
65 | _pop = null;
66 | _sbFade = null;
67 | daukfFade = null;
68 | };
69 | }
70 |
71 | public void ShowOverlay()
72 | {
73 | _pop.IsOpen = true;
74 | }
75 |
76 | public void FadeIntoTheme()
77 | {
78 | _sbFade.Begin();
79 | }
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/RuntimeThemeSwitchingDemo/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
4 | },
5 | "frameworks": {
6 | "uap10.0": {}
7 | },
8 | "runtimes": {
9 | "win10-arm": {},
10 | "win10-arm-aot": {},
11 | "win10-x86": {},
12 | "win10-x86-aot": {},
13 | "win10-x64": {},
14 | "win10-x64-aot": {}
15 | }
16 | }
--------------------------------------------------------------------------------
/runtimethemeswitching.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/validvoid/RuntimeThemeSwitchingDemo/84798fa518e8bec48ae9f8d7f336e051f0a39f87/runtimethemeswitching.gif
--------------------------------------------------------------------------------