Skip to content

Commit f1e75a3

Browse files
authored
Merge pull request #45 from tomaz82/fixes
Enhance romid detection + remember last import directory
2 parents cd5b374 + 64b2b7b commit f1e75a3

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

b2sbackglassdesigner/b2sbackglassdesigner/Modules/moduleB2S.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Module moduleB2S
5353
Public Property DefaultOpacity() As Single = 1
5454
Public Property DefaultVPTablesFolder() As String = String.Empty
5555
Public Property LatestAuthor() As String = String.Empty
56+
Public Property LatestImportDirectory() As String = String.Empty
5657

5758
Public Property NoToolEvents() As Boolean = False
5859

b2sbackglassdesigner/b2sbackglassdesigner/classes/Base classes/formBase.vb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
If node.SelectSingleNode("LatestAuthor") IsNot Nothing Then
7373
LatestAuthor = node.SelectSingleNode("LatestAuthor").Attributes("Value").InnerText
7474
End If
75+
If node.SelectSingleNode("LatestImportDirectory") IsNot Nothing Then
76+
LatestImportDirectory = node.SelectSingleNode("LatestImportDirectory").Attributes("Value").InnerText
77+
End If
7578
Me.Location = New Point(x, y)
7679
Me.Size = New Size(width, height)
7780
Me.WindowState = If(maximized, FormWindowState.Maximized, FormWindowState.Normal)
@@ -151,6 +154,7 @@
151154
helper.AddXMLAttribute(XmlSettings, nodeForm, "Opacity", "Value", CInt(DefaultOpacity * 100).ToString())
152155
helper.AddXMLAttribute(XmlSettings, nodeForm, "VPTablesFolder", "Value", DefaultVPTablesFolder)
153156
helper.AddXMLAttribute(XmlSettings, nodeForm, "LatestAuthor", "Value", LatestAuthor)
157+
helper.AddXMLAttribute(XmlSettings, nodeForm, "LatestImportDirectory", "Value", LatestImportDirectory)
154158
End If
155159
' save
156160
Try

b2sbackglassdesigner/b2sbackglassdesigner/classes/Tab/B2STabPage.vb

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,23 +1079,30 @@ Public Class B2STabPage
10791079
.Location = loc
10801080
.Image = image
10811081
.IsImageSnippit = True
1082-
If Char.IsDigit(name.Last()) Then
1083-
Dim copy As String = name
1084-
Dim numbers As String = ""
1085-
While Char.IsDigit(copy.Last())
1086-
numbers = copy.Last() + numbers
1087-
copy = copy.Substring(0, copy.Length - 1)
1082+
1083+
If name.Length AndAlso Char.IsDigit(name.Last()) Then
1084+
Dim romtype As String = name
1085+
Dim romid As String = ""
1086+
1087+
While romtype.Length AndAlso Char.IsDigit(romtype.Last())
1088+
romid = romtype.Last() + romid
1089+
romtype = romtype.Substring(0, romtype.Length - 1)
10881090
End While
1089-
If numbers.Length AndAlso copy.Length Then
1090-
If copy.Substring(copy.Length - 1, 1) = "L" Then
1091-
.RomID = CInt(numbers)
1091+
1092+
If romid.Length Then
1093+
.RomID = CInt(romid)
1094+
End If
1095+
1096+
If romid.Length AndAlso romtype.Length Then
1097+
If romtype.EndsWith("L") Then
10921098
.RomIDType = eRomIDType.Lamp
1093-
ElseIf copy.Substring(copy.Length - 1, 1) = "S" Then
1094-
.RomID = CInt(numbers)
1099+
.RomInverted = romtype.EndsWith("iL")
1100+
ElseIf romtype.EndsWith("S") Then
10951101
.RomIDType = eRomIDType.Solenoid
1096-
ElseIf copy.Length > 1 AndAlso copy.Substring(copy.Length - 2, 2) = "Gi" Then
1097-
.RomID = CInt(numbers)
1102+
.RomInverted = romtype.EndsWith("iS")
1103+
ElseIf romtype.EndsWith("Gi") Then
10981104
.RomIDType = eRomIDType.GIString
1105+
.RomInverted = romtype.EndsWith("iGi")
10991106
End If
11001107
End If
11011108
End If

b2sbackglassdesigner/b2sbackglassdesigner/formDesigner.vb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,12 @@ Public Class formDesigner
522522
With filedialog
523523
.Filter = "'directB2S' backglass file (*.directb2s)|*.directb2s|ALL (*.*)|*.*"
524524
.FileName = String.Empty
525-
.InitialDirectory = BackglassProjectsPath
525+
.InitialDirectory = If(LatestImportDirectory.Length, LatestImportDirectory, BackglassProjectsPath)
526526
If .ShowDialog(Me) = DialogResult.OK Then
527527
Dim backglassdata As Backglass.Data = Nothing
528528
Cursor.Current = Cursors.WaitCursor
529+
LatestImportDirectory = IO.Path.GetDirectoryName(.FileName)
530+
SaveSettings()
529531
Try
530532
coding.ImportDirectB2SFile(backglassdata, .FileName)
531533
If backglassdata IsNot Nothing Then

0 commit comments

Comments
 (0)