Skip to content

Commit

Permalink
#71 Make position method B2SSetPos(Id, xpos,ypos) also work in EXE mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JockeJarre committed Dec 11, 2024
1 parent 7842b36 commit eaad780
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 19 deletions.
59 changes: 59 additions & 0 deletions b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,9 @@ Public Class formBackglass
' maybe show or hide some illus by groupname
GetThruAllIlluGroups(regkey)

' maybe position something
GetThruAllPositions(regkey)

End Using

End Sub
Expand Down Expand Up @@ -1578,6 +1581,62 @@ Public Class formBackglass

End Sub

Private Sub GetThruAllPositions(ByVal regkey As RegistryKey)
Try

Dim ledPositions As String = regkey.GetValue("B2SPositions", String.Empty)
If Not String.IsNullOrEmpty(ledPositions) AndAlso ledPositions.Contains(",") Then
Dim id As Integer = 0
Dim xpos As Integer = 0
Dim ypos As Integer = 0

regkey.DeleteValue("B2SPositions", False)
' get thru all positions
For Each ledPosition As String In ledPositions.Split(Chr(1))
If Not String.IsNullOrEmpty(ledPosition) Then
Dim items() As String = ledPosition.Split(","c)
id = CInt(items(0))
xpos = CInt(items(1))
ypos = CInt(items(2))
MySetPos(id, xpos, ypos)
End If
Next
End If
Catch ex As Exception

End Try

End Sub

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

If B2SData.UsedRomLampIDs.ContainsKey(id) Then
Dim rescaleBackglass As SizeF
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
If picbox.Left <> xpos OrElse picbox.Top <> ypos Then
If (picbox.InvokeRequired) Then
picbox.BeginInvoke(Sub()
picbox.Left = xpos
picbox.Top = ypos
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate()
End Sub)
Else
picbox.Left = xpos
picbox.Top = ypos
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate()
End If
End If
End If
Next
End If

End Sub

Private Function ConvertLEDValue4Reels(ByVal ledvalue As Integer) As Integer

Dim ret As Integer = 0
Expand Down
39 changes: 20 additions & 19 deletions b2sbackglassserver/b2sbackglassserver/Server.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2182,34 +2182,35 @@ Public Class Server
If B2SData.IsBackglassRunning Then

If B2SData.IsBackglassStartedAsEXE Then

Else
If B2SData.UsedRomLampIDs.ContainsKey(id) Then
Dim rescaleBackglass As SizeF
Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S", True)
Dim illugroups As String = regkey.GetValue("B2SPositions", String.Empty)
regkey.SetValue("B2SPositions", illugroups & Chr(1) & id.ToString() & "," & xpos.ToString() & "," & ypos.ToString())
End Using
ElseIf 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
If picbox.Left <> xpos OrElse picbox.Top <> ypos Then
If (picbox.InvokeRequired) Then
picbox.BeginInvoke(Sub()
picbox.Left = xpos
picbox.Top = ypos
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate()
End Sub)
Else
picbox.Left = xpos
picbox.Top = ypos
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate()
End If
If picbox.Left <> xpos OrElse picbox.Top <> ypos Then
If (picbox.InvokeRequired) Then
picbox.BeginInvoke(Sub()
picbox.Left = xpos
picbox.Top = ypos
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate()
End Sub)
Else
picbox.Left = xpos
picbox.Top = ypos
picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height)
If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate()
End If
End If
End If
Next
End If
End If
End If

End Sub

Expand Down

0 comments on commit eaad780

Please sign in to comment.