diff --git a/MessageBoxEx/App.config b/MessageBoxEx/App.config new file mode 100644 index 00000000..bd27edc0 --- /dev/null +++ b/MessageBoxEx/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/MessageBoxEx/MessageBoxEx.vbproj b/MessageBoxEx/MessageBoxEx.vbproj new file mode 100644 index 00000000..5c5e5933 --- /dev/null +++ b/MessageBoxEx/MessageBoxEx.vbproj @@ -0,0 +1,139 @@ + + + + + Debug + AnyCPU + {EF29F400-BE45-4283-9D18-CA7ACD9ACCC9} + Library + + + DigitalData.Controls.MessageBoxEx + DigitalData.Controls.MessageBoxEx + 512 + Windows + v4.6.1 + true + true + + + + AnyCPU + true + full + true + true + bin\Debug\ + DigitalData.Controls.MessageBoxEx.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + DigitalData.Controls.MessageBoxEx.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + False + D:\ProgramFiles\DevExpress 21.2\Components\Bin\Framework\DevExpress.XtraEditors.v21.2.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + MsgBoxEx.vb + Form + + + + True + Application.myapp + True + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MsgBoxEx.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + \ No newline at end of file diff --git a/MessageBoxEx/MsgBoxEx.Designer.vb b/MessageBoxEx/MsgBoxEx.Designer.vb new file mode 100644 index 00000000..46e2116c --- /dev/null +++ b/MessageBoxEx/MsgBoxEx.Designer.vb @@ -0,0 +1,135 @@ + +Partial Class MsgBoxEx + Inherits DevExpress.XtraEditors.XtraForm + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + + Private Sub InitializeComponent() + Me.chkBx = New System.Windows.Forms.CheckBox() + Me.btn1 = New System.Windows.Forms.Button() + Me.btn2 = New System.Windows.Forms.Button() + Me.messageLbl = New System.Windows.Forms.Label() + Me.btn3 = New System.Windows.Forms.Button() + Me.PanelControl1 = New DevExpress.XtraEditors.PanelControl() + CType(Me.PanelControl1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.PanelControl1.SuspendLayout() + Me.SuspendLayout() + ' + 'chkBx + ' + Me.chkBx.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.chkBx.AutoSize = True + Me.chkBx.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.chkBx.Location = New System.Drawing.Point(12, 76) + Me.chkBx.Name = "chkBx" + Me.chkBx.Size = New System.Drawing.Size(152, 20) + Me.chkBx.TabIndex = 22 + Me.chkBx.Text = "Don't show this again" + Me.chkBx.UseVisualStyleBackColor = True + Me.chkBx.Visible = False + ' + 'btn1 + ' + Me.btn1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btn1.AutoSize = True + Me.btn1.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.btn1.Location = New System.Drawing.Point(161, 12) + Me.btn1.Name = "btn1" + Me.btn1.Size = New System.Drawing.Size(100, 23) + Me.btn1.TabIndex = 5 + Me.btn1.Text = "Button1" + Me.btn1.UseVisualStyleBackColor = True + Me.btn1.Visible = False + ' + 'btn2 + ' + Me.btn2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btn2.AutoSize = True + Me.btn2.Location = New System.Drawing.Point(267, 12) + Me.btn2.Name = "btn2" + Me.btn2.Size = New System.Drawing.Size(100, 23) + Me.btn2.TabIndex = 6 + Me.btn2.Text = "Button2" + Me.btn2.UseVisualStyleBackColor = True + Me.btn2.Visible = False + ' + 'messageLbl + ' + Me.messageLbl.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.messageLbl.Location = New System.Drawing.Point(58, 10) + Me.messageLbl.Name = "messageLbl" + Me.messageLbl.Size = New System.Drawing.Size(415, 75) + Me.messageLbl.TabIndex = 19 + Me.messageLbl.Text = "[Message]" + ' + 'btn3 + ' + Me.btn3.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btn3.AutoSize = True + Me.btn3.Location = New System.Drawing.Point(373, 12) + Me.btn3.Name = "btn3" + Me.btn3.Size = New System.Drawing.Size(100, 23) + Me.btn3.TabIndex = 7 + Me.btn3.Text = "Button3" + Me.btn3.UseVisualStyleBackColor = True + Me.btn3.Visible = False + ' + 'PanelControl1 + ' + Me.PanelControl1.Controls.Add(Me.btn1) + Me.PanelControl1.Controls.Add(Me.btn3) + Me.PanelControl1.Controls.Add(Me.btn2) + Me.PanelControl1.Dock = System.Windows.Forms.DockStyle.Bottom + Me.PanelControl1.Location = New System.Drawing.Point(0, 102) + Me.PanelControl1.Name = "PanelControl1" + Me.PanelControl1.Size = New System.Drawing.Size(485, 47) + Me.PanelControl1.TabIndex = 23 + ' + 'MsgBoxEx + ' + Me.Appearance.BackColor = System.Drawing.SystemColors.ControlLightLight + Me.Appearance.Options.UseBackColor = True + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None + Me.CancelButton = Me.btn1 + Me.ClientSize = New System.Drawing.Size(485, 149) + Me.Controls.Add(Me.PanelControl1) + Me.Controls.Add(Me.chkBx) + Me.Controls.Add(Me.messageLbl) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "MsgBoxEx" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "[Title]" + CType(Me.PanelControl1, System.ComponentModel.ISupportInitialize).EndInit() + Me.PanelControl1.ResumeLayout(False) + Me.PanelControl1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Private chkBx As System.Windows.Forms.CheckBox + Private WithEvents btn1 As System.Windows.Forms.Button + Private WithEvents btn2 As System.Windows.Forms.Button + Private messageLbl As System.Windows.Forms.Label + Private WithEvents btn3 As System.Windows.Forms.Button + Friend WithEvents PanelControl1 As DevExpress.XtraEditors.PanelControl +End Class diff --git a/MessageBoxEx/MsgBoxEx.resx b/MessageBoxEx/MsgBoxEx.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/MessageBoxEx/MsgBoxEx.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MessageBoxEx/MsgBoxEx.vb b/MessageBoxEx/MsgBoxEx.vb new file mode 100644 index 00000000..90a4b95d --- /dev/null +++ b/MessageBoxEx/MsgBoxEx.vb @@ -0,0 +1,188 @@ +Public Class MsgBoxEx + Public Sub New(ByVal message As String, ByVal 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) + Me.New(message, title, getMessageBoxIcon(icon)) + End Sub + + Public Sub New(ByVal message As String, ByVal title As String, ByVal 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) + End Sub + + Private Shared Function getMessageBoxIcon(ByVal icon As MessageBoxIcon) As Icon + Dim oIcon As Icon = Nothing + + Select Case icon + Case MessageBoxIcon.Asterisk + oIcon = SystemIcons.Asterisk + Case MessageBoxIcon.[Error] + oIcon = SystemIcons.[Error] + Case MessageBoxIcon.Exclamation + oIcon = SystemIcons.Exclamation + Case MessageBoxIcon.Question + oIcon = SystemIcons.Question + End Select + + If oIcon IsNot Nothing Then + Return DevExpress.Utils.Drawing.Helpers.StockIconHelper.GetWindows8AssociatedIcon(oIcon) + Else + Return Nothing + End If + End Function + + Private m_minWidth As Integer + Private m_minHeight As Integer + + Public Sub SetMinSize(ByVal width As Integer, ByVal height As Integer) + m_minWidth = width + m_minHeight = height + End Sub + + Public Sub SetButtons(ParamArray names As String()) + Dim drs As DialogResult() = New DialogResult(names.Length - 1) {} + + For i As Integer = 0 To names.Length - 1 + drs(i) = DialogResult.None + Next + + Me.SetButtons(names, drs) + End Sub + + Public Sub SetButtons(ByVal names As String(), ByVal results As DialogResult()) + Me.SetButtons(names, results, 1) + End Sub + + Public Sub SetButtons(ByVal names As String(), ByVal results As DialogResult(), ByVal 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)) + + If count > 1 Then + m_minButtonRowWidth += setButtonParams(btn2, names(1), If(def = 2, 1, 3), results(1)) + BUTTON_SPACE + End If + + If count > 2 Then + m_minButtonRowWidth += setButtonParams(btn3, names(2), If(def = 3, 1, 4), results(2)) + BUTTON_SPACE + End If + End Sub + + 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 + btn.Text = text + btn.Visible = True + btn.DialogResult = dr + btn.TabIndex = tab + Return btn.Size.Width + End Function + + Public Sub SetCheckbox(ByVal text As String) + Me.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 + 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}) + m_minButtonRowWidth += 2 * FORM_X_MARGIN + Me.setDialogSize() + Me.setButtonRowLocations() + End Sub + + Const FORM_Y_MARGIN As Integer = 10 + Const FORM_X_MARGIN As Integer = 16 + Const BUTTON_SPACE As Integer = 5 + Const CHECKBOX_SPACE As Integer = 15 + 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 + 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 s As Size = New Size() + s.Width = If(requiredWidth > minSetWidth, requiredWidth, minSetWidth) + s.Height = If(requiredHeight > minSetHeight, requiredHeight, minSetHeight) + Me.ClientSize = s + End Sub + + Private Sub setButtonRowLocations() + Dim formWidth As Integer = Me.ClientRectangle.Width + Dim x As Integer = formWidth - FORM_X_MARGIN + Dim y As Integer = btn1.Location.Y + + If btn3.Visible Then + x -= btn3.Size.Width + btn3.Location = New Point(x, y) + x -= BUTTON_SPACE + End If + + If btn2.Visible Then + x -= btn2.Size.Width + btn2.Location = New Point(x, y) + x -= BUTTON_SPACE + End If + + 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) + End Sub + + Private m_sysIcon As Icon + + Protected Overrides Sub OnPaint(ByVal 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)) + End If + + MyBase.OnPaint(e) + End Sub + + Public ReadOnly Property CheckboxChecked As Boolean + Get + Return Me.chkBx.Checked + End Get + End Property + + Private m_result As DialogBoxResult + + Public ReadOnly Property Result As DialogBoxResult + Get + Return m_result + End Get + End Property + + Private Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn1.Click, btn2.Click, btn3.Click + If sender.Equals(btn1) Then + m_result = DialogBoxResult.Button1 + ElseIf sender.Equals(btn2) Then + m_result = DialogBoxResult.Button2 + ElseIf sender.Equals(btn3) Then + m_result = DialogBoxResult.Button3 + End If + + If (CType(sender, Button)).DialogResult = DialogResult.None Then + Close() + End If + End Sub + + Enum DialogBoxResult + Button1 + Button2 + Button3 + End Enum +End Class diff --git a/MessageBoxEx/My Project/Application.Designer.vb b/MessageBoxEx/My Project/Application.Designer.vb new file mode 100644 index 00000000..8ab460ba --- /dev/null +++ b/MessageBoxEx/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/MessageBoxEx/My Project/Application.myapp b/MessageBoxEx/My Project/Application.myapp new file mode 100644 index 00000000..1243847f --- /dev/null +++ b/MessageBoxEx/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/MessageBoxEx/My Project/AssemblyInfo.vb b/MessageBoxEx/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..f8c008b8 --- /dev/null +++ b/MessageBoxEx/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID wird für die typelib-ID verwendet, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' indem Sie "*" wie unten gezeigt eingeben: +' + + + diff --git a/MessageBoxEx/My Project/Resources.Designer.vb b/MessageBoxEx/My Project/Resources.Designer.vb new file mode 100644 index 00000000..0780c22a --- /dev/null +++ b/MessageBoxEx/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.Controls.MessageBoxEx.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/MessageBoxEx/My Project/Resources.resx b/MessageBoxEx/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/MessageBoxEx/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MessageBoxEx/My Project/Settings.Designer.vb b/MessageBoxEx/My Project/Settings.Designer.vb new file mode 100644 index 00000000..5c0538e7 --- /dev/null +++ b/MessageBoxEx/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.DigitalData.Controls.MessageBoxEx.My.MySettings + Get + Return Global.DigitalData.Controls.MessageBoxEx.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/MessageBoxEx/My Project/Settings.settings b/MessageBoxEx/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/MessageBoxEx/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + +