190607 c1
- Add Pilz.Drawing.Drawing3D.OpenGLFactory - Fix small bugs in Pilz.UI.PaintingControl
This commit is contained in:
@@ -107,6 +107,7 @@ Public Class PaintingControl
|
||||
Set
|
||||
If _ZoomFactor <> Value Then
|
||||
_ZoomFactor = Value
|
||||
ResetAllBufferedImages()
|
||||
RaiseEvent ZoomFactorChanged(Me, New EventArgs)
|
||||
End If
|
||||
End Set
|
||||
@@ -116,6 +117,13 @@ Public Class PaintingControl
|
||||
DoubleBuffered = True
|
||||
End Sub
|
||||
|
||||
Private Sub ResetAllBufferedImages()
|
||||
For Each ob As PaintingObject In PaintingObjects
|
||||
ob.ResetImageBuffer()
|
||||
Next
|
||||
Refresh()
|
||||
End Sub
|
||||
|
||||
Private Sub CheckKeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown, Me.KeyUp
|
||||
pressedShift = e.Shift
|
||||
pressedControl = e.Control
|
||||
@@ -166,6 +174,7 @@ Public Class PaintingControl
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
If AutoSingleSelection Then
|
||||
Dim objtosel As PaintingObject = curObjMouseDown
|
||||
If objtosel?.EnableSelection Then
|
||||
@@ -218,8 +227,10 @@ Public Class PaintingControl
|
||||
|
||||
If _IsMovingObjects Then
|
||||
_IsMovingObjects = False
|
||||
For Each obj As PaintingObject In GetSelectedObjects()
|
||||
obj.RaiseMoved(New EventArgs)
|
||||
Next
|
||||
AutoArrangeToGrid()
|
||||
'CalculateScrollValues()
|
||||
End If
|
||||
|
||||
If curObjMouseDown IsNot Nothing Then
|
||||
@@ -304,43 +315,38 @@ Public Class PaintingControl
|
||||
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)
|
||||
Dim sp As PointF = savedPos(obj)
|
||||
|
||||
If Not movedObjs.Contains(obj) Then
|
||||
UpdateObjectPosition(e, obj, sp)
|
||||
movedObjs.Add(obj)
|
||||
End If
|
||||
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
|
||||
If obj.PinnedObjects.Count > 0 Then
|
||||
UpdateObjectPositions(e, obj.PinnedObjects, movedObjs)
|
||||
movedObjs.AddRange(obj.PinnedObjects.ToArray)
|
||||
End If
|
||||
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)
|
||||
obj.RaiseMoving(New EventArgs)
|
||||
End Sub
|
||||
|
||||
Private Function IsResizingObjs(objs As IList(Of PaintingObject)) As Boolean
|
||||
@@ -355,19 +361,25 @@ Public Class PaintingControl
|
||||
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
|
||||
Dim val As PaintingObject = Nothing
|
||||
|
||||
For i As Integer = PaintingObjects.Count - 1 To 0 Step -1
|
||||
Dim obj As PaintingObject = PaintingObjects(i)
|
||||
|
||||
If val Is Nothing Then
|
||||
If UseExtRect Then
|
||||
If HelpfulDrawingFunctions.IsPointInRectangle(p, obj.RectangleExtended) Then
|
||||
val = obj
|
||||
End If
|
||||
Else
|
||||
If HelpfulDrawingFunctions.IsPointInRectangle(p, obj.Rectangle) Then
|
||||
val = obj
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Return Nothing
|
||||
Return val
|
||||
End Function
|
||||
|
||||
Public Function GetObjects(p As Point) As PaintingObject()
|
||||
@@ -439,46 +451,6 @@ Public Class PaintingControl
|
||||
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)
|
||||
@@ -579,6 +551,15 @@ Public Class PaintingControl
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function IsPinnedObject(o As PaintingObject) As Boolean
|
||||
For Each obj As PaintingObject In PaintingObjects
|
||||
If obj.PinnedObjects.Contains(o) Then
|
||||
Return True
|
||||
End If
|
||||
Next
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Sub AutoArrangeToGrid()
|
||||
If GridEnabled Then
|
||||
For Each obj As PaintingObject In GetSelectedObjects()
|
||||
|
||||
Reference in New Issue
Block a user