Zooflow: Implement Single file Search Results, Rework client wrt Address parsing

This commit is contained in:
Jonathan Jenne
2022-04-13 15:39:01 +02:00
parent 7716a04452
commit 160040535d
23 changed files with 346 additions and 234 deletions

View File

@@ -1,21 +1,22 @@
Public Class MsgBoxEx
Public Sub New(ByVal message As String, ByVal title As String)
Public Sub New(message As String, title As String)
Me.New(message, title, MessageBoxIcon.None)
End Sub
Public Sub New(ByVal message As String, ByVal title As String, ByVal icon As MessageBoxIcon)
Public Sub New(message As String, title As String, icon As MessageBoxIcon)
Me.New(message, title, getMessageBoxIcon(icon))
End Sub
Public Sub New(ByVal message As String, ByVal title As String, ByVal icon As Icon)
Public Sub New(message As String, title As String, icon As Icon)
InitializeComponent()
Me.messageLbl.Text = message
Me.Text = title
Me.m_sysIcon = icon
If Me.m_sysIcon Is Nothing Then Me.messageLbl.Location = New System.Drawing.Point(FORM_X_MARGIN, FORM_Y_MARGIN)
messageLbl.Text = message
Text = title
m_sysIcon = icon
If m_sysIcon Is Nothing Then messageLbl.Location = New System.Drawing.Point(FORM_X_MARGIN, FORM_Y_MARGIN)
SetButtons("OK")
End Sub
Private Shared Function getMessageBoxIcon(ByVal icon As MessageBoxIcon) As Icon
Private Shared Function getMessageBoxIcon(icon As MessageBoxIcon) As Icon
Dim oIcon As Icon = Nothing
Select Case icon
@@ -39,7 +40,7 @@
Private m_minWidth As Integer
Private m_minHeight As Integer
Public Sub SetMinSize(ByVal width As Integer, ByVal height As Integer)
Public Sub SetMinSize(width As Integer, height As Integer)
m_minWidth = width
m_minHeight = height
End Sub
@@ -51,18 +52,18 @@
drs(i) = DialogResult.None
Next
Me.SetButtons(names, drs)
SetButtons(names, drs)
End Sub
Public Sub SetButtons(ByVal names As String(), ByVal results As DialogResult())
Me.SetButtons(names, results, 1)
Public Sub SetButtons(names As String(), results As DialogResult())
SetButtons(names, results, 1)
End Sub
Public Sub SetButtons(ByVal names As String(), ByVal results As DialogResult(), ByVal def As Integer)
Public Sub SetButtons(names As String(), results As DialogResult(), def As Integer)
If names Is Nothing Then Throw New ArgumentNullException("btnText", "Button Text is null")
Dim count As Integer = names.Length
If count < 1 OrElse count > 3 Then Throw New ArgumentException("Invalid number of buttons. Must be between 1 and 3.")
m_minButtonRowWidth += setButtonParams(btn1, names(0), If(def = 1, 1, 2), results(0))
m_minButtonRowWidth = setButtonParams(btn1, names(0), If(def = 1, 1, 2), results(0))
If count > 1 Then
m_minButtonRowWidth += setButtonParams(btn2, names(1), If(def = 2, 1, 3), results(1)) + BUTTON_SPACE
@@ -75,7 +76,7 @@
Private m_minButtonRowWidth As Integer
Private Shared Function setButtonParams(ByVal btn As Button, ByVal text As String, ByVal tab As Integer, ByVal dr As DialogResult) As Integer
Private Shared Function setButtonParams(btn As Button, text As String, tab As Integer, dr As DialogResult) As Integer
btn.Text = text
btn.Visible = True
btn.DialogResult = dr
@@ -83,22 +84,22 @@
Return btn.Size.Width
End Function
Public Sub SetCheckbox(ByVal text As String)
Me.SetCheckbox(text, False)
Public Sub SetCheckbox(text As String)
SetCheckbox(text, False)
End Sub
Public Sub SetCheckbox(ByVal text As String, ByVal chcked As Boolean)
Me.chkBx.Visible = True
Me.chkBx.Text = text
Me.chkBx.Checked = chcked
Me.m_minButtonRowWidth += Me.chkBx.Size.Width + CHECKBOX_SPACE
Public Sub SetCheckbox(text As String, chcked As Boolean)
chkBx.Visible = True
chkBx.Text = text
chkBx.Checked = chcked
m_minButtonRowWidth += chkBx.Size.Width + CHECKBOX_SPACE
End Sub
Private Sub DialogBox_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not btn1.Visible Then Me.SetButtons(New String() {"OK"}, New DialogResult() {DialogResult.OK})
Private Sub DialogBox_Load(sender As Object, e As EventArgs)
If Not btn1.Visible Then SetButtons(New String() {"OK"}, New DialogResult() {DialogResult.OK})
m_minButtonRowWidth += 2 * FORM_X_MARGIN
Me.setDialogSize()
Me.setButtonRowLocations()
setDialogSize()
setButtonRowLocations()
End Sub
Const FORM_Y_MARGIN As Integer = 10
@@ -108,19 +109,19 @@
Const TEXT_Y_MARGIN As Integer = 30
Private Sub setDialogSize()
Dim requiredWidth As Integer = Me.messageLbl.Location.X + Me.messageLbl.Size.Width + FORM_X_MARGIN
Dim requiredWidth As Integer = messageLbl.Location.X + messageLbl.Size.Width + FORM_X_MARGIN
requiredWidth = If(requiredWidth > m_minButtonRowWidth, requiredWidth, m_minButtonRowWidth)
Dim requiredHeight As Integer = Me.messageLbl.Location.Y + Me.messageLbl.Size.Height - Me.btn2.Location.Y + Me.ClientSize.Height + TEXT_Y_MARGIN
Dim minSetWidth As Integer = If(Me.ClientSize.Width > Me.m_minWidth, Me.ClientSize.Width, Me.m_minWidth)
Dim minSetHeight As Integer = If(Me.ClientSize.Height > Me.m_minHeight, Me.ClientSize.Height, Me.m_minHeight)
Dim requiredHeight As Integer = messageLbl.Location.Y + messageLbl.Size.Height - btn2.Location.Y + ClientSize.Height + TEXT_Y_MARGIN
Dim minSetWidth As Integer = If(ClientSize.Width > m_minWidth, ClientSize.Width, m_minWidth)
Dim minSetHeight As Integer = If(ClientSize.Height > m_minHeight, ClientSize.Height, m_minHeight)
Dim s As Size = New Size()
s.Width = If(requiredWidth > minSetWidth, requiredWidth, minSetWidth)
s.Height = If(requiredHeight > minSetHeight, requiredHeight, minSetHeight)
Me.ClientSize = s
ClientSize = s
End Sub
Private Sub setButtonRowLocations()
Dim formWidth As Integer = Me.ClientRectangle.Width
Dim formWidth As Integer = ClientRectangle.Width
Dim x As Integer = formWidth - FORM_X_MARGIN
Dim y As Integer = btn1.Location.Y
@@ -138,12 +139,12 @@
x -= btn1.Size.Width
btn1.Location = New Point(x, y)
If Me.chkBx.Visible Then Me.chkBx.Location = New Point(FORM_X_MARGIN, Me.chkBx.Location.Y)
If chkBx.Visible Then chkBx.Location = New Point(FORM_X_MARGIN, chkBx.Location.Y)
End Sub
Private m_sysIcon As Icon
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Protected Overrides Sub OnPaint(e As PaintEventArgs)
If m_sysIcon IsNot Nothing Then
Dim g As Graphics = e.Graphics
g.DrawIconUnstretched(m_sysIcon, New Rectangle(FORM_X_MARGIN, FORM_Y_MARGIN, m_sysIcon.Width, m_sysIcon.Height))
@@ -154,7 +155,7 @@
Public ReadOnly Property CheckboxChecked As Boolean
Get
Return Me.chkBx.Checked
Return chkBx.Checked
End Get
End Property
@@ -166,7 +167,7 @@
End Get
End Property
Private Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn1.Click, btn2.Click, btn3.Click
Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn1.Click, btn2.Click, btn3.Click
If sender.Equals(btn1) Then
m_result = DialogBoxResult.Button1
ElseIf sender.Equals(btn2) Then