1
- using System . IO ;
2
- using System . Reflection ;
3
- using System . Threading . Tasks ;
4
- using System . Windows . Controls ;
1
+ using System . Reflection ;
5
2
using MaterialDesignColors ;
6
- using MaterialDesignThemes . UITests . WPF . DatePickers ;
7
- using MaterialDesignThemes . Wpf ;
8
- using XamlTest ;
9
3
10
- namespace MaterialDesignThemes . UITests
4
+ namespace MaterialDesignThemes . UITests ;
5
+
6
+ public static class XamlTestMixins
11
7
{
12
- public static class XamlTestMixins
8
+ public static async Task InitializeWithMaterialDesign ( this IApp app ,
9
+ BaseTheme baseTheme = BaseTheme . Light ,
10
+ PrimaryColor primary = PrimaryColor . DeepPurple ,
11
+ SecondaryColor secondary = SecondaryColor . Lime ,
12
+ ColorAdjustment ? colorAdjustment = null )
13
13
{
14
- public static async Task InitializeWithMaterialDesign ( this IApp app ,
15
- BaseTheme baseTheme = BaseTheme . Light ,
16
- PrimaryColor primary = PrimaryColor . DeepPurple ,
17
- SecondaryColor secondary = SecondaryColor . Lime ,
18
- ColorAdjustment ? colorAdjustment = null )
14
+ string colorAdjustString = "" ;
15
+ if ( colorAdjustment != null )
19
16
{
20
- string colorAdjustString = "" ;
21
- if ( colorAdjustment != null )
22
- {
23
- colorAdjustString = "ColorAdjustment=\" {materialDesign:ColorAdjustment}\" " ;
24
- }
17
+ colorAdjustString = "ColorAdjustment=\" {materialDesign:ColorAdjustment}\" " ;
18
+ }
25
19
26
- string applicationResourceXaml = $@ "<ResourceDictionary
20
+ string applicationResourceXaml = $@ "<ResourceDictionary
27
21
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
28
22
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
29
23
xmlns:materialDesign=""http://materialdesigninxaml.net/winfx/xaml/themes"">
@@ -34,22 +28,22 @@ public static async Task InitializeWithMaterialDesign(this IApp app,
34
28
<ResourceDictionary Source = ""pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"" />
35
29
</ResourceDictionary.MergedDictionaries>
36
30
</ResourceDictionary>" ;
37
-
38
- await app . Initialize ( applicationResourceXaml ,
39
- Path . GetFullPath ( "MaterialDesignColors.dll" ) ,
40
- Path . GetFullPath ( "MaterialDesignThemes.Wpf.dll" ) ,
41
- Assembly . GetExecutingAssembly ( ) . Location ) ;
42
- }
31
+
32
+ await app . Initialize ( applicationResourceXaml ,
33
+ Path . GetFullPath ( "MaterialDesignColors.dll" ) ,
34
+ Path . GetFullPath ( "MaterialDesignThemes.Wpf.dll" ) ,
35
+ Assembly . GetExecutingAssembly ( ) . Location ) ;
36
+ }
43
37
44
- public static async Task < IVisualElement < T > > CreateWindowWith < T > ( this IApp app , string xaml , params ( string namespacePrefix , Type type ) [ ] additionalNamespaceDeclarations )
38
+ public static async Task < IVisualElement < T > > CreateWindowWith < T > ( this IApp app , string xaml , params ( string namespacePrefix , Type type ) [ ] additionalNamespaceDeclarations )
39
+ {
40
+ var extraNamespaceDeclarations = new StringBuilder ( "" ) ;
41
+ foreach ( ( string namespacePrefix , Type type ) in additionalNamespaceDeclarations )
45
42
{
46
- var extraNamespaceDeclarations = new StringBuilder ( "" ) ;
47
- foreach ( ( string namespacePrefix , Type type ) in additionalNamespaceDeclarations )
48
- {
49
- extraNamespaceDeclarations . AppendLine ( $@ "xmlns:{ namespacePrefix } =""clr-namespace:{ type . Namespace } ;assembly={ type . Assembly . GetName ( ) . Name } """);
50
- }
43
+ extraNamespaceDeclarations . AppendLine ( $@ "xmlns:{ namespacePrefix } =""clr-namespace:{ type . Namespace } ;assembly={ type . Assembly . GetName ( ) . Name } """);
44
+ }
51
45
52
- string windowXaml = @$" < Window
46
+ string windowXaml = @$" < Window
53
47
xmlns= ""http: //schemas.microsoft.com/winfx/2006/xaml/presentation""
54
48
xmlns: x= ""http: //schemas.microsoft.com/winfx/2006/xaml""
55
49
xmlns: d= ""http: //schemas.microsoft.com/expression/blend/2008""
@@ -70,13 +64,13 @@ public static async Task<IVisualElement<T>> CreateWindowWith<T>(this IApp app, s
70
64
WindowStartupLocation = "" CenterScreen"">
71
65
{ xaml }
72
66
< / Window > ";
73
- IWindow window = await app . CreateWindow ( windowXaml ) ;
74
- return await window. GetElement < T > ( ".Content" ) ;
75
- }
67
+ IWindow window = await app . CreateWindow ( windowXaml ) ;
68
+ return await window. GetElement < T > ( ".Content" ) ;
69
+ }
76
70
77
- public static async Task< IVisualElement > CreateWindowWith ( this IApp app , string xaml )
78
- {
79
- string windowXaml = @$"< Window
71
+ public static async Task< IVisualElement > CreateWindowWith ( this IApp app , string xaml )
72
+ {
73
+ string windowXaml = @$"< Window
80
74
xmlns= ""http: //schemas.microsoft.com/winfx/2006/xaml/presentation""
81
75
xmlns: x= ""http: //schemas.microsoft.com/winfx/2006/xaml""
82
76
xmlns: d= ""http: //schemas.microsoft.com/expression/blend/2008""
@@ -96,14 +90,14 @@ public static async Task<IVisualElement> CreateWindowWith(this IApp app, string
96
90
WindowStartupLocation = "" CenterScreen"">
97
91
{ xaml }
98
92
< / Window > ";
99
- IWindow window = await app . CreateWindow ( windowXaml ) ;
100
- return await window. GetElement ( ".Content" ) ;
101
- }
93
+ IWindow window = await app . CreateWindow ( windowXaml ) ;
94
+ return await window. GetElement ( ".Content" ) ;
95
+ }
102
96
103
- public static async Task< IVisualElement > CreateWindowWithUserControl < TControl > ( this IApp app )
104
- where TControl : UserControl
105
- {
106
- string windowXaml = @$"< Window
97
+ public static async Task< IVisualElement > CreateWindowWithUserControl < TControl > ( this IApp app )
98
+ where TControl : UserControl
99
+ {
100
+ string windowXaml = @$"< Window
107
101
xmlns= ""http: //schemas.microsoft.com/winfx/2006/xaml/presentation""
108
102
xmlns: x= ""http: //schemas.microsoft.com/winfx/2006/xaml""
109
103
xmlns: d= ""http: //schemas.microsoft.com/expression/blend/2008""
@@ -124,8 +118,7 @@ public static async Task<IVisualElement> CreateWindowWithUserControl<TControl>(t
124
118
WindowStartupLocation = "" CenterScreen"">
125
119
< local : { typeof ( TControl ) . Name } / >
126
120
< / Window > ";
127
- IWindow window = await app . CreateWindow ( windowXaml ) ;
128
- return await window. GetElement ( ".Content.Content" ) ;
129
- }
121
+ IWindow window = await app . CreateWindow ( windowXaml ) ;
122
+ return await window. GetElement ( ".Content.Content" ) ;
130
123
}
131
124
}
0 commit comments