Skip to content

Commit

Permalink
A bit more merged / Split
Browse files Browse the repository at this point in the history
  • Loading branch information
JockeJarre committed Jun 29, 2024
1 parent 276e801 commit 8a81eb5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
<DefineConstants>B2S="DLL"</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<DefineConstants>B2S="EXE"</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -42,6 +43,7 @@
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<RegisterForComInterop>false</RegisterForComInterop>
<Prefer32Bit>false</Prefer32Bit>
<DefineConstants>B2S="EXE"</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -55,6 +57,7 @@
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>true</RemoveIntegerChecks>
<Prefer32Bit>false</Prefer32Bit>
<DefineConstants>B2S="EXE"</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@ Imports Microsoft.Win32

Module B2SBackglassServerEXE
Sub Main()
'If IsAdmin() Then
' MessageBox.Show("You should not start this as Administrator!", My.Resources.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop)
' Exit Sub
'End If
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New formBackglass())
End Sub
Private Function IsAdmin() As Boolean
Dim identity As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim principal As New WindowsPrincipal(identity)
Return principal.IsInRole(WindowsBuiltInRole.Administrator)
End Function
End Module
102 changes: 54 additions & 48 deletions b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@ Public Class formBackglass
Private formSettings As formSettings = Nothing
Private formMode As formMode = Nothing

#If B2S = "DLL" Then
Private startupTimer As Timer = Nothing
Private snifferTimer As Timer = Nothing

Private snifferLamps As B2SSnifferPanel = Nothing
Private snifferSolenoids As B2SSnifferPanel = Nothing
Private snifferGIStrings As B2SSnifferPanel = Nothing
Private chkSniffer As CheckBox = Nothing
Private Const snifferTimerInterval As Integer = 311
#Else
Private timer As Timer = Nothing
Private tabletimer As Timer = Nothing
Private tableTimer As Timer = Nothing
Private B2STimer As Timer = Nothing
Private tableHandle As Integer = 0
#End If

Private rotateTimer As Timer = Nothing
Private rotateSlowDownSteps As Integer = 0
Expand All @@ -31,16 +41,10 @@ Public Class formBackglass
Private rotateSteps As Integer = 0
Private rotateAngle As Single = 0
Private rotateTimerInterval As Integer = 0

Private Const MA_NOACTIVATE As System.Int32 = 3
Private Const WM_MOUSEACTIVATE As Integer = &H21

Private snifferLamps As B2SSnifferPanel = Nothing
Private snifferSolenoids As B2SSnifferPanel = Nothing
Private snifferGIStrings As B2SSnifferPanel = Nothing
Private chkSniffer As CheckBox = Nothing
Private snifferTimer As Timer = Nothing
Private Const snifferTimerInterval As Integer = 311

#Region " Properties "
Protected Overrides Sub WndProc(ByRef m As Message)
'Don't allow the window to be activated by swallowing the mouse event.
Expand Down Expand Up @@ -266,9 +270,9 @@ Public Class formBackglass
timer.Start()

' create 'table is still running' timer
tabletimer = New Timer
tabletimer.Interval = 207
AddHandler tabletimer.Tick, AddressOf TableTimer_Tick
tableTimer = New Timer
tableTimer.Interval = 207
AddHandler tableTimer.Tick, AddressOf TableTimer_Tick

' create B2S data timer
B2STimer = New Timer
Expand All @@ -284,7 +288,6 @@ Public Class formBackglass

End Sub

#End If
Private Sub formBackglass_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown

If Not B2SSettings.FormToFront Then
Expand All @@ -297,22 +300,22 @@ Public Class formBackglass
SetFocusToVPPlayer()

End Sub
#End If

Private Sub formBackglass_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

On Error Resume Next

If rotateTimer IsNot Nothing Then rotateTimer.Stop()
#If B2S = "DLL" Then
' stop all timers as DLL
If startupTimer IsNot Nothing Then startupTimer.Stop()
If rotateTimer IsNot Nothing Then rotateTimer.Stop()
If snifferTimer IsNot Nothing Then snifferTimer.Stop()

#Else
' stop all timers as EXE
If timer IsNot Nothing Then timer.Stop()
If tabletimer IsNot Nothing Then tabletimer.Stop()
If tableTimer IsNot Nothing Then tableTimer.Stop()
If B2STimer IsNot Nothing Then B2STimer.Stop()
If rotateTimer IsNot Nothing Then rotateTimer.Stop()

#End If
' unload DMD form stuff
If formDMD IsNot Nothing Then
formDMD.Close()
Expand Down Expand Up @@ -426,14 +429,14 @@ Public Class formBackglass
Me.Hide()
Return
End If

#If B2S = "DLL" Then
If B2SStatistics.LogStatistics Then
' invalidate the statistics controls
DrawSniffer()

Return
End If

#End If
' some rendering hints
e.Graphics.PageUnit = GraphicsUnit.Pixel
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
Expand Down Expand Up @@ -536,6 +539,9 @@ Public Class formBackglass
End If

End Sub

#If B2S = "DLL" Then

Private Sub DrawSniffer()

' invalidate the statistics controls
Expand All @@ -548,6 +554,28 @@ Public Class formBackglass
#End Region

#Region "some timer events"

Private Sub StartupTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

startupTimer.Stop()

' maybe show some 'startup on' images
ShowStartupImages()

' start autostarted animations
B2SAnimation.AutoStart()

End Sub

Private Sub SnifferTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

If B2SStatistics.LogStatistics Then
Me.Invalidate()
End If

End Sub
#Else

Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)

timer.Stop()
Expand All @@ -565,22 +593,19 @@ Public Class formBackglass
SetFocusToVPPlayer()

' start table check timer
tabletimer.Start()
tableTimer.Start()

End Sub

Private Sub TableTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

If tableHandle <> 0 AndAlso Not IsWindow(tableHandle) Then
' get out here
tabletimer.Stop()
tableTimer.Stop()
Me.Close()
Me.Dispose()
End If

End Sub
#If B2S = "DLL" Then
#Else
Private Sub B2STimer_Tick()

' poll registry data
Expand All @@ -590,6 +615,7 @@ Public Class formBackglass
ShowStartupImages()

End Sub

#End If
Private Sub RotateTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

Expand Down Expand Up @@ -643,32 +669,10 @@ Public Class formBackglass

End Sub


Private Sub StartupTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

startupTimer.Stop()

' maybe show some 'startup on' images
ShowStartupImages()

' start autostarted animations
B2SAnimation.AutoStart()

End Sub

Private Sub SnifferTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

If B2SStatistics.LogStatistics Then
Me.Invalidate()
End If

End Sub

#End Region

#Region "polling action B2SBackglassServerEXE"
#If B2S = "DLL" Then
#Else
#If B2S = "EXE" Then
Private isVisibleStateSet As Boolean = False
Private lastTopVisible As Boolean = False
Private lastSecondVisible As Boolean = False
Expand Down Expand Up @@ -3524,6 +3528,7 @@ Public Class formBackglass
Return Drawing.Color.FromArgb(CInt(colorvalues(0)), CInt(colorvalues(1)), CInt(colorvalues(2)))
End Function

#If B2S = "EXE" Then
Private Sub SetFocusToVPPlayer()

' set focus to the VP player
Expand All @@ -3532,6 +3537,7 @@ Public Class formBackglass
tableHandle = proc.TableHandle

End Sub
#End If

Private Function RandomStarter(ByVal top As Integer) As Integer

Expand Down

0 comments on commit 8a81eb5

Please sign in to comment.