Skip to content

Commit

Permalink
SteveJones72's Potential New Feature to B2S Snippet x/y translation #71
Browse files Browse the repository at this point in the history
  • Loading branch information
JockeJarre committed Jun 21, 2024
1 parent 0a663f9 commit ac68072
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
17 changes: 9 additions & 8 deletions b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Public Class B2SScreen
Public Property IsDMDToBeShown() As Boolean = False
Public Property StartBackground() As Boolean = False

Public Property rescaleBackglass As SizeF = New SizeF(1, 1)

#Region "constructor and startup"

Expand Down Expand Up @@ -446,11 +447,11 @@ Public Class B2SScreen
End If

' calculate backglass rescale factors
Dim rescaleBackglassX As Single = formBackglass.Width / Me.BackglassSize.Width
Dim rescaleBackglassY As Single = formBackglass.Height / Me.BackglassSize.Height

If formBackglass.BackgroundImage IsNot Nothing Then
rescaleBackglassX = formBackglass.BackgroundImage.Width / Me.BackglassSize.Width
rescaleBackglassY = formBackglass.BackgroundImage.Height / Me.BackglassSize.Height
rescaleBackglass = New SizeF(CSng(formBackglass.BackgroundImage.Width / Me.BackglassSize.Width), CSng(formBackglass.BackgroundImage.Height / Me.BackglassSize.Height))
Else
rescaleBackglass = New SizeF(CSng(formBackglass.Width / Me.BackglassSize.Width), CSng(formBackglass.Height / Me.BackglassSize.Height))
End If

' maybe rescale the location and the size because this is the default and therefore it has to be done
Expand All @@ -459,9 +460,9 @@ Public Class B2SScreen
If IsDMDToBeShown Then
If Me.DMDAtDefaultLocation Then
Me.DMDSize = Me.formDMD.Size
If rescaleBackglassX <> 1 OrElse rescaleBackglassY <> 1 Then
Me.DMDLocation = New Point(Int(Me.DMDLocation.X / rescaleBackglassX), Int(Me.DMDLocation.Y / rescaleBackglassY))
Me.DMDSize = New Size(Int(Me.DMDSize.Width / rescaleBackglassX), Int(Me.DMDSize.Height / rescaleBackglassY))
If rescaleBackglass.Width <> 1 OrElse rescaleBackglass.Height <> 1 Then
Me.DMDLocation = New Point(Int(Me.DMDLocation.X / rescaleBackglass.Width), Int(Me.DMDLocation.Y / rescaleBackglass.Height))
Me.DMDSize = New Size(Int(Me.DMDSize.Width / rescaleBackglass.Width), Int(Me.DMDSize.Height / rescaleBackglass.Height))
End If
End If

Expand All @@ -475,7 +476,7 @@ Public Class B2SScreen
End If

' move and scale all picked objects
ScaleAllControls(rescaleBackglassX, rescaleBackglassY, rescaleDMDX, rescaleDMDY)
ScaleAllControls(rescaleBackglass.Width, rescaleBackglass.Height, rescaleDMDX, rescaleDMDY)

' show the backglass form
formBackglass.StartPosition = FormStartPosition.Manual
Expand Down
10 changes: 6 additions & 4 deletions b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,12 @@ Public Class formBackglass
If drawme Then
If B2SData.OnAndOffImage Then
If B2SData.IsOffImageVisible AndAlso picbox.OffImage IsNot Nothing Then
'e.Graphics.DrawImage(picbox.OffImage, picbox.RectangleF)
e.Graphics.DrawImage(picbox.OffImage, picbox.RectangleF.Location)
Else
'e.Graphics.DrawImage(picbox.BackgroundImage, picbox.RectangleF)
e.Graphics.DrawImage(picbox.BackgroundImage, picbox.RectangleF.Location)
End If
Else
'e.Graphics.DrawImage(picbox.BackgroundImage, picbox.RectangleF)
e.Graphics.DrawImage(picbox.BackgroundImage, picbox.RectangleF.Location)
e.Graphics.DrawImage(picbox.BackgroundImage, picbox.RectangleF.Location.X, picbox.RectangleF.Location.Y)
End If
End If

Expand Down Expand Up @@ -1871,6 +1868,11 @@ Public Class formBackglass

End Sub

Public Sub GetScaleFactor(ByRef scale As SizeF)

scale = B2SScreen.rescaleBackglass

End Sub
#End Region


Expand Down
37 changes: 37 additions & 0 deletions b2sbackglassserver/b2sbackglassserver/Server.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Imports System.Text
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Linq.Expressions
Imports System.Drawing

<ProgId("B2S.Server"), ComClass(Server.ClassID, Server.InterfaceID, Server.EventsID)>
Public Class Server
Expand Down Expand Up @@ -1707,6 +1708,13 @@ Public Class Server

End Sub

Public Sub B2SSetPos(ByVal idORname As Object, ByVal xpos As Object, ByVal ypos As Object)

If IsNumeric(idORname) And IsNumeric(xpos) And IsNumeric(ypos) Then
MyB2SSetPos(CInt(idORname), CInt(xpos), CInt(ypos))
End If
End Sub

' method to set illumination
Public Sub B2SSetIllumination(ByVal name As Object, ByVal value As Object)

Expand Down Expand Up @@ -2127,6 +2135,35 @@ Public Class Server

End Sub

Private Sub MyB2SSetPos(ByVal id As Integer, ByVal xpos As Integer, ByVal ypos As Integer)

If B2SData.IsBackglassRunning Then

If B2SData.IsBackglassStartedAsEXE Then

Else
If B2SData.UsedRomLampIDs.ContainsKey(id) Then
Dim rescaleBackglass As SizeF
Me.formBackglass.GetScaleFactor(rescaleBackglass)

For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(id)
If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then
picbox.Left += xpos
picbox.Top += ypos
' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes.
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
'Invalidating this object does not work, need to Invalidate the parent.
If picbox.Parent IsNot Nothing Then
picbox.Parent.Invalidate()
End If
End If
Next
End If
End If
End If

End Sub

Private Sub MyB2SSetLED(ByVal digit As Integer, ByVal value As Object)

If Not B2SData.IsBackglassRunning Then Return
Expand Down

0 comments on commit ac68072

Please sign in to comment.