diff --git a/Pilz.Collections/App.config b/Pilz.Collections/App.config new file mode 100644 index 0000000..1729194 --- /dev/null +++ b/Pilz.Collections/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Pilz.Collections/My Project/Application.Designer.vb b/Pilz.Collections/My Project/Application.Designer.vb new file mode 100644 index 0000000..8ab460b --- /dev/null +++ b/Pilz.Collections/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Collections/My Project/Application.myapp b/Pilz.Collections/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/Pilz.Collections/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/Pilz.Collections/My Project/AssemblyInfo.vb b/Pilz.Collections/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..16e3ed2 --- /dev/null +++ b/Pilz.Collections/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Collections/My Project/Resources.Designer.vb b/Pilz.Collections/My Project/Resources.Designer.vb new file mode 100644 index 0000000..efc949e --- /dev/null +++ b/Pilz.Collections/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Collections.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Collections/My Project/Resources.resx b/Pilz.Collections/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Collections/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Collections/My Project/Settings.Designer.vb b/Pilz.Collections/My Project/Settings.Designer.vb new file mode 100644 index 0000000..69fe663 --- /dev/null +++ b/Pilz.Collections/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Collections.My.MySettings + Get + Return Global.Pilz.Collections.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Collections/My Project/Settings.settings b/Pilz.Collections/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Collections/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Collections/Pilz.Collections.vbproj b/Pilz.Collections/Pilz.Collections.vbproj new file mode 100644 index 0000000..b0fc5b8 --- /dev/null +++ b/Pilz.Collections/Pilz.Collections.vbproj @@ -0,0 +1,145 @@ + + + + + Debug + AnyCPU + {E4B2D294-8479-4014-942D-0B460E453DEA} + Library + + + Pilz.Collections + Pilz.Collections + 512 + Windows + v4.5 + + + + AnyCPU + true + full + true + true + bin\Debug\ + Pilz.Collections.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,40008 + false + + + AnyCPU + none + false + true + true + bin\Release\ + Pilz.Collections.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false + true + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x86\Debug\ + Pilz.Collections.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,40008 + full + x86 + MinimumRecommendedRules.ruleset + true + + + true + bin\x86\Release\ + true + Pilz.Collections.xml + true + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + x86 + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Pilz.Collections/SimpleHistory/Enums.vb b/Pilz.Collections/SimpleHistory/Enums.vb new file mode 100644 index 0000000..8438552 --- /dev/null +++ b/Pilz.Collections/SimpleHistory/Enums.vb @@ -0,0 +1,12 @@ +Namespace SimpleHistory + + ''' + ''' Specify which member types you would include. + ''' + Public Enum ObjectValueType + None = 0 + Field = 1 + [Property] = 2 + End Enum + +End Namespace \ No newline at end of file diff --git a/Pilz.Collections/SimpleHistory/HistoryPoint.vb b/Pilz.Collections/SimpleHistory/HistoryPoint.vb new file mode 100644 index 0000000..a023780 --- /dev/null +++ b/Pilz.Collections/SimpleHistory/HistoryPoint.vb @@ -0,0 +1,543 @@ +Imports System.Reflection + +Namespace SimpleHistory + + ''' + ''' Represent some Object States and Actions. + ''' + Public Class HistoryPoint + + ''' + ''' Represents the Name of this History Point + ''' + ''' + Public Property Name As String = "" + ''' + ''' A List of Object States and Actions. + ''' + ''' + Public ReadOnly Property Entries As New List(Of ObjectBase) + ''' + ''' Some data can be refered on this HistoryPoint. Don't know, in some situations this can be helpful. + ''' + Public ReadOnly Tag As Object = Nothing + + Public Function HasEntries(Of T As ObjectBase)() As Boolean + Return Entries.Where(Function(n) TypeOf n Is T).Count > 0 + End Function + + Friend Sub Undo() + For Each s As ObjectBase In Entries.OrderBy(Function(n) n.UndoPriority) + If TypeOf s Is ObjectState Then + CType(s, ObjectState).Patch() + ElseIf TypeOf s Is ObjectAction Then + CType(s, ObjectAction).Undo() + End If + Next + End Sub + + Friend Sub Redo() + For Each s As ObjectBase In Entries.OrderBy(Function(n) n.RedoPriority) + If TypeOf s Is ObjectState Then + CType(s, ObjectState).Patch() + ElseIf TypeOf s Is ObjectAction Then + CType(s, ObjectAction).Redo() + End If + Next + End Sub + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify which members to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), whiteList As MemberWhiteList) As HistoryPoint + Return FromObject({obj}, ObjectValueType.None, CObj(whiteList), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify which members to exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), blackList As MemberBlackList) As HistoryPoint + Return FromObject({obj}, ObjectValueType.None, CObj(blackList), BindingFlags.Default) + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), BindingFlags.Default) + Else + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), BindingFlags.Default) + End If + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, membersToStore, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), BindingFlags.Default) + Else + Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), BindingFlags.Default) + End If + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' The Binding Flags that the members should have. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, flags, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' The Binding Flags that the members should have. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), flags) + Else + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), flags) + End If + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' The Binding Flags that the members should have. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, flags, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' The Binding Flags that the members should have. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), flags) + Else + Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), flags) + End If + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify which members to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, whiteList As MemberWhiteList) As HistoryPoint + Return FromObject({obj}, ObjectValueType.None, CObj(whiteList), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify which members to exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, blackList As MemberBlackList) As HistoryPoint + Return FromObject({obj}, ObjectValueType.None, CObj(blackList), BindingFlags.Default) + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), BindingFlags.Default) + Else + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), BindingFlags.Default) + End If + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, membersToStore, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), BindingFlags.Default) + Else + Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), BindingFlags.Default) + End If + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' The Binding Flags that the members should have. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, flags, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' The Binding Flags that the members should have. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), flags) + Else + Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), flags) + End If + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' The Binding Flags that the members should have. + ''' The member names to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint + Return FromObject(obj, flags, True, memberName) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' The Binding Flags that the members should have. + ''' If true, the memberName-Array has member names that should be included. + ''' The member names to include/exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint + If isWhiteList Then + Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), flags) + Else + Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), flags) + End If + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object) As HistoryPoint + Return FromObject({obj}, ObjectValueType.None, CObj(Nothing), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType) As HistoryPoint + Return FromObject({obj}, membersToStore, CObj(Nothing), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' Specify which members to include. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, whiteList As MemberWhiteList) As HistoryPoint + Return FromObject({obj}, membersToStore, CObj(whiteList), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' Specify which members to exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, blackList As MemberBlackList) As HistoryPoint + Return FromObject({obj}, membersToStore, CObj(blackList), BindingFlags.Default) + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, flags As BindingFlags) As HistoryPoint + Return FromObject({obj}, ObjectValueType.None, CObj(Nothing), flags) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, flags As BindingFlags) As HistoryPoint + Return FromObject({obj}, membersToStore, CObj(Nothing), flags) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' Specify which members to include. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, whiteList As MemberWhiteList, flags As BindingFlags) As HistoryPoint + Return FromObject({obj}, membersToStore, CObj(whiteList), flags) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The object that should be included. + ''' Specify what member types to include. + ''' Specify which members to exclude. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, blackList As MemberBlackList, flags As BindingFlags) As HistoryPoint + Return FromObject({obj}, membersToStore, CObj(blackList), flags) + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object()) As HistoryPoint + Return FromObject(objs, ObjectValueType.None, CObj(Nothing), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType) As HistoryPoint + Return FromObject(objs, membersToStore, CObj(Nothing), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' Specify which members to include. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, whiteList As MemberWhiteList) As HistoryPoint + Return FromObject(objs, membersToStore, CObj(whiteList), BindingFlags.Default) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' Specify which members to exclude. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, blackList As MemberBlackList) As HistoryPoint + Return FromObject(objs, membersToStore, CObj(blackList), BindingFlags.Default) + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), flags As BindingFlags) As HistoryPoint + Return FromObject(objs, ObjectValueType.None, CObj(Nothing), flags) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, flags As BindingFlags) As HistoryPoint + Return FromObject(objs, membersToStore, CObj(Nothing), flags) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' Specify which members to include. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, whiteList As MemberWhiteList, flags As BindingFlags) As HistoryPoint + Return FromObject(objs, membersToStore, CObj(whiteList), flags) + End Function + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' Specify which members to exclude. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, blackList As MemberBlackList, flags As BindingFlags) As HistoryPoint + Return FromObject(objs, membersToStore, CObj(blackList), flags) + End Function + + ''' + ''' Creates an History Point with Object States automaticly from input. + ''' + ''' The objects that should be included. + ''' Specify what member types to include. + ''' Specify which members to include. + ''' The Binding Flags that the members should have. + ''' A History Point with Object States. + Private Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, whiteOrBlackList As Object, flags As BindingFlags) As HistoryPoint + Dim hp As New HistoryPoint + + If whiteOrBlackList Is Nothing Then whiteOrBlackList = New MemberBlackList + Dim isWhiteList As Boolean = TypeOf whiteOrBlackList Is MemberWhiteList + + If flags = BindingFlags.Default Then + flags = BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic + End If + If membersToStore = ObjectValueType.None Then + membersToStore = ObjectValueType.Field Or ObjectValueType.Property + End If + + For Each obj As Object In objs + If (membersToStore And ObjectValueType.Field) = ObjectValueType.Field Then + + For Each fi As FieldInfo In obj.GetType.GetFields(flags) + + Dim contains As Boolean = whiteOrBlackList.Contains(fi.Name) + If If(isWhiteList, contains, Not contains) Then + + Dim os As New ObjectState + os.Object = obj + os.MemberName = fi.Name + os.MemberType = ObjectValueType.Field + os.MemberFlags = flags + os.ValueToPatch = fi.GetValue(obj) + hp.Entries.Add(os) + + End If + + Next + + End If + + If (membersToStore And ObjectValueType.Property) = ObjectValueType.Property Then + + For Each pi As PropertyInfo In obj.GetType.GetProperties(flags) + + Dim contains As Boolean = whiteOrBlackList.Contains(pi.Name) + If If(isWhiteList, contains, Not contains) Then + + Dim os As New ObjectState + os.Object = obj + os.MemberName = pi.Name + os.MemberType = ObjectValueType.Property + os.MemberFlags = flags + os.ValueToPatch = pi.GetValue(obj) + hp.Entries.Add(os) + + End If + + Next + + End If + Next + + Return hp + End Function + + ''' + ''' Combines some History Points to one. + ''' + ''' An array of History Points to combine. + ''' One History Point that contains all Data of inputted History Points. + Public Shared Function Concat(ParamArray hps As HistoryPoint()) As HistoryPoint + Return Concat(hps.FirstOrDefault?.Name, hps) + End Function + + ''' + ''' Combines some History Points to one. + ''' + ''' An array of History Points to combine. + ''' One History Point that contains all Data of inputted History Points. + Public Shared Function Concat(newName As String, ParamArray hps As HistoryPoint()) As HistoryPoint + Dim hp As New HistoryPoint + + For Each _hp As HistoryPoint In hps + hp.Entries.AddRange(_hp.Entries) + Next + + Return hp + End Function + + End Class + +End Namespace diff --git a/Pilz.Collections/SimpleHistory/MemberLists.vb b/Pilz.Collections/SimpleHistory/MemberLists.vb new file mode 100644 index 0000000..05fdf82 --- /dev/null +++ b/Pilz.Collections/SimpleHistory/MemberLists.vb @@ -0,0 +1,33 @@ +Namespace SimpleHistory + + ''' + ''' List contianing member names to include. + ''' + Public Class MemberWhiteList + Inherits List(Of String) + + Public Sub New() + MyBase.New + End Sub + + Public Sub New(entries As String()) + MyBase.New(entries) + End Sub + End Class + + ''' + ''' List contianing member names to exclude + ''' + Public Class MemberBlackList + Inherits List(Of String) + + Public Sub New() + MyBase.New + End Sub + + Public Sub New(entries As String()) + MyBase.New(entries) + End Sub + End Class + +End Namespace \ No newline at end of file diff --git a/Pilz.Collections/SimpleHistory/ObjectAction.vb b/Pilz.Collections/SimpleHistory/ObjectAction.vb new file mode 100644 index 0000000..7861237 --- /dev/null +++ b/Pilz.Collections/SimpleHistory/ObjectAction.vb @@ -0,0 +1,165 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +Namespace SimpleHistory + + Public Class ObjectAction + Inherits ObjectBase + + Public Property [Object] As Object = Nothing + Public ReadOnly Property ParametersUndo As New List(Of Object) + Public ReadOnly Property ParametersRedo As New List(Of Object) + Public Property MethodUndo As MethodInfo = Nothing + Public Property MethodRedo As MethodInfo = Nothing + Public Property AutogenerateObject As Boolean = True + + ''' + ''' Creates a new Instance of Object Action. + ''' + Public Sub New() + End Sub + + Private Function GetMethodInfo(obj As Object, name As String, flags As BindingFlags) + Return obj.GetType.GetMethod(name, flags) + End Function + + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The name of the methode to call on Undo. + ''' The name of the methode to call on Redo. + Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String) + Me.New(obj, methodNameUndo, methodNameRedo, {}, {}, BindingFlags.Default, BindingFlags.Default) + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The name of the methode to call on Undo. + ''' The name of the methode to call on Redo. + ''' The parameters for calling the methode on Undo. + ''' The parameters for calling the methode on Redo. + Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String, paramsUndo As Object(), paramsRedo As Object()) + Me.New(obj, methodNameUndo, methodNameRedo, paramsUndo, paramsRedo, BindingFlags.Default, BindingFlags.Default) + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The name of the methode to call on Undo. + ''' The name of the methode to call on Redo. + ''' The parameters for calling the methode on Undo. + ''' The parameters for calling the methode on Redo. + ''' The Binding Flags of Methode on Undo. + ''' The Binding Flags of Methode on Redo. + Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String, paramsUndo As Object(), paramsRedo As Object(), methodFlagsUndo As BindingFlags, methodFlagsRedo As BindingFlags) + [Object] = obj + ParametersUndo.AddRange(paramsUndo) + ParametersRedo.AddRange(paramsRedo) + MethodUndo = GetMethodInfo(obj, methodNameUndo, GetFlags(methodFlagsUndo)) + MethodRedo = GetMethodInfo(obj, methodNameRedo, GetFlags(methodFlagsRedo)) + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The name of the methode to call on Undo. + ''' The name of the methode to call on Redo. + ''' The Binding Flags of Methode on Undo. + ''' The Binding Flags of Methode on Redo. + Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String, methodFlagsUndo As BindingFlags, methodFlagsRedo As BindingFlags) + Me.New(obj, methodNameUndo, methodNameRedo, {}, {}, methodFlagsUndo, methodFlagsRedo) + End Sub + + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The MethodInfo of the methode to call on Undo. + ''' The MethodInfo of the methode to call on Redo. + Public Sub New(obj As Object, methodUndo As MethodInfo, methodRedo As MethodInfo) + [Object] = obj + Me.MethodUndo = methodUndo + Me.MethodRedo = methodRedo + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The MethodInfo of the methode to call on Undo. + ''' The MethodInfo of the methode to call on Redo. + ''' The parameters for calling the methode on Undo. + ''' The parameters for calling the methode on Redo. + Public Sub New(obj As Object, methodUndo As MethodInfo, methodRedo As MethodInfo, paramsUndo As Object(), paramsRedo As Object()) + Me.New(obj, methodUndo, methodRedo) + ParametersUndo.AddRange(paramsUndo) + ParametersRedo.AddRange(paramsRedo) + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The Delegate of the methode to call on Undo. + ''' The Delegate of the methode to call on Redo. + Public Sub New(obj As Object, methodUndo As [Delegate], methodRedo As [Delegate]) + [Object] = obj + Me.MethodUndo = methodUndo.Method + Me.MethodRedo = methodRedo.Method + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The Delegate of the methode to call on Undo. + ''' The Delegate of the methode to call on Redo. + ''' The parameters for calling the methode on Undo. + ''' The parameters for calling the methode on Redo. + Public Sub New(obj As Object, methodUndo As [Delegate], methodRedo As [Delegate], paramsUndo As Object(), paramsRedo As Object()) + Me.New(obj, methodUndo, methodRedo) + ParametersUndo.AddRange(paramsUndo) + ParametersRedo.AddRange(paramsRedo) + End Sub + ''' + ''' Creates a new Instance of Object Action. + ''' + ''' The Objects that contains the methodes to call. + ''' The Action of the methode to call on Undo. + ''' The Action of the methode to call on Redo. + Public Sub New(obj As Object, methodUndo As Action, methodRedo As Action) + [Object] = obj + Me.MethodUndo = methodUndo.Method + Me.MethodRedo = methodRedo.Method + End Sub + + Private Function GetFlags(flags As BindingFlags) As BindingFlags + If flags = BindingFlags.Default Then + flags = BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic + End If + Return flags + End Function + + Friend Sub Undo() + CheckIfObjIsNothing(MethodUndo) + MethodUndo?.Invoke([Object], ParametersUndo.ToArray) + End Sub + + Friend Sub Redo() + CheckIfObjIsNothing(MethodRedo) + MethodRedo?.Invoke([Object], ParametersRedo.ToArray) + End Sub + + Private Sub CheckIfObjIsNothing(mi As MethodInfo) + If mi IsNot Nothing AndAlso Not mi.IsStatic AndAlso AutogenerateObject Then + If (Me.Object Is Nothing OrElse Me.Object.GetType <> mi.ReflectedType) AndAlso Not mi.IsStatic Then + Dim constructor As ConstructorInfo = mi.ReflectedType.GetConstructor(Type.EmptyTypes) + Dim classObject As Object = constructor.Invoke({}) + Me.Object = classObject + End If + End If + End Sub + + End Class + + +End Namespace \ No newline at end of file diff --git a/Pilz.Collections/SimpleHistory/ObjectBase.vb b/Pilz.Collections/SimpleHistory/ObjectBase.vb new file mode 100644 index 0000000..76a201e --- /dev/null +++ b/Pilz.Collections/SimpleHistory/ObjectBase.vb @@ -0,0 +1,13 @@ +Namespace SimpleHistory + + Public Class ObjectBase + + Public Shared Property DefaultPriorityValue As Integer = 1000 + + Public Property UndoPriority As Integer = DefaultPriorityValue + Public Property RedoPriority As Integer = DefaultPriorityValue + + End Class + + +End Namespace \ No newline at end of file diff --git a/Pilz.Collections/SimpleHistory/ObjectState.vb b/Pilz.Collections/SimpleHistory/ObjectState.vb new file mode 100644 index 0000000..9678686 --- /dev/null +++ b/Pilz.Collections/SimpleHistory/ObjectState.vb @@ -0,0 +1,84 @@ +Imports System.Reflection + +Namespace SimpleHistory + + Public Class ObjectState + Inherits ObjectBase + + ''' + ''' The Object including the members to patch. + ''' + ''' + Public Property [Object] As Object = Nothing + ''' + ''' The name of the Member to patch. + ''' + ''' + Public Property MemberName As String = "" + ''' + ''' The Value that should be patched. + ''' + ''' + Public Property ValueToPatch As Object = Nothing + ''' + ''' The member types to include at searching for the member. + ''' + ''' + Public Property MemberType As ObjectValueType = ObjectValueType.Field + ''' + ''' The Binding Flags that are used at searching for the member. + ''' + ''' + Public Property MemberFlags As BindingFlags = BindingFlags.Default + + ''' + ''' Creates a new Instance of ObjectState from input. + ''' + ''' The Object including the members to patch. + ''' The name of the Member to patch. + ''' The member types to include at searching for the member. + ''' The Binding Flags that are used at searching for the member. + Public Sub New(obj As Object, valname As String, valToPatch As Object, valtype As ObjectValueType) + [Object] = obj + MemberName = valname + ValueToPatch = valToPatch + MemberType = valtype + End Sub + + ''' + ''' Creates a new Instance of ObjectState. + ''' + Public Sub New() + End Sub + + Friend Sub Patch() + Dim t As Type = [Object].GetType + Select Case MemberType + Case ObjectValueType.Field + Dim f As FieldInfo = t.GetField(MemberName, MemberFlags) + Dim temp As Object = Nothing + + If f IsNot Nothing Then + temp = f.GetValue([Object]) + f.SetValue([Object], ValueToPatch) + ValueToPatch = temp + End If + + Case ObjectValueType.Property + Dim p As PropertyInfo = t.GetProperty(MemberName, BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static) + Dim temp As Object = Nothing + + If p IsNot Nothing Then + temp = p.GetValue([Object]) + p.SetValue([Object], ValueToPatch) + ValueToPatch = temp + End If + + Case Else + Throw New Exception("ValueType is invalid!") + End Select + End Sub + + End Class + +End Namespace \ No newline at end of file diff --git a/Pilz.Collections/SimpleHistory/SimpleHistory.vb b/Pilz.Collections/SimpleHistory/SimpleHistory.vb new file mode 100644 index 0000000..46dc39d --- /dev/null +++ b/Pilz.Collections/SimpleHistory/SimpleHistory.vb @@ -0,0 +1,89 @@ +Imports System.Reflection + +Namespace SimpleHistory + + Public Class HistoryStack + + Private stackPast As New Stack(Of HistoryPoint) + Private stackFuture As New Stack(Of HistoryPoint) + + ''' + ''' Checks if the History has past changes. + ''' + ''' + Public Function HasChanges() As Boolean + Return stackPast.Count > 0 + End Function + + ''' + ''' Patch Object States and call Undo Actions. + ''' + Public Function Undo() As HistoryPoint + Dim ret As HistoryPoint + + If stackPast.Count > 0 Then + + Dim hp As HistoryPoint = stackPast.Pop + hp.Undo() + stackFuture.Push(hp) + ret = hp + + Else + ret = Nothing + + End If + + Return ret + End Function + + ''' + ''' Patch Object States and call Redo Actions. + ''' + Public Function Redo() As HistoryPoint + Dim ret As HistoryPoint + + If stackFuture.Count > 0 Then + + Dim hp As HistoryPoint = stackFuture.Pop + hp.Redo() + stackPast.Push(hp) + ret = hp + + Else + ret = Nothing + + End If + + Return ret + End Function + + ''' + ''' Clear the History. + ''' + Public Sub Clear() + stackPast.Clear() + stackFuture.Clear() + End Sub + + ''' + ''' Store a History Point. + ''' + ''' The History Point to add to the past changes. + ''' The name to set for the History Point. + Public Sub Store(point As HistoryPoint, newName As String) + point.Name = newName + Store(point) + End Sub + + ''' + ''' Store a History Point. + ''' + ''' The History Point to add to the past changes. + Public Sub Store(point As HistoryPoint) + stackPast.Push(point) + stackFuture.Clear() + End Sub + + End Class + +End Namespace diff --git a/Pilz.Configuration/ISettingsManager.vb b/Pilz.Configuration/ISettingsManager.vb new file mode 100644 index 0000000..7be6f54 --- /dev/null +++ b/Pilz.Configuration/ISettingsManager.vb @@ -0,0 +1,6 @@ +Public Interface ISettingsManager + Property ConfigFilePath As String + Sub Save() + Sub Load() + Sub Reset() +End Interface \ No newline at end of file diff --git a/Pilz.Configuration/My Project/Application.Designer.vb b/Pilz.Configuration/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Pilz.Configuration/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Configuration/My Project/Application.myapp b/Pilz.Configuration/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.Configuration/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.Configuration/My Project/AssemblyInfo.vb b/Pilz.Configuration/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..d92aa5f --- /dev/null +++ b/Pilz.Configuration/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Configuration/My Project/Resources.Designer.vb b/Pilz.Configuration/My Project/Resources.Designer.vb new file mode 100644 index 0000000..9c23f4c --- /dev/null +++ b/Pilz.Configuration/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Configuration.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Configuration/My Project/Resources.resx b/Pilz.Configuration/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Configuration/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Configuration/My Project/Settings.Designer.vb b/Pilz.Configuration/My Project/Settings.Designer.vb new file mode 100644 index 0000000..1470709 --- /dev/null +++ b/Pilz.Configuration/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Configuration.My.MySettings + Get + Return Global.Pilz.Configuration.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Configuration/My Project/Settings.settings b/Pilz.Configuration/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Configuration/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Configuration/Pilz.Configuration.vbproj b/Pilz.Configuration/Pilz.Configuration.vbproj new file mode 100644 index 0000000..6d1c540 --- /dev/null +++ b/Pilz.Configuration/Pilz.Configuration.vbproj @@ -0,0 +1,111 @@ + + + + + Debug + AnyCPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC} + Library + Pilz.Configuration + Pilz.Configuration + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.Configuration.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.Configuration.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Pilz.Configuration/SettingsBase.vb b/Pilz.Configuration/SettingsBase.vb new file mode 100644 index 0000000..2f2ee29 --- /dev/null +++ b/Pilz.Configuration/SettingsBase.vb @@ -0,0 +1,20 @@ +Imports Newtonsoft.Json + +Public MustInherit Class SettingsBase + + Public Sub New() + ResetValues() + End Sub + + + Friend _settingsManager As ISettingsManager + + Public ReadOnly Property SettingsManager As ISettingsManager + Get + Return _settingsManager + End Get + End Property + + Public MustOverride Sub ResetValues() + +End Class diff --git a/Pilz.Configuration/SettingsManager.vb b/Pilz.Configuration/SettingsManager.vb new file mode 100644 index 0000000..6649651 --- /dev/null +++ b/Pilz.Configuration/SettingsManager.vb @@ -0,0 +1,110 @@ +Imports System.IO +Imports System.Reflection +Imports Newtonsoft.Json.Linq + +Public NotInheritable Class SettingsManager(Of T As SettingsBase) + Implements ISettingsManager + + Private defaultInstance As T = Nothing + Private enableAutoSave As Boolean = False + Private addedHandler As Boolean = False + + Public Property ConfigFilePath As String Implements ISettingsManager.ConfigFilePath + + Public Property AutoSaveOnExit As Boolean + Get + Return enableAutoSave + End Get + Set + If enableAutoSave <> Value Then + enableAutoSave = Value + Select Case enableAutoSave + Case True + If Not addedHandler Then + AddAutoSaveHandler() + End If + Case False + If addedHandler Then + RemoveAutoSaveHandler() + End If + End Select + End If + End Set + End Property + + Private Sub AddAutoSaveHandler() + AddHandler Windows.Forms.Application.ApplicationExit, AddressOf AutoSaveSettingsOnExit + addedHandler = True + End Sub + Private Sub RemoveAutoSaveHandler() + RemoveHandler Windows.Forms.Application.ApplicationExit, AddressOf AutoSaveSettingsOnExit + addedHandler = False + End Sub + + Public ReadOnly Property Instance As T + Get + If defaultInstance Is Nothing Then + Load() + End If + Return defaultInstance + End Get + End Property + + Public Sub New() + ConfigFilePath = "" + AutoSaveOnExit = False + End Sub + Public Sub New(fileName As String, autoSaveOnExit As Boolean) + ConfigFilePath = fileName + Me.AutoSaveOnExit = autoSaveOnExit + End Sub + + Private Sub AutoSaveSettingsOnExit(sender As Object, e As EventArgs) + Save() + End Sub + + Public Sub Save() Implements ISettingsManager.Save + If Not String.IsNullOrEmpty(ConfigFilePath) AndAlso defaultInstance IsNot Nothing Then + SavePrivate() + End If + End Sub + + Public Sub Load() Implements ISettingsManager.Load + If Not String.IsNullOrEmpty(ConfigFilePath) AndAlso File.Exists(ConfigFilePath) Then + LoadPrivate() + Else + CreateNewInstance() + End If + + If defaultInstance IsNot Nothing Then + defaultInstance._settingsManager = Me + End If + End Sub + + Public Sub Reset() Implements ISettingsManager.Reset + Instance.ResetValues() + End Sub + + Private Sub CreateNewInstance() + Dim ctor As ConstructorInfo = GetType(T).GetConstructor({}) + If ctor IsNot Nothing Then + defaultInstance = ctor.Invoke({}) + + defaultInstance.ResetValues() + Else + Throw New Exception("The base type has no constructor with no parameters.") + End If + End Sub + + Private Sub LoadPrivate() + defaultInstance = JObject.Parse(File.ReadAllText(ConfigFilePath)).ToObject(Of T) + End Sub + + Private Sub SavePrivate() + Dim obj As JObject = JObject.FromObject(defaultInstance) + If obj IsNot Nothing Then + File.WriteAllText(ConfigFilePath, obj.ToString) + End If + End Sub + +End Class \ No newline at end of file diff --git a/Pilz.Configuration/packages.config b/Pilz.Configuration/packages.config new file mode 100644 index 0000000..7f83af3 --- /dev/null +++ b/Pilz.Configuration/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Pilz.Cryptography/My Project/Application.Designer.vb b/Pilz.Cryptography/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Pilz.Cryptography/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Cryptography/My Project/Application.myapp b/Pilz.Cryptography/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.Cryptography/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.Cryptography/My Project/AssemblyInfo.vb b/Pilz.Cryptography/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..0eae44b --- /dev/null +++ b/Pilz.Cryptography/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Cryptography/My Project/Resources.Designer.vb b/Pilz.Cryptography/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1309395 --- /dev/null +++ b/Pilz.Cryptography/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Cryptography.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Cryptography/My Project/Resources.resx b/Pilz.Cryptography/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Cryptography/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Cryptography/My Project/Settings.Designer.vb b/Pilz.Cryptography/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0a6103e --- /dev/null +++ b/Pilz.Cryptography/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Cryptography.My.MySettings + Get + Return Global.Pilz.Cryptography.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Cryptography/My Project/Settings.settings b/Pilz.Cryptography/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Cryptography/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Cryptography/Pilz.Cryptography.vbproj b/Pilz.Cryptography/Pilz.Cryptography.vbproj new file mode 100644 index 0000000..bc64c81 --- /dev/null +++ b/Pilz.Cryptography/Pilz.Cryptography.vbproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4} + Library + Pilz.Cryptography + Pilz.Cryptography + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.Cryptography.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.Cryptography.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/Pilz.Drawing/BitmapExtensions.vb b/Pilz.Drawing/BitmapExtensions.vb new file mode 100644 index 0000000..afe580f --- /dev/null +++ b/Pilz.Drawing/BitmapExtensions.vb @@ -0,0 +1,20 @@ +Imports System.Drawing +Imports System.Runtime.CompilerServices + +Public Module BitmapExtensions + + + Public Sub InvertColors(bmp As Bitmap) + For y As Integer = 0 To bmp.Height - 1 + For x As Integer = 0 To bmp.Width - 1 + Dim inv As Color = bmp.GetPixel(x, y) + inv = Color.FromArgb(inv.A, + Byte.MaxValue - inv.R, + Byte.MaxValue - inv.G, + Byte.MaxValue - inv.B) + bmp.SetPixel(x, y, inv) + Next + Next + End Sub + +End Module diff --git a/Pilz.Drawing/HelpfulDrawingFunctions.vb b/Pilz.Drawing/HelpfulDrawingFunctions.vb new file mode 100644 index 0000000..b7d74d3 --- /dev/null +++ b/Pilz.Drawing/HelpfulDrawingFunctions.vb @@ -0,0 +1,41 @@ +Imports System.Drawing +Imports System.Drawing.Drawing2D + +Public Class HelpfulDrawingFunctions + + Public Shared Function IsPointInRectangle(p As PointF, rect As RectangleF) As Boolean + Dim bList As New List(Of Boolean) + + bList.Add(p.X > rect.Left) + bList.Add(p.X < rect.Right) + bList.Add(p.Y > rect.Top) + bList.Add(p.Y < rect.Bottom) + + Return Not bList.Contains(False) + End Function + + Public Shared Function OverlapsTwoRectangles(a As RectangleF, b As RectangleF) As Boolean + Return a.IntersectsWith(b) 'RectangleF.Intersect(a, b) <> RectangleF.Empty + End Function + + Public Shared Function GetRectangle(p1 As PointF, p2 As PointF) As RectangleF + Dim rect As New RectangleF + Dim startIsEnd As Boolean = p1.X > p2.X AndAlso p1.Y > p2.Y + + Dim xValues() As Integer = {p1.X, p2.X} + Dim yValues() As Integer = {p1.Y, p2.Y} + + rect.Location = New PointF(xValues.OrderBy(Function(n) n).First, + yValues.OrderBy(Function(n) n).First) + + rect.Size = New SizeF(xValues.OrderByDescending(Function(n) n).First, + yValues.OrderByDescending(Function(n) n).First) + + rect.Size = New SizeF(rect.Size.Width - rect.Location.X, + rect.Size.Height - rect.Location.Y) + + Return rect + End Function + +End Class + diff --git a/Pilz.Drawing/My Project/Application.Designer.vb b/Pilz.Drawing/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Pilz.Drawing/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Drawing/My Project/Application.myapp b/Pilz.Drawing/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.Drawing/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.Drawing/My Project/AssemblyInfo.vb b/Pilz.Drawing/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..c0a2a4b --- /dev/null +++ b/Pilz.Drawing/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Drawing/My Project/Resources.Designer.vb b/Pilz.Drawing/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e4895af --- /dev/null +++ b/Pilz.Drawing/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Drawing.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Drawing/My Project/Resources.resx b/Pilz.Drawing/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Drawing/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Drawing/My Project/Settings.Designer.vb b/Pilz.Drawing/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d79ad0b --- /dev/null +++ b/Pilz.Drawing/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Drawing.My.MySettings + Get + Return Global.Pilz.Drawing.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Drawing/My Project/Settings.settings b/Pilz.Drawing/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Drawing/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Drawing/Pilz.Drawing.vbproj b/Pilz.Drawing/Pilz.Drawing.vbproj new file mode 100644 index 0000000..a7b8251 --- /dev/null +++ b/Pilz.Drawing/Pilz.Drawing.vbproj @@ -0,0 +1,107 @@ + + + + + Debug + AnyCPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6} + Library + Pilz.Drawing + Pilz.Drawing + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.Drawing.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.Drawing.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/Pilz.Drawing/PointD.vb b/Pilz.Drawing/PointD.vb new file mode 100644 index 0000000..f37d80f --- /dev/null +++ b/Pilz.Drawing/PointD.vb @@ -0,0 +1,31 @@ +Public Class PointD + + Public Property X As Double + Public Property Y As Double + + Public Sub New() + X = 0 + Y = 0 + End Sub + + Public Sub New(x As Double, y As Double) + Me.X = x + Me.Y = y + End Sub + + Public Shared ReadOnly Property Empty As PointD + Get + Return New PointD + End Get + End Property + + Public Shared Operator =(val1 As PointD, val2 As PointD) As Boolean + Return val1.X = val2.X AndAlso val1.Y = val2.Y + End Operator + + Public Shared Operator <>(val1 As PointD, val2 As PointD) As Boolean + Return val1.X <> val2.X OrElse val1.Y <> val2.Y + End Operator + + +End Class diff --git a/Pilz.IO/EventArgs/DataEventargs.vb b/Pilz.IO/EventArgs/DataEventargs.vb new file mode 100644 index 0000000..83073f9 --- /dev/null +++ b/Pilz.IO/EventArgs/DataEventargs.vb @@ -0,0 +1,10 @@ +Public Class DataEventArgs : Inherits EventArgs + + Public ReadOnly Data As Byte() + + Public Sub New(bytes As Byte()) + MyBase.New() + Data = bytes + End Sub + +End Class diff --git a/Pilz.IO/ManagedPipes/ManagedPipe.vb b/Pilz.IO/ManagedPipes/ManagedPipe.vb new file mode 100644 index 0000000..ff64541 --- /dev/null +++ b/Pilz.IO/ManagedPipes/ManagedPipe.vb @@ -0,0 +1,53 @@ +''' +''' stellt den Erben "Server" und "Client" 2 verschiedene +''' Message-Events zur Verfügung, und ein Event-Raisendes Dispose +''' +Public MustInherit Class ManagedPipe : Implements IDisposable + + Public Delegate Sub EventHandlerWithOneArgument(Of T0)(Sender As T0) + + ''' + ''' Zur Ausgabe chat-verwaltungstechnischer Status-Informationen + ''' + Public Event StatusMessage As EventHandler(Of DataEventArgs) + ''' Zur Ausgabe von Chat-Messages + Public Event RetriveData As EventHandler(Of DataEventArgs) + Public Event Disposed As EventHandlerWithOneArgument(Of ManagedPipe) + + Private _IsDisposed As Boolean = False + + Protected MustOverride Sub Dispose(disposing As Boolean) + Public MustOverride Sub Send(bytes As Byte()) + Public MustOverride Function SendAsnyc(bytes As Byte()) As Task + + Protected Sub OnStatusMessage(ByVal e As DataEventArgs) + RaiseEvent StatusMessage(Me, e) + End Sub + + Protected Sub OnRetriveData(ByVal e As DataEventArgs) + RaiseEvent RetriveData(Me, e) + End Sub + + Public Sub RemoveFrom(Of T As ManagedPipe)(ByVal Coll As ICollection(Of T)) + Coll.Remove(DirectCast(Me, T)) + End Sub + + Public ReadOnly Property IsDisposed() As Boolean + Get + Return _IsDisposed + End Get + End Property + + Public Sub AddTo(Of T As ManagedPipe)(ByVal Coll As ICollection(Of T)) + Coll.Add(Me) + End Sub + + Public Sub Dispose() Implements IDisposable.Dispose + If _IsDisposed Then Return + _IsDisposed = True + Dispose(True) ' rufe die erzwungenen Überschreibungen von Sub Dispose(Boolean) + RaiseEvent Disposed(Me) + GC.SuppressFinalize(Me) + End Sub + +End Class diff --git a/Pilz.IO/ManagedPipes/ManagedPipeClient.vb b/Pilz.IO/ManagedPipes/ManagedPipeClient.vb new file mode 100644 index 0000000..d0ef505 --- /dev/null +++ b/Pilz.IO/ManagedPipes/ManagedPipeClient.vb @@ -0,0 +1,91 @@ +Imports System.Net +Imports System.Text +Imports System.IO.Pipes +Imports Pilz.Threading + +Public Class ManagedPipeClient : Inherits ManagedPipe + + Private pipeStream As PipeStream + Private _Buf(&H400 - 1) As Byte + + Public Property RaiseEventsGui As Boolean = True + + Public Sub New(pipeName As String) + Me.New(pipeName, ".") + End Sub + + Public Sub New(pipeName As String, serverName As String) + Me.New(pipeName, serverName, -1) + End Sub + + Public Sub New(pipeName As String, connectionTimeout As Integer) + Me.New(pipeName, ".", connectionTimeout) + End Sub + + Public Sub New(pipeName As String, serverName As String, connectionTimeout As Integer) + Dim clnt As New NamedPipeClientStream(serverName, pipeName, PipeDirection.InOut, PipeOptions.Asynchronous) + clnt.Connect(connectionTimeout) + If Not clnt.IsConnected Then + Throw New TimeoutException("Connection timeout!") + End If + SetPipe(clnt) + End Sub + + Public Sub New(pipe As PipeStream) + SetPipe(pipe) + End Sub + + Private Sub SetPipe(pipe As PipeStream) + pipeStream = pipe + pipeStream.BeginRead(_Buf, 0, _Buf.Length, AddressOf EndRead, Nothing) + End Sub + + Private Sub EndRead(ar As IAsyncResult) + If IsDisposed Then Return + + Dim bytesCount As Integer = pipeStream.EndRead(ar) + If bytesCount = 0 Then 'leere Datenübermittlung signalisiert Verbindungsabbruch + If RaiseEventsGui Then + CrossThreadsInvokeing.RunGui(AddressOf Dispose) + Else + Dispose() + End If + Return + End If + + Dim list As New List(Of Byte) + + For i As Integer = 0 To bytesCount - 1 + list.Add(_Buf(i)) + Next + + Do While bytesCount = _Buf.Length + bytesCount = pipeStream.Read(_Buf, 0, _Buf.Length) + For i As Integer = 0 To bytesCount - 1 + list.Add(_Buf(i)) + Next + Loop + + Dim deargs As New DataEventArgs(list.ToArray) + If RaiseEventsGui Then + CrossThreadsInvokeing.RunGui(AddressOf OnRetriveData, deargs) + Else + OnRetriveData(deargs) + End If + + pipeStream.BeginRead(_Buf, 0, _Buf.Length, AddressOf EndRead, Nothing) + End Sub + + Public Overrides Function SendAsnyc(bytes() As Byte) As Task + Return Task.Run(Sub() Send(bytes)) + End Function + + Public Overrides Sub Send(data As Byte()) + pipeStream.Write(data, 0, data.Length) + End Sub + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + pipeStream.Dispose() + End Sub + +End Class diff --git a/Pilz.IO/ManagedPipes/ManagedPipeServer.vb b/Pilz.IO/ManagedPipes/ManagedPipeServer.vb new file mode 100644 index 0000000..9d50580 --- /dev/null +++ b/Pilz.IO/ManagedPipes/ManagedPipeServer.vb @@ -0,0 +1,104 @@ +Imports System.Net +Imports System.IO.Pipes +Imports Pilz.Threading + +Public Class ManagedPipeServer : Inherits ManagedPipe + + 'Pro Verbindung(sanfrage) wird ein Client-Objekt generiert, das den Datenaustausch dieser Verbindung abwickelt + Private _Clients As New List(Of ManagedPipeClient) + Private ReadOnly pipeName As String = "" + Private ReadOnly maxNumbersOfServerInstances As Integer + Private numberOfStartedServerInstances As Integer = 0 + + Public Sub New(ByVal pipeName As String) + Me.New(pipeName, 1) + End Sub + + Public Sub New(pipeName As String, maxNumbersOfServerInstances As Integer) + Me.pipeName = pipeName + Me.maxNumbersOfServerInstances = maxNumbersOfServerInstances + CreateWaitingStream() + End Sub + + Private Sub CreateWaitingStream() + If numberOfStartedServerInstances < maxNumbersOfServerInstances Then + Dim strm = New NamedPipeServerStream(pipeName, PipeDirection.InOut, maxNumbersOfServerInstances, PipeTransmissionMode.Byte, PipeOptions.Asynchronous) + numberOfStartedServerInstances += 1 + strm.BeginWaitForConnection(AddressOf EndAccept, strm) + Console.WriteLine("Start Waiting for new Connection ...") + End If + End Sub + + Private Sub EndAccept(ByVal ar As IAsyncResult) + Dim strm = DirectCast(ar.AsyncState, NamedPipeServerStream) + + strm.EndWaitForConnection(ar) + + If IsDisposed Then + strm.Dispose() + Return + End If + + With New ManagedPipeClient(strm) + AddHandler .RetriveData, AddressOf Client_RetriveData + AddHandler .StatusMessage, AddressOf Client_StatusMessage + AddHandler .Disposed, AddressOf Client_Disposed + .AddTo(_Clients) + End With + + Console.WriteLine("Client accepted!") + + CreateWaitingStream() + End Sub + +#Region "_Clients-Ereignisverarbeitung" + + Private Sub Client_Disposed(ByVal Sender As ManagedPipe) + 'den Client für die beendete Verbindung entfernen + Sender.RemoveFrom(_Clients) + numberOfStartedServerInstances -= 1 + CreateWaitingStream() + End Sub + + Private Sub Client_RetriveData(ByVal sender As Object, ByVal e As DataEventArgs) + 'einkommende ChatMessages anzeigen, und an alle versenden + OnRetriveData(e) + End Sub + + Private Sub Client_StatusMessage(ByVal sender As Object, ByVal e As DataEventArgs) + 'einkommende StatusMessages durchreichen (zur Anzeige) + OnStatusMessage(e) + End Sub + +#End Region '_Clients-Ereignisverarbeitung + + Public Overrides Function SendAsnyc(bytes() As Byte) As Task + Return Task.Run(Sub() Send(bytes)) + End Function + + Public Overrides Sub Send(data As Byte()) + Console.WriteLine("Sending Data ...") + + 'OnRetriveData(New DataEventargs(data)) ' anzeigen + + For Each client As ManagedPipeClient In _Clients ' an alle versenden + client.Send(data) + Next + + Console.WriteLine("Data send!") + End Sub + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + If numberOfStartedServerInstances < maxNumbersOfServerInstances Then + Using clnt As New NamedPipeClientStream(pipeName) + 'Herstellen einer Dummi-Verbindung, damit der ServerStream aus dem Wartezustand herauskommt. + clnt.Connect() + End Using + End If + + For i As Integer = _Clients.Count - 1 To 0 Step -1 + _Clients(i).Dispose() + Next + End Sub + +End Class diff --git a/Pilz.IO/My Project/Application.Designer.vb b/Pilz.IO/My Project/Application.Designer.vb new file mode 100644 index 0000000..8ab460b --- /dev/null +++ b/Pilz.IO/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.IO/My Project/Application.myapp b/Pilz.IO/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.IO/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.IO/My Project/AssemblyInfo.vb b/Pilz.IO/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ed26f17 --- /dev/null +++ b/Pilz.IO/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.IO/My Project/Resources.Designer.vb b/Pilz.IO/My Project/Resources.Designer.vb new file mode 100644 index 0000000..1d554f0 --- /dev/null +++ b/Pilz.IO/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.IO.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.IO/My Project/Resources.resx b/Pilz.IO/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.IO/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.IO/My Project/Settings.Designer.vb b/Pilz.IO/My Project/Settings.Designer.vb new file mode 100644 index 0000000..784f9bc --- /dev/null +++ b/Pilz.IO/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.IO.My.MySettings + Get + Return Global.Pilz.IO.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.IO/My Project/Settings.settings b/Pilz.IO/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.IO/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.IO/Pilz.IO.vbproj b/Pilz.IO/Pilz.IO.vbproj new file mode 100644 index 0000000..d70fe2d --- /dev/null +++ b/Pilz.IO/Pilz.IO.vbproj @@ -0,0 +1,135 @@ + + + + + Debug + AnyCPU + {35591965-8339-41A2-8CD3-962ED54670AC} + Library + Pilz.IO + Pilz.IO + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.IO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.IO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x86\Debug\ + Pilz.IO.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + full + x86 + MinimumRecommendedRules.ruleset + true + + + true + bin\x86\Release\ + Pilz.IO.xml + true + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + pdbonly + x86 + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + {d9c8655e-4f1c-4348-a51c-ab00fd9a14bb} + CrossThreads + + + + \ No newline at end of file diff --git a/Pilz.Reflection.PluginSystem/Attributes/FuncWithCodeMethodAttribute.vb b/Pilz.Reflection.PluginSystem/Attributes/FuncWithCodeMethodAttribute.vb new file mode 100644 index 0000000..e3b1c1e --- /dev/null +++ b/Pilz.Reflection.PluginSystem/Attributes/FuncWithCodeMethodAttribute.vb @@ -0,0 +1,19 @@ +Namespace Attributes + + Public Class PluginFunctionAttribute + Inherits Attribute + + Public ReadOnly Property FunctionCode As String + Public ReadOnly Property Params As Object() + + ''' + ''' The function code for this PluginFunction. + ''' The parameters for this PluginFunction. + Public Sub New(funcCode As String, ParamArray params As Object()) + Me.FunctionCode = funcCode + Me.Params = params + End Sub + + End Class + +End Namespace diff --git a/Pilz.Reflection.PluginSystem/Attributes/LoadMethodAttribute.vb b/Pilz.Reflection.PluginSystem/Attributes/LoadMethodAttribute.vb new file mode 100644 index 0000000..d898afc --- /dev/null +++ b/Pilz.Reflection.PluginSystem/Attributes/LoadMethodAttribute.vb @@ -0,0 +1,7 @@ +Namespace Attributes + + Public Class LoadMethodAttribute + Inherits Attribute + End Class + +End Namespace diff --git a/Pilz.Reflection.PluginSystem/My Project/Application.Designer.vb b/Pilz.Reflection.PluginSystem/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Reflection.PluginSystem/My Project/Application.myapp b/Pilz.Reflection.PluginSystem/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.Reflection.PluginSystem/My Project/AssemblyInfo.vb b/Pilz.Reflection.PluginSystem/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..6cc80cf --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Reflection.PluginSystem/My Project/Resources.Designer.vb b/Pilz.Reflection.PluginSystem/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a3fab67 --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Reflection.PluginSystem.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Reflection.PluginSystem/My Project/Resources.resx b/Pilz.Reflection.PluginSystem/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Reflection.PluginSystem/My Project/Settings.Designer.vb b/Pilz.Reflection.PluginSystem/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6cda84d --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Reflection.PluginSystem.My.MySettings + Get + Return Global.Pilz.Reflection.PluginSystem.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Reflection.PluginSystem/My Project/Settings.settings b/Pilz.Reflection.PluginSystem/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Reflection.PluginSystem/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Reflection.PluginSystem/Pilz.Reflection.PluginSystem.vbproj b/Pilz.Reflection.PluginSystem/Pilz.Reflection.PluginSystem.vbproj new file mode 100644 index 0000000..b07f49c --- /dev/null +++ b/Pilz.Reflection.PluginSystem/Pilz.Reflection.PluginSystem.vbproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7} + Library + Pilz.Reflection.PluginSystem + Pilz.Reflection.PluginSystem + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.Reflection.PluginSystem.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.Reflection.PluginSystem.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/Pilz.Reflection.PluginSystem/Plugin.vb b/Pilz.Reflection.PluginSystem/Plugin.vb new file mode 100644 index 0000000..c978598 --- /dev/null +++ b/Pilz.Reflection.PluginSystem/Plugin.vb @@ -0,0 +1,118 @@ +Imports System.IO +Imports System.Reflection +Imports Pilz.Reflection.PluginSystem.Attributes + +Public Class Plugin + + ''' + ''' A collection of Methods that contains PluginFunctions that will be called automatically when loading the Plugin, as long as the property AutoCallMainFunctions is set to True. + ''' + ''' + Public ReadOnly Property MainFunctions As IReadOnlyList(Of PluginFunction) + + ''' + ''' A collection of Methods with a FunctionCode (excluding all PluginFunctions from MainFunctions). + ''' + ''' + Public ReadOnly Property PluginFunctions As IReadOnlyList(Of PluginFunction) + + ''' + ''' Load a new Plugin and its PluginFunctions. + ''' + ''' + ''' If true, all MainMethods of a Plugin will be called as soon as a Plugin is loaded. + ''' The name of the type where to search for Methods when loading a new Plugin. + Public Sub New(filePath As String, autoCallMainFunction As Boolean, entryTypeName As String) + Dim asm As Assembly = Assembly.LoadFile(filePath) + Dim modul As Type = asm.GetType(entryTypeName) + + If modul Is Nothing Then + Throw New PluginLoadException("Plugin Modul not found!") + End If + + 'Define the attribute types to observe + Dim entryMethodType As Type = GetType(LoadMethodAttribute) + Dim implementMethodType As Type = GetType(PluginFunctionAttribute) + + 'Create the lists + Dim mainMethods As New List(Of PluginFunction) + Dim implementMethods As New List(Of PluginFunction) + + 'Search for PluginFunctions + For Each mi As MethodInfo In modul.GetMethods + Dim found As Boolean = False + + 'Check if the method has one of the defined attributes + For Each attr As Attribute In Attribute.GetCustomAttributes(mi) + If Not found Then + Dim t As Type = attr.GetType + + Select Case t + Case entryMethodType + mainMethods.Add(New PluginFunction(mi, Me)) + + Case implementMethodType + With CType(attr, PluginFunctionAttribute) + implementMethods.Add(New PluginFunction(mi, Me, .Params, .FunctionCode)) + End With + + End Select + + found = True + End If + Next + Next + + 'Set the collections + Me.MainFunctions = mainMethods + Me.PluginFunctions = implementMethods + + 'Call all PluginFunctions in MainFunctions + If autoCallMainFunction Then + For Each func As PluginFunction In mainMethods + Dim params As ParameterInfo() = func.Method.GetParameters + If params.Length = 1 Then + Dim startupExe As String = Assembly.GetEntryAssembly.Location + Dim args As String() = {startupExe, filePath} + func.Invoke({args}) + ElseIf Not params.Any Then + func.Invoke() + End If + Next + End If + End Sub + + ''' + ''' Get all PluginFunctions that have one of the given function codes. + ''' + ''' + ''' + Public Function GetFunctions(ParamArray funcCodes As String()) As IEnumerable(Of PluginFunction) + Dim funcs As New List(Of PluginFunction) + + For Each func As PluginFunction In PluginFunctions + If funcCodes.Contains(func.FunctionCode) Then + funcs.Add(func) + End If + Next + + Return funcs + End Function + + ''' + ''' Get the first PluginFunction that have the one of the given function codes. + ''' + ''' + Public Function GetFunction(ParamArray funcCodes As String()) As PluginFunction + Dim f As PluginFunction = Nothing + + For Each func As PluginFunction In PluginFunctions + If f Is Nothing AndAlso funcCodes.Contains(func.FunctionCode) Then + f = func + End If + Next + + Return f + End Function + +End Class diff --git a/Pilz.Reflection.PluginSystem/PluginFunction.vb b/Pilz.Reflection.PluginSystem/PluginFunction.vb new file mode 100644 index 0000000..28c0b3f --- /dev/null +++ b/Pilz.Reflection.PluginSystem/PluginFunction.vb @@ -0,0 +1,73 @@ +Imports System.Reflection + +Public Class PluginFunction + + ''' + ''' Gets the method to invoke when invoking this PluginFunction. + ''' + ''' + Public ReadOnly Property Method As MethodInfo + + ''' + ''' Gets the refered Plugin for this PluginFunction, if it has one. + ''' + ''' + Public ReadOnly Property Plugin As Plugin + + ''' + ''' Gets the Parameters that was given by the attribute. + ''' + ''' + Public ReadOnly Property Params As Object() + + ''' + ''' Gets the function code for this PluginFunction. + ''' + ''' + Public ReadOnly Property FunctionCode As String + + ''' + ''' Creates a new instance of a PluginFunction. + ''' + ''' The Method to invoke when invoking this PluginFunction. + ''' The Plugin that is the Parent of this PluginFunction. This value can be NULL. + Public Sub New(method As MethodInfo, plugin As Plugin) + Me.Method = method + Me.Plugin = plugin + End Sub + + ''' + ''' Creates a new instance of a PluginFunction. + ''' + ''' The Method to invoke when invoking this PluginFunction.. + ''' The Plugin that is the Parent of this PluginFunction. This value can be NULL. + ''' The Parameters that was given by the attribute. + ''' The function code for this PluginFunction. + Public Sub New(method As MethodInfo, plugin As Plugin, params As Object(), funcCode As String) + Me.New(method, plugin) + Me.Params = params + Me.FunctionCode = funcCode + End Sub + + ''' + ''' Invokes the Method of the PluginFunction. + ''' + Public Sub Invoke() + Method.Invoke(Nothing, Nothing) + End Sub + + ''' + ''' Invokes the Method of the PluginFunction. + ''' + Public Sub Invoke(ParamArray params As Object()) + Method.Invoke(Nothing, params) + End Sub + + ''' + ''' Invokes the Method of the PluginFunction and returns the return value. + ''' + Public Function InvokeGet(ParamArray params As Object()) As Object + Return Method.Invoke(Nothing, params) + End Function + +End Class diff --git a/Pilz.Reflection.PluginSystem/PluginLoadException.vb b/Pilz.Reflection.PluginSystem/PluginLoadException.vb new file mode 100644 index 0000000..fef7f10 --- /dev/null +++ b/Pilz.Reflection.PluginSystem/PluginLoadException.vb @@ -0,0 +1,11 @@ +Public Class PluginLoadException + Inherits Exception + + Public Sub New() + MyBase.New + End Sub + + Public Sub New(message As String) + MyBase.New(message) + End Sub +End Class diff --git a/Pilz.Reflection.PluginSystem/PluginManager.vb b/Pilz.Reflection.PluginSystem/PluginManager.vb new file mode 100644 index 0000000..c7acaa8 --- /dev/null +++ b/Pilz.Reflection.PluginSystem/PluginManager.vb @@ -0,0 +1,129 @@ +Imports System.IO + +Public Class PluginManager + + ''' + ''' The name of the type where to search for Methods when loading a new Plugin. + ''' + ''' + Public Property EntryTypeName As String = "Plugin" + + ''' + ''' If true, all MainMethods of a Plugin will be called as soon as a Plugin is loaded. + ''' + ''' + Public Property AutoCallMainFunctions As Boolean = True + + ''' + ''' A collection of all loaded Plugins. + ''' + ''' + Public ReadOnly Property Plugins As New Dictionary(Of String, Plugin) + + ''' + ''' Loads Plugins that can be found at the given path and adds them to the Plugins-List. + ''' + ''' The path where to search for Plugins to load. + Public Function LoadPlugins(pluginPath As String) As IEnumerable(Of Plugin) + Return LoadPlugins(pluginPath, True) + End Function + + ''' + ''' Loads Plugins that can be found at the given path and adds them to the Plugins-List. + ''' + ''' The path where to search for Plugins to load. + ''' If true, the Plugins will be added to Plugins-List after loading. + Public Function LoadPlugins(pluginPath As String, addToList As Boolean) As IEnumerable(Of Plugin) + Return LoadPlugins(pluginPath, addToList, AutoCallMainFunctions, EntryTypeName) + End Function + + ''' + ''' Loads Plugins that can be found at the given path and adds them to the Plugins-List. + ''' + ''' The path where to search for Plugins to load. + ''' If true, the Plugins will be added to Plugins-List after loading. + ''' If true, all MainMethods of a Plugin will be called as soon as a Plugin is loaded. + ''' The name of the type where to search for Methods when loading a new Plugin. + Public Function LoadPlugins(pluginPath As String, addToList As Boolean, autoCallMainFunction As Boolean, entryTypeName As String) As IEnumerable(Of Plugin) + Dim loaded As New List(Of Plugin) + + For Each f As String In Directory.GetFiles(pluginPath, "*.dll", SearchOption.AllDirectories) + Dim p As Plugin = LoadPlugin(f, addToList) + If p IsNot Nothing Then + loaded.Add(p) + End If + Next + + Return loaded + End Function + + ''' + ''' Loads a Plugin and adds it to the Plugins-List. + ''' + ''' The path to the plugin to load. + ''' If true, the Plugin will be added to Plugins-List after loading. + Public Function LoadPlugin(filePath As String, addToList As Boolean) As Plugin + Return LoadPlugin(filePath, addToList, AutoCallMainFunctions, EntryTypeName) + End Function + + ''' + ''' Loads a Plugin and adds it to the Plugins-List. + ''' + ''' The path to the plugin to load. + ''' If true, the Plugin will be added to Plugins-List after loading. + ''' If true, all MainMethods of a Plugin will be called as soon as a Plugin is loaded. + ''' The name of the type where to search for Methods when loading a new Plugin. + Public Function LoadPlugin(filePath As String, addToList As Boolean, autoCallMainFunction As Boolean, entryTypeName As String) As Plugin + Try + Dim plugin As New Plugin(filePath, autoCallMainFunction, entryTypeName) + If addToList Then Plugins.Add(filePath, plugin) + Return plugin + Catch ex As Exception + Return Nothing + End Try + End Function + + ''' + ''' Loads a Plugin and adds it to the Plugins-List. + ''' + ''' The path to the plugin to load. + Public Function LoadPlugin(filePath As String) As Plugin + Return LoadPlugin(filePath, True) + End Function + + ''' + ''' Get all PluginFunctions that have one of the given function codes. + ''' + ''' + ''' + Public Function GetFunctions(ParamArray funcCodes As String()) As IEnumerable(Of PluginFunction) + Dim list As New List(Of PluginFunction) + + For Each kvp In Plugins + list.AddRange(kvp.Value.GetFunctions(funcCodes)) + Next + + Return list + End Function + + ''' + ''' Get the first PluginFunction that have the one of the given function codes. + ''' + ''' + Public Function GetFunction(ParamArray funcCodes As String()) As PluginFunction + Dim f As PluginFunction = Nothing + + For Each kvp In Plugins + If f Is Nothing Then + For Each func As PluginFunction In kvp.Value.GetFunctions(funcCodes) + If f Is Nothing Then + f = func + End If + Next + End If + Next + + Return f + End Function + +End Class diff --git a/Pilz.Threading/CrossThreadsInvokeing.vb b/Pilz.Threading/CrossThreadsInvokeing.vb new file mode 100644 index 0000000..a37f0ae --- /dev/null +++ b/Pilz.Threading/CrossThreadsInvokeing.vb @@ -0,0 +1,65 @@ +'IDE-Voreinstellungen: +'Option Explicit On +'Option Strict On + +'"My Project"-Einstellungen: +'Imports Microsoft.VisualBasic.ControlChars +'Imports System.Windows.Forms +'Imports System + +Imports System.Windows.Forms + +''' +''' Stellt Methoden bereit, mit denen ein beliebiger Methoden-Aufruf mit bis zu 3 Argumenten +''' in einen Nebenthread verlegt werden kann, bzw. aus einem Nebenthread in den Hauptthread +''' +Public Class CrossThreadsInvokeing + + Public Shared Sub RunAsync(Of T1, T2, T3)(ByVal Action As Action(Of T1, T2, T3), ByVal Arg1 As T1, ByVal Arg2 As T2, ByVal Arg3 As T3) + ' Aufruf von Action.EndInvoke() gewährleisten, indem er als Callback-Argument mitgegeben wird + Action.BeginInvoke(Arg1, Arg2, Arg3, AddressOf Action.EndInvoke, Nothing) + End Sub + Public Shared Sub RunAsync(Of T1, T2)(ByVal Action As Action(Of T1, T2), ByVal Arg1 As T1, ByVal Arg2 As T2) + Action.BeginInvoke(Arg1, Arg2, AddressOf Action.EndInvoke, Nothing) + End Sub + Public Shared Sub RunAsync(Of T1)(ByVal Action As Action(Of T1), ByVal Arg1 As T1) + Action.BeginInvoke(Arg1, AddressOf Action.EndInvoke, Nothing) + End Sub + Public Shared Sub RunAsync(ByVal Action As Action) + Action.BeginInvoke(AddressOf Action.EndInvoke, Nothing) + End Sub + + Private Shared Function GuiCrossInvoke(ByVal Action As [Delegate], ByVal ParamArray Args() As Object) As Boolean + Dim frms As FormCollection = Application.OpenForms + + 'If frms.Count = 0 Then + ' 'wenn kein Form mehr da ist, so tun, als ob das Invoking ausgeführt wäre + ' Return True + 'ElseIf frms(0).InvokeRequired Then + 'frms(0).BeginInvoke(Action, Args) + 'Return True + 'End If + + If frms.Count > 0 AndAlso frms(0).InvokeRequired Then + frms(0).BeginInvoke(Action, Args) + Return True + End If + + Return False + End Function + + Public Shared Sub RunGui(Of T1, T2, T3)(ByVal Action As Action(Of T1, T2, T3), ByVal Arg1 As T1, ByVal Arg2 As T2, ByVal Arg3 As T3) + 'falls Invoking nicht erforderlich, die Action direkt ausführen + If Not GuiCrossInvoke(Action, Arg1, Arg2, Arg3) Then Action(Arg1, Arg2, Arg3) + End Sub + Public Shared Sub RunGui(Of T1, T2)(ByVal Action As Action(Of T1, T2), ByVal Arg1 As T1, ByVal Arg2 As T2) + If Not GuiCrossInvoke(Action, Arg1, Arg2) Then Action(Arg1, Arg2) + End Sub + Public Shared Sub RunGui(Of T1)(ByVal Action As Action(Of T1), ByVal Arg1 As T1) + If Not GuiCrossInvoke(Action, Arg1) Then Action(Arg1) + End Sub + Public Shared Sub RunGui(ByVal Action As Action) + If Not GuiCrossInvoke(Action) Then Action() + End Sub + +End Class diff --git a/Pilz.Threading/My Project/Application.Designer.vb b/Pilz.Threading/My Project/Application.Designer.vb new file mode 100644 index 0000000..8ab460b --- /dev/null +++ b/Pilz.Threading/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Threading/My Project/Application.myapp b/Pilz.Threading/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.Threading/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.Threading/My Project/AssemblyInfo.vb b/Pilz.Threading/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..4418d63 --- /dev/null +++ b/Pilz.Threading/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Threading/My Project/Resources.Designer.vb b/Pilz.Threading/My Project/Resources.Designer.vb new file mode 100644 index 0000000..cd77810 --- /dev/null +++ b/Pilz.Threading/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Threading.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Threading/My Project/Resources.resx b/Pilz.Threading/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Threading/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Threading/My Project/Settings.Designer.vb b/Pilz.Threading/My Project/Settings.Designer.vb new file mode 100644 index 0000000..6a2281a --- /dev/null +++ b/Pilz.Threading/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Threading.My.MySettings + Get + Return Global.Pilz.Threading.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Threading/My Project/Settings.settings b/Pilz.Threading/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Threading/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Threading/Pilz.Threading.vbproj b/Pilz.Threading/Pilz.Threading.vbproj new file mode 100644 index 0000000..5d6f578 --- /dev/null +++ b/Pilz.Threading/Pilz.Threading.vbproj @@ -0,0 +1,127 @@ + + + + + Debug + AnyCPU + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB} + Library + Pilz.Threading + Pilz.Threading + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.Threading.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.Threading.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x86\Debug\ + Pilz.Threading.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + full + x86 + MinimumRecommendedRules.ruleset + true + + + true + bin\x86\Release\ + Pilz.Threading.xml + true + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + pdbonly + x86 + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/Pilz.UI/My Project/Application.Designer.vb b/Pilz.UI/My Project/Application.Designer.vb new file mode 100644 index 0000000..8ab460b --- /dev/null +++ b/Pilz.UI/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.UI/My Project/Application.myapp b/Pilz.UI/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.UI/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.UI/My Project/AssemblyInfo.vb b/Pilz.UI/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..31f117b --- /dev/null +++ b/Pilz.UI/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.UI/My Project/Resources.Designer.vb b/Pilz.UI/My Project/Resources.Designer.vb new file mode 100644 index 0000000..b6cfcb8 --- /dev/null +++ b/Pilz.UI/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.UI.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.UI/My Project/Resources.resx b/Pilz.UI/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.UI/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.UI/My Project/Settings.Designer.vb b/Pilz.UI/My Project/Settings.Designer.vb new file mode 100644 index 0000000..d282691 --- /dev/null +++ b/Pilz.UI/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.UI.My.MySettings + Get + Return Global.Pilz.UI.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.UI/My Project/Settings.settings b/Pilz.UI/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.UI/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.UI/PaintingControl/DefaultDrawMethodes.vb b/Pilz.UI/PaintingControl/DefaultDrawMethodes.vb new file mode 100644 index 0000000..09bb875 --- /dev/null +++ b/Pilz.UI/PaintingControl/DefaultDrawMethodes.vb @@ -0,0 +1,220 @@ +Imports System.Drawing +Imports System.Drawing.Drawing2D +Imports System.Windows.Forms +Imports Pilz.Drawing + +''' +''' Contains static methods that are used for the standart PaintingObject Types. +''' +Public Class DefaultDrawMethodes + + Public Shared Sub DrawText(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + Dim b As New SolidBrush(obj.TextColor) + Dim p As New PointF + Dim rect As New Rectangle(e.X, e.Y, obj.Width, obj.Height) + + Dim f As StringFormat = StringFormat.GenericDefault + f.Alignment = obj.HorizontalTextAlignment + f.LineAlignment = obj.VerticalTextAlignment + + Dim zoomFactor As Single + If obj.Parent Is Nothing Then + zoomFactor = 1.0! + Else + zoomFactor = obj.Parent.ZoomFactor.Width + End If + + e.Graphics.DrawString(obj.Text, New Font(obj.TextFont.FontFamily, obj.TextFont.Size * zoomFactor, obj.TextFont.Style), b, rect, f) + End Sub + + Public Shared Sub DrawPicture(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + Dim objImg As Image + Dim result As RectangleF + Dim image As Bitmap + + SyncLock e.PaintingObject.Parent + If obj?.Image Is Nothing Then Return + objImg = obj.Image + End SyncLock + + image = obj.BufferedImage + result = CalculateImageResolution(obj, objImg.Size) + + If obj.ImageProperties.Rotate = 90 OrElse obj.ImageProperties.Rotate = 270 Then + result = CalculateImageResolution(obj, New SizeF(objImg.Size.Height, objImg.Size.Width)) + Else + result = result + End If + + If image Is Nothing Then + Dim needRescaleImageBecauseRot As Boolean = False + + image = DrawToNewImage(objImg, result.Size) + + Select Case obj.ImageProperties.Rotate + Case 90 + image.RotateFlip(RotateFlipType.Rotate90FlipNone) + needRescaleImageBecauseRot = True + Case 180 + image.RotateFlip(RotateFlipType.Rotate180FlipNone) + Case 270 + image.RotateFlip(RotateFlipType.Rotate270FlipNone) + needRescaleImageBecauseRot = True + End Select + If obj.ImageProperties.FlipX Then + image.RotateFlip(RotateFlipType.RotateNoneFlipX) + End If + If obj.ImageProperties.FlipY Then + image.RotateFlip(RotateFlipType.RotateNoneFlipY) + End If + + If needRescaleImageBecauseRot Then + result = CalculateImageResolution(obj, New SizeF(objImg.Size.Height, objImg.Size.Width)) + image = DrawToNewImage(image, result.Size) + End If + + obj.BufferedImage = image + End If + + If image IsNot Nothing Then + e.Graphics.DrawImageUnscaled(image, New Rectangle(New Point(obj.Location.X + result.Location.X - e.Offset.X, obj.Location.Y + result.Location.Y - e.Offset.Y), result.Size.ToSize)) + End If + End Sub + + Private Shared Function DrawToNewImage(image As Bitmap, newSize As SizeF) As Bitmap + Dim bmp As New Bitmap(CInt(newSize.Width), CInt(newSize.Height)) + Dim gimage As Graphics = Graphics.FromImage(bmp) + gimage.SmoothingMode = SmoothingMode.HighQuality + gimage.PixelOffsetMode = PixelOffsetMode.HighQuality + gimage.PageUnit = GraphicsUnit.Pixel + gimage.InterpolationMode = InterpolationMode.HighQualityBicubic + gimage.DrawImage(image, New RectangleF(PointF.Empty, newSize)) + gimage.Dispose() + Return bmp + End Function + + Public Shared Sub DrawLine(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + Dim p2 As New Pen(obj.OutlineColor, obj.OutlineThicknes) With {.DashStyle = obj.OutlineDashStyle} + p2.Alignment = PenAlignment.Center + Dim no As PointF = New PointF(e.X, e.Y) + e.Graphics.DrawLine(p2, no, no + obj.Size) + End Sub + + Private Shared Function CalculateImageResolution(obj As PaintingObject, imageSize As SizeF) As RectangleF + Dim result As New RectangleF + Dim objrect As New RectangleF(obj.Location, obj.Size) + Dim size As SizeF = imageSize + Dim clientRectangle As RectangleF = objrect + Dim val As Single = clientRectangle.Width / size.Width + + clientRectangle = objrect + Dim num As Single = Math.Min(val, clientRectangle.Height / size.Height) + + result.Width = CInt(Math.Truncate(size.Width * num)) + result.Height = CInt(Math.Truncate(size.Height * num)) + + clientRectangle = objrect + result.X = (clientRectangle.Width - result.Width) \ 2 + + clientRectangle = objrect + result.Y = (clientRectangle.Height - result.Height) \ 2 + + Return result + End Function + + Public Shared Sub DrawTriangle(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + + If obj.EnableFill Then + Dim b As New SolidBrush(obj.FillColor) + Dim p1 As New Point(obj.Size.Width / 2 + e.X, e.Y) + Dim p2 As New Point(e.X, e.Y + obj.Size.Height) + Dim p3 As New Point(e.X + obj.Size.Width, e.Y + obj.Size.Height) + e.Graphics.FillPolygon(b, {p1, p2, p3}) + End If + + If obj.EnableOutline Then + Dim lw As Single = obj.OutlineThicknes + Dim p As New Pen(obj.OutlineColor, obj.OutlineThicknes) With {.DashStyle = obj.OutlineDashStyle, .Alignment = PenAlignment.Inset} + Dim p1 As New Point(obj.Size.Width / 2 + e.X, e.Y) + Dim p2 As New Point(e.X, e.Y + obj.Size.Height) + Dim p3 As New Point(e.X + obj.Size.Width, e.Y + obj.Size.Height) + e.Graphics.DrawPolygon(p, {p1, p2, p3}) + End If + End Sub + + Public Shared Sub DrawRectangle(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + Dim hol As Single = obj.OutlineThicknes / 2 + + If obj.EnableFill Then + Dim b As New SolidBrush(obj.FillColor) + Dim rect As Rectangle = If(obj.EnableOutline, + New Rectangle(e.X + hol, e.Y + hol, obj.Size.Width - hol * 2, obj.Size.Height - hol * 2), + New Rectangle(e.X, e.Y, obj.Size.Width, obj.Size.Height)) + e.Graphics.FillRectangle(b, rect) + End If + + If obj.EnableOutline Then + Dim p As New Pen(obj.OutlineColor, obj.OutlineThicknes) With {.DashStyle = obj.OutlineDashStyle, .Alignment = PenAlignment.Inset} + Dim rect As New Rectangle(e.X, e.Y, obj.Size.Width, obj.Size.Height) + e.Graphics.DrawRectangle(p, rect) + End If + End Sub + + Public Shared Sub DrawEllipse(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + + If obj.EnableFill Then + Dim b As New SolidBrush(obj.FillColor) + Dim rect As Rectangle = New Rectangle(e.X, e.Y, obj.Size.Width, obj.Size.Height) + e.Graphics.FillEllipse(b, rect) + End If + + If obj.EnableOutline Then + Dim p As New Pen(obj.OutlineColor, obj.OutlineThicknes) With {.DashStyle = obj.OutlineDashStyle, .Alignment = PenAlignment.Inset} + Dim rect As New Rectangle(e.X, e.Y, obj.Size.Width, obj.Size.Height) + e.Graphics.DrawEllipse(p, rect) + End If + End Sub + + Public Shared Sub DrawSelection(e As PaintingObjectPaintEventArgs) + Dim obj As PaintingObject = e.PaintingObject + Dim lw As Single = 2.5! + Dim hlw As Single = lw / 2 + Dim hlwphol As Single = hlw '+ hol + Dim hlwpholm2 As Single = hlwphol * 2 + + Dim p As New Pen(Color.CornflowerBlue, lw) With {.DashStyle = obj.SelectionDashStyle, .Alignment = PenAlignment.Outset} + Dim rect As New Rectangle(e.X - hlwphol, e.Y - hlwphol, obj.Size.Width + hlwpholm2, obj.Size.Height + hlwpholm2) + e.Graphics.DrawRectangle(p, rect) + End Sub + + Public Shared Sub DrawGrid(e As PaintEventArgs, pc As PaintingControl, offset As PointF) + Dim p As New Pen(pc.GridColor, 0.5) + + Dim curX As Integer = pc.GridChunkSize.Width * pc.ZoomFactor.Width - offset.X + Do While curX < pc.Width + e.Graphics.DrawLine(p, curX, -offset.Y, curX, pc.Height) + curX += (pc.GridChunkSize.Width * pc.ZoomFactor.Width) + Loop + + Dim curY As Integer = pc.GridChunkSize.Height * pc.ZoomFactor.Height - offset.Y + Do While curY < pc.Height + e.Graphics.DrawLine(p, -offset.X, curY, pc.Width, curY) + curY += (pc.GridChunkSize.Height * pc.ZoomFactor.Height) + Loop + End Sub + + Public Shared Sub DrawAreaSelection(e As PaintEventArgs, pc As PaintingControl, startMousePos As PointF, lastMousePos As PointF) + Dim p As New Pen(pc.AreaSelectionColor) + p.DashStyle = DashStyle.DashDot + p.Width = 3 + Dim rectToDraw As RectangleF = HelpfulDrawingFunctions.GetRectangle(startMousePos, lastMousePos) + e.Graphics.DrawRectangle(p, rectToDraw.X, rectToDraw.Y, rectToDraw.Width, rectToDraw.Height) + End Sub + +End Class diff --git a/Pilz.UI/PaintingControl/EventArgs/PaintingObjectEventArgs.vb b/Pilz.UI/PaintingControl/EventArgs/PaintingObjectEventArgs.vb new file mode 100644 index 0000000..ef5c14b --- /dev/null +++ b/Pilz.UI/PaintingControl/EventArgs/PaintingObjectEventArgs.vb @@ -0,0 +1,16 @@ +Imports System.Drawing +Imports System.IO +Imports System.Windows.Forms +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq + +Public Class PaintingObjectEventArgs + Inherits EventArgs + + Public ReadOnly Property PaintingObjects As PaintingObject() = Nothing + + Friend Sub New(paintingObjects As PaintingObject()) + _PaintingObjects = paintingObjects + End Sub + +End Class diff --git a/Pilz.UI/PaintingControl/EventArgs/PaintingObjectPaintEventArgs.vb b/Pilz.UI/PaintingControl/EventArgs/PaintingObjectPaintEventArgs.vb new file mode 100644 index 0000000..aaca912 --- /dev/null +++ b/Pilz.UI/PaintingControl/EventArgs/PaintingObjectPaintEventArgs.vb @@ -0,0 +1,78 @@ +Imports System.Drawing +Imports System.IO +Imports System.Windows.Forms +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq + +Public Class PaintingObjectPaintEventArgs + Inherits EventArgs + + ''' + ''' The Painting Object to draw. + ''' + ''' + Public ReadOnly Property PaintingObject As PaintingObject + + ''' + ''' The current offset of the page on the screen. + ''' + ''' + Public ReadOnly Property Offset As PointF + + ''' + ''' The Grpahics from the parent PaintingControl. + ''' + ''' + Public ReadOnly Property Graphics As Graphics + + ''' + ''' The position of the PaintingObject on Screen. + ''' + ''' + Public ReadOnly Property Location As PointF + Get + Return New PointF(X, Y) + End Get + End Property + + ''' + ''' The X position of the PaintingObject on Screen. + ''' + ''' + Public ReadOnly Property X As Single + Get + Return PaintingObject.X - Offset.X + End Get + End Property + + ''' + ''' The Y position of the PaintingObject on Screen. + ''' + ''' + Public ReadOnly Property Y As Single + Get + Return PaintingObject.Y - Offset.Y + End Get + End Property + + ''' + ''' The rectangle of the PaintingObject on Screen. + ''' + ''' + Public ReadOnly Property Rectangle As RectangleF + Get + Return New RectangleF(X, Y, PaintingObject.Width, PaintingObject.Height) + End Get + End Property + + Friend Sub New(obj As PaintingObject, g As Graphics) + Me.New(obj, g, obj.Parent.Offset) + End Sub + + Friend Sub New(obj As PaintingObject, g As Graphics, offset As PointF) + PaintingObject = obj + Me.Offset = offset + Graphics = g + End Sub + +End Class diff --git a/Pilz.UI/PaintingControl/IPaintingObjectContainer.vb b/Pilz.UI/PaintingControl/IPaintingObjectContainer.vb new file mode 100644 index 0000000..6909c7d --- /dev/null +++ b/Pilz.UI/PaintingControl/IPaintingObjectContainer.vb @@ -0,0 +1,5 @@ +Imports System.Drawing + +Public Interface IPaintingObjectContainer + +End Interface diff --git a/Pilz.UI/PaintingControl/ImageProperties.vb b/Pilz.UI/PaintingControl/ImageProperties.vb new file mode 100644 index 0000000..b572234 --- /dev/null +++ b/Pilz.UI/PaintingControl/ImageProperties.vb @@ -0,0 +1,5 @@ +Public Class PaintingObjectImageProperties + Public Property FlipY As Boolean = False + Public Property FlipX As Boolean = False + Public Property Rotate As UShort = 0 +End Class diff --git a/Pilz.UI/PaintingControl/PaintingControl.resx b/Pilz.UI/PaintingControl/PaintingControl.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingControl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.UI/PaintingControl/PaintingControl.vb b/Pilz.UI/PaintingControl/PaintingControl.vb new file mode 100644 index 0000000..5143f04 --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingControl.vb @@ -0,0 +1,660 @@ +Imports System.Drawing +Imports System.Drawing.Drawing2D +Imports System.Runtime.CompilerServices +Imports System.Windows.Forms +Imports Pilz.Drawing + +Public Class PaintingControl + Inherits UserControl + Implements IPaintingObjectContainer + + Private curObjMouseDown As PaintingObject = Nothing + Private bgColor As Color = Color.White + Private startMousePos As Point = Nothing + Private lastMousePos As Point = Nothing + Private lastHashCode As Integer = 0 + Private calcOffset_MouseOnTab As Point = Point.Empty + Private calcOffset_IsActive As Boolean = False + Private calcOffset_LastOffset As PointF = PointF.Empty + + Private Overloads Property ForeColor As Color + Private Overloads Property Font As Font + Private Overloads Property Text As String + + Public Property Offset As PointF = PointF.Empty + Public ReadOnly Property PaintingObjects As New PaintingObjectList(Me) + Public Property AutoAreaSelection As Boolean = True + Public Property AutoSingleSelection As Boolean = True + Public Property AutoMultiselection As Boolean = True + Public Property AutoRemoveSelection As Boolean = True + Public Property AreaSelectionDashStyle As DashStyle = DashStyle.DashDot + Public Property AreaSelectionColor As Color = Color.CornflowerBlue + Public Property AutoMoveObjects As Boolean = True + Private _IsAreaSelecting As Boolean = False + Public ReadOnly Property IsMovingObjects As Boolean = False + Public Property GridEnabled As Boolean = True + Public Property GridVisible As Boolean = False + Public Property GridChunkSize As New Size(20, 20) + Public Property GridColor As Color = Color.LightGray + Public Property DrawGridMethode As DelegateDrawPaintingControlGridMethode = AddressOf DefaultDrawMethodes.DrawGrid + Public Property DrawAreaSelectionMethode As DelegateDrawPaintingControlAreaSelectionMethode = AddressOf DefaultDrawMethodes.DrawAreaSelection + Private _ZoomFactor As New SizeF(1, 1) + + Private _stopDrawing As Integer = -1 + Private bufferedImg As Image = Nothing + + Private pressedShift As Boolean = False + Private pressedControl As Boolean = False + Private pressedAlt As Boolean = False + + 'Friend WithEvents HScrollBarAdv1 As DevComponents.DotNetBar.ScrollBar.HScrollBarAdv + 'Friend WithEvents VScrollBarAdv1 As DevComponents.DotNetBar.VScrollBarAdv + + Private savedPos As New Dictionary(Of PaintingObject, PointF) + + Public Event SelectionChanged(sender As Object, e As PaintingObjectEventArgs) + Public Event PaintingObjectAdded(sender As Object, e As PaintingObjectEventArgs) + Public Event PaintingObjectRemoved(sender As Object, e As PaintingObjectEventArgs) + Public Event AfterScrollingDone(sender As Object, e As EventArgs) + Public Event ZoomFactorChanged(sender As Object, e As EventArgs) + + Public ReadOnly Property SelectedObjects As PaintingObject() + Get + Dim objs As New List(Of PaintingObject) + + For Each obj As PaintingObject In PaintingObjects + If obj.Selected Then + objs.Add(obj) + End If + Next + + Return objs.ToArray + End Get + End Property + + Public ReadOnly Property IsLayoutSuspended As Boolean + Get + Return Me.GetType.GetField("layoutSuspendCount", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(Me) <> 0 + End Get + End Property + + Public ReadOnly Property StopDrawing As Boolean + Get + Return _stopDrawing > -1 + End Get + End Property + + Public Overrides Property BackColor As Color + Get + Return bgColor + End Get + Set(value As Color) + bgColor = value + If value <> Color.Transparent Then + MyBase.BackColor = value + End If + End Set + End Property + Public ReadOnly Property IsAreaSelecting As Boolean + Get + Return _IsAreaSelecting AndAlso startMousePos <> lastMousePos + End Get + End Property + Public Property ZoomFactor As SizeF + Get + Return _ZoomFactor + End Get + Set + If _ZoomFactor <> Value Then + _ZoomFactor = Value + RaiseEvent ZoomFactorChanged(Me, New EventArgs) + End If + End Set + End Property + + Public Sub New() + DoubleBuffered = True + End Sub + + Private Sub CheckKeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown, Me.KeyUp + pressedShift = e.Shift + pressedControl = e.Control + pressedAlt = e.Alt + End Sub + + Friend ReadOnly Property AreaSelectionRectangle As RectangleF + Get + Return HelpfulDrawingFunctions.GetRectangle(startMousePos, lastMousePos) + End Get + End Property + + Private Sub CheckMouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick + For Each obj As PaintingObject In GetObjects(New Point(e.X + Offset.X, e.Y + Offset.Y)) + If Not obj.MouseTransparency Then + obj.RaiseMouseClick(GetMouseEventArgs(e, obj)) + End If + Next + End Sub + + Private Sub CheckMouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown + lastMousePos = New Point(e.X + Offset.X, e.Y + Offset.Y) + + curObjMouseDown = GetObjects(lastMousePos).Where(Function(n) Not n.MouseTransparency).LastOrDefault + curObjMouseDown?.RaiseMouseDown(GetMouseEventArgs(e, curObjMouseDown)) + + If Not GetSelectedObjects.Contains(curObjMouseDown) Then + Dim hasMovedObjects As Boolean = False + If _IsMovingObjects Then + For Each obj As PaintingObject In GetSelectedObjects() + If HelpfulDrawingFunctions.IsPointInRectangle(lastMousePos, obj.Rectangle) Then + hasMovedObjects = True + Exit For + End If + Next + End If + + If (Not hasMovedObjects) AndAlso (Not _IsAreaSelecting) Then + Dim selChanged As New List(Of PaintingObject) + + If AutoRemoveSelection AndAlso Not pressedShift Then + For Each obj As PaintingObject In PaintingObjects + If obj.Selected Then + obj.SelectedDirect = False + If Not selChanged.Contains(obj) Then + selChanged.Add(obj) + End If + End If + Next + End If + If AutoSingleSelection Then + Dim objtosel As PaintingObject = curObjMouseDown + If objtosel?.EnableSelection Then + objtosel.SelectedDirect = Not objtosel.Selected + If Not selChanged.Contains(objtosel) Then + selChanged.Add(objtosel) + Else + selChanged.Remove(objtosel) + End If + End If + End If + + RaiseEvent SelectionChanged(Me, New PaintingObjectEventArgs(selChanged.ToArray)) + End If + End If + + If pressedControl Then + + calcOffset_MouseOnTab = New Point(e.X, e.Y) + calcOffset_LastOffset = Offset + calcOffset_IsActive = True + Cursor = Cursors.Arrow + + Else + + Select Case e.Button + Case MouseButtons.Left + savedPos.Clear() + If AutoMoveObjects Then + SaveObjectPositions(e, GetSelectedObjects) + End If + If savedPos.Count > 0 Then + _IsMovingObjects = True + ElseIf AutoAreaSelection Then + startMousePos = New Point(e.X + Offset.X, e.Y + Offset.Y) + lastMousePos = startMousePos 'New Point(e.X - Offset.X, e.Y - Offset.Y) + _IsAreaSelecting = True + End If + End Select + + End If + End Sub + Public Sub RaiseSelectionChanged() + RaiseEvent SelectionChanged(Me, New PaintingObjectEventArgs(SelectedObjects)) + End Sub + Private Sub CheckMouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp + If _IsAreaSelecting Then + _IsAreaSelecting = False + End If + + If _IsMovingObjects Then + _IsMovingObjects = False + AutoArrangeToGrid() + 'CalculateScrollValues() + End If + + If curObjMouseDown IsNot Nothing Then + If Not curObjMouseDown.MouseTransparency Then + curObjMouseDown.RaiseMouseUp(GetMouseEventArgs(e, curObjMouseDown)) + End If + curObjMouseDown = Nothing + End If + + If calcOffset_IsActive Then + calcOffset_IsActive = False + Cursor = Cursors.Default + CalcNewOffset(e.Location) + RaiseEvent AfterScrollingDone(Me, New EventArgs) + End If + End Sub + Private Sub CheckMouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove + If _IsAreaSelecting OrElse _IsMovingObjects Then + lastMousePos = New Point(e.X + Offset.X, e.Y + Offset.Y) + End If + + If _IsAreaSelecting Then + SelectControlsInArea() + End If + + If _IsMovingObjects Then + UpdateObjectPositions(e) + End If + + For Each obj As PaintingObject In GetObjects(New Point(e.X + Offset.X, e.Y + Offset.Y)) + If Not obj.MouseTransparency Then + obj.RaiseMouseMove(GetMouseEventArgs(e, obj)) + End If + Next + + Dim topObj As PaintingObject = GetObject(New Point(e.X + Offset.X, e.Y + Offset.Y), True) + If topObj IsNot Nothing Then + Cursor = topObj.Cursor + ElseIf calcOffset_IsActive Then + Cursor = Cursors.Arrow + Else + Cursor = Cursors.Default + End If + + If calcOffset_IsActive Then + If pressedControl Then + CalcNewOffset(e.Location) + Else + calcOffset_IsActive = False + End If + End If + + Refresh() + End Sub + + Private Sub CalcNewOffset(newMousePos As Point) + Offset = New PointF(calcOffset_LastOffset.X - (newMousePos.X - calcOffset_MouseOnTab.X), + calcOffset_LastOffset.Y - (newMousePos.Y - calcOffset_MouseOnTab.Y)) + If Offset.X < 0 Then + Offset = New PointF(0, Offset.Y) + End If + If Offset.Y < 0 Then + Offset = New PointF(Offset.X, 0) + End If + End Sub + + Private Function GetSelectedObjects() As PaintingObject() + Dim objs As New List(Of PaintingObject) + + For Each obj As PaintingObject In PaintingObjects + If obj.Selected Then objs.Add(obj) + Next + + Return objs.ToArray + End Function + + Private Sub SaveObjectPositions(e As MouseEventArgs, objs As IList) + For Each obj As PaintingObject In objs + If Not savedPos.ContainsKey(obj) Then + savedPos.Add(obj, New PointF(e.X - obj.Location.X + Offset.X, e.Y - obj.Location.Y + Offset.Y)) + SaveObjectPositions(e, obj.PinnedObjects) + End If + Next + End Sub + Private Sub UpdateObjectPositions(e As MouseEventArgs) + UpdateObjectPositions(e, GetSelectedObjects) + End Sub + Private Sub UpdateObjectPositions(e As MouseEventArgs, objs As IList(Of PaintingObject), Optional movedObjs As List(Of PaintingObject) = Nothing) + If IsResizingObjs(objs) Then Return + If movedObjs Is Nothing Then movedObjs = New List(Of PaintingObject) + Dim updateprocesses As New List(Of Task) + + SuspendDrawing() + + For Each obj As PaintingObject In objs + updateprocesses.Add(Task.Run( + Sub() + Dim sp As PointF = savedPos(obj) + + If Not movedObjs.Contains(obj) Then + UpdateObjectPosition(e, obj, sp) + movedObjs.Add(obj) + End If + + If obj.PinnedObjects.Count > 0 Then + UpdateObjectPositions(e, obj.PinnedObjects, movedObjs) + movedObjs.AddRange(obj.PinnedObjects.ToArray) + End If + End Sub)) + Next + + For Each a In updateprocesses + Do Until a.IsCompleted + Loop + Next + + ResumeDrawing(False) + End Sub + Private Sub UpdateObjectPosition(e As MouseEventArgs, obj As PaintingObject, sp As PointF) + obj.Location = New Point(e.X - sp.X + Offset.X, + e.Y - sp.Y + Offset.Y) + End Sub + + Private Function IsResizingObjs(objs As IList(Of PaintingObject)) As Boolean + For Each obj As PaintingObject In objs + If obj.IsResizing Then Return True + Next + Return False + End Function + + Private Function GetMouseEventArgs(e As MouseEventArgs, obj As PaintingObject) As MouseEventArgs + Return New MouseEventArgs(e.Button, e.Clicks, e.X - obj.X + Offset.X, e.Y - obj.Y + Offset.Y, e.Delta) + End Function + + Public Function GetObject(p As PointF, Optional UseExtRect As Boolean = False) As PaintingObject + For Each obj As PaintingObject In PaintingObjects + If UseExtRect Then + If HelpfulDrawingFunctions.IsPointInRectangle(p, obj.RectangleExtended) Then + Return obj + End If + Else + If HelpfulDrawingFunctions.IsPointInRectangle(p, obj.Rectangle) Then + Return obj + End If + End If + Next + + Return Nothing + End Function + + Public Function GetObjects(p As Point) As PaintingObject() + Dim objs As New List(Of PaintingObject) + + For Each obj As PaintingObject In PaintingObjects + If HelpfulDrawingFunctions.IsPointInRectangle(p, obj.RectangleExtended) Then + objs.Add(obj) + End If + Next + + Return objs.ToArray + End Function + + Public Function GetObjects(startPoint As Point, endPoint As Point) As PaintingObject() + Return GetObjects(New Rectangle(startPoint, CType(endPoint - startPoint, Size))) + End Function + + Public Function GetObjects(rect As Rectangle) As PaintingObject() + Dim objs As New List(Of PaintingObject) + + For Each obj As PaintingObject In PaintingObjects + Dim objRect As RectangleF = obj.Rectangle + If HelpfulDrawingFunctions.IsPointInRectangle(objRect.Location, rect) OrElse + HelpfulDrawingFunctions.IsPointInRectangle(objRect.Location + objRect.Size, rect) OrElse + HelpfulDrawingFunctions.IsPointInRectangle(New PointF(objRect.Left, objRect.Bottom), rect) OrElse + HelpfulDrawingFunctions.IsPointInRectangle(New PointF(objRect.Right, objRect.Top), rect) Then + objs.Add(obj) + End If + Next + + Return objs.ToArray + End Function + + Protected Overrides ReadOnly Property CreateParams As CreateParams + Get + Dim cp = MyBase.CreateParams + + 'If EnableFullTransparentBackground Then + ' cp.ExStyle = cp.ExStyle Or &H20 'WS_EX_TRANSPARENT + 'End If + + Return cp + End Get + End Property + + ''' + ''' Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + ''' + ''' + Protected Overrides Sub WndProc(ByRef m As Message) + Dim WM_NCHITTEST As Integer = &H84 + Dim HTTRANSPARENT As Integer = -1 + + 'If m.Msg = WM_NCHITTEST Then + ' m.Result = CType(HTTRANSPARENT, IntPtr) + 'Else + ' MyBase.WndProc(m) + 'End If + + MyBase.WndProc(m) + End Sub + + Protected Overrides Sub OnPaintBackground(e As PaintEventArgs) + 'Stop Drawing directly to the parent + Me.SuspendLayout() + + 'Draw Background + MyBase.OnPaintBackground(e) + End Sub + + Private Function GetCurrentHashValue() As Integer + Dim hashes As New List(Of Integer) + + hashes.AddRange({Offset.X, + Offset.Y, + Size.Width, + Size.Height}) + + For Each p As PaintingObject In PaintingObjects + hashes.AddRange({p.Location.X, + p.Location.Y, + p.Size.Width, + p.Size.Height, + p.DrawMethodes.Count, + p.FillColor.ToArgb, + p.OutlineColor.ToArgb, + p.SelectionColor.ToArgb, + p.TextColor.ToArgb, + p.Type, + p.Text.GetHashCode / p.Text.Length, + p.Visible, + p.VerticalTextAlignment, + p.HorizontalTextAlignment}) + Next + + Dim hash As Integer = 0 + + For Each h As Integer In hashes + Try + hash += h + Catch ex As Exception + If h <> 0 AndAlso h <> 1 Then + hash /= h + End If + End Try + Next + + Return hash + End Function + + Protected Overrides Sub OnPaint(e As PaintEventArgs) + 'Do default Drawing Methode + MyBase.OnPaint(e) + + If StopDrawing Then + e.Graphics.DrawImage(bufferedImg, Point.Empty) + Else + With e.Graphics + .SmoothingMode = SmoothingMode.HighQuality + .PixelOffsetMode = PixelOffsetMode.HighQuality + .PageUnit = GraphicsUnit.Pixel + .InterpolationMode = InterpolationMode.HighQualityBicubic + End With + + If GridVisible Then + DrawGridMethode?.Invoke(e, Me, Offset) + End If + + Dim baserect As RectangleF = New RectangleF(Offset, Size) + + For Each obj As PaintingObject In PaintingObjects + If obj.Visible AndAlso HelpfulDrawingFunctions.OverlapsTwoRectangles(obj.Rectangle, baserect) Then + obj.Draw(e, Offset) + End If + Next + + If _IsAreaSelecting Then + DrawAreaSelectionMethode?.Invoke(e, Me, New PointF(startMousePos.X - Offset.X, startMousePos.Y - Offset.Y), New PointF(lastMousePos.X - Offset.X, lastMousePos.Y - Offset.Y)) + End If + End If + + 'Start Drawing directly to the Form + ResumeLayout(False) + End Sub + + Public Overloads Function CreateGraphics() As Graphics + Return MyBase.CreateGraphics + End Function + + Public Sub PaintFullView(g As Graphics) + For Each obj As PaintingObject In PaintingObjects + If obj.Visible Then + obj.Draw(g, PointF.Empty) + End If + Next + End Sub + + Private Function CalcTextSize(obj As PaintingObject) As SizeF + Return CalcTextSize(obj, Parent.CreateGraphics) + End Function + Private Function CalcTextSize(obj As PaintingObject, g As Graphics) As SizeF + Return g.MeasureString(obj.Text, obj.TextFont, obj.Width) + End Function + + Private Sub SelectControlsInArea() + Dim rect As RectangleF = HelpfulDrawingFunctions.GetRectangle(startMousePos, lastMousePos) + For Each obj As PaintingObject In PaintingObjects + obj.Selected = HelpfulDrawingFunctions.OverlapsTwoRectangles(obj.Rectangle, rect) + Next + End Sub + + Public Sub ArrangeToGrid(obj As PaintingObject) + Dim zoomedGridChunkSize As New SizeF(GridChunkSize.Width * ZoomFactor.Width, Me.GridChunkSize.Height * ZoomFactor.Height) + + Dim modTop As Integer = obj.Y Mod zoomedGridChunkSize.Height + Dim modLeft As Integer = obj.X Mod zoomedGridChunkSize.Width + + Dim halfHeight As Integer = zoomedGridChunkSize.Height / 2 + Dim halfWidth As Integer = zoomedGridChunkSize.Width / 2 + + If modTop > halfHeight Then + obj.Y += (zoomedGridChunkSize.Height - modTop) + Else + obj.Y -= modTop + End If + + If modLeft > halfWidth Then + obj.X += (zoomedGridChunkSize.Width - modLeft) + Else + obj.X -= modLeft + End If + + If obj.EnableResize AndAlso Not obj.HardcodedSize Then + Dim modH As Integer = obj.Height Mod zoomedGridChunkSize.Height + Dim modW As Integer = obj.Width Mod zoomedGridChunkSize.Width + + If modH > halfHeight Then + obj.Height += (zoomedGridChunkSize.Height - modH) + Else + obj.Height -= modH + End If + + If modW > halfWidth Then + obj.Width += (zoomedGridChunkSize.Width - modW) + Else + obj.Width -= modW + End If + End If + End Sub + + Public Sub AutoArrangeToGrid() + If GridEnabled Then + For Each obj As PaintingObject In GetSelectedObjects() + If obj.AutoAlignToGrid Then + ArrangeToGrid(obj) + End If + Next + If Not StopDrawing Then Refresh() + End If + End Sub + + Public Function GetFullSize() As SizeF + Return GetFullSize(PaintingObjects) + End Function + + Public Shared Function GetFullSize(objects As IEnumerable(Of PaintingObject)) As SizeF + Dim curX As Single = 0 + Dim curY As Single = 0 + + For Each po As PaintingObject In objects + Dim myX As Single = po.X + po.Width + If curX < myX Then + curX = myX + End If + Dim myY As Single = po.Y + po.Height + If curY < myY Then + curY = myY + End If + Next + + Return New SizeF(curX + 20, curY + 20) + End Function + + Friend Sub RaisePaintingObjectAdded(args As PaintingObjectEventArgs) + RaiseEvent PaintingObjectAdded(Me, args) + End Sub + Friend Sub RaisePaintingObjectRemoved(args As PaintingObjectEventArgs) + RaiseEvent PaintingObjectRemoved(Me, args) + End Sub + + Private Sub PaintingControl_PaintingObjectAdded(sender As Object, e As PaintingObjectEventArgs) Handles Me.PaintingObjectAdded, Me.PaintingObjectRemoved + 'CalculateScrollValues() + End Sub + + Private Sub CheckMouseWheel(sender As Object, e As MouseEventArgs) Handles Me.MouseWheel + If pressedControl Then + Dim val As Single = e.Delta / 120 / 10 + ZoomFactor = New SizeF(Math.Max(ZoomFactor.Width + val, 0.25), Math.Max(ZoomFactor.Height + val, 0.25)) + Refresh() + End If + End Sub + + Public Sub SuspendDrawing() + If _stopDrawing < 0 Then + 'bufferedImg = New Bitmap(Width, Height) + 'DrawToBitmap(bufferedImg, New Rectangle(0, 0, bufferedImg.Width, bufferedImg.Height)) + Utils.SuspendDrawing(Me) + End If + _stopDrawing += 1 + End Sub + + Public Sub ResumeDrawing() + ResumeDrawing(True) + End Sub + + Public Sub ResumeDrawing(executeRefresh As Boolean) + If _stopDrawing >= 0 Then + _stopDrawing -= 1 + End If + + If _stopDrawing = -1 Then + 'bufferedImg.Dispose() + 'bufferedImg = Nothing + 'If executeRefresh Then Refresh() + Utils.ResumeDrawing(Me, executeRefresh) + End If + End Sub + +End Class diff --git a/Pilz.UI/PaintingControl/PaintingControlDelegates.vb b/Pilz.UI/PaintingControl/PaintingControlDelegates.vb new file mode 100644 index 0000000..6516ca2 --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingControlDelegates.vb @@ -0,0 +1,6 @@ +Imports System.Drawing +Imports System.Windows.Forms + +Public Delegate Sub DelegateDrawPaintingObjectMethode(e As PaintingObjectPaintEventArgs) +Public Delegate Sub DelegateDrawPaintingControlGridMethode(e As PaintEventArgs, pc As PaintingControl, offset As PointF) +Public Delegate Sub DelegateDrawPaintingControlAreaSelectionMethode(e As PaintEventArgs, pc As PaintingControl, startMousePos As PointF, lastMousePos As PointF) diff --git a/Pilz.UI/PaintingControl/PaintingObject.vb b/Pilz.UI/PaintingControl/PaintingObject.vb new file mode 100644 index 0000000..5ceaa73 --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingObject.vb @@ -0,0 +1,586 @@ +Imports System.Drawing +Imports System.Drawing.Drawing2D +Imports System.Reflection +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices +Imports System.Runtime.Serialization +Imports System.Windows.Forms +Imports Newtonsoft.Json + + Public Class PaintingObject + Implements ICloneable, IPaintingObjectContainer + + Private resizeEngine As PaintingObjectResizing = Nothing + Private _Selected As Boolean = False + + Private _Parent As PaintingControl = Nothing + Public Property FillColor As Color = Color.Blue + Public Property OutlineColor As Color = Color.DarkBlue + Public Property OutlineThicknes As Single = 1 + Public Property OutlineDashStyle As DashStyle = DashStyle.Solid + Private _Text As String = "" + Public Property TextPosition As TextPosition = TextPosition.FullCenter + Public Property VerticalTextAlignment As StringAlignment = StringAlignment.Center + Public Property HorizontalTextAlignment As StringAlignment = StringAlignment.Center + Public Property TextFont As New Font(FontFamily.GenericSansSerif, 8.25) + Public Property TextColor As Color = Color.Black + Private _Location As New PointF(50, 50) + Private _Size As New SizeF(50, 80) + Public Property EnableFill As Boolean = True + Public Property EnableOutline As Boolean = True + Public Property SelectionColor As Color = Color.CornflowerBlue + Public Property SelectionDashStyle As DashStyle = DashStyle.Dot + Private _EnableSelection As Boolean = True + Public Property Image As Image = Nothing + Public Property BufferedImage As Image = Nothing + Public Property ImageSizeMode As ImageSizeMode + Public Property ImageProperties As New PaintingObjectImageProperties + Public Property Tag As String = Nothing + Public Property Name As String = "" + Public ReadOnly Property PinnedObjects As New List(Of PaintingObject) + Public ReadOnly Property DrawMethodes As New List(Of DelegateDrawPaintingObjectMethode) + Public ReadOnly Property DrawSelectionMethode As DelegateDrawPaintingObjectMethode = AddressOf DefaultDrawMethodes.DrawSelection + Public Property Cursor As Cursor = Cursors.Default + Public Property HardcodedSize As Boolean = False + Private _Visible As Boolean = True + Private _AutoAlignToGrid As Boolean = False + Public Property MouseTransparency As Boolean = False + Public ReadOnly Property Layering As New PaintingObjectLayering(Me) + Public ReadOnly Property PaintingObjects As New PaintingObjectList(_Parent) With {.EnableRaisingEvents = False} + + Public Event MouseClick(sender As PaintingObject, e As MouseEventArgs) + Public Event MouseDown(sender As PaintingObject, e As MouseEventArgs) + Public Event MouseUp(sender As PaintingObject, e As MouseEventArgs) + Public Event MouseMove(sender As PaintingObject, e As MouseEventArgs) + Public Event SelectedChanged(sender As PaintingObject, e As EventArgs) + Public Event Paint(sender As PaintingObject, e As PaintEventArgs) + Public Event ParentChanged(sender As PaintingObject, e As EventArgs) + Public Event VisibleChanged(sender As PaintingObject, e As EventArgs) + + Public Sub New() + End Sub + + Public Sub New(type As PaintingObjectType) + Me.Type = type + End Sub + + Public Sub New(type As PaintingObjectType, drawMethodes As DelegateDrawPaintingObjectMethode()) + Me.New(type) + Me.DrawMethodes.AddRange(drawMethodes) + End Sub + + Public Sub RaiseMouseClick(e As MouseEventArgs) + RaiseEvent MouseClick(Me, e) + End Sub + Public Sub RaiseMouseDown(e As MouseEventArgs) + RaiseEvent MouseDown(Me, e) + End Sub + Public Sub RaiseMouseUp(e As MouseEventArgs) + RaiseEvent MouseUp(Me, e) + End Sub + Public Sub RaiseMouseMove(e As MouseEventArgs) + RaiseEvent MouseMove(Me, e) + End Sub + Private Sub RaisePaint(e As PaintEventArgs) + RaiseEvent Paint(Me, e) + End Sub + + Public Property Type As PaintingObjectType + Get + Dim tt As PaintingObjectType = PaintingObjectType.Custom + + For Each d As DelegateDrawPaintingObjectMethode In DrawMethodes + If d.Method.DeclaringType Is GetType(DefaultDrawMethodes) Then + Select Case d.Method.Name + Case "DrawPicture" + tt = tt Or PaintingObjectType.Picture + Case "DrawText" + tt = tt Or PaintingObjectType.Text + Case "DrawRectangle" + tt = tt Or PaintingObjectType.Rectangle + Case "DrawEllipse" + tt = tt Or PaintingObjectType.Elipse + Case "DrawTriangle" + tt = tt Or PaintingObjectType.Triangle + Case "DrawLine" + tt = tt Or PaintingObjectType.Line + End Select + End If + Next + + Return tt + End Get + Set(value As PaintingObjectType) + DrawMethodes.Clear() + + If (value And PaintingObjectType.Picture) = PaintingObjectType.Picture Then + DrawMethodes.Add(AddressOf DefaultDrawMethodes.DrawPicture) + End If + + If (value And PaintingObjectType.Rectangle) = PaintingObjectType.Rectangle Then + DrawMethodes.Add(AddressOf DefaultDrawMethodes.DrawRectangle) + End If + + If (value And PaintingObjectType.Elipse) = PaintingObjectType.Elipse Then + DrawMethodes.Add(AddressOf DefaultDrawMethodes.DrawEllipse) + End If + + If (value And PaintingObjectType.Triangle) = PaintingObjectType.Triangle Then + DrawMethodes.Add(AddressOf DefaultDrawMethodes.DrawTriangle) + End If + + If (value And PaintingObjectType.Line) = PaintingObjectType.Line Then + DrawMethodes.Add(AddressOf DefaultDrawMethodes.DrawLine) + End If + + If (value And PaintingObjectType.Text) = PaintingObjectType.Text Then + DrawMethodes.Add(AddressOf DefaultDrawMethodes.DrawText) + End If + End Set + End Property + + Public Property Location As PointF + Get + If Parent IsNot Nothing Then + Return New PointF(_Location.X * Parent.ZoomFactor.Width, + _Location.Y * Parent.ZoomFactor.Height) + Else + Return _Location + End If + End Get + Set(value As PointF) + If Parent IsNot Nothing Then + _Location = New PointF(value.X / Parent.ZoomFactor.Width, + value.Y / Parent.ZoomFactor.Height) + Else + _Location = value + End If + End Set + End Property + + Public Property Size As SizeF + Get + If Parent IsNot Nothing Then + Return New SizeF(_Size.Width * Parent.ZoomFactor.Width, + _Size.Height * Parent.ZoomFactor.Height) + Else + Return _Size + End If + End Get + Set(value As SizeF) + If Parent IsNot Nothing Then + _Size = New SizeF(value.Width / Parent.ZoomFactor.Width, + value.Height / Parent.ZoomFactor.Height) + Else + _Size = value + End If + ResetImageBuffer() + End Set + End Property + + Public Property SizeDirect As SizeF + Get + Return _Size + End Get + Set(value As SizeF) + _Size = value + ResetImageBuffer() + End Set + End Property + + Public Property AutoAlignToGrid As Boolean + Get + Return _AutoAlignToGrid + End Get + Set(value As Boolean) + _AutoAlignToGrid = value + If value Then ArrangeToGrid() + End Set + End Property + + Public ReadOnly Property IsResizing As Boolean + Get + If resizeEngine Is Nothing Then + Return False + Else + Return resizeEngine?.IsResizing + End If + End Get + End Property + + Public Property Parent As PaintingControl + Get + Return _Parent + End Get + Set(value As PaintingControl) + Dim re As Boolean = value IsNot _Parent + _Parent = value + If re Then RaiseEvent ParentChanged(Me, New EventArgs) + End Set + End Property + + Public Property Visible As Boolean + Get + Return _Visible + End Get + Set(value As Boolean) + If value <> _Visible Then + _Visible = value + If Not value AndAlso Not _EnableSelection Then EnableResize = False + RaiseEvent VisibleChanged(Me, New EventArgs) + End If + End Set + End Property + + Public Property Selected As Boolean + Get + Return _Selected + End Get + Set(value As Boolean) + SetSelection(value, True) + End Set + End Property + + Public Property SelectedDirect As Boolean + Get + Return Selected + End Get + Set(value As Boolean) + SetSelection(value, False) + End Set + End Property + + Private Sub SetSelection(value As Boolean, raiseEventOnParent As Boolean) + If EnableSelection Then + If _Selected <> value Then + _Selected = value + RaiseEvent SelectedChanged(Me, New EventArgs) + If raiseEventOnParent Then + Parent.RaiseSelectionChanged() + End If + End If + Else + _Selected = False + End If + End Sub + + Public Property Width As Single + Get + Return Size.Width + End Get + Set(value As Single) + Size = New SizeF(value, Size.Height) + End Set + End Property + Public Property Height As Single + Get + Return Size.Height + End Get + Set(value As Single) + Size = New SizeF(Size.Width, value) + End Set + End Property + + Public Property X As Single + Get + Return Location.X + End Get + Set(value As Single) + Location = New PointF(value, Location.Y) + End Set + End Property + Public Property Y As Single + Get + Return Location.Y + End Get + Set(value As Single) + Location = New PointF(Location.X, value) + End Set + End Property + + Public Property Text As String + Get + Return _Text + End Get + Set(value As String) + _Text = value + End Set + End Property + + Public Property Rectangle As RectangleF + Get + Return New RectangleF(Location, Size) + End Get + Set(value As RectangleF) + Location = value.Location + Size = value.Size + End Set + End Property + + Public Property EnableSelection As Boolean + Get + Return _EnableSelection + End Get + Set(value As Boolean) + _EnableSelection = value + If Not value AndAlso Not _Visible Then EnableResize = False + If Not value Then Selected = False + End Set + End Property + + Public Property RectangleExtended As Rectangle + Get + Return New Rectangle(X - 12, + Y - 12, + Width + 12 + 12, + Height + 12 + 12) + End Get + Set(value As Rectangle) + X = value.X + 12 + Y = value.Y + 12 + Width = value.Width - 12 - 12 + Height = value.Height - 12 - 12 + End Set + End Property + + Public Sub FitSizeToText() + If Parent Is Nothing Then + Throw New Exception("You have to put that PaintingObject to a PaintingControl before.") + End If + + Dim g As Graphics = Parent.CreateGraphics() + Dim newSize As SizeF = g.MeasureString(Text, TextFont) + SizeDirect = newSize + New SizeF(1, 0) + End Sub + + Public Sub SetBounds(x As Integer, y As Integer, width As Integer, height As Integer) + Location = New Point(x, y) + Size = New Size(width, height) + End Sub + + Public Property Left As Integer + Get + Return X + End Get + Set(value As Integer) + X = value + End Set + End Property + + Public Property Top() As Integer + Get + Return Y + End Get + Set(value As Integer) + Y = value + End Set + End Property + + Public ReadOnly Property Right As Integer + Get + Return X + Width + End Get + End Property + + Public ReadOnly Property Bottom() As Integer + Get + Return Y + Height + End Get + End Property + + Public Property EnableResize As Boolean + Get + If resizeEngine Is Nothing Then + Return False + Else + Return resizeEngine.Enabled + End If + End Get + Set(value As Boolean) + If resizeEngine Is Nothing AndAlso value Then + resizeEngine = New PaintingObjectResizing(Me) + ElseIf resizeEngine IsNot Nothing Then + resizeEngine.Enabled = value + End If + End Set + End Property + + Public Sub Remove() + Parent?.PaintingObjects.Remove(Me) + End Sub + + Public Sub AutoArrangeToGrid() + If Parent?.GridEnabled AndAlso AutoAlignToGrid Then + ArrangeToGrid() + End If + End Sub + + Public Sub ArrangeToGrid() + If Parent IsNot Nothing Then + Parent.ArrangeToGrid(Me) + If Not Parent.StopDrawing Then Parent.Refresh() + End If + End Sub + + Public Sub Draw(e As PaintEventArgs) + Draw(e, PointF.Empty) + End Sub + + Public Sub Draw(e As PaintEventArgs, offset As PointF) + Draw(e.Graphics, offset) + + If Visible Then + RaisePaint(e) + End If + End Sub + + Public Sub Draw(g As Graphics, offset As PointF) + If Visible Then + Dim poevargs As New PaintingObjectPaintEventArgs(Me, g, offset) + + For Each dm As DelegateDrawPaintingObjectMethode In DrawMethodes + dm?.Invoke(poevargs) + Next + + If Selected AndAlso DrawSelectionMethode IsNot Nothing Then + DrawSelectionMethode?.Invoke(poevargs) + End If + End If + End Sub + + Public Function Clone() As Object Implements ICloneable.Clone + Return Clone(True) + End Function + + Public Function Clone(includePinnedObject As Boolean) As Object + Dim obj As New PaintingObject + Dim t As Type = Me.GetType + Dim blackField As New List(Of String) From { + NameOf(_PinnedObjects), + NameOf(resizeEngine), + NameOf(_Parent), + NameOf(BufferedImage) + } + + Dim fields As FieldInfo() = t.GetFields(BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.IgnoreCase Or BindingFlags.Instance) + For Each field As FieldInfo In fields + If Not blackField.Contains(field.Name) Then + field.SetValue(obj, field.GetValue(Me)) + End If + Next + + If includePinnedObject Then + obj.PinnedObjects.AddRange(PinnedObjects) + End If + + obj.EnableResize = EnableResize + + Return obj + End Function + + + Public Sub BringToFront() + Layering.BringToTop() + End Sub + + + Public Sub SendToBack() + Layering.SendToBack() + End Sub + + Public Sub ResetImageBuffer() + BufferedImage = Nothing + End Sub + +End Class + +Public Class PaintingObjectList + Inherits List(Of PaintingObject) + + Friend ReadOnly Property MyParent As PaintingControl + Friend Property EnableRaisingEvents As Boolean = True + Public ReadOnly Property Layering As New PaintingObjectListLayering(Me) + + Public Sub New() + Me.New(Nothing) + End Sub + + Public Sub New(parent As PaintingControl) + MyParent = parent + End Sub + + Public Overloads Sub Add(item As PaintingObject) + item.Parent = myParent + MyBase.Add(item) + item.AutoArrangeToGrid() + If EnableRaisingEvents Then + MyParent?.RaisePaintingObjectAdded(New PaintingObjectEventArgs({item})) + End If + End Sub + + Public Overloads Sub AddRange(items As PaintingObject()) + For Each item As PaintingObject In items + item.Parent = myParent + Next + MyBase.AddRange(items) + For Each item As PaintingObject In items + item.AutoArrangeToGrid() + Next + If EnableRaisingEvents Then + MyParent?.RaisePaintingObjectAdded(New PaintingObjectEventArgs(items)) + End If + End Sub + + Public Overloads Sub Insert(index As Integer, item As PaintingObject) + item.Parent = myParent + MyBase.Insert(index, item) + myParent?.AutoArrangeToGrid() + If EnableRaisingEvents Then + MyParent?.RaisePaintingObjectAdded(New PaintingObjectEventArgs({item})) + End If + End Sub + + Public Overloads Sub Remove(item As PaintingObject) + item.Parent = Nothing + MyBase.Remove(item) + If EnableRaisingEvents Then + MyParent?.RaisePaintingObjectRemoved(New PaintingObjectEventArgs({item})) + End If + End Sub + + Public Overloads Sub RemoveAt(index As Integer) + Me(index).Parent = Nothing + Dim item As PaintingObject = Me(index) + MyBase.RemoveAt(index) + If EnableRaisingEvents Then + MyParent?.RaisePaintingObjectRemoved(New PaintingObjectEventArgs({item})) + End If + End Sub + +End Class + +Public Enum PaintingObjectType + Custom = 0 + Text = 1 + Picture = 2 + Line = 4 + Triangle = 8 + Rectangle = 16 + Elipse = 32 +End Enum + +Public Enum ImageSizeMode + Fit + Zoom + Original +End Enum + +Public Enum TextPosition + HLeft = &H1 + HRight = &H2 + HCenter = &H4 + VUp = &H10 + VDown = &H20 + VCenter = &H40 + FullCenter = HCenter Or VCenter +End Enum diff --git a/Pilz.UI/PaintingControl/PaintingObjectLayering.vb b/Pilz.UI/PaintingControl/PaintingObjectLayering.vb new file mode 100644 index 0000000..f56e4ac --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingObjectLayering.vb @@ -0,0 +1,85 @@ +Public Class PaintingObjectLayering + + Public ReadOnly Property PaintingObject As PaintingObject + + ''' + ''' Get the current object list from the painting object. + ''' + ''' Returns the current object list from the painting object. + Public ReadOnly Property ObjectList As PaintingObjectList + Get + Return PaintingObject.Parent.PaintingObjects + End Get + End Property + + ''' + ''' Create a new instance of object layer managing. + ''' + ''' + Public Sub New(obj As PaintingObject) + PaintingObject = obj + End Sub + + ''' + ''' Moves the object by the given number of indicies. + ''' + ''' The number how many objects it should be moved. + Public Sub MoveObject(count As Integer) + Dim oldIndex As Integer = ObjectList.IndexOf(PaintingObject) + Dim newIndex As Integer = oldIndex + count + MoveObjectTo(newIndex) + End Sub + + ''' + ''' Moves the object to the new index. + ''' + ''' + Public Sub MoveObjectTo(newIndex As Integer) + Dim list As PaintingObjectList = ObjectList + + 'Check & make index valid + If newIndex >= ObjectList.Count Then + newIndex = ObjectList.Count - 1 + ElseIf newIndex < 0 Then + newIndex = 0 + End If + + 'Remove object + list.Remove(PaintingObject) + + 'Insert object at new index + list.Insert(newIndex, PaintingObject) + + 'Order all objects again + list.Layering.OrderAll() + End Sub + + ''' + ''' Moves the object to the front. + ''' + Public Sub BringToTop() + MoveObjectTo(ObjectList.Count - 1) + End Sub + + ''' + ''' Moves the object to the back. + ''' + Public Sub SendToBack() + MoveObjectTo(0) + End Sub + + ''' + ''' Moves the object fordward by one + ''' + Public Sub OneToTop() + MoveObject(+1) + End Sub + + ''' + ''' Moves the object backward by one + ''' + Public Sub OneToBack() + MoveObject(-1) + End Sub + +End Class diff --git a/Pilz.UI/PaintingControl/PaintingObjectListLayering.vb b/Pilz.UI/PaintingControl/PaintingObjectListLayering.vb new file mode 100644 index 0000000..64100ec --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingObjectListLayering.vb @@ -0,0 +1,73 @@ +Public Class PaintingObjectListLayering + + + Public ReadOnly Property ObjectList As PaintingObjectList + Public ReadOnly Property Conditions As New Dictionary(Of Integer, Func(Of PaintingObject, Boolean)) + + ''' + ''' Get the order function will checkout the conditions. + ''' + ''' Returns true, if conditions are aviable, otherwise false. + Public ReadOnly Property EnableConditions As Boolean + Get + Return Conditions.Any + End Get + End Property + + ''' + ''' Create a new instance of object list layer managing. + ''' + ''' + Public Sub New(list As PaintingObjectList) + ObjectList = list + End Sub + + ''' + ''' Order all objects using the conditions. If no conditions are setted, this method will do nothing. + ''' + Public Sub OrderAll() + If EnableConditions Then + OrderAllPrivate() + End If + End Sub + + Private Sub OrderAllPrivate() + Dim list As PaintingObjectList = ObjectList + Dim listOld As List(Of PaintingObject) = list.ToList + Dim toRemove As New List(Of PaintingObject) + + 'Disable raising events + ObjectList.EnableRaisingEvents = False + + 'Clear list + list.Clear() + + 'Add ordered + For Each kvp In Conditions.OrderBy(Function(n) n.Key) + Dim func = kvp.Value + + For Each obj As PaintingObject In listOld + If func(obj) Then + 'Add to list + list.Add(obj) + + 'Add to remove + toRemove.Add(obj) + End If + Next + + 'Remove remembered objects + For Each obj As PaintingObject In toRemove + listOld.Remove(obj) + Next + toRemove.Clear() + Next + + 'Enable raising events + ObjectList.EnableRaisingEvents = True + + 'Refresh + ObjectList.MyParent?.Refresh() + End Sub + +End Class diff --git a/Pilz.UI/PaintingControl/PaintingObjectResizing.vb b/Pilz.UI/PaintingControl/PaintingObjectResizing.vb new file mode 100644 index 0000000..002e303 --- /dev/null +++ b/Pilz.UI/PaintingControl/PaintingObjectResizing.vb @@ -0,0 +1,171 @@ +Imports System.Drawing +Imports System.Windows.Forms +Imports Newtonsoft.Json +Imports Pilz.Drawing + + Friend Class PaintingObjectResizing + + Private WithEvents mObj As PaintingObject + Private WithEvents mObjParent As Control = Nothing + Private WithEvents mObjControl As Control = Nothing + Private mMouseDown As Boolean = False + Private mEdge As EdgeEnum = EdgeEnum.None + Private mWidth As Integer = 4 + Private qWidth As Integer = 4 * 4 + Private rect As New Rectangle + + Public Property Enabled As Boolean = True + Public Property MinimumSize As New SizeF(15, 15) + + Private Enum EdgeEnum + None + Right + Left + Top + Bottom + TopLeft + TopRight + BottomLeft + BottomRight + End Enum + + Public ReadOnly Property IsResizing As Boolean + Get + Return mMouseDown AndAlso mEdge <> EdgeEnum.None + End Get + End Property + + Public Sub New(obj As PaintingObject) + mObj = obj + mObjControl = mObj.Parent + End Sub + + Shared Function ApplyToControl(obj As PaintingObject) As PaintingObjectResizing + Return New PaintingObjectResizing(obj) + End Function + + Private Sub mControl_MouseDown(sender As Object, e As MouseEventArgs) Handles mObj.MouseDown + If e.Button = System.Windows.Forms.MouseButtons.Left Then + mMouseDown = True + End If + End Sub + + Private Sub mControl_MouseUp(sender As Object, e As MouseEventArgs) Handles mObj.MouseUp + mMouseDown = False + + If mObj.Selected Then + mObj.AutoArrangeToGrid() + End If + End Sub + + Private Sub KeepInRange(ByRef size As SizeF) + If size.Height < MinimumSize.Height OrElse size.Width < MinimumSize.Width Then + size = New SizeF(Math.Max(size.Width, MinimumSize.Width), + Math.Max(size.Height, MinimumSize.Height)) + End If + End Sub + + Private Sub mControl_MouseMove(sender As Object, e As MouseEventArgs) Handles mObjControl.MouseMove + + If mMouseDown AndAlso mEdge <> EdgeEnum.None Then + + Dim eX As Integer = e.X + mObj.Parent.Offset.X + Dim eY As Integer = e.Y + mObj.Parent.Offset.Y + + Select Case mEdge + Case EdgeEnum.TopLeft + mObj.SetBounds(eX, eY, mObj.Width + (mObj.Left - eX), mObj.Height + (mObj.Top - eY)) + Case EdgeEnum.TopRight + mObj.SetBounds(mObj.Left, eY, eX - mObj.Left, mObj.Height + (mObj.Top - eY)) + Case EdgeEnum.BottomRight + mObj.SetBounds(mObj.Left, mObj.Top, eX - mObj.Left, eY - mObj.Top) + Case EdgeEnum.BottomLeft + mObj.SetBounds(eX, mObj.Top, mObj.Width + (mObj.Left - eX), eY - mObj.Top) + Case EdgeEnum.Left + mObj.SetBounds(eX, mObj.Top, mObj.Width + (mObj.Left - eX), mObj.Height) + Case EdgeEnum.Right + mObj.SetBounds(mObj.Left, mObj.Top, eX - mObj.Left, mObj.Height) + Case EdgeEnum.Top + mObj.SetBounds(mObj.Left, eY, mObj.Width, mObj.Height + (mObj.Top - eY)) + Case EdgeEnum.Bottom + mObj.SetBounds(mObj.Left, mObj.Top, mObj.Width, eY - mObj.Top) + End Select + + KeepInRange(mObj.Size) + + ElseIf Not mMouseDown Then + + Dim eX As Integer = e.X - mObj.X + mObj.Parent.Offset.X + Dim eY As Integer = e.Y - mObj.Y + mObj.Parent.Offset.Y + Dim eLocation As New Point(eX, eY) + Dim extRect As RectangleF = mObj.RectangleExtended + Dim oldRect As RectangleF = mObj.Rectangle + + Dim newRect As New RectangleF + newRect.X = extRect.X - oldRect.X + newRect.Y = extRect.Y - oldRect.Y + newRect.Width = (extRect.Width - oldRect.Width) / 2 + newRect.Height = (extRect.Height - oldRect.Height) / 2 + + Dim setToNone As Boolean = False + + If Enabled Then + Select Case True + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(newRect.X, newRect.Y, newRect.Width, newRect.Height)) + mObj.Cursor = Cursors.SizeNWSE + mEdge = EdgeEnum.TopLeft + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(mObj.Width, newRect.Y, newRect.Width, newRect.Height)) + mObj.Cursor = Cursors.SizeNESW + mEdge = EdgeEnum.TopRight + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(mObj.Width, mObj.Height, newRect.Width, newRect.Height)) + mObj.Cursor = Cursors.SizeNWSE + mEdge = EdgeEnum.BottomRight + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(newRect.X, mObj.Height, newRect.Width, newRect.Height)) + mObj.Cursor = Cursors.SizeNESW + mEdge = EdgeEnum.BottomLeft + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(-newRect.Width, 0, newRect.Width, mObj.Height)) + mObj.Cursor = Cursors.SizeWE + mEdge = EdgeEnum.Left + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(mObj.Width, 0, newRect.Width, mObj.Height)) + mObj.Cursor = Cursors.SizeWE + mEdge = EdgeEnum.Right + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(0, -newRect.Height, mObj.Width, newRect.Height)) + mObj.Cursor = Cursors.SizeNS + mEdge = EdgeEnum.Top + Case HelpfulDrawingFunctions.IsPointInRectangle(eLocation, New Rectangle(0, mObj.Height, mObj.Width, newRect.Height)) + mObj.Cursor = Cursors.SizeNS + mEdge = EdgeEnum.Bottom + Case Else + setToNone = True + End Select + Else + setToNone = True + End If + + If setToNone Then + mObj.Cursor = Cursors.Default + mEdge = EdgeEnum.None + End If + End If + End Sub + + Private Sub mControl_Paint(sender As PaintingObject, e As PaintEventArgs) Handles mObj.Paint + 'e.Graphics.FillRectangle(brush, rect) + End Sub + + Private Sub mControl_MouseLeave(ByVal sender As PaintingObject, ByVal e As EventArgs) Handles mObj.SelectedChanged + If Not sender.Selected Then + mEdge = EdgeEnum.None + End If + End Sub + + Private Sub mObjParent_ParentChanged(sender As Object, e As EventArgs) Handles mObjControl.ParentChanged + mObjParent = mObjControl.Parent + End Sub + + Private Sub mObj_ParentChanged(sender As PaintingObject, e As EventArgs) Handles mObj.ParentChanged + mObjControl = mObj.Parent + mObjParent = mObjControl?.Parent + End Sub + +End Class diff --git a/Pilz.UI/Pilz.UI-NuGet/PaintingControls.nuspec b/Pilz.UI/Pilz.UI-NuGet/PaintingControls.nuspec new file mode 100644 index 0000000..dba8132 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/PaintingControls.nuspec @@ -0,0 +1,27 @@ + + + + PaintingControls + 1.0.0.0 + PaintingControls + Pilzinsel64 + Pilzinsel64 + https://github.com/dotnet/corefx/blob/master/LICENSE.TXT + https://www.nuget.org/packages/PaintingControls/ + false + Create an PaintingControl and add several PaintingObjects containing visual objects. +The PaintingControl has some user actions that can be enabled/disabled. +Also you can completly customize the drawing process of an PaintingObject. +It is very simple to use. + + Copyright © Pilzinsel64 2018 + control object paint visual + + + + PaintingControls is a simple way to paint and control visual objects. + + + + + \ No newline at end of file diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net45/PaintingControls.dll b/Pilz.UI/Pilz.UI-NuGet/lib/net45/PaintingControls.dll new file mode 100644 index 0000000..c199143 Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/lib/net45/PaintingControls.dll differ diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net45/PaintingControls.xml b/Pilz.UI/Pilz.UI-NuGet/lib/net45/PaintingControls.xml new file mode 100644 index 0000000..9225e96 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/lib/net45/PaintingControls.xml @@ -0,0 +1,32 @@ + + + + +PaintingControls + + + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + + + + + diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net451/PaintingControls.dll b/Pilz.UI/Pilz.UI-NuGet/lib/net451/PaintingControls.dll new file mode 100644 index 0000000..e32f7bf Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/lib/net451/PaintingControls.dll differ diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net451/PaintingControls.xml b/Pilz.UI/Pilz.UI-NuGet/lib/net451/PaintingControls.xml new file mode 100644 index 0000000..f75d8c2 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/lib/net451/PaintingControls.xml @@ -0,0 +1,32 @@ + + + + +PaintingControls + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + + + + + diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net452/PaintingControls.dll b/Pilz.UI/Pilz.UI-NuGet/lib/net452/PaintingControls.dll new file mode 100644 index 0000000..80ddf7f Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/lib/net452/PaintingControls.dll differ diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net452/PaintingControls.xml b/Pilz.UI/Pilz.UI-NuGet/lib/net452/PaintingControls.xml new file mode 100644 index 0000000..f75d8c2 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/lib/net452/PaintingControls.xml @@ -0,0 +1,32 @@ + + + + +PaintingControls + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + + + + + diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net46/PaintingControls.dll b/Pilz.UI/Pilz.UI-NuGet/lib/net46/PaintingControls.dll new file mode 100644 index 0000000..0ec52d9 Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/lib/net46/PaintingControls.dll differ diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net46/PaintingControls.xml b/Pilz.UI/Pilz.UI-NuGet/lib/net46/PaintingControls.xml new file mode 100644 index 0000000..f75d8c2 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/lib/net46/PaintingControls.xml @@ -0,0 +1,32 @@ + + + + +PaintingControls + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + + + + + diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net461/PaintingControls.dll b/Pilz.UI/Pilz.UI-NuGet/lib/net461/PaintingControls.dll new file mode 100644 index 0000000..561517b Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/lib/net461/PaintingControls.dll differ diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net461/PaintingControls.xml b/Pilz.UI/Pilz.UI-NuGet/lib/net461/PaintingControls.xml new file mode 100644 index 0000000..f75d8c2 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/lib/net461/PaintingControls.xml @@ -0,0 +1,32 @@ + + + + +PaintingControls + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + + + + + diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net471/PaintingControls.dll b/Pilz.UI/Pilz.UI-NuGet/lib/net471/PaintingControls.dll new file mode 100644 index 0000000..16c5c19 Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/lib/net471/PaintingControls.dll differ diff --git a/Pilz.UI/Pilz.UI-NuGet/lib/net471/PaintingControls.xml b/Pilz.UI/Pilz.UI-NuGet/lib/net471/PaintingControls.xml new file mode 100644 index 0000000..f75d8c2 --- /dev/null +++ b/Pilz.UI/Pilz.UI-NuGet/lib/net471/PaintingControls.xml @@ -0,0 +1,32 @@ + + + + +PaintingControls + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Sorg dafür, dass Events durch dieses Control durchdringen zum Parnet-Control. + + + + + diff --git a/Pilz.UI/Pilz.UI-NuGet/nuget.exe b/Pilz.UI/Pilz.UI-NuGet/nuget.exe new file mode 100644 index 0000000..0cc4088 Binary files /dev/null and b/Pilz.UI/Pilz.UI-NuGet/nuget.exe differ diff --git a/Pilz.UI/Pilz.UI.vbproj b/Pilz.UI/Pilz.UI.vbproj new file mode 100644 index 0000000..772d1bb --- /dev/null +++ b/Pilz.UI/Pilz.UI.vbproj @@ -0,0 +1,156 @@ + + + + + Debug + AnyCPU + {827C60BF-4D92-4D39-92F0-4285923266A1} + Library + Pilz.UI + Pilz.UI + 512 + Windows + v4.5 + + + + true + full + true + true + bin\Debug\ + Pilz.UI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + none + false + true + true + bin\Release\ + Pilz.UI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + true + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x86\Debug\ + Pilz.UI.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + full + x86 + MinimumRecommendedRules.ruleset + true + + + true + bin\x86\Release\ + true + Pilz.UI.xml + true + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + x86 + MinimumRecommendedRules.ruleset + + + + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UserControl + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + PaintingControl.vb + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + {1a0b8106-2449-4908-b5e1-a00d8e9cf8f6} + Pilz.Drawing + + + + \ No newline at end of file diff --git a/Pilz.UI/Utilities/DrawingControl.vb b/Pilz.UI/Utilities/DrawingControl.vb new file mode 100644 index 0000000..02b44a8 --- /dev/null +++ b/Pilz.UI/Utilities/DrawingControl.vb @@ -0,0 +1,28 @@ +Imports System.Runtime.CompilerServices +Imports System.Windows.Forms + +Namespace Utils + + Public Module DrawingControl + + Private Const WM_SETREDRAW = 11 + + + Public Sub SuspendDrawing(control As Control) + SendMessage(control.Handle, WM_SETREDRAW, False, 0) + End Sub + + + Public Sub ResumeDrawing(control As Control) + ResumeDrawing(control, True) + End Sub + + + Public Sub ResumeDrawing(control As Control, redraw As Boolean) + SendMessage(control.Handle, WM_SETREDRAW, True, 0) + If redraw Then control.Refresh() + End Sub + + End Module + +End Namespace diff --git a/Pilz.UI/Utilities/User32Bridge.vb b/Pilz.UI/Utilities/User32Bridge.vb new file mode 100644 index 0000000..be8d6b6 --- /dev/null +++ b/Pilz.UI/Utilities/User32Bridge.vb @@ -0,0 +1,5 @@ +Public Module User32Bridge + + Friend Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, Msg As Integer, wParam As Boolean, lParam As Integer) As Integer + +End Module diff --git a/Pilz.UI/packages.config b/Pilz.UI/packages.config new file mode 100644 index 0000000..7f83af3 --- /dev/null +++ b/Pilz.UI/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Pilz.Win32/Mapped/FileInfo.vb b/Pilz.Win32/Mapped/FileInfo.vb new file mode 100644 index 0000000..fe3bce4 --- /dev/null +++ b/Pilz.Win32/Mapped/FileInfo.vb @@ -0,0 +1,22 @@ +Imports System.Drawing +Imports Pilz.Win32.Native + +Namespace Mapped + + Public Class FileInfo + + Public ReadOnly Property Icon As Icon + Public ReadOnly Property SystemIconIndex As Integer + Public ReadOnly Property Displayname As String + Public ReadOnly Property Typename As String + + Friend Sub New(info As SHFILEINFO) + Icon = Icon.FromHandle(info.hIcon) + SystemIconIndex = info.iIcon + Displayname = info.szDisplayName + Typename = info.szTypeName + End Sub + + End Class + +End Namespace diff --git a/Pilz.Win32/My Project/Application.Designer.vb b/Pilz.Win32/My Project/Application.Designer.vb new file mode 100644 index 0000000..8ab460b --- /dev/null +++ b/Pilz.Win32/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz.Win32/My Project/Application.myapp b/Pilz.Win32/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz.Win32/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz.Win32/My Project/AssemblyInfo.vb b/Pilz.Win32/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..7215404 --- /dev/null +++ b/Pilz.Win32/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz.Win32/My Project/Resources.Designer.vb b/Pilz.Win32/My Project/Resources.Designer.vb new file mode 100644 index 0000000..75efaf8 --- /dev/null +++ b/Pilz.Win32/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Win32.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz.Win32/My Project/Resources.resx b/Pilz.Win32/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz.Win32/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz.Win32/My Project/Settings.Designer.vb b/Pilz.Win32/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0cc5b4a --- /dev/null +++ b/Pilz.Win32/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.Win32.My.MySettings + Get + Return Global.Pilz.Win32.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz.Win32/My Project/Settings.settings b/Pilz.Win32/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz.Win32/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz.Win32/Native/SHFILEINFO.vb b/Pilz.Win32/Native/SHFILEINFO.vb new file mode 100644 index 0000000..96242b8 --- /dev/null +++ b/Pilz.Win32/Native/SHFILEINFO.vb @@ -0,0 +1,15 @@ +Imports System.Runtime.InteropServices + +Namespace Native + + Friend Structure SHFILEINFO + Public hIcon As IntPtr + Public iIcon As Integer + Public dwAttributes As UInteger + + Public szDisplayName As String + + Public szTypeName As String + End Structure + +End Namespace diff --git a/Pilz.Win32/Pilz.Win32.vbproj b/Pilz.Win32/Pilz.Win32.vbproj new file mode 100644 index 0000000..2de4aac --- /dev/null +++ b/Pilz.Win32/Pilz.Win32.vbproj @@ -0,0 +1,107 @@ + + + + + Debug + AnyCPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497} + Library + Pilz.Win32 + Pilz.Win32 + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.Win32.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.Win32.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/Pilz.sln b/Pilz.sln new file mode 100644 index 0000000..f366730 --- /dev/null +++ b/Pilz.sln @@ -0,0 +1,121 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.329 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz", "Pilz\Pilz.vbproj", "{277D2B83-7613-4C49-9CAB-E080195A6E0C}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Drawing", "Pilz.Drawing\Pilz.Drawing.vbproj", "{1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.UI", "Pilz.UI\Pilz.UI.vbproj", "{827C60BF-4D92-4D39-92F0-4285923266A1}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Collections", "Pilz.Collections\Pilz.Collections.vbproj", "{E4B2D294-8479-4014-942D-0B460E453DEA}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Threading", "Pilz.Threading\Pilz.Threading.vbproj", "{D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.IO", "Pilz.IO\Pilz.IO.vbproj", "{35591965-8339-41A2-8CD3-962ED54670AC}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Cryptography", "Pilz.Cryptography\Pilz.Cryptography.vbproj", "{DF980F5D-820C-4CD3-A865-C40791BF7CE4}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Win32", "Pilz.Win32\Pilz.Win32.vbproj", "{0BE0428D-AC97-4812-ADFC-6D7D00AEE497}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Configuration", "Pilz.Configuration\Pilz.Configuration.vbproj", "{A56C6153-C61F-4B10-BE06-35EB0448CFDC}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Pilz.Reflection.PluginSystem", "Pilz.Reflection.PluginSystem\Pilz.Reflection.PluginSystem.vbproj", "{F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Debug|x86.ActiveCfg = Debug|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Debug|x86.Build.0 = Debug|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Release|Any CPU.Build.0 = Release|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Release|x86.ActiveCfg = Release|Any CPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C}.Release|x86.Build.0 = Release|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Debug|x86.ActiveCfg = Debug|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Debug|x86.Build.0 = Debug|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Release|Any CPU.Build.0 = Release|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Release|x86.ActiveCfg = Release|Any CPU + {1A0B8106-2449-4908-B5E1-A00D8E9CF8F6}.Release|x86.Build.0 = Release|Any CPU + {827C60BF-4D92-4D39-92F0-4285923266A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {827C60BF-4D92-4D39-92F0-4285923266A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {827C60BF-4D92-4D39-92F0-4285923266A1}.Debug|x86.ActiveCfg = Debug|x86 + {827C60BF-4D92-4D39-92F0-4285923266A1}.Debug|x86.Build.0 = Debug|x86 + {827C60BF-4D92-4D39-92F0-4285923266A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {827C60BF-4D92-4D39-92F0-4285923266A1}.Release|Any CPU.Build.0 = Release|Any CPU + {827C60BF-4D92-4D39-92F0-4285923266A1}.Release|x86.ActiveCfg = Release|x86 + {827C60BF-4D92-4D39-92F0-4285923266A1}.Release|x86.Build.0 = Release|x86 + {E4B2D294-8479-4014-942D-0B460E453DEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4B2D294-8479-4014-942D-0B460E453DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4B2D294-8479-4014-942D-0B460E453DEA}.Debug|x86.ActiveCfg = Debug|x86 + {E4B2D294-8479-4014-942D-0B460E453DEA}.Debug|x86.Build.0 = Debug|x86 + {E4B2D294-8479-4014-942D-0B460E453DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4B2D294-8479-4014-942D-0B460E453DEA}.Release|Any CPU.Build.0 = Release|Any CPU + {E4B2D294-8479-4014-942D-0B460E453DEA}.Release|x86.ActiveCfg = Release|x86 + {E4B2D294-8479-4014-942D-0B460E453DEA}.Release|x86.Build.0 = Release|x86 + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Debug|x86.ActiveCfg = Debug|x86 + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Debug|x86.Build.0 = Debug|x86 + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Release|Any CPU.Build.0 = Release|Any CPU + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Release|x86.ActiveCfg = Release|x86 + {D9C8655E-4F1C-4348-A51C-AB00FD9A14BB}.Release|x86.Build.0 = Release|x86 + {35591965-8339-41A2-8CD3-962ED54670AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35591965-8339-41A2-8CD3-962ED54670AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35591965-8339-41A2-8CD3-962ED54670AC}.Debug|x86.ActiveCfg = Debug|x86 + {35591965-8339-41A2-8CD3-962ED54670AC}.Debug|x86.Build.0 = Debug|x86 + {35591965-8339-41A2-8CD3-962ED54670AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35591965-8339-41A2-8CD3-962ED54670AC}.Release|Any CPU.Build.0 = Release|Any CPU + {35591965-8339-41A2-8CD3-962ED54670AC}.Release|x86.ActiveCfg = Release|x86 + {35591965-8339-41A2-8CD3-962ED54670AC}.Release|x86.Build.0 = Release|x86 + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Debug|x86.ActiveCfg = Debug|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Debug|x86.Build.0 = Debug|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Release|Any CPU.Build.0 = Release|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Release|x86.ActiveCfg = Release|Any CPU + {DF980F5D-820C-4CD3-A865-C40791BF7CE4}.Release|x86.Build.0 = Release|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Debug|x86.ActiveCfg = Debug|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Debug|x86.Build.0 = Debug|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Release|Any CPU.Build.0 = Release|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Release|x86.ActiveCfg = Release|Any CPU + {0BE0428D-AC97-4812-ADFC-6D7D00AEE497}.Release|x86.Build.0 = Release|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Debug|x86.ActiveCfg = Debug|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Debug|x86.Build.0 = Debug|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Release|Any CPU.Build.0 = Release|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Release|x86.ActiveCfg = Release|Any CPU + {A56C6153-C61F-4B10-BE06-35EB0448CFDC}.Release|x86.Build.0 = Release|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Debug|x86.ActiveCfg = Debug|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Debug|x86.Build.0 = Debug|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Release|Any CPU.Build.0 = Release|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Release|x86.ActiveCfg = Release|Any CPU + {F7975470-4CA3-4FAB-BB6A-A3AF3978ABB7}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {728F13B2-34E5-46C6-BB39-3203EE238C2A} + EndGlobalSection +EndGlobal diff --git a/Pilz/My Project/Application.Designer.vb b/Pilz/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Pilz/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Pilz/My Project/Application.myapp b/Pilz/My Project/Application.myapp new file mode 100644 index 0000000..758895d --- /dev/null +++ b/Pilz/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/Pilz/My Project/AssemblyInfo.vb b/Pilz/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..900251e --- /dev/null +++ b/Pilz/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/Pilz/My Project/Resources.Designer.vb b/Pilz/My Project/Resources.Designer.vb new file mode 100644 index 0000000..a205072 --- /dev/null +++ b/Pilz/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Pilz/My Project/Resources.resx b/Pilz/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Pilz/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Pilz/My Project/Settings.Designer.vb b/Pilz/My Project/Settings.Designer.vb new file mode 100644 index 0000000..e6de5b2 --- /dev/null +++ b/Pilz/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Pilz.My.MySettings + Get + Return Global.Pilz.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Pilz/My Project/Settings.settings b/Pilz/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Pilz/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Pilz/Pilz.vbproj b/Pilz/Pilz.vbproj new file mode 100644 index 0000000..d0f8cda --- /dev/null +++ b/Pilz/Pilz.vbproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {277D2B83-7613-4C49-9CAB-E080195A6E0C} + Library + Pilz + Pilz + 512 + Windows + v4.5 + true + + + true + full + true + true + bin\Debug\ + Pilz.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + Pilz.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file