1- using System ;
1+ using MileXamlControlsDemoNetCore . UI . Backdrop ;
2+ using System ;
23using System . Collections . ObjectModel ;
34using Windows . Media . Core ;
45using Windows . System ;
5- using Windows . UI . Composition . Desktop ;
66using Windows . UI ;
77using Windows . UI . Xaml ;
88using Windows . UI . Xaml . Controls ;
99using Windows . UI . Xaml . Media ;
10- using MileXamlControlsDemoNetCore . UI . Backdrop ;
11- using MileXamlControlsDemoNetCore . Backdrop ;
10+
11+ #pragma warning disable IDE0060
1212
1313namespace MileXamlControlsDemoNetCore
1414{
1515 public sealed partial class MainPage : Page
1616 {
17- private ObservableCollection < TreeViewItemModel > TreeViewDataList = [
17+ private ObservableCollection < TreeViewItemModel > TreeViewDataList { get ; } = [
1818 new ( ) {
1919 Name = "TreeView Root Node 1" , IsSelected = true ,
2020 ChildrenNode = [
@@ -32,11 +32,8 @@ public sealed partial class MainPage : Page
3232 }
3333 ] ;
3434
35- private DesktopWindowTarget DesktopWindowTarget { get ; set ; }
36-
3735 private ElementTheme currentTheme = ElementTheme . Default ;
3836 private bool currentInputActiveState = false ;
39- private SystemBackdrop currentSystemBackdrop = null ;
4037
4138 public MainPage ( )
4239 {
@@ -52,6 +49,7 @@ private async void HyperlinkButton_Click(object sender, RoutedEventArgs args)
5249 var vp9LinkUri = new Uri ( "ms-windows-store://pdp/?productid=9N4D0MSMP0PT" ) ;
5350 await Launcher . LaunchUriAsync ( vp9LinkUri ) ;
5451 }
52+
5553 private async void HyperlinkButton_Click1 ( object sender , RoutedEventArgs args )
5654 {
5755 var vp9LinkUri = new Uri ( "https://learn.microsoft.com/en-us/answers/questions/635070/(ver-10-0-19041-0)-c-winrt-treeview-nodes-not-prop?childtoview=635698" ) ;
@@ -60,15 +58,7 @@ private async void HyperlinkButton_Click1(object sender, RoutedEventArgs args)
6058
6159 private void OnLoaded ( object sender , RoutedEventArgs e )
6260 {
63- DesktopWindowTarget = BackdropHelper . InitializeDesktopWindowTarget ( Program . MainForm , false ) ;
64-
65- currentSystemBackdrop = new MicaBackdrop ( DesktopWindowTarget , this , Program . MainForm )
66- {
67- Kind = MicaKind . Base ,
68- RequestedTheme = currentTheme ,
69- IsInputActive = currentInputActiveState
70- } ;
71- currentSystemBackdrop . InitializeBackdrop ( ) ;
61+ Background = new MicaBrush ( MicaKind . Base , this , Program . MainForm , currentInputActiveState ) ;
7262
7363 currentTheme = ElementTheme . Default ;
7464 currentInputActiveState = false ;
@@ -84,86 +74,39 @@ private void SwitchSystemBackdropClick(object sender, RoutedEventArgs args)
8474 if ( SystemBackdropNameText . Text == "None" )
8575 {
8676 Background = new SolidColorBrush ( Colors . Transparent ) ;
87- currentSystemBackdrop ? . Dispose ( ) ;
88- currentSystemBackdrop = null ;
89- currentSystemBackdrop = new MicaBackdrop ( DesktopWindowTarget , this , Program . MainForm )
90- {
91- Kind = MicaKind . Base ,
92- RequestedTheme = currentTheme ,
93- IsInputActive = currentInputActiveState
94- } ;
95- currentSystemBackdrop . InitializeBackdrop ( ) ;
77+ Background = new MicaBrush ( MicaKind . Base , this , Program . MainForm , currentInputActiveState ) ;
9678
9779 SystemBackdropNameText . Text = "MicaBase" ;
9880 ThemeNameText . Text = currentTheme . ToString ( ) ;
9981 InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
10082 }
10183 else if ( SystemBackdropNameText . Text == "MicaBase" )
10284 {
103- Background = new SolidColorBrush ( Colors . Transparent ) ;
104- currentSystemBackdrop ? . Dispose ( ) ;
105- currentSystemBackdrop = null ;
106- currentSystemBackdrop = new MicaBackdrop ( DesktopWindowTarget , this , Program . MainForm )
107- {
108- Kind = MicaKind . BaseAlt ,
109- RequestedTheme = currentTheme ,
110- IsInputActive = currentInputActiveState
111- } ;
112- currentSystemBackdrop . InitializeBackdrop ( ) ;
85+ Background = new MicaBrush ( MicaKind . BaseAlt , this , Program . MainForm , currentInputActiveState ) ;
11386
11487 SystemBackdropNameText . Text = "MicaAlt" ;
11588 ThemeNameText . Text = currentTheme . ToString ( ) ;
11689 InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
11790 }
11891 else if ( SystemBackdropNameText . Text == "MicaAlt" )
11992 {
120- Background = new SolidColorBrush ( Colors . Transparent ) ;
121- currentSystemBackdrop ? . Dispose ( ) ;
122- currentSystemBackdrop = null ;
123- currentSystemBackdrop = new DesktopAcrylicBackdrop ( DesktopWindowTarget , this , Program . MainForm )
124- {
125- Kind = DesktopAcrylicKind . Default ,
126- RequestedTheme = currentTheme ,
127- IsInputActive = currentInputActiveState ,
128- UseHostBackdropBrush = true
129- } ;
130- currentSystemBackdrop . InitializeBackdrop ( ) ;
93+ Background = new DesktopAcrylicBrush ( DesktopAcrylicKind . Default , this , Program . MainForm , currentInputActiveState , true ) ;
13194
13295 SystemBackdropNameText . Text = "DesktopAcrylicDefault" ;
13396 ThemeNameText . Text = currentTheme . ToString ( ) ;
13497 InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
13598 }
13699 else if ( SystemBackdropNameText . Text == "DesktopAcrylicDefault" )
137100 {
138- Background = new SolidColorBrush ( Colors . Transparent ) ;
139- currentSystemBackdrop ? . Dispose ( ) ;
140- currentSystemBackdrop = null ;
141- currentSystemBackdrop = new DesktopAcrylicBackdrop ( DesktopWindowTarget , this , Program . MainForm )
142- {
143- Kind = DesktopAcrylicKind . Base ,
144- RequestedTheme = currentTheme ,
145- IsInputActive = currentInputActiveState ,
146- UseHostBackdropBrush = true
147- } ;
148- currentSystemBackdrop . InitializeBackdrop ( ) ;
101+ Background = new DesktopAcrylicBrush ( DesktopAcrylicKind . Base , this , Program . MainForm , currentInputActiveState , true ) ;
149102
150103 SystemBackdropNameText . Text = "DesktopAcrylicBase" ;
151104 ThemeNameText . Text = currentTheme . ToString ( ) ;
152105 InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
153106 }
154107 else if ( SystemBackdropNameText . Text == "DesktopAcrylicBase" )
155108 {
156- Background = new SolidColorBrush ( Colors . Transparent ) ;
157- currentSystemBackdrop ? . Dispose ( ) ;
158- currentSystemBackdrop = null ;
159- currentSystemBackdrop = new DesktopAcrylicBackdrop ( DesktopWindowTarget , this , Program . MainForm )
160- {
161- Kind = DesktopAcrylicKind . Thin ,
162- RequestedTheme = currentTheme ,
163- IsInputActive = currentInputActiveState ,
164- UseHostBackdropBrush = true
165- } ;
166- currentSystemBackdrop . InitializeBackdrop ( ) ;
109+ Background = new DesktopAcrylicBrush ( DesktopAcrylicKind . Thin , this , Program . MainForm , currentInputActiveState , true ) ;
167110
168111 SystemBackdropNameText . Text = "DesktopAcrylicThin" ;
169112 ThemeNameText . Text = currentTheme . ToString ( ) ;
@@ -172,10 +115,7 @@ private void SwitchSystemBackdropClick(object sender, RoutedEventArgs args)
172115 else if ( SystemBackdropNameText . Text == "DesktopAcrylicThin" )
173116 {
174117 SystemBackdropNameText . Text = "None" ;
175- currentSystemBackdrop ? . Dispose ( ) ;
176- currentSystemBackdrop = null ;
177118 ThemeNameText . Text = currentTheme . ToString ( ) ;
178- InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
179119
180120 if ( ActualTheme is ElementTheme . Light )
181121 {
@@ -195,11 +135,7 @@ private void SwitchThemeClick(object sender, RoutedEventArgs args)
195135 RequestedTheme = ElementTheme . Light ;
196136 currentTheme = ElementTheme . Light ;
197137 ThemeNameText . Text = ElementTheme . Light . ToString ( ) ;
198- if ( currentSystemBackdrop is not null )
199- {
200- currentSystemBackdrop . RequestedTheme = ElementTheme . Light ;
201- }
202- else
138+ if ( SystemBackdropNameText . Text == "None" )
203139 {
204140 Background = new SolidColorBrush ( Color . FromArgb ( 255 , 243 , 243 , 243 ) ) ;
205141 }
@@ -209,11 +145,7 @@ private void SwitchThemeClick(object sender, RoutedEventArgs args)
209145 RequestedTheme = ElementTheme . Dark ;
210146 currentTheme = ElementTheme . Dark ;
211147 ThemeNameText . Text = ElementTheme . Dark . ToString ( ) ;
212- if ( currentSystemBackdrop is not null )
213- {
214- currentSystemBackdrop . RequestedTheme = ElementTheme . Dark ;
215- }
216- else
148+ if ( SystemBackdropNameText . Text == "None" )
217149 {
218150 Background = new SolidColorBrush ( Color . FromArgb ( 255 , 32 , 32 , 32 ) ) ;
219151 }
@@ -223,20 +155,13 @@ private void SwitchThemeClick(object sender, RoutedEventArgs args)
223155 RequestedTheme = ElementTheme . Default ;
224156 currentTheme = ElementTheme . Default ;
225157 ThemeNameText . Text = ElementTheme . Default . ToString ( ) ;
226- if ( currentSystemBackdrop is not null )
158+ if ( ActualTheme is ElementTheme . Light )
227159 {
228- currentSystemBackdrop . RequestedTheme = ElementTheme . Default ;
160+ Background = new SolidColorBrush ( Color . FromArgb ( 255 , 243 , 243 , 243 ) ) ;
229161 }
230162 else
231163 {
232- if ( ActualTheme is ElementTheme . Light )
233- {
234- Background = new SolidColorBrush ( Color . FromArgb ( 255 , 243 , 243 , 243 ) ) ;
235- }
236- else
237- {
238- Background = new SolidColorBrush ( Color . FromArgb ( 255 , 32 , 32 , 32 ) ) ;
239- }
164+ Background = new SolidColorBrush ( Color . FromArgb ( 255 , 32 , 32 , 32 ) ) ;
240165 }
241166 }
242167 }
@@ -247,25 +172,38 @@ private void SwitchInputActiveStateClick(object sender, RoutedEventArgs args)
247172 {
248173 currentInputActiveState = false ;
249174 InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
250- if ( currentSystemBackdrop is not null )
251- {
252- currentSystemBackdrop . IsInputActive = false ;
253- }
254175 }
255176 else
256177 {
257178 currentInputActiveState = true ;
258179 InputActiveStateText . Text = currentInputActiveState . ToString ( ) ;
259- if ( currentSystemBackdrop is not null )
260- {
261- currentSystemBackdrop . IsInputActive = true ;
262- }
180+ }
181+
182+ if ( SystemBackdropNameText . Text == "Base" )
183+ {
184+ Background = new MicaBrush ( MicaKind . Base , this , Program . MainForm , currentInputActiveState ) ;
185+ }
186+ else if ( SystemBackdropNameText . Text == "MicaAlt" )
187+ {
188+ Background = new MicaBrush ( MicaKind . BaseAlt , this , Program . MainForm , currentInputActiveState ) ;
189+ }
190+ else if ( SystemBackdropNameText . Text == "DesktopAcrylicDefault" )
191+ {
192+ Background = new DesktopAcrylicBrush ( DesktopAcrylicKind . Default , this , Program . MainForm , currentInputActiveState , true ) ;
193+ }
194+ else if ( SystemBackdropNameText . Text == "DesktopAcrylicBase" )
195+ {
196+ Background = new DesktopAcrylicBrush ( DesktopAcrylicKind . Base , this , Program . MainForm , currentInputActiveState , true ) ;
197+ }
198+ else if ( SystemBackdropNameText . Text == "DesktopAcrylicThin" )
199+ {
200+ Background = new DesktopAcrylicBrush ( DesktopAcrylicKind . Thin , this , Program . MainForm , currentInputActiveState , true ) ;
263201 }
264202 }
265203
266204 private void OnActualThemeChanged ( FrameworkElement sender , object args )
267205 {
268- if ( currentSystemBackdrop is not null )
206+ if ( SystemBackdropNameText . Text == "None" )
269207 {
270208 if ( ActualTheme is ElementTheme . Light )
271209 {
0 commit comments