From 67207b15dd6725e65d241f260b8e4950c090a83d Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Fri, 19 Jun 2020 01:50:19 +0200 Subject: [PATCH] FrmListBoxDialog --- VAR.Toolbox/UI/FrmListBoxDialog.Designer.cs | 90 +++++++++++++++++++++ VAR.Toolbox/UI/FrmListBoxDialog.cs | 36 +++++++++ VAR.Toolbox/VAR.Toolbox.csproj | 6 ++ 3 files changed, 132 insertions(+) create mode 100644 VAR.Toolbox/UI/FrmListBoxDialog.Designer.cs create mode 100644 VAR.Toolbox/UI/FrmListBoxDialog.cs diff --git a/VAR.Toolbox/UI/FrmListBoxDialog.Designer.cs b/VAR.Toolbox/UI/FrmListBoxDialog.Designer.cs new file mode 100644 index 0000000..f414482 --- /dev/null +++ b/VAR.Toolbox/UI/FrmListBoxDialog.Designer.cs @@ -0,0 +1,90 @@ +namespace VAR.Toolbox.UI +{ + partial class FrmListBoxDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lsbItems = new System.Windows.Forms.ListBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnAccept = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // lsbItems + // + this.lsbItems.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lsbItems.FormattingEnabled = true; + this.lsbItems.Location = new System.Drawing.Point(12, 12); + this.lsbItems.Name = "lsbItems"; + this.lsbItems.Size = new System.Drawing.Size(338, 407); + this.lsbItems.TabIndex = 0; + this.lsbItems.SelectedIndexChanged += new System.EventHandler(this.lsbItems_SelectedIndexChanged); + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(275, 436); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 1; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // btnAccept + // + this.btnAccept.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnAccept.Location = new System.Drawing.Point(194, 436); + this.btnAccept.Name = "btnAccept"; + this.btnAccept.Size = new System.Drawing.Size(75, 23); + this.btnAccept.TabIndex = 2; + this.btnAccept.Text = "Accept"; + this.btnAccept.UseVisualStyleBackColor = true; + // + // FrmListBoxDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(362, 465); + this.Controls.Add(this.btnAccept); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.lsbItems); + this.Name = "FrmListBoxDialog"; + this.Text = "ListBoxDialog"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListBox lsbItems; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnAccept; + } +} \ No newline at end of file diff --git a/VAR.Toolbox/UI/FrmListBoxDialog.cs b/VAR.Toolbox/UI/FrmListBoxDialog.cs new file mode 100644 index 0000000..993dae4 --- /dev/null +++ b/VAR.Toolbox/UI/FrmListBoxDialog.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Windows.Forms; + +namespace VAR.Toolbox.UI +{ + public partial class FrmListBoxDialog : Form + { + public FrmListBoxDialog() + { + InitializeComponent(); + } + + public string Title + { + get { return base.Text; } + set { Text = value; } + } + + public void LoadItems(List items) + { + lsbItems.Items.Clear(); + lsbItems.Items.AddRange(items.ToArray()); + } + + public string Value + { + get { return (lsbItems.SelectedItem as string) ?? string.Empty; } + } + + private void lsbItems_SelectedIndexChanged(object sender, System.EventArgs e) + { + DialogResult = DialogResult.OK; + Close(); + } + } +} diff --git a/VAR.Toolbox/VAR.Toolbox.csproj b/VAR.Toolbox/VAR.Toolbox.csproj index efd932f..b878bfb 100644 --- a/VAR.Toolbox/VAR.Toolbox.csproj +++ b/VAR.Toolbox/VAR.Toolbox.csproj @@ -138,6 +138,12 @@ FrmDialogString.cs + + Form + + + FrmListBoxDialog.cs + Form