Merge branch 'master' of https://gitlab.com/Pilzinsel64/pilz-framework
This commit is contained in:
@@ -11,20 +11,19 @@ namespace Pilz.Cryptography
|
|||||||
public class SecureString
|
public class SecureString
|
||||||
{
|
{
|
||||||
public static ICrypter DefaultCrypter { get; set; }
|
public static ICrypter DefaultCrypter { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public ICrypter Crypter { get; set; }
|
public ICrypter Crypter { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
|
||||||
public string EncryptedValue { get; set; }
|
public string EncryptedValue { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public string Value
|
public string Value
|
||||||
{
|
{
|
||||||
get => GetCrypter().Decrypt(EncryptedValue);
|
get => GetCrypter()?.Decrypt(EncryptedValue);
|
||||||
set => EncryptedValue = GetCrypter().Encrypt(value);
|
set => EncryptedValue = GetCrypter().Encrypt(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
private SecureString(JsonConstructorAttribute dummyAttribute)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public SecureString() :
|
public SecureString() :
|
||||||
this(string.Empty, true)
|
this(string.Empty, true)
|
||||||
{
|
{
|
||||||
@@ -73,7 +72,7 @@ namespace Pilz.Cryptography
|
|||||||
public static implicit operator string(SecureString value) => value?.Value;
|
public static implicit operator string(SecureString value) => value?.Value;
|
||||||
public static implicit operator SecureString(string value) => new SecureString(value, false);
|
public static implicit operator SecureString(string value) => new SecureString(value, false);
|
||||||
|
|
||||||
public static bool operator ==(SecureString left, SecureString right) => left.EncryptedValue == right.EncryptedValue;
|
public static bool operator ==(SecureString left, SecureString right) => left?.EncryptedValue == right?.EncryptedValue;
|
||||||
public static bool operator !=(SecureString left, SecureString right) => left.EncryptedValue != right.EncryptedValue;
|
public static bool operator !=(SecureString left, SecureString right) => left?.EncryptedValue != right?.EncryptedValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,13 @@ namespace Pilz.Json.Converters
|
|||||||
var idString = serializer.Deserialize<string>(reader);
|
var idString = serializer.Deserialize<string>(reader);
|
||||||
SecureString id;
|
SecureString id;
|
||||||
|
|
||||||
if (existingValue is object)
|
if (existingValue is SecureString)
|
||||||
|
{
|
||||||
id = (SecureString)existingValue;
|
id = (SecureString)existingValue;
|
||||||
else
|
|
||||||
id = new SecureString();
|
|
||||||
|
|
||||||
id.EncryptedValue = idString;
|
id.EncryptedValue = idString;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
id = new SecureString(idString, true);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,13 @@ namespace Pilz.Cryptography
|
|||||||
byte[] bytes = TextEncoding.GetBytes(key);
|
byte[] bytes = TextEncoding.GetBytes(key);
|
||||||
byte[] array = sha1CryptoServiceProvider.ComputeHash(bytes);
|
byte[] array = sha1CryptoServiceProvider.ComputeHash(bytes);
|
||||||
|
|
||||||
var output = new byte[checked(length - 1 + 1)];
|
var output = new byte[length];
|
||||||
array.CopyTo(output, 0);
|
var lowerLength = Math.Min(array.Length, output.Length);
|
||||||
|
|
||||||
return array;
|
for (int i = 0; i < lowerLength; i++)
|
||||||
|
output[i] = array[i];
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string EncryptData(string plaintext)
|
private string EncryptData(string plaintext)
|
||||||
@@ -63,7 +66,7 @@ namespace Pilz.Cryptography
|
|||||||
|
|
||||||
public string Encrypt(string plainValue)
|
public string Encrypt(string plainValue)
|
||||||
{
|
{
|
||||||
return EncryptData(plainValue);
|
return EncryptData(plainValue ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Decrypt(string encryptedValue)
|
public string Decrypt(string encryptedValue)
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
Public Class PluginManager
|
Public Class PluginManager
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Gets or sets an indicator if an exception should throw on error while loading a plugin.
|
||||||
|
''' </summary>
|
||||||
|
''' <returns></returns>
|
||||||
|
Public Property ThrowOnError As Boolean = False
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' The name of the type where to search for Methods when loading a new Plugin.
|
''' The name of the type where to search for Methods when loading a new Plugin.
|
||||||
''' </summary>
|
''' </summary>
|
||||||
@@ -79,7 +85,11 @@ Public Class PluginManager
|
|||||||
If addToList Then Plugins.Add(filePath, plugin)
|
If addToList Then Plugins.Add(filePath, plugin)
|
||||||
Return plugin
|
Return plugin
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
If ThrowOnError Then
|
||||||
|
Throw
|
||||||
|
Else
|
||||||
Return Nothing
|
Return Nothing
|
||||||
|
End If
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|||||||
15
Pilz.UI/PaintingControl/ArrowLineCapProps.vb
Normal file
15
Pilz.UI/PaintingControl/ArrowLineCapProps.vb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Imports System.Drawing
|
||||||
|
Imports System.Drawing.Drawing2D
|
||||||
|
|
||||||
|
Public Class ArrowLineCapProps
|
||||||
|
Inherits LineCapProps
|
||||||
|
|
||||||
|
Public Property Size As New Size(10, 10)
|
||||||
|
Public Property IsFilles As Boolean = True
|
||||||
|
|
||||||
|
Friend Overrides Function Configure() As LineCapConfigurationArgs
|
||||||
|
Dim cap As New AdjustableArrowCap(Size.Width, Size.Height, IsFilles)
|
||||||
|
Return New LineCapConfigurationArgs(cap)
|
||||||
|
End Function
|
||||||
|
|
||||||
|
End Class
|
||||||
@@ -112,7 +112,22 @@ Public Class DefaultDrawMethodes
|
|||||||
|
|
||||||
Public Shared Sub DrawLine(e As PaintingObjectPaintEventArgs)
|
Public Shared Sub DrawLine(e As PaintingObjectPaintEventArgs)
|
||||||
Dim obj As PaintingObject = e.PaintingObject
|
Dim obj As PaintingObject = e.PaintingObject
|
||||||
Dim p2 As New Pen(obj.OutlineColor, obj.OutlineThicknes) With {.DashStyle = obj.OutlineDashStyle}
|
Dim p2 As New Pen(obj.OutlineColor, obj.OutlineThicknes) With {
|
||||||
|
.DashStyle = obj.OutlineDashStyle
|
||||||
|
}
|
||||||
|
|
||||||
|
If obj.LineEndCap IsNot Nothing Then
|
||||||
|
Dim args As LineCapConfigurationArgs = obj.LineEndCap.Configure
|
||||||
|
p2.StartCap = args.LineCap
|
||||||
|
p2.CustomStartCap = args.CustomLineCap
|
||||||
|
End If
|
||||||
|
|
||||||
|
If obj.LineStartCap IsNot Nothing Then
|
||||||
|
Dim args As LineCapConfigurationArgs = obj.LineStartCap.Configure
|
||||||
|
p2.EndCap = args.LineCap
|
||||||
|
p2.CustomEndCap = args.CustomLineCap
|
||||||
|
End If
|
||||||
|
|
||||||
p2.Alignment = PenAlignment.Center
|
p2.Alignment = PenAlignment.Center
|
||||||
Dim no As PointF = New PointF(e.X, e.Y)
|
Dim no As PointF = New PointF(e.X, e.Y)
|
||||||
e.Graphics.DrawLine(p2, no, no + obj.Size)
|
e.Graphics.DrawLine(p2, no, no + obj.Size)
|
||||||
|
|||||||
13
Pilz.UI/PaintingControl/DefaultLineCapProps.vb
Normal file
13
Pilz.UI/PaintingControl/DefaultLineCapProps.vb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Imports System.Drawing.Drawing2D
|
||||||
|
|
||||||
|
Public Class DefaultLineCapProps
|
||||||
|
Inherits LineCapProps
|
||||||
|
|
||||||
|
Public Property LineCap As LineCap = LineCap.Flat
|
||||||
|
Public Property CustomLineCap As CustomLineCap = Nothing
|
||||||
|
|
||||||
|
Friend Overrides Function Configure() As LineCapConfigurationArgs
|
||||||
|
Return New LineCapConfigurationArgs(LineCap, CustomLineCap)
|
||||||
|
End Function
|
||||||
|
|
||||||
|
End Class
|
||||||
21
Pilz.UI/PaintingControl/LineCapConfigurationArgs.vb
Normal file
21
Pilz.UI/PaintingControl/LineCapConfigurationArgs.vb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Imports System.Drawing.Drawing2D
|
||||||
|
|
||||||
|
Public Class LineCapConfigurationArgs
|
||||||
|
|
||||||
|
Public ReadOnly Property LineCap As LineCap
|
||||||
|
Public ReadOnly Property CustomLineCap As CustomLineCap
|
||||||
|
|
||||||
|
Public Sub New(lineCap As LineCap)
|
||||||
|
Me.New(lineCap, Nothing)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub New(customLineCap As CustomLineCap)
|
||||||
|
Me.New(Nothing, customLineCap)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub New(lineCap As LineCap, customLineCap As CustomLineCap)
|
||||||
|
Me.LineCap = lineCap
|
||||||
|
Me.CustomLineCap = customLineCap
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
End Class
|
||||||
7
Pilz.UI/PaintingControl/LineCapProps.vb
Normal file
7
Pilz.UI/PaintingControl/LineCapProps.vb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Imports System.Drawing
|
||||||
|
|
||||||
|
Public MustInherit Class LineCapProps
|
||||||
|
|
||||||
|
Friend MustOverride Function Configure() As LineCapConfigurationArgs
|
||||||
|
|
||||||
|
End Class
|
||||||
@@ -196,7 +196,7 @@ Public Class PaintingControl
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If pressedControl Then
|
If pressedAlt Then
|
||||||
|
|
||||||
calcOffset_MouseOnTab = New Point(e.X, e.Y)
|
calcOffset_MouseOnTab = New Point(e.X, e.Y)
|
||||||
calcOffset_LastOffset = Offset
|
calcOffset_LastOffset = Offset
|
||||||
@@ -281,7 +281,7 @@ Public Class PaintingControl
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
If calcOffset_IsActive Then
|
If calcOffset_IsActive Then
|
||||||
If pressedControl Then
|
If pressedAlt Then
|
||||||
CalcNewOffset(e.Location)
|
CalcNewOffset(e.Location)
|
||||||
Else
|
Else
|
||||||
calcOffset_IsActive = False
|
calcOffset_IsActive = False
|
||||||
@@ -314,7 +314,7 @@ Public Class PaintingControl
|
|||||||
|
|
||||||
Private Sub SaveObjectPositions(e As MouseEventArgs, objs As IList)
|
Private Sub SaveObjectPositions(e As MouseEventArgs, objs As IList)
|
||||||
For Each obj As PaintingObject In objs
|
For Each obj As PaintingObject In objs
|
||||||
If Not savedPos.ContainsKey(obj) Then
|
If Not obj.HardcodedLocation AndAlso Not savedPos.ContainsKey(obj) Then
|
||||||
savedPos.Add(obj, New PointF(e.X - obj.Location.X + Offset.X, e.Y - obj.Location.Y + Offset.Y))
|
savedPos.Add(obj, New PointF(e.X - obj.Location.X + Offset.X, e.Y - obj.Location.Y + Offset.Y))
|
||||||
SaveObjectPositions(e, obj.PinnedObjects)
|
SaveObjectPositions(e, obj.PinnedObjects)
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ Imports Newtonsoft.Json
|
|||||||
Public Property OutlineColor As Color = Color.DarkBlue
|
Public Property OutlineColor As Color = Color.DarkBlue
|
||||||
Public Property OutlineThicknes As Single = 1
|
Public Property OutlineThicknes As Single = 1
|
||||||
Public Property OutlineDashStyle As DashStyle = DashStyle.Solid
|
Public Property OutlineDashStyle As DashStyle = DashStyle.Solid
|
||||||
|
Public Property LineStartCap As LineCapProps = Nothing
|
||||||
|
Public Property LineEndCap As LineCapProps = Nothing
|
||||||
<JsonProperty>
|
<JsonProperty>
|
||||||
Private _Text As String = ""
|
Private _Text As String = ""
|
||||||
Public Property TextPosition As TextPosition = TextPosition.FullCenter
|
Public Property TextPosition As TextPosition = TextPosition.FullCenter
|
||||||
@@ -40,7 +42,8 @@ Imports Newtonsoft.Json
|
|||||||
<JsonIgnore> Public Property BufferedImage As Image = Nothing
|
<JsonIgnore> Public Property BufferedImage As Image = Nothing
|
||||||
Public Property ImageSizeMode As ImageSizeMode
|
Public Property ImageSizeMode As ImageSizeMode
|
||||||
Public Property ImageProperties As New PaintingObjectImageProperties
|
Public Property ImageProperties As New PaintingObjectImageProperties
|
||||||
Public Property Tag As String = Nothing
|
<JsonIgnore>
|
||||||
|
Public Property Tag As Object = Nothing
|
||||||
Public Property Name As String = ""
|
Public Property Name As String = ""
|
||||||
Public ReadOnly Property PinnedObjects As New List(Of PaintingObject)
|
Public ReadOnly Property PinnedObjects As New List(Of PaintingObject)
|
||||||
<JsonIgnore>
|
<JsonIgnore>
|
||||||
@@ -49,6 +52,7 @@ Imports Newtonsoft.Json
|
|||||||
Public ReadOnly Property DrawSelectionMethode As DelegateDrawPaintingObjectMethode = AddressOf DefaultDrawMethodes.DrawSelection
|
Public ReadOnly Property DrawSelectionMethode As DelegateDrawPaintingObjectMethode = AddressOf DefaultDrawMethodes.DrawSelection
|
||||||
Public Property Cursor As Cursor = Cursors.Default
|
Public Property Cursor As Cursor = Cursors.Default
|
||||||
Public Property HardcodedSize As Boolean = False
|
Public Property HardcodedSize As Boolean = False
|
||||||
|
Public Property HardcodedLocation As Boolean = False
|
||||||
<JsonProperty>
|
<JsonProperty>
|
||||||
Private _Visible As Boolean = True
|
Private _Visible As Boolean = True
|
||||||
<JsonProperty>
|
<JsonProperty>
|
||||||
@@ -181,6 +185,15 @@ Imports Newtonsoft.Json
|
|||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
<JsonIgnore> Public Property LocationDirect As PointF
|
||||||
|
Get
|
||||||
|
Return _Location
|
||||||
|
End Get
|
||||||
|
Set(value As PointF)
|
||||||
|
_Location = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
<JsonIgnore> Public Property Size As SizeF
|
<JsonIgnore> Public Property Size As SizeF
|
||||||
Get
|
Get
|
||||||
If Parent IsNot Nothing Then
|
If Parent IsNot Nothing Then
|
||||||
@@ -419,6 +432,20 @@ Imports Newtonsoft.Json
|
|||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
<JsonProperty(NameOf(Tag))>
|
||||||
|
Public Property TagString As String
|
||||||
|
Get
|
||||||
|
If TypeOf Tag Is String Then
|
||||||
|
Return Tag
|
||||||
|
Else
|
||||||
|
Return String.Empty
|
||||||
|
End If
|
||||||
|
End Get
|
||||||
|
Set(value As String)
|
||||||
|
Tag = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
Public Property EnableResize As Boolean
|
Public Property EnableResize As Boolean
|
||||||
Get
|
Get
|
||||||
If resizeEngine Is Nothing Then
|
If resizeEngine Is Nothing Then
|
||||||
@@ -454,7 +481,7 @@ Imports Newtonsoft.Json
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub Draw(e As PaintEventArgs)
|
Public Sub Draw(e As PaintEventArgs)
|
||||||
Draw(e, PointF.Empty)
|
Draw(e, e.ClipRectangle.Location)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub Draw(e As PaintEventArgs, offset As PointF)
|
Public Sub Draw(e As PaintEventArgs, offset As PointF)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Public Class PaintingObjectLayering
|
Public Class PaintingObjectLayering
|
||||||
|
|
||||||
<JsonProperty(NameOf(PaintingObject))>
|
'<JsonProperty(NameOf(PaintingObject))>
|
||||||
Private ReadOnly _PaintingObject As PaintingObject
|
Private ReadOnly _PaintingObject As PaintingObject
|
||||||
|
|
||||||
<JsonIgnore>
|
<JsonIgnore>
|
||||||
|
|||||||
Reference in New Issue
Block a user