1
+ # If _MyType <> "Empty" Then
2
+
3
+ Namespace My
4
+ ''' <summary>
5
+ ''' Module used to define the properties that are available in the My Namespace for WPF
6
+ ''' </summary>
7
+ ''' <remarks></remarks>
8
+ < Global .Microsoft.VisualBasic.HideModuleName()> _
9
+ Module MyWpfExtension
10
+ Private s_Computer As New ThreadSafeObjectProvider( Of Global .Microsoft.VisualBasic.Devices.Computer)
11
+ Private s_User As New ThreadSafeObjectProvider( Of Global .Microsoft.VisualBasic.ApplicationServices.User)
12
+ Private s_Windows As New ThreadSafeObjectProvider( Of MyWindows)
13
+ Private s_Log As New ThreadSafeObjectProvider( Of Global .Microsoft.VisualBasic.Logging.Log)
14
+ ''' <summary>
15
+ ''' Returns the application object for the running application
16
+ ''' </summary>
17
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1811:AvoidUncalledPrivateCode" )> _
18
+ Friend ReadOnly Property Application() As Application
19
+ Get
20
+ Return CType ( Global .System.Windows.Application.Current, Application)
21
+ End Get
22
+ End Property
23
+ ''' <summary>
24
+ ''' Returns information about the host computer.
25
+ ''' </summary>
26
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1811:AvoidUncalledPrivateCode" )> _
27
+ Friend ReadOnly Property Computer() As Global .Microsoft.VisualBasic.Devices.Computer
28
+ Get
29
+ Return s_Computer.GetInstance()
30
+ End Get
31
+ End Property
32
+ ''' <summary>
33
+ ''' Returns information for the current user. If you wish to run the application with the current
34
+ ''' Windows user credentials, call My.User.InitializeWithWindowsUser().
35
+ ''' </summary>
36
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1811:AvoidUncalledPrivateCode" )> _
37
+ Friend ReadOnly Property User() As Global .Microsoft.VisualBasic.ApplicationServices.User
38
+ Get
39
+ Return s_User.GetInstance()
40
+ End Get
41
+ End Property
42
+ ''' <summary>
43
+ ''' Returns the application log. The listeners can be configured by the application's configuration file.
44
+ ''' </summary>
45
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1811:AvoidUncalledPrivateCode" )> _
46
+ Friend ReadOnly Property Log() As Global .Microsoft.VisualBasic.Logging.Log
47
+ Get
48
+ Return s_Log.GetInstance()
49
+ End Get
50
+ End Property
51
+
52
+ ''' <summary>
53
+ ''' Returns the collection of Windows defined in the project.
54
+ ''' </summary>
55
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1811:AvoidUncalledPrivateCode" )> _
56
+ Friend ReadOnly Property Windows() As MyWindows
57
+ < Global .System.Diagnostics.DebuggerHidden()> _
58
+ Get
59
+ Return s_Windows.GetInstance()
60
+ End Get
61
+ End Property
62
+ < Global .System.ComponentModel.EditorBrowsableAttribute( Global .System.ComponentModel.EditorBrowsableState.Never)> _
63
+ < Global .Microsoft.VisualBasic.MyGroupCollection( "System.Windows.Window" , "Create__Instance__" , "Dispose__Instance__" , "My.MyWpfExtenstionModule.Windows" )> _
64
+ Friend NotInheritable Class MyWindows
65
+ < Global .System.Diagnostics.DebuggerHidden()> _
66
+ Private Shared Function Create__Instance__( Of T As { New , Global .System.Windows.Window})( ByVal Instance As T) As T
67
+ If Instance Is Nothing Then
68
+ If s_WindowBeingCreated IsNot Nothing Then
69
+ If s_WindowBeingCreated.ContainsKey( GetType (T)) = True Then
70
+ Throw New Global .System.InvalidOperationException( "The window cannot be accessed via My.Windows from the Window constructor." )
71
+ End If
72
+ Else
73
+ s_WindowBeingCreated = New Global .System.Collections.Hashtable()
74
+ End If
75
+ s_WindowBeingCreated.Add( GetType (T), Nothing )
76
+ Return New T()
77
+ s_WindowBeingCreated.Remove( GetType (T))
78
+ Else
79
+ Return Instance
80
+ End If
81
+ End Function
82
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1822:MarkMembersAsStatic" )> _
83
+ < Global .System.Diagnostics.DebuggerHidden()> _
84
+ Private Sub Dispose__Instance__( Of T As Global .System.Windows.Window)( ByRef instance As T)
85
+ instance = Nothing
86
+ End Sub
87
+ < Global .System.Diagnostics.DebuggerHidden()> _
88
+ < Global .System.ComponentModel.EditorBrowsableAttribute( Global .System.ComponentModel.EditorBrowsableState.Never)> _
89
+ Public Sub New ()
90
+ MyBase .New()
91
+ End Sub
92
+ < Global .System.ThreadStatic()> Private Shared s_WindowBeingCreated As Global .System.Collections.Hashtable
93
+ < Global .System.ComponentModel.EditorBrowsable( Global .System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function Equals ( ByVal o As Object ) As Boolean
94
+ Return MyBase .Equals(o)
95
+ End Function
96
+ < Global .System.ComponentModel.EditorBrowsable( Global .System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function GetHashCode() As Integer
97
+ Return MyBase .GetHashCode
98
+ End Function
99
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1822:MarkMembersAsStatic" )> _
100
+ < Global .System.ComponentModel.EditorBrowsable( Global .System.ComponentModel.EditorBrowsableState.Never)> _
101
+ Friend Overloads Function [GetType]() As Global .System.Type
102
+ Return GetType (MyWindows)
103
+ End Function
104
+ < Global .System.ComponentModel.EditorBrowsable( Global .System.ComponentModel.EditorBrowsableState.Never)> Public Overrides Function ToString() As String
105
+ Return MyBase .ToString
106
+ End Function
107
+ End Class
108
+ End Module
109
+ End Namespace
110
+ Partial Class Application
111
+ Inherits Global .System.Windows.Application
112
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1811:AvoidUncalledPrivateCode" )> _
113
+ < Global .System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance" , "CA1822:MarkMembersAsStatic" )> _
114
+ Friend ReadOnly Property Info() As Global .Microsoft.VisualBasic.ApplicationServices.AssemblyInfo
115
+ < Global .System.Diagnostics.DebuggerHidden()> _
116
+ Get
117
+ Return New Global .Microsoft.VisualBasic.ApplicationServices.AssemblyInfo( Global .System.Reflection.Assembly.GetExecutingAssembly())
118
+ End Get
119
+ End Property
120
+ End Class
121
+ # End If
0 commit comments