Skip to content

Commit b15573c

Browse files
authored
Merge pull request #46 from tomaz82/misc
Misc
2 parents 31f7a7c + 7a81f3b commit b15573c

File tree

6 files changed

+479
-273
lines changed

6 files changed

+479
-273
lines changed

b2sbackglassdesigner/b2sbackglassdesigner/classes/B2S/GeneralData.vb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@
4242
IsDirty = True
4343
Save()
4444
End Sub
45-
Public Sub RemoveImageSet(ByVal index As Integer)
46-
45+
Public Sub RemoveImageSet(ByVal index As Integer, ByVal type As eImageSetType)
46+
Select Case type
47+
Case eImageSetType.ReelImages
48+
ImportedReelImageSets.RemoveAt(index)
49+
Case eImageSetType.CreditReelImages
50+
ImportedCreditReelImageSets.RemoveAt(index)
51+
Case eImageSetType.LEDImages
52+
ImportedLEDImageSets.RemoveAt(index)
53+
End Select
4754
IsDirty = True
4855
Save()
4956
End Sub

b2sbackglassdesigner/b2sbackglassdesigner/classes/Tab/B2STabPage.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Public Class B2STabPage
4343

4444
Private PictureBox As B2SPictureBox = Nothing
4545
Private DMDPictureBox As B2SPictureBox = Nothing
46-
Private ReadOnly Property CurrentPictureBox() As B2SPictureBox
46+
Public ReadOnly Property CurrentPictureBox() As B2SPictureBox
4747
Get
4848
Return If(BackglassData IsNot Nothing, If(BackglassData.IsDMDImageShown, DMDPictureBox, PictureBox), Nothing)
4949
End Get

b2sbackglassdesigner/b2sbackglassdesigner/formDesigner.vb

Lines changed: 125 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Public Class formDesigner
4040
#Region "events"
4141

4242
Private Sub formDesigner_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
43-
43+
' allow drag and drop
44+
Me.AllowDrop = True
4445
' start app title and status bar
4546
Me.Text = Headline
4647
'Me.KeyPreview = True
@@ -55,10 +56,9 @@ Public Class formDesigner
5556

5657
' listbox to undo
5758
Undo.ListBox = formToolUndo.lbHistory
58-
5959
End Sub
60-
Private Sub formDesigner_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
6160

61+
Private Sub formDesigner_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
6262
' open up the tool windows
6363
For Each formName As String In MyBase.StartToolForms
6464
Select Case formName
@@ -89,8 +89,8 @@ Public Class formDesigner
8989
Catch ex As Exception
9090
MessageBox.Show(String.Format(My.Resources.MSG_StartupSaveError, ex.Message), AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
9191
End Try
92-
9392
End Sub
93+
9494
Private Sub formDesigner_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
9595
Do While B2STab.TabPages.Count > 0
9696
B2STab.SelectedIndex = B2STab.TabPages.Count - 1
@@ -102,6 +102,48 @@ Public Class formDesigner
102102
Loop
103103
End Sub
104104

105+
Private Sub formDesigner_DragEnter(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
106+
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
107+
e.Effect = DragDropEffects.Copy
108+
Else
109+
e.Effect = DragDropEffects.None
110+
End If
111+
End Sub
112+
113+
Private Sub formDesigner_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
114+
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
115+
Dim file_paths As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
116+
For Each file_path As String In file_paths
117+
If (My.Computer.FileSystem.GetFileInfo(file_path).Extension = ".directb2s") Then
118+
LoadDirectB2S(file_path)
119+
ElseIf (My.Computer.FileSystem.GetFileInfo(file_path).Extension = ".b2s") Then
120+
LoadB2S(file_path)
121+
ElseIf (My.Computer.FileSystem.GetFileInfo(file_path).Extension = ".b2b") Then
122+
LoadB2B(file_path)
123+
ElseIf (My.Computer.FileSystem.GetFileInfo(file_path).Extension = ".png") Then
124+
If Backglass.currentTabPage IsNot Nothing Then
125+
Dim image As Image = Bitmap.FromFile(file_path).Copy(True)
126+
127+
If image IsNot Nothing Then
128+
If Not Backglass.currentTabPage.ShowIlluFrames Then
129+
tsmiShowIlluFrames.PerformClick()
130+
End If
131+
Dim name As String = IO.Path.GetFileNameWithoutExtension(file_path)
132+
Dim box As B2SPictureBox = Backglass.currentTabPage.CurrentPictureBox
133+
Dim location As Point = box.PointToClient(New Point(e.X, e.Y))
134+
If location.X < 0 Or location.X > box.Width Or location.Y < 0 Or location.Y > box.Height Then
135+
location = New Point(0, 0)
136+
End If
137+
Backglass.currentTabPage.Illumination_AddSnippit(name, image, New Point(location.X / box.Mouse.factor, location.Y / box.Mouse.factor))
138+
Backglass.currentData.Images.Insert(Images.eImageInfoType.Title4IlluminationSnippits, New Images.ImageInfo(Images.eImageInfoType.IlluminationSnippits, name, image))
139+
LoadToolResourcesForm()
140+
End If
141+
End If
142+
End If
143+
Next file_path
144+
End If
145+
End Sub
146+
105147
Private Sub B2STab_LightsReportProgress(sender As Object, e As Illumination.Lights.LightsProgressEventArgs) Handles B2STab.LightsReportProgress
106148
ShowProgress(e.Progress)
107149
End Sub
@@ -391,23 +433,10 @@ Public Class formDesigner
391433
.FileName = String.Empty
392434
.InitialDirectory = BackglassProjectsPath
393435
If .ShowDialog(Me) = DialogResult.OK Then
394-
Dim backglassdata As Backglass.Data = Nothing
395-
Cursor.Current = Cursors.WaitCursor
396-
save.LoadData(backglassdata, .FileName)
397-
Cursor.Current = Cursors.Default
398-
If backglassdata IsNot Nothing Then
399-
If backglassdata.IsBackup Then
400-
If MessageBox.Show(My.Resources.MSG_BackupFile, AppTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
401-
Exit Sub
402-
End If
403-
End If
404-
LoadData(backglassdata)
405-
End If
436+
LoadB2S(.FileName)
406437
End If
407438
End With
408-
ShowStatus()
409439
End Using
410-
LockUnlockMenus()
411440
End Sub
412441
Private Sub OpenBackup_Click(sender As System.Object, e As System.EventArgs) Handles tsmiOpenBackup.Click
413442
Using filedialog As OpenFileDialog = New OpenFileDialog
@@ -416,22 +445,10 @@ Public Class formDesigner
416445
.FileName = String.Empty
417446
.InitialDirectory = BackglassProjectsPath
418447
If .ShowDialog(Me) = DialogResult.OK Then
419-
Dim backglassdata As Backglass.Data = Nothing
420-
Cursor.Current = Cursors.WaitCursor
421-
save.LoadData(backglassdata, .FileName)
422-
Cursor.Current = Cursors.Default
423-
If backglassdata IsNot Nothing Then
424-
If backglassdata.IsBackup Then
425-
LoadData(backglassdata)
426-
Else
427-
MessageBox.Show(My.Resources.MSG_NoBackupFile, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
428-
End If
429-
End If
448+
LoadB2B(.FileName)
430449
End If
431450
End With
432-
ShowStatus()
433451
End Using
434-
LockUnlockMenus()
435452
End Sub
436453

437454
Private Sub Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsmiClose.Click
@@ -524,19 +541,7 @@ Public Class formDesigner
524541
.FileName = String.Empty
525542
.InitialDirectory = If(LatestImportDirectory.Length, LatestImportDirectory, BackglassProjectsPath)
526543
If .ShowDialog(Me) = DialogResult.OK Then
527-
Dim backglassdata As Backglass.Data = Nothing
528-
Cursor.Current = Cursors.WaitCursor
529-
LatestImportDirectory = IO.Path.GetDirectoryName(.FileName)
530-
SaveSettings()
531-
Try
532-
coding.ImportDirectB2SFile(backglassdata, .FileName)
533-
If backglassdata IsNot Nothing Then
534-
LoadData(backglassdata)
535-
End If
536-
Catch ex As Exception
537-
MessageBox.Show(My.Resources.MSG_ImportError2, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
538-
End Try
539-
Cursor.Current = Cursors.Default
544+
LoadDirectB2S(.FileName)
540545
End If
541546
End With
542547
ShowStatus()
@@ -582,18 +587,8 @@ Public Class formDesigner
582587
End Sub
583588
Private Sub OpenRecent_ChildClick(ByVal sender As Object, ByVal e As EventArgs)
584589
If TypeOf sender.Tag Is KeyValuePair(Of Integer, Recent.recentEntry) Then
585-
Dim path As String = BackglassProjectsPath
586-
Dim backglassdata As Backglass.Data = Nothing
587-
Cursor.Current = Cursors.WaitCursor
588-
If save.LoadData(backglassdata, IO.Path.Combine(path, sender.Tag.Value.Name) & ".b2s") Then
589-
LoadData(backglassdata)
590-
Else
591-
MessageBox.Show(My.Resources.MSG_NoProjectFileFound, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
592-
recent.RemoveFromRecentList(sender.Tag.Key)
593-
End If
594-
Cursor.Current = Cursors.Default
590+
LoadB2S(IO.Path.Combine(BackglassProjectsPath, sender.Tag.Value.Name) & ".b2s")
595591
End If
596-
ShowStatus()
597592
End Sub
598593

599594
Private Sub ClearThisList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsmiClearThisList.Click
@@ -1160,7 +1155,6 @@ Public Class formDesigner
11601155
If Not Backglass.currentTabPage.ShowIlluFrames Then
11611156
tsmiShowIlluFrames.PerformClick()
11621157
End If
1163-
Backglass.currentTabPage.ShowIlluFrames = True
11641158
' add bulb
11651159
Backglass.currentTabPage.Illumination_AddBulb()
11661160
End If
@@ -1171,7 +1165,6 @@ Public Class formDesigner
11711165
If Not Backglass.currentTabPage.ShowIlluFrames Then
11721166
tsmiShowIlluFrames.PerformClick()
11731167
End If
1174-
Backglass.currentTabPage.ShowIlluFrames = True
11751168
' add bulb
11761169
If formAddSnippit Is Nothing Then formAddSnippit = New formAddSnippit()
11771170
formAddSnippit.ShowDialog(Me)
@@ -1435,6 +1428,66 @@ Public Class formDesigner
14351428

14361429
#Region "private methods"
14371430

1431+
Private Sub LoadDirectB2S(ByVal filename As String)
1432+
Dim backglassdata As Backglass.Data = Nothing
1433+
Cursor.Current = Cursors.WaitCursor
1434+
LatestImportDirectory = IO.Path.GetDirectoryName(filename)
1435+
SaveSettings()
1436+
Try
1437+
coding.ImportDirectB2SFile(backglassdata, filename)
1438+
If backglassdata IsNot Nothing Then
1439+
LoadData(backglassdata)
1440+
End If
1441+
Catch ex As Exception
1442+
MessageBox.Show(My.Resources.MSG_ImportError2, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
1443+
End Try
1444+
Cursor.Current = Cursors.Default
1445+
ShowStatus()
1446+
LockUnlockMenus()
1447+
End Sub
1448+
1449+
Private Sub LoadB2S(ByVal filename As String)
1450+
Dim backglassdata As Backglass.Data = Nothing
1451+
Cursor.Current = Cursors.WaitCursor
1452+
Try
1453+
save.LoadData(backglassdata, filename)
1454+
If backglassdata IsNot Nothing Then
1455+
If backglassdata.IsBackup Then
1456+
If MessageBox.Show(My.Resources.MSG_BackupFile, AppTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
1457+
LoadData(backglassdata)
1458+
End If
1459+
Else
1460+
LoadData(backglassdata)
1461+
End If
1462+
End If
1463+
Catch ex As Exception
1464+
MessageBox.Show(My.Resources.MSG_ImportError2, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
1465+
End Try
1466+
Cursor.Current = Cursors.Default
1467+
ShowStatus()
1468+
LockUnlockMenus()
1469+
End Sub
1470+
1471+
Private Sub LoadB2B(ByVal filename As String)
1472+
Dim backglassdata As Backglass.Data = Nothing
1473+
Cursor.Current = Cursors.WaitCursor
1474+
Try
1475+
save.LoadData(backglassdata, filename)
1476+
If backglassdata IsNot Nothing Then
1477+
If backglassdata.IsBackup Then
1478+
LoadData(backglassdata)
1479+
Else
1480+
MessageBox.Show(My.Resources.MSG_NoBackupFile, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
1481+
End If
1482+
End If
1483+
Catch ex As Exception
1484+
MessageBox.Show(My.Resources.MSG_ImportError2, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
1485+
End Try
1486+
Cursor.Current = Cursors.Default
1487+
ShowStatus()
1488+
LockUnlockMenus()
1489+
End Sub
1490+
14381491
Private Function OpenSettings(ByVal newtable As Boolean, Optional ByVal savetableas As Boolean = False) As Boolean
14391492
Dim ret As Boolean = False
14401493
Dim isANewTable As Boolean = (newtable AndAlso Not savetableas)
@@ -1734,6 +1787,14 @@ Public Class formDesigner
17341787
formToolIllumination.rbAlignCenter.Checked = True
17351788
End If
17361789
formToolIllumination.MyFont = If(String.IsNullOrEmpty(.FontName), Nothing, New Font(.FontName, .FontSize, .FontStyle))
1790+
1791+
formToolIllumination.ignoreChange = True
1792+
formToolIllumination.txtLocationX.Text = .Location.X.ToString()
1793+
formToolIllumination.txtLocationY.Text = .Location.Y.ToString()
1794+
formToolIllumination.txtSizeWidth.Text = .Size.Width.ToString()
1795+
formToolIllumination.txtSizeHeight.Text = .Size.Height.ToString()
1796+
formToolIllumination.ignoreChange = False
1797+
17371798
formToolIllumination.ZOrder = .ZOrder
17381799
formToolIllumination.IsSnippit = .IsImageSnippit
17391800
formToolIllumination.SnippitType = .SnippitInfo.SnippitType
@@ -1763,6 +1824,13 @@ Public Class formDesigner
17631824
formToolIllumination.MyFont = Nothing
17641825
formToolIllumination.ZOrder = 0
17651826
formToolIllumination.IsSnippit = False
1827+
1828+
formToolIllumination.ignoreChange = True
1829+
formToolIllumination.txtLocationX.Text = ""
1830+
formToolIllumination.txtLocationY.Text = ""
1831+
formToolIllumination.txtSizeWidth.Text = ""
1832+
formToolIllumination.txtSizeHeight.Text = ""
1833+
formToolIllumination.ignoreChange = False
17661834
End If
17671835
' set headlines and lock/unlock some fields
17681836
If Backglass.currentData IsNot Nothing Then

0 commit comments

Comments
 (0)