Files
staxrip/Source/Forms/SimpleSettingsForm.vb
2025-05-19 14:33:41 +02:00

175 lines
6.8 KiB
VB.net

Imports System.Threading.Tasks
Imports StaxRip.UI
Public Class SimpleSettingsForm
Inherits DialogBase
#Region " Designer "
Friend WithEvents bnCancel As StaxRip.UI.ButtonEx
Friend WithEvents SimpleUI As StaxRip.SimpleUI
Friend WithEvents LineControl As StaxRip.UI.LineControl
Private components As System.ComponentModel.IContainer
Friend WithEvents tlpMain As TableLayoutPanel
Friend WithEvents flpButtons As FlowLayoutPanel
Friend WithEvents bnOK As StaxRip.UI.ButtonEx
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.bnCancel = New StaxRip.UI.ButtonEx()
Me.bnOK = New StaxRip.UI.ButtonEx()
Me.SimpleUI = New StaxRip.SimpleUI()
Me.LineControl = New StaxRip.UI.LineControl()
Me.tlpMain = New System.Windows.Forms.TableLayoutPanel()
Me.flpButtons = New System.Windows.Forms.FlowLayoutPanel()
Me.tlpMain.SuspendLayout()
Me.flpButtons.SuspendLayout()
Me.SuspendLayout()
'
'bnCancel
'
Me.bnCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.bnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.bnCancel.Location = New System.Drawing.Point(265, 0)
Me.bnCancel.Margin = New System.Windows.Forms.Padding(15, 0, 0, 0)
Me.bnCancel.Size = New System.Drawing.Size(250, 70)
Me.bnCancel.Text = "Cancel"
'
'bnOK
'
Me.bnOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.bnOK.DialogResult = System.Windows.Forms.DialogResult.OK
Me.bnOK.Location = New System.Drawing.Point(0, 0)
Me.bnOK.Margin = New System.Windows.Forms.Padding(0)
Me.bnOK.Size = New System.Drawing.Size(250, 70)
Me.bnOK.Text = "OK"
'
'SimpleUI
'
Me.SimpleUI.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.SimpleUI.Location = New System.Drawing.Point(15, 15)
Me.SimpleUI.Margin = New System.Windows.Forms.Padding(15, 5, 15, 0)
Me.SimpleUI.Name = "SimpleUI"
Me.SimpleUI.Size = New System.Drawing.Size(1161, 667)
Me.SimpleUI.TabIndex = 2
'
'LineControl1
'
Me.LineControl.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.LineControl.Location = New System.Drawing.Point(15, 682)
Me.LineControl.Margin = New System.Windows.Forms.Padding(15, 0, 15, 0)
Me.LineControl.Name = "LineControl1"
Me.LineControl.Size = New System.Drawing.Size(1161, 30)
Me.LineControl.TabIndex = 5
'
'tlpMain
'
Me.tlpMain.ColumnCount = 1
Me.tlpMain.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
Me.tlpMain.Controls.Add(Me.SimpleUI, 0, 0)
Me.tlpMain.Controls.Add(Me.LineControl, 0, 1)
Me.tlpMain.Controls.Add(Me.flpButtons, 0, 2)
Me.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill
Me.tlpMain.Location = New System.Drawing.Point(0, 0)
Me.tlpMain.Margin = New System.Windows.Forms.Padding(5)
Me.tlpMain.Name = "tlpMain"
Me.tlpMain.RowCount = 3
Me.tlpMain.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333!))
Me.tlpMain.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.tlpMain.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.tlpMain.Size = New System.Drawing.Size(1191, 797)
Me.tlpMain.TabIndex = 8
'
'flpButtons
'
Me.flpButtons.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.flpButtons.AutoSize = True
Me.flpButtons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
Me.flpButtons.Controls.Add(Me.bnOK)
Me.flpButtons.Controls.Add(Me.bnCancel)
Me.flpButtons.Location = New System.Drawing.Point(661, 712)
Me.flpButtons.Margin = New System.Windows.Forms.Padding(0, 0, 15, 15)
Me.flpButtons.Name = "flpButtons"
Me.flpButtons.Size = New System.Drawing.Size(515, 70)
Me.flpButtons.TabIndex = 6
'
'SimpleSettingsForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(288.0!, 288.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi
Me.CancelButton = Me.bnCancel
Me.ClientSize = New System.Drawing.Size(1191, 797)
Me.Controls.Add(Me.tlpMain)
Me.KeyPreview = True
Me.Margin = New System.Windows.Forms.Padding(0)
Me.Name = "SimpleSettingsForm"
Me.tlpMain.ResumeLayout(False)
Me.tlpMain.PerformLayout()
Me.flpButtons.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private HelpParagraphs As String()
Sub New(title As String, ParamArray helpParagraphs As String())
InitializeComponent()
SetMinimumSize(33, 25)
ScaleClientSize(40, 32.75)
Text = $"{title} - {g.DefaultCommands.GetApplicationDetails()}"
Me.HelpParagraphs = helpParagraphs
SimpleUI.Tree.Select()
ApplyTheme()
AddHandler ThemeManager.CurrentThemeChanged, AddressOf OnThemeChanged
End Sub
Protected Overrides Sub Dispose(disposing As Boolean)
RemoveHandler ThemeManager.CurrentThemeChanged, AddressOf OnThemeChanged
components?.Dispose()
MyBase.Dispose(disposing)
End Sub
Sub OnThemeChanged(theme As Theme)
ApplyTheme(theme)
End Sub
Sub ApplyTheme()
ApplyTheme(ThemeManager.CurrentTheme)
End Sub
Sub ApplyTheme(theme As Theme)
If DesignHelp.IsDesignMode Then Exit Sub
BackColor = theme.General.BackColor
End Sub
Protected Overrides Sub OnResize(e As EventArgs)
MyBase.OnResize(e)
'Text = $"{Size.Width}x{Size.Height}"
End Sub
Sub SimpleSettingsForm_HelpRequested(sender As Object, e As HelpEventArgs) Handles Me.HelpRequested
Dim form As New HelpForm()
form.Doc.WriteStart(Text)
If Not HelpParagraphs Is Nothing Then
For Each i As String In HelpParagraphs
form.Doc.WriteParagraph(i)
Next
End If
If Not SimpleUI.ActivePage.TipProvider Is Nothing Then
form.Doc.WriteTips(SimpleUI.ActivePage.TipProvider.GetTips)
End If
form.Show()
End Sub
End Class