forked from IcemanF1/ALTTPRCropDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOBSWebSocketCropper.vb
1402 lines (1169 loc) · 61.2 KB
/
OBSWebSocketCropper.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.Configuration
Imports OBSWebsocketDotNet
Imports ALTTPRCropDashboard.Data
Imports ALTTPRCropDashboard.DB
Imports System.IO
Imports ALTTPRCropDashboard.Data.ViewModels
Imports System.Globalization
Public Class ObsWebSocketCropper
Public ProgramName As String = "OBS WebSocket Cropper"
Public WithEvents Obs As New ObsWebSocketPlus
Public ObsConnectionStatus As String
Public ObsConnectionStatus2 As String
Private WithEvents _obs2 As New ObsWebSocketPlus
Public ReadOnly Property ConnectionString As String
Get
Return My.Settings.ConnectionString1 & ":" & My.Settings.ConnectionPort1
End Get
End Property
Public ReadOnly Property ConnectionString2 As String
Get
Return My.Settings.ConnectionString2 & ":" & My.Settings.ConnectionPort2
End Get
End Property
Public Shared ObsSettingsResult As String
Public Shared NewRunnerName As String
Public Shared NewRunnerTwitch As String
Public Shared GetObsInfo As Boolean
Public Shared ReuseInfo As Boolean
Private Const ApprovedChars As String = "0123456789"
Private _cropApi As CropApi
Private ReadOnly _cropperMath As New CropperMath
Private _vlcListLeft As New DataSet
Private _vlcListRight As New DataSet
Private ReadOnly _viewModel As New CropperViewModel
Private _check2NdObs As Boolean
Private _lastUpdate As Integer
#Region " Create New Tables "
Private Sub CreateNewSourceTable()
If _vlcListLeft.Tables.Count = 0 Then
_vlcListLeft.Tables.Add("Processes")
_vlcListLeft.Tables("Processes").Columns.Add("VLCName")
Else
_vlcListLeft.Tables("Processes").Clear()
End If
If _vlcListRight.Tables.Count = 0 Then
_vlcListRight.Tables.Add("Processes")
_vlcListRight.Tables("Processes").Columns.Add("VLCName")
Else
_vlcListRight.Tables("Processes").Clear()
End If
End Sub
#End Region
#Region " Button Clicks "
Private Sub btnSetRightCrop_Click(sender As Object, e As EventArgs) Handles btnSetRightCrop.Click
If _viewModel.RightRunner.MasterSize.Height = 0 OrElse _viewModel.RightRunner.MasterSize.Width = 0 Then
_viewModel.RightRunner.MasterSize.UpdateFromSize(GetMasterSize(True))
End If
Try
SetNewNewMath(True)
Catch ex As ErrorResponseException
MessageBox.Show(Me, "Error while getting information from OBS. Are you sure you are on the correct scene?")
End Try
End Sub
Private Sub btnConnectOBS1_Click(sender As Object, e As EventArgs) Handles btnConnectOBS1.Click
ConnectToObs()
End Sub
Private Sub btnGetLeftCrop_Click(sender As Object, e As EventArgs) Handles btnGetLeftCrop.Click
Try
If MsgBox("This action will overwrite the current crop info for all game/timer windows! Are you sure you wish to continue?", MsgBoxStyle.YesNo, ProgramName) = MsgBoxResult.Yes Then
FillCurrentCropInfoFromObs(False)
End If
Catch ex As ErrorResponseException
MessageBox.Show(Me, "Error while getting information from OBS. Are you sure you are on the correct scene?")
End Try
End Sub
Private Sub btnGetRightCrop_Click(sender As Object, e As EventArgs) Handles btnGetRightCrop.Click
Try
If MsgBox("This action will overwrite the current crop info for all game/timer windows! Are you sure you wish to continue?", MsgBoxStyle.YesNo, ProgramName) = MsgBoxResult.Yes Then
FillCurrentCropInfoFromObs(True)
End If
Catch ex As ErrorResponseException
MessageBox.Show(Me, "Error while getting information from OBS. Are you sure you are on the correct scene?")
End Try
End Sub
Private Sub btnSetLeftCrop_Click(sender As Object, e As EventArgs) Handles btnSetLeftCrop.Click
Try
If _viewModel.LeftRunner.MasterSize.Height = 0 OrElse _viewModel.LeftRunner.MasterSize.Width = 0 Then
_viewModel.LeftRunner.MasterSize.UpdateFromSize(GetMasterSize(False))
End If
SetNewNewMath(False)
Catch ex As ErrorResponseException
MessageBox.Show(Me, "Error while getting information from OBS. Are you sure you are on the correct scene?")
End Try
End Sub
Private Sub btnSetTrackCommNames_Click(sender As Object, e As EventArgs) Handles btnSetTrackCommNames.Click
If Not String.IsNullOrWhiteSpace(My.Settings.LeftRunnerOBS) AndAlso Not String.IsNullOrWhiteSpace(cbLeftRunnerName.Text) Then
DispatchToObs(Sub(o) o.SetTextGdi(My.Settings.LeftRunnerOBS, cbLeftRunnerName.Text))
End If
If Not String.IsNullOrWhiteSpace(My.Settings.RightRunnerOBS) AndAlso Not String.IsNullOrWhiteSpace(cbRightRunnerName.Text) Then
DispatchToObs(Sub(o) o.SetTextGdi(My.Settings.RightRunnerOBS, cbRightRunnerName.Text))
End If
If Not String.IsNullOrWhiteSpace(My.Settings.CommentaryOBS) AndAlso Not String.IsNullOrWhiteSpace(txtCommentaryNames.Text) Then
DispatchToObs(Sub(o) o.SetTextGdi(My.Settings.CommentaryOBS, txtCommentaryNames.Text))
End If
If Not String.IsNullOrWhiteSpace(My.Settings.LeftTrackerOBS) AndAlso Not String.IsNullOrWhiteSpace(txtLeftTrackerURL.Text) Then
Dim TrackerURL = If(ConfigurationManager.AppSettings("TrackerURL"), "")
Dim trackerString As String
If txtLeftTrackerURL.Text.ToLower.StartsWith("http") Then
trackerString = txtLeftTrackerURL.Text
Else
trackerString = TrackerURL & txtLeftTrackerURL.Text
End If
DispatchToObs(Sub(o) o.SetBrowserSource(My.Settings.LeftTrackerOBS, trackerString))
End If
If Not String.IsNullOrWhiteSpace(My.Settings.RightTrackerOBS) AndAlso Not String.IsNullOrWhiteSpace(txtRightTrackerURL.Text) Then
Dim TrackerURL = If(ConfigurationManager.AppSettings("TrackerURL"), "")
Dim trackerString As String
If txtRightTrackerURL.Text.ToLower.StartsWith("http") Then
trackerString = txtRightTrackerURL.Text
Else
trackerString = TrackerURL & txtRightTrackerURL.Text
End If
DispatchToObs(Sub(o) o.SetBrowserSource(My.Settings.RightTrackerOBS, trackerString))
End If
End Sub
Private Sub ObsConnectionChanged(sender As Object, e As EventArgs) Handles Obs.Connected, Obs.Disconnected
RefreshVlc()
ObsConnectionStatus = If(Obs.IsConnected, "Connected", "Not Connected")
_viewModel.ObsConnected = Obs.IsConnected
lblOBS1ConnectedStatus.Text = ObsConnectionStatus
If Not _viewModel.ObsConnected Then
'If our primary OBS connection died, then the secondary connection is also no longer useful.
DispatchToObs(Sub(o) o.Disconnect())
End If
End Sub
Private Sub Obs2ConnectionChanged(sender As Object, e As EventArgs) Handles _obs2.Connected, _obs2.Disconnected
ObsConnectionStatus2 = If(_obs2.IsConnected, "Connected", "Not Connected")
lblOBS2ConnectedStatus.Text = ObsConnectionStatus
End Sub
Private Sub btnSaveLeftCrop_Click(sender As Object, e As EventArgs) Handles btnSaveLeftCrop.Click
SaveRunnerCrop(False)
End Sub
Private Sub btnSaveRightCrop_Click(sender As Object, e As EventArgs) Handles btnSaveRightCrop.Click
SaveRunnerCrop(True)
End Sub
Private Sub btnSyncWithServer_Click(sender As Object, e As EventArgs) Handles btnSyncWithServer.Click
SyncWithServer()
End Sub
Private Sub SyncWithServer()
Cursor = Cursors.WaitCursor
Try
If Not String.IsNullOrWhiteSpace(ConfigurationManager.AppSettings("ServerURL")) Then
_cropApi = New CropApi(ConfigurationManager.AppSettings("ServerURL"))
SendToServer()
GetSyncFromServer()
Else
MsgBox("You are missing the API config file. Please ask someone in the restream channel in discord if you believe you should need this file.", MsgBoxStyle.OkOnly, ProgramName)
End If
Finally
Cursor = Cursors.Default
End Try
End Sub
Private Sub btnGetProcesses_Click(sender As Object, e As EventArgs) Handles btnGetProcesses.Click
RefreshVlc()
End Sub
Private Sub btnSetLeftVLC_Click(sender As Object, e As EventArgs) Handles btnSetLeftVLC.Click
SetVlcWindows(False)
End Sub
''' <summary>
''' Call the same code on all connected OBS instances
''' </summary>
''' <param name="callback">The code to execute</param>
Private Sub DispatchToObs(callback As Action(Of ObsWebSocketPlus))
If callback Is Nothing Then
Exit Sub
End If
If Obs.IsConnected Then
callback(Obs)
End If
If _obs2.IsConnected Then
callback(_obs2)
End If
End Sub
Private Sub SetVlcWindows(isRightWindow As Boolean)
Dim vlcSource As String = If(isRightWindow, cbRightVLCSource.Text, cbLeftVLCSource.Text)
Dim gameSource As String = If(isRightWindow, My.Settings.RightGameName, My.Settings.LeftGameName)
Dim timerSource As String = If(isRightWindow, My.Settings.RightTimerName, My.Settings.LeftTimerName)
Dim vmRunner = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
If Not String.IsNullOrWhiteSpace(vlcSource) Then
vlcSource = vlcSource.Replace(":", "#3A") & ":QWidget:vlc.exe"
If Not String.IsNullOrWhiteSpace(gameSource) Then
DispatchToObs(Sub(o) o.SetSourceSettings(gameSource, False, vlcSource, 1))
End If
If Not String.IsNullOrWhiteSpace(timerSource) Then
DispatchToObs(Sub(o) o.SetSourceSettings(timerSource, False, vlcSource, 1))
End If
GetCurrentCropSettings(isRightWindow)
End If
End Sub
Private Sub btn2ndOBS_Click(sender As Object, e As EventArgs) Handles btn2ndOBS.Click
GetIniFile(False, False)
_check2NdObs = True
Timer1.Start()
End Sub
Private Sub btnConnectOBS2_Click(sender As Object, e As EventArgs) Handles btnConnectOBS2.Click
ConnectToObs2()
End Sub
Private Sub btnSetRightVLC_Click(sender As Object, e As EventArgs) Handles btnSetRightVLC.Click
SetVlcWindows(True)
End Sub
Private Sub btnNewLeftRunner_Click(sender As Object, e As EventArgs) Handles btnNewLeftRunner.Click
AddNewRunner(False)
End Sub
Private Sub btnNewRightRunner_Click(sender As Object, e As EventArgs) Handles btnNewRightRunner.Click
AddNewRunner(True)
End Sub
Private Sub btnLeftTimerDB_Click(sender As Object, e As EventArgs) Handles btnLeftTimerDB.Click
ClearTextBoxes(False, "Timer")
RefreshCropFromData(False, "Timer")
End Sub
Private Sub btnLeftGameDB_Click(sender As Object, e As EventArgs) Handles btnLeftGameDB.Click
ClearTextBoxes(False, "Game")
RefreshCropFromData(False, "Game")
End Sub
Private Sub btnRightTimerDB_Click(sender As Object, e As EventArgs) Handles btnRightTimerDB.Click
ClearTextBoxes(True, "Timer")
RefreshCropFromData(True, "Timer")
End Sub
Private Sub btnRightGameDB_Click(sender As Object, e As EventArgs) Handles btnRightGameDB.Click
ClearTextBoxes(True, "Game")
RefreshCropFromData(True, "Game")
End Sub
Private Sub btnLeftTimerUncrop_Click(sender As Object, e As EventArgs) Handles btnLeftTimerUncrop.Click
If Not String.IsNullOrWhiteSpace(My.Settings.LeftTimerName) Then
Uncrop(My.Settings.LeftTimerName)
End If
End Sub
Private Sub btnRightTimerUncrop_Click(sender As Object, e As EventArgs) Handles btnRightTimerUncrop.Click
If Not String.IsNullOrWhiteSpace(My.Settings.RightTimerName) Then
Uncrop(My.Settings.RightTimerName)
End If
End Sub
Private Sub btnRightGameUncrop_Click(sender As Object, e As EventArgs) Handles btnRightGameUncrop.Click
If Not String.IsNullOrWhiteSpace(My.Settings.RightGameName) Then
Uncrop(My.Settings.RightGameName)
End If
End Sub
Private Sub btnLeftGameUncrop_Click(sender As Object, e As EventArgs) Handles btnLeftGameUncrop.Click
If Not String.IsNullOrWhiteSpace(My.Settings.LeftGameName) Then
Uncrop(My.Settings.LeftGameName)
End If
End Sub
#End Region
#Region " Crop Math / Crop Settings "
Private Sub GetCurrentCropSettings(isRightWindow As Boolean)
Dim runnerVm = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
runnerVm.CurrentSize.UpdateFromSize(GetMasterSize(isRightWindow))
SetHeightLabels()
End Sub
Private Sub SaveRunnerCrop(isRightWindow As Boolean)
Dim needsRefresh = False
Dim submitterName = My.Settings.TwitchChannel
Dim runnerVm = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
Dim runnerTwitch = runnerVm.Twitch
Dim runnerName = runnerVm.Name
GetCurrentCropSettings(isRightWindow)
Dim savedMasterSize = runnerVm.MasterSize.AsSize()
Dim masterSizeWithoutDefaultRight As Size = _cropperMath.RemoveDefaultCropSize(_cropperMath.RemoveScaling(savedMasterSize, runnerVm.Scale))
Dim cropWithoutDefaultGame As Rectangle = _cropperMath.RemoveDefaultCrop(_cropperMath.RemoveScaling(runnerVm.GameCrop.AsRectangle(), savedMasterSize, runnerVm.Scale))
Dim cropWithoutDefaultTimer As Rectangle = _cropperMath.RemoveDefaultCrop(_cropperMath.RemoveScaling(runnerVm.TimerCrop.AsRectangle(), savedMasterSize, runnerVm.Scale))
Using context As New CropDbContext
If Not String.IsNullOrWhiteSpace(runnerTwitch) Then
Dim runner = context.Crops.FirstOrDefault(Function(x) x.Submitter = submitterName AndAlso x.Runner = runnerTwitch)
If runner Is Nothing Then
'Swap with twitch name
runner = New Crop With {
.Submitter = submitterName,
.Runner = runnerTwitch,
.Id = Guid.NewGuid()
}
context.Crops.Add(runner)
needsRefresh = True
End If
runner.GameCropTop = cropWithoutDefaultGame.Top
runner.GameCropBottom = cropWithoutDefaultGame.Bottom
runner.GameCropRight = cropWithoutDefaultGame.Right
runner.GameCropLeft = cropWithoutDefaultGame.Left
runner.TimerCropTop = cropWithoutDefaultTimer.Top
runner.TimerCropBottom = cropWithoutDefaultTimer.Bottom
runner.TimerCropRight = cropWithoutDefaultTimer.Right
runner.TimerCropLeft = cropWithoutDefaultTimer.Left
runner.SizeHeight = masterSizeWithoutDefaultRight.Height
runner.SizeWidth = masterSizeWithoutDefaultRight.Width
runner.SubmittedOn = Nothing
runner.RunnerName = runnerName
context.SaveChanges()
End If
End Using
If needsRefresh Then
RefreshRunnerNames()
End If
End Sub
Private Function GetMasterSize(isRight As Boolean) As Size
If isRight AndAlso String.IsNullOrWhiteSpace(My.Settings.RightGameName) Then
Return Size.Empty
End If
If Not isRight AndAlso String.IsNullOrWhiteSpace(My.Settings.LeftGameName) Then
Return Size.Empty
End If
Dim currentScene = If(Obs.StudioModeEnabled, Obs.GetPreviewScene(), Obs.GetCurrentScene())
Dim target = If(isRight, My.Settings.RightGameName, My.Settings.LeftGameName).ToLower
Dim adequateSource = currentScene.Items.FirstOrDefault(Function(scene) scene.SourceName.ToLower = target)
If adequateSource.SourceName Is Nothing OrElse String.IsNullOrWhiteSpace(adequateSource.SourceName) Then
MessageBox.Show(Me, $"Cannot find source {target} in the current scene. Are you on the right scene?")
End If
Return New Size(adequateSource.SourceWidth, adequateSource.SourceHeight)
End Function
Private Sub ResetHeightWidthLabels()
lblLMasterHeight.Text = "Master Height: 0"
lblLMasterWidth.Text = "Master Width: 0"
lblLSourceHeight.Text = "Source Height: 0"
lblLSourceWidth.Text = "Master Width: 0"
lblRMasterHeight.Text = "Master Height: 0"
lblRMasterWidth.Text = "Master Width: 0"
lblRSourceHeight.Text = "Source Height: 0"
lblRSourceWidth.Text = "Master Width: 0"
End Sub
Private Sub SetHeightLabels()
lblLMasterHeight.Text = "Master Height: " & _viewModel.LeftRunner.MasterSize.Height
lblLMasterWidth.Text = "Master Width: " & _viewModel.LeftRunner.MasterSize.Width
lblLSourceHeight.Text = "Source Height: " & _viewModel.LeftRunner.CurrentSize.Height
lblLSourceWidth.Text = "Source Width: " & _viewModel.LeftRunner.CurrentSize.Width
lblRMasterHeight.Text = "Master Height: " & _viewModel.RightRunner.MasterSize.Height
lblRMasterWidth.Text = "Master Width: " & _viewModel.RightRunner.MasterSize.Width
lblRSourceHeight.Text = "Source Height: " & _viewModel.RightRunner.CurrentSize.Height
lblRSourceWidth.Text = "Source Width: " & _viewModel.RightRunner.CurrentSize.Width
End Sub
Private Sub ProcessCrop(cropWithDefault As Rectangle, savedMasterSize As Size, currentMasterSize As Size, sourceName As String, scaling As Double,
boundingSize As Rectangle, positionX As Integer, positionY As Integer)
Dim resultingCrop = _cropperMath.AdjustCrop(New CropInfo With {
.MasterSizeWithoutDefault = _cropperMath.RemoveDefaultCropSize(_cropperMath.RemoveScaling(savedMasterSize, scaling)),
.CropWithoutDefault = _cropperMath.RemoveDefaultCrop(_cropperMath.RemoveScaling(cropWithDefault, savedMasterSize, scaling))
}, _cropperMath.RemoveDefaultCropSize(_cropperMath.RemoveScaling(currentMasterSize, scaling)))
Dim realCrop = _cropperMath.AddScaling(_cropperMath.AddDefaultCrop(resultingCrop.CropWithBlackBarsWithoutDefault), _cropperMath.AddScaling(_cropperMath.AddDefaultCropSize(resultingCrop.MasterSizeWithoutDefault), scaling), scaling)
Obs.SetSceneItemProperties(sourceName, realCrop.Top, realCrop.Bottom, realCrop.Left, realCrop.Right, boundingSize.Width, boundingSize.Height, positionX, positionY)
If ObsConnectionStatus2 = "Connected" Then
_obs2.SetSceneItemProperties(sourceName, realCrop.Top, realCrop.Bottom, realCrop.Left, realCrop.Right, boundingSize.Width, boundingSize.Height, positionX, positionY)
End If
End Sub
Private Sub SetNewNewMath(isRightWindow As Boolean)
GetCurrentCropSettings(isRightWindow)
RefreshCropperDefaultCrop()
Dim runnerVm = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
Dim gameSource = If(isRightWindow, My.Settings.RightGameName, My.Settings.LeftGameName)
Dim timerSource = If(isRightWindow, My.Settings.RightTimerName, My.Settings.LeftTimerName)
Dim positionXTimer = If(isRightWindow, 1046, 56)
Dim positionXGame = If(isRightWindow, 674, 48)
Dim boundingSizeGame As New Rectangle
boundingSizeGame.Width = 558
boundingSizeGame.Height = 446
Dim boundingSizeTimer As New Rectangle
boundingSizeTimer.Width = 178
boundingSizeTimer.Height = 47
If runnerVm.MasterSize.Height > 0 And runnerVm.MasterSize.Width > 0 Then
If Not String.IsNullOrWhiteSpace(gameSource) Then
ProcessCrop(runnerVm.GameCrop.AsRectangle(),
runnerVm.MasterSize.AsSize(),
runnerVm.CurrentSize.AsSize(),
gameSource,
runnerVm.Scale,
boundingSizeGame,
positionXGame,
83
)
End If
If Not String.IsNullOrWhiteSpace(timerSource) Then
ProcessCrop(runnerVm.TimerCrop.AsRectangle(),
runnerVm.MasterSize.AsSize(),
runnerVm.CurrentSize.AsSize(),
timerSource,
runnerVm.Scale,
boundingSizeTimer,
positionXTimer,
24
)
End If
Else
MsgBox("Master Height/Width is 0. Can't crop yet.", MsgBoxStyle.OkOnly, ProgramName)
End If
End Sub
#End Region
#Region " Refresh / Set User Info "
Private Sub RefreshRunnerNames()
Dim tempLeftRunner As String = cbLeftRunnerName.Text
Dim tempRightRunner As String = cbRightRunnerName.Text
ReuseInfo = False
Using context As New CropDbContext
Dim validNames = context.Crops.OrderBy(Function(r) r.Runner).Select(Function(r) New With {.RacerName = r.RunnerName}).Distinct().ToList().OrderBy(Function(r) r.RacerName, StringComparer.CurrentCultureIgnoreCase).ToList()
cbLeftRunnerName.DataSource = validNames
cbRightRunnerName.DataSource = validNames.ToList()
End Using
cbLeftRunnerName.Text = tempLeftRunner
cbRightRunnerName.Text = tempRightRunner
ReuseInfo = True
End Sub
Private Function ParsePercent(percent As String) As Double
If (String.IsNullOrWhiteSpace(percent)) Then
Return 1
End If
Return Double.Parse(percent.Replace("%", "")) / 100.0
End Function
Private Sub RefreshCropFromData(isRightWindow As Boolean, ByVal refreshAction As String)
If Not Obs.IsConnected Then
Return
End If
Dim savedMasterSize As Size
Dim realMasterSize As Size
Dim scaling As Double
Dim savedCrop As Rectangle
Dim realCrop As Rectangle
Dim runnerVm = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
Dim runnerName = If(isRightWindow, cbRightRunnerName.Text, cbLeftRunnerName.Text)
Using context As New CropDbContext
Dim runnerInfo As Crop
scaling = runnerVm.Scale
runnerInfo = context.Crops.FirstOrDefault(Function(r) r.Submitter = My.Settings.TwitchChannel AndAlso r.RunnerName = runnerName)
If runnerInfo Is Nothing Then
runnerInfo = context.Crops.OrderByDescending(Function(r) r.SubmittedOn).FirstOrDefault(Function(r) r.RunnerName = runnerName)
End If
If runnerInfo Is Nothing Then
runnerInfo = New Crop
Dim initialSize = _cropperMath.RemoveDefaultCropSize(_cropperMath.RemoveScaling(GetMasterSize(isRightWindow), scaling))
runnerInfo.SizeWidth = initialSize.Width
runnerInfo.SizeHeight = initialSize.Height
End If
savedCrop = Rectangle.FromLTRB(runnerInfo.TimerCropLeft, runnerInfo.TimerCropTop, runnerInfo.TimerCropRight, runnerInfo.TimerCropBottom)
realCrop = _cropperMath.AddDefaultCrop(savedCrop)
savedMasterSize = New Size(runnerInfo.SizeWidth, runnerInfo.SizeHeight)
If refreshAction = "Both" Or refreshAction = "Timer" Then
realMasterSize = _cropperMath.AddScaling(_cropperMath.AddDefaultCropSize(savedMasterSize), scaling)
realCrop = _cropperMath.AddScaling(realCrop, realMasterSize, runnerVm.Scale)
runnerVm.TimerCrop.UpdateFromRectangle(realCrop)
End If
savedCrop = Rectangle.FromLTRB(runnerInfo.GameCropLeft, runnerInfo.GameCropTop, runnerInfo.GameCropRight, runnerInfo.GameCropBottom)
realCrop = _cropperMath.AddDefaultCrop(savedCrop)
If refreshAction = "Both" Or refreshAction = "Game" Then
realCrop = _cropperMath.AddScaling(realCrop, realMasterSize, scaling)
runnerVm.GameCrop.UpdateFromRectangle(realCrop)
runnerVm.Twitch = runnerInfo.Runner
End If
If isRightWindow Then
lblRightRunnerTwitch.Text = "Twitch: " & runnerVm.Twitch
Else
lblLeftRunnerTwitch.Text = "Twitch: " & runnerVm.Twitch
End If
runnerVm.MasterSize.UpdateFromSize(realMasterSize)
runnerVm.Scale = scaling
End Using
SetHeightLabels()
End Sub
Private Sub RefreshObs()
Dim lObs = Process.GetProcesses().Where(Function(pr) pr.ProcessName.StartsWith("obs", True, Globalization.CultureInfo.InvariantCulture)).ToList()
If lObs.Count > 1 Then
Timer1.Stop()
GetIniFile(False, True)
_check2NdObs = False
ElseIf lObs.Count = 1 Then
Dim obsProcess As New ProcessStartInfo
Dim workDirectory As String
workDirectory = lObs.Item(0).MainModule.FileName.Remove(lObs.Item(0).MainModule.FileName.LastIndexOf("\"), lObs.Item(0).MainModule.FileName.Length - lObs.Item(0).MainModule.FileName.LastIndexOf("\"))
obsProcess.FileName = lObs.Item(0).MainModule.FileName
obsProcess.WorkingDirectory = workDirectory
Process.Start(obsProcess)
End If
End Sub
Private Sub RefreshVlc()
Dim vlcProcesses = Process.GetProcesses().Where(Function(pr) pr.ProcessName.StartsWith("vlc", True, Globalization.CultureInfo.InvariantCulture)).ToList()
If Not vlcProcesses.Any() Then
Exit Sub
End If
Dim leftVlc, rightVlc As String
If Not String.IsNullOrWhiteSpace(cbRightVLCSource.Text) Then
rightVlc = cbRightVLCSource.Text
Else
rightVlc = ""
End If
If Not String.IsNullOrWhiteSpace(cbLeftVLCSource.Text) Then
leftVlc = cbLeftVLCSource.Text
Else
leftVlc = ""
End If
_vlcListLeft.Clear()
_vlcListRight.Clear()
Dim data = vlcProcesses.Select(Function(v) New With {.VLCName = v.MainWindowTitle}).ToList()
_vlcListRight = _vlcListLeft.Copy
cbLeftVLCSource.DataSource = data
cbLeftVLCSource.DisplayMember = "VLCName"
cbLeftVLCSource.ValueMember = "VLCName"
cbRightVLCSource.DataSource = data.ToList()
cbRightVLCSource.DisplayMember = "VLCName"
cbRightVLCSource.ValueMember = "VLCName"
cbRightVLCSource.Text = ""
cbLeftVLCSource.Text = ""
If Not String.IsNullOrWhiteSpace(lblLeftRunnerTwitch.Text) Then
Dim tempText = lblLeftRunnerTwitch.Text.Remove(0, 8)
Dim match = data.FirstOrDefault(Function(d) d.VLCName.StartsWith(tempText, True, CultureInfo.InvariantCulture))
If match IsNot Nothing Then
cbLeftVLCSource.Text = match.VLCName
End If
End If
If Not String.IsNullOrWhiteSpace(lblRightRunnerTwitch.Text) Then
Dim tempText = lblRightRunnerTwitch.Text.Remove(0, 8)
Dim match = data.FirstOrDefault(Function(d) d.VLCName.StartsWith(tempText, True, CultureInfo.InvariantCulture))
If match IsNot Nothing Then
cbRightVLCSource.Text = match.VLCName
End If
End If
End Sub
Private Sub ClearTextBoxes(isRightWindow As Boolean, refreshAction As String)
Dim runnerVm = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
If refreshAction = "Both" OrElse refreshAction = "Game" Then
runnerVm.GameCrop.UpdateFromRectangle(Rectangle.Empty)
End If
If refreshAction = "Both" OrElse refreshAction = "Timer" Then
runnerVm.TimerCrop.UpdateFromRectangle(Rectangle.Empty)
End If
End Sub
Private Sub FillCurrentCropInfoFromObs(isRightWindow As Boolean)
Dim sceneName As String = If(Obs.StudioModeEnabled, Obs.GetPreviewScene().Name, Obs.GetCurrentScene().Name)
Dim runnerVm = If(isRightWindow, _viewModel.RightRunner, _viewModel.LeftRunner)
runnerVm.MasterSize.UpdateFromSize(GetMasterSize(isRightWindow))
Dim timerSource = If(isRightWindow, My.Settings.RightTimerName, My.Settings.LeftTimerName)
Dim gameSource = If(isRightWindow, My.Settings.RightGameName, My.Settings.LeftGameName)
If Not String.IsNullOrWhiteSpace(timerSource) Then
runnerVm.TimerCrop.UpdateFromRectangle(Obs.GetSceneItemProperties(sceneName, timerSource).Crop)
End If
If Not String.IsNullOrWhiteSpace(gameSource) Then
runnerVm.GameCrop.UpdateFromRectangle(Obs.GetSceneItemProperties(sceneName, gameSource).Crop)
End If
End Sub
#End Region
Private Sub ValidateKeyPress(sender As Object, e As KeyPressEventArgs) _
Handles txtCropRightTimer_Top.KeyPress, txtCropRightTimer_Right.KeyPress,
txtCropRightTimer_Left.KeyPress, txtCropRightTimer_Bottom.KeyPress,
txtCropRightGame_Top.KeyPress, txtCropRightGame_Right.KeyPress,
txtCropRightGame_Left.KeyPress, txtCropRightGame_Bottom.KeyPress,
txtCropLeftTimer_Top.KeyPress, txtCropLeftTimer_Right.KeyPress,
txtCropLeftTimer_Left.KeyPress, txtCropLeftTimer_Bottom.KeyPress,
txtCropLeftGame_Top.KeyPress, txtCropLeftGame_Right.KeyPress,
txtCropLeftGame_Left.KeyPress, txtCropLeftGame_Bottom.KeyPress
e.Handled = CheckIfKeyAllowed(e.KeyChar)
End Sub
Public Shared Function CheckIfKeyAllowed(keyChar As String) As Boolean
Return Not ApprovedChars.Contains(keyChar) AndAlso keyChar <> vbBack
End Function
#Region " Runner Drop Downs "
Private Sub cbLeftRunner_KeyUp(sender As Object, e As KeyEventArgs) Handles cbLeftRunnerName.KeyUp
Dim index As Integer
Dim actual As String
Dim found As String
If ((e.KeyCode = Keys.Back) Or
(e.KeyCode = Keys.Left) Or
(e.KeyCode = Keys.Right) Or
(e.KeyCode = Keys.Up) Or
(e.KeyCode = Keys.Delete) Or
(e.KeyCode = Keys.Down) Or
(e.KeyCode = Keys.PageUp) Or
(e.KeyCode = Keys.PageDown) Or
(e.KeyCode = Keys.Home) Or
(e.KeyCode = Keys.End)) Then
Return
End If
' Store the actual text that has been typed.
actual = cbLeftRunnerName.Text
' Find the first match for the typed value.
index = cbLeftRunnerName.FindString(actual)
' Get the text of the first match.
If (index > -1) Then
found = cbLeftRunnerName.Items(index).ToString()
' Select this item from the list.
cbLeftRunnerName.SelectedIndex = index
' Select the portion of the text that was automatically
' added so that additional typing will replace it.
cbLeftRunnerName.SelectionStart = actual.Length
cbLeftRunnerName.SelectionLength = found.Length
End If
End Sub
Private Sub cbRightRunner_KeyUp(sender As Object, e As KeyEventArgs) Handles cbRightRunnerName.KeyUp
Dim index As Integer
Dim actual As String
Dim found As String
If ((e.KeyCode = Keys.Back) Or
(e.KeyCode = Keys.Left) Or
(e.KeyCode = Keys.Right) Or
(e.KeyCode = Keys.Up) Or
(e.KeyCode = Keys.Delete) Or
(e.KeyCode = Keys.Down) Or
(e.KeyCode = Keys.PageUp) Or
(e.KeyCode = Keys.PageDown) Or
(e.KeyCode = Keys.Home) Or
(e.KeyCode = Keys.End)) Then
Return
End If
' Store the actual text that has been typed.
actual = cbRightRunnerName.Text
' Find the first match for the typed value.
index = cbRightRunnerName.FindString(actual)
' Get the text of the first match.
If (index > -1) Then
found = cbRightRunnerName.Items(index).ToString()
' Select this item from the list.
cbRightRunnerName.SelectedIndex = index
' Select the portion of the text that was automatically
' added so that additional typing will replace it.
cbRightRunnerName.SelectionStart = actual.Length
cbRightRunnerName.SelectionLength = found.Length
End If
End Sub
Private Sub cbRightRunner_TextChanged(sender As Object, e As EventArgs) Handles cbRightRunnerName.TextChanged
If ReuseInfo = True Then
_viewModel.RightRunner.Name = cbRightRunnerName.Text
ClearTextBoxes(True, "Both")
RefreshCropFromData(True, "Both")
End If
End Sub
Private Sub cbLeftRunner_TextChanged(sender As Object, e As EventArgs) Handles cbLeftRunnerName.TextChanged
If ReuseInfo = True Then
_viewModel.LeftRunner.Name = cbLeftRunnerName.Text
ClearTextBoxes(False, "Both")
RefreshCropFromData(False, "Both")
End If
End Sub
#End Region
#Region " Misc Functions "
Private Sub RegisterExpertModeFeatures(ParamArray features() As Control)
For Each control In features
control.DataBindings.Add("Visible", My.Settings, NameOf(My.Settings.ExpertMode), False, DataSourceUpdateMode.OnPropertyChanged)
Next
End Sub
Private Sub RegisterObsDependency(ParamArray features() As Control)
For Each control In features
control.DataBindings.Add("Enabled", _viewModel, NameOf(_viewModel.ObsConnected), False, DataSourceUpdateMode.OnPropertyChanged)
Next
End Sub
Private Sub RegisterCropBindings(cropVm As CropViewModel, leftControl As Control, topControl As Control, bottomControl As Control, rightControl As Control)
leftControl.DataBindings.Add("Text", cropVm, NameOf(cropVm.Left), False, DataSourceUpdateMode.OnPropertyChanged)
topControl.DataBindings.Add("Text", cropVm, NameOf(cropVm.Top), False, DataSourceUpdateMode.OnPropertyChanged)
bottomControl.DataBindings.Add("Text", cropVm, NameOf(cropVm.Bottom), False, DataSourceUpdateMode.OnPropertyChanged)
rightControl.DataBindings.Add("Text", cropVm, NameOf(cropVm.Right), False, DataSourceUpdateMode.OnPropertyChanged)
End Sub
Private Sub ConfigureDataBindings()
' Expert mode only features
RegisterExpertModeFeatures(lblLeftStreamlink, lblRightStreamlink)
RegisterExpertModeFeatures(lblLeftScaling, cbLeftScaling, lblRightScaling, cbRightScaling)
RegisterExpertModeFeatures(chkAlwaysOnTop)
RegisterExpertModeFeatures(lblLeftVOD, lblRightVOD)
RegisterExpertModeFeatures(lblViewLeftOnTwitch, lblViewRightOnTwitch)
RegisterExpertModeFeatures(lblOBS2ConnectedStatus, btnConnectOBS2, btn2ndOBS)
RegisterExpertModeFeatures(btnLeftGameDB, btnLeftTimerDB, btnRightTimerDB, btnRightGameDB)
chkAlwaysOnTop.DataBindings.Add("Checked", My.Settings, NameOf(My.Settings.AlwaysOnTop), False, DataSourceUpdateMode.OnPropertyChanged)
DataBindings.Add("TopMost", My.Settings, NameOf(My.Settings.AlwaysOnTop), False, DataSourceUpdateMode.OnPropertyChanged)
'All OBS dependencies
RegisterObsDependency(btnSetLeftCrop, btnSetRightCrop)
RegisterObsDependency(btnGetLeftCrop, btnGetRightCrop)
RegisterObsDependency(btnSaveLeftCrop, btnSaveRightCrop)
RegisterObsDependency(btnSetLeftVLC, btnSetRightVLC, btnGetProcesses, cbLeftVLCSource, cbRightVLCSource)
RegisterObsDependency(btnSetTrackCommNames, btnNewLeftRunner, btnNewRightRunner)
RegisterObsDependency(btnSyncWithServer, btn2ndOBS, btnConnectOBS2)
RegisterObsDependency(gbTrackerComms, gbLeftGameWindow, gbRightGameWindow, gbLeftTimerWindow, gbRightTimerWindow)
RegisterObsDependency(cbLeftRunnerName, cbRightRunnerName)
RegisterObsDependency(lblLeftVOD, lblRightVOD)
RegisterObsDependency(lblViewLeftOnTwitch, lblViewRightOnTwitch)
RegisterObsDependency(lblLeftStreamlink, lblRightStreamlink)
'Bind all crop info
RegisterCropBindings(_viewModel.LeftRunner.GameCrop,
txtCropLeftGame_Left,
txtCropLeftGame_Top,
txtCropLeftGame_Bottom,
txtCropLeftGame_Right)
RegisterCropBindings(_viewModel.LeftRunner.TimerCrop,
txtCropLeftTimer_Left,
txtCropLeftTimer_Top,
txtCropLeftTimer_Bottom,
txtCropLeftTimer_Right)
RegisterCropBindings(_viewModel.RightRunner.GameCrop,
txtCropRightGame_Left,
txtCropRightGame_Top,
txtCropRightGame_Bottom,
txtCropRightGame_Right)
RegisterCropBindings(_viewModel.RightRunner.TimerCrop,
txtCropRightTimer_Left,
txtCropRightTimer_Top,
txtCropRightTimer_Bottom,
txtCropRightTimer_Right)
End Sub
Private Sub OBSWebScocketCropper_Load(sender As Object, e As EventArgs) Handles Me.Load
RefreshCropperDefaultCrop()
ReuseInfo = True
lblOBS1ConnectedStatus.Text = "Not Connected"
lblOBS2ConnectedStatus.Text = "Not Connected"
ConfigureDataBindings()
CreateNewSourceTable()
If My.Settings.HasFinishedWelcome = False Then
Dim uSettings As New UserSettings
UserSettings.ShowVLCOption = True
uSettings.ShowDialog(Me)
If My.Settings.HasFinishedWelcome = False Then
MsgBox("There are no default settings loaded. Program will close. Please change and then save some settings before continuing.", MsgBoxStyle.OkOnly, ProgramName)
Close()
End If
CheckUnusedFields()
If ObsSettingsResult = "VLC" Then
VlcSettings.ShowDialog(Me)
End If
RefreshRunnerNames()
Else
ResetHeightWidthLabels()
RefreshRunnerNames()
RefreshCropperDefaultCrop()
CheckUnusedFields()
End If
ExpertModeToolStripMenuItem.Checked = My.Settings.ExpertMode
End Sub
Private Sub AboutToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
About.ShowDialog(Me)
End Sub
Private Sub ExitToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Close()
End Sub
Private Sub ChangeVLCSettingsToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles ChangeVLCSettingsToolStripMenuItem.Click
VlcSettings.ShowDialog(Me)
RefreshCropperDefaultCrop()
End Sub
Private Sub ExpertModeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExpertModeToolStripMenuItem.Click
My.Settings.ExpertMode = ExpertModeToolStripMenuItem.Checked
My.Settings.Save()
End Sub
Private Sub ChangeUserSettingsToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles ChangeUserSettingsToolStripMenuItem.Click
Dim uSettings As New UserSettings
UserSettings.ShowVLCOption = False
uSettings.ShowDialog(Me)
If My.Settings.HasFinishedWelcome = False Then
MsgBox("There are no default settings loaded. Program will close. Please change and then save some settings before continuing.", MsgBoxStyle.OkOnly, ProgramName)
Close()
Else
RefreshRunnerNames()
RefreshCropperDefaultCrop()
CheckUnusedFields()
End If
End Sub
Private Sub GetSyncFromServer()
Dim cropList As IEnumerable(Of RunnerInfo)
Try
cropList = _cropApi.GetCrops()
Catch ex As Exception
MessageBox.Show(Me, "Error While retrieving data from server: " & ex.ToString())
Return
End Try
Using context As New CropDbContext
Dim validGuids As New List(Of Guid)
For Each runnerInfo In cropList
Dim runnerInfoCopy = runnerInfo
Dim existingCrops = context.Crops.Where(Function(x) x.Runner = runnerInfoCopy.Runner)
For Each crop In runnerInfo.Crops
If Not crop.Id.HasValue Then
Throw New ArgumentNullException(NameOf(crop.Id))
End If
Dim id = If(crop.Id, Guid.Empty)
validGuids.Add(id)
Dim matchingItem = If(existingCrops.FirstOrDefault(Function(x) x.Id = id),
New Crop With {.Runner = runnerInfo.Runner})
matchingItem.SizeWidth = crop.Size.Width
matchingItem.SizeHeight = crop.Size.Height
matchingItem.GameCropTop = crop.GameCrop.Top
matchingItem.GameCropBottom = crop.GameCrop.Bottom
matchingItem.GameCropRight = crop.GameCrop.Right
matchingItem.GameCropLeft = crop.GameCrop.Left
matchingItem.TimerCropTop = crop.TimerCrop.Top
matchingItem.TimerCropBottom = crop.TimerCrop.Bottom
matchingItem.TimerCropRight = crop.TimerCrop.Right
matchingItem.TimerCropLeft = crop.TimerCrop.Left
matchingItem.Submitter = crop.Submitter
matchingItem.SubmittedOn = crop.SubmittedOn
If crop.RunnerName Is Nothing Then
matchingItem.RunnerName = runnerInfo.Runner
Else
matchingItem.RunnerName = crop.RunnerName
End If
If matchingItem.Id <> crop.Id Then
matchingItem.Id = id
context.Crops.Add(matchingItem)
End If
Next
Next
'This will need to be updated back to raw sql in context.Database.ExecuteSqlCommand
Dim nonExistingItems = context.Crops.Where(Function(x) Not validGuids.Contains(x.Id))
For Each item In nonExistingItems
item.SubmittedOn = Nothing
Next
context.SaveChanges()
End Using
RefreshRunnerNames()
End Sub
Private Sub GetIniFile(python As Boolean, resetWebSocketPort As Boolean)
Dim appDataPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Dim fileName As String = appDataPath & "\obs-studio\global.ini"
Dim iniContents As Dictionary(Of String, Dictionary(Of String, String)) = IniParser.ParseFile(fileName)
For Each sectionName As String In iniContents.Keys
For Each valueName As String In iniContents(sectionName).Keys
Dim value As String = iniContents(sectionName)(valueName)
'[SectionName]
'ValueName=Value
'ValueName=Value
'
'SectionName: The name of the current section (ex: Jones).
'ValueName : The name of the current value (ex: Email).
'Value : The value of [ValueName] (ex: [email protected]).
If python = True Then
If sectionName.ToLower = "python" Then
If valueName.ToLower = "path64bit" Then
MsgBox(value, MsgBoxStyle.OkOnly)
''IniParser.WritePrivateProfileStringW(SectionName, ValueName, Value & "_Test", FileName)
End If
End If
Else
If sectionName.ToLower = "websocketapi" Then
If valueName.ToLower = "serverport" Then
If resetWebSocketPort = True Then
IniParser.WritePrivateProfileStringW(sectionName, valueName, My.Settings.ConnectionPort1.ToString, fileName)
Else
IniParser.WritePrivateProfileStringW(sectionName, valueName, My.Settings.ConnectionPort2.ToString, fileName)
End If