refactor flyoutbase and radflyoutbase

- hopefully fix problems with child classes and tabindex problems
This commit is contained in:
Pilzinsel64
2025-01-14 07:50:47 +01:00
parent 0e2f393334
commit cb2831ce4a
6 changed files with 240 additions and 521 deletions

View File

@@ -1,136 +0,0 @@
namespace Pilz.UI.Telerik.Dialogs
{
partial class RadFlyoutBase
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Komponenten-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
radButton_Cancel = new global::Telerik.WinControls.UI.RadButton();
radButton_Confirm = new global::Telerik.WinControls.UI.RadButton();
tableLayoutPanel_ActionPanel = new TableLayoutPanel();
tableLayoutPanel_TitlePanel = new TableLayoutPanel();
radLabel_Title = new global::Telerik.WinControls.UI.RadLabel();
((System.ComponentModel.ISupportInitialize)radButton_Cancel).BeginInit();
((System.ComponentModel.ISupportInitialize)radButton_Confirm).BeginInit();
tableLayoutPanel_ActionPanel.SuspendLayout();
tableLayoutPanel_TitlePanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)radLabel_Title).BeginInit();
SuspendLayout();
//
// radButton_Cancel
//
radButton_Cancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
radButton_Cancel.ImageAlignment = ContentAlignment.MiddleRight;
radButton_Cancel.Location = new Point(187, 3);
radButton_Cancel.Name = "radButton_Cancel";
radButton_Cancel.Size = new Size(110, 24);
radButton_Cancel.TabIndex = 1;
radButton_Cancel.Text = "Cancel";
radButton_Cancel.TextAlignment = ContentAlignment.MiddleLeft;
radButton_Cancel.TextImageRelation = TextImageRelation.ImageBeforeText;
radButton_Cancel.Click += RadButton_Cancel_Click;
//
// radButton_Confirm
//
radButton_Confirm.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
radButton_Confirm.ImageAlignment = ContentAlignment.MiddleRight;
radButton_Confirm.Location = new Point(71, 3);
radButton_Confirm.Name = "radButton_Confirm";
radButton_Confirm.Size = new Size(110, 24);
radButton_Confirm.TabIndex = 0;
radButton_Confirm.Text = "Okay";
radButton_Confirm.TextAlignment = ContentAlignment.MiddleLeft;
radButton_Confirm.TextImageRelation = TextImageRelation.ImageBeforeText;
radButton_Confirm.Click += RadButton_Confirm_Click;
//
// tableLayoutPanel_ActionPanel
//
tableLayoutPanel_ActionPanel.ColumnCount = 3;
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.Controls.Add(radButton_Confirm, 1, 0);
tableLayoutPanel_ActionPanel.Controls.Add(radButton_Cancel, 2, 0);
tableLayoutPanel_ActionPanel.Dock = DockStyle.Bottom;
tableLayoutPanel_ActionPanel.Location = new Point(0, 120);
tableLayoutPanel_ActionPanel.Name = "tableLayoutPanel_ActionPanel";
tableLayoutPanel_ActionPanel.RowCount = 1;
tableLayoutPanel_ActionPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
tableLayoutPanel_ActionPanel.Size = new Size(300, 30);
tableLayoutPanel_ActionPanel.TabIndex = 3;
tableLayoutPanel_ActionPanel.TabStop = false;
//
// tableLayoutPanel_TitlePanel
//
tableLayoutPanel_TitlePanel.ColumnCount = 1;
tableLayoutPanel_TitlePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Controls.Add(radLabel_Title, 0, 0);
tableLayoutPanel_TitlePanel.Dock = DockStyle.Top;
tableLayoutPanel_TitlePanel.Location = new Point(0, 0);
tableLayoutPanel_TitlePanel.Name = "tableLayoutPanel_TitlePanel";
tableLayoutPanel_TitlePanel.RowCount = 1;
tableLayoutPanel_TitlePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Size = new Size(300, 30);
tableLayoutPanel_TitlePanel.TabIndex = 2;
tableLayoutPanel_TitlePanel.TabStop = false;
tableLayoutPanel_TitlePanel.Visible = false;
//
// radLabel_Title
//
radLabel_Title.AutoSize = false;
radLabel_Title.Dock = DockStyle.Fill;
radLabel_Title.Location = new Point(3, 3);
radLabel_Title.Name = "radLabel_Title";
radLabel_Title.Size = new Size(294, 24);
radLabel_Title.TabIndex = 20;
radLabel_Title.TabStop = false;
radLabel_Title.TextImageRelation = TextImageRelation.ImageBeforeText;
//
// RadFlyoutBase
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel_TitlePanel);
Controls.Add(tableLayoutPanel_ActionPanel);
Name = "RadFlyoutBase";
Size = new Size(300, 150);
((System.ComponentModel.ISupportInitialize)radButton_Cancel).EndInit();
((System.ComponentModel.ISupportInitialize)radButton_Confirm).EndInit();
tableLayoutPanel_ActionPanel.ResumeLayout(false);
tableLayoutPanel_TitlePanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)radLabel_Title).EndInit();
ResumeLayout(false);
}
#endregion
private global::Telerik.WinControls.UI.RadButton radButton_Cancel;
private global::Telerik.WinControls.UI.RadButton radButton_Confirm;
private TableLayoutPanel tableLayoutPanel_ActionPanel;
private TableLayoutPanel tableLayoutPanel_TitlePanel;
private global::Telerik.WinControls.UI.RadLabel radLabel_Title;
}
}

View File

@@ -1,9 +1,18 @@
using Telerik.WinControls; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Telerik.WinControls;
using Telerik.WinControls.UI;
namespace Pilz.UI.Telerik.Dialogs; namespace Pilz.UI.Telerik.Dialogs;
public partial class RadFlyoutBase : UserControl public partial class RadFlyoutBase : UserControl
{ {
private RadButton radButton_Cancel;
private RadButton radButton_Confirm;
private TableLayoutPanel tableLayoutPanel_ActionPanel;
private TableLayoutPanel tableLayoutPanel_TitlePanel;
private RadLabel radLabel_Title;
public static RadSvgImage? CancelSvg { get; set; } = null; public static RadSvgImage? CancelSvg { get; set; } = null;
public static RadSvgImage? ConfirmSvg { get; set; } = null; public static RadSvgImage? ConfirmSvg { get; set; } = null;
@@ -11,30 +20,52 @@ public partial class RadFlyoutBase : UserControl
public bool RegisterDialogAccept { get; set; } = true; public bool RegisterDialogAccept { get; set; } = true;
public bool RegisterDialogCancel { get; set; } = false; public bool RegisterDialogCancel { get; set; } = false;
protected bool ActionPanelVisible [DefaultValue(true)]
public bool ActionPanelVisible
{ {
get => tableLayoutPanel_ActionPanel.Visible; get => tableLayoutPanel_ActionPanel.Visible;
set => tableLayoutPanel_ActionPanel.Visible = value; set => tableLayoutPanel_ActionPanel.Visible = value;
} }
[DefaultValue(true)]
protected bool CancelButtonVisible protected bool CancelButtonVisible
{ {
get => radButton_Cancel.Visible; get => radButton_Cancel.Visible;
set => radButton_Cancel.Visible = value; set => radButton_Cancel.Visible = value;
} }
[DefaultValue(true)]
protected bool CancelButtonEnable protected bool CancelButtonEnable
{ {
get => radButton_Cancel.Enabled; get => radButton_Cancel.Enabled;
set => radButton_Cancel.Enabled = value; set => radButton_Cancel.Enabled = value;
} }
[DefaultValue(true)]
protected bool ConfirmButtonEnable protected bool ConfirmButtonEnable
{ {
get => radButton_Confirm.Enabled; get => radButton_Confirm.Enabled;
set => radButton_Confirm.Enabled = value; set => radButton_Confirm.Enabled = value;
} }
[Localizable(true)]
[DefaultValue("Okay")]
public string ConfirmButtonText
{
get => radButton_Confirm.Text;
set => radButton_Confirm.Text = value;
}
[Localizable(true)]
[DefaultValue("Cancel")]
public string CancelButtonText
{
get => radButton_Cancel.Text;
set => radButton_Cancel.Text = value;
}
[Localizable(true)]
[DefaultValue("")]
public string Title public string Title
{ {
get => radLabel_Title.Text; get => radLabel_Title.Text;
@@ -45,6 +76,7 @@ public partial class RadFlyoutBase : UserControl
} }
} }
[DefaultValue(null)]
public RadSvgImage TitleIcon public RadSvgImage TitleIcon
{ {
get => radLabel_Title.SvgImage; get => radLabel_Title.SvgImage;
@@ -59,22 +91,95 @@ public partial class RadFlyoutBase : UserControl
{ {
InitializeComponent(); InitializeComponent();
ParentChanged += FlyoutDialogBase_ParentChanged; ParentChanged += FlyoutDialogBase_ParentChanged;
}
// Change TabIndex to a very high value [MemberNotNull(nameof(radButton_Cancel))]
// -> prevent conflicts with controls based on this class [MemberNotNull(nameof(radButton_Confirm))]
radButton_Cancel.TabIndex = int.MaxValue - 1; [MemberNotNull(nameof(tableLayoutPanel_ActionPanel))]
[MemberNotNull(nameof(tableLayoutPanel_TitlePanel))]
[MemberNotNull(nameof(radLabel_Title))]
private void InitializeComponent()
{
// radButton_Cancel
radButton_Cancel = new()
{
Name = "radButton_Cancel",
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
ImageAlignment = ContentAlignment.MiddleRight,
Size = new Size(110, 24),
TabIndex = 1,
Text = "Cancel",
TextAlignment = ContentAlignment.MiddleLeft,
TextImageRelation = TextImageRelation.ImageBeforeText,
SvgImage = CancelSvg
};
radButton_Cancel.TabIndex = int.MaxValue; radButton_Cancel.TabIndex = int.MaxValue;
radButton_Cancel.Click += RadButton_Cancel_Click;
// SVG Symbols // radButton_Confirm
radButton_Cancel.SvgImage = CancelSvg; radButton_Confirm = new()
radButton_Confirm.SvgImage = ConfirmSvg; {
Name = "radButton_Confirm",
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
ImageAlignment = ContentAlignment.MiddleRight,
Size = new Size(110, 24),
TabIndex = 0,
Text = "Okay",
TextAlignment = ContentAlignment.MiddleLeft,
TextImageRelation = TextImageRelation.ImageBeforeText,
SvgImage = ConfirmSvg
};
radButton_Confirm.TabIndex = int.MaxValue - 1;
radButton_Confirm.Click += RadButton_Confirm_Click;
// Hide bars in Designer // radLabel_Title
//if (DesignMode) radLabel_Title = new()
//{ {
// tableLayoutPanel_ActionPanel.Visible = false; Name = "radLabel_Title",
// tableLayoutPanel_TitlePanel.Visible = false; AutoSize = false,
//} Dock = DockStyle.Fill,
TabStop = false,
TextImageRelation = TextImageRelation.ImageBeforeText
};
// tableLayoutPanel_ActionPanel
tableLayoutPanel_ActionPanel = new()
{
Name = "tableLayoutPanel_ActionPanel",
Dock = DockStyle.Bottom,
Size = new Size(ClientSize.Width, 30),
TabStop = false,
ColumnCount = 3,
RowCount = 1,
};
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
tableLayoutPanel_ActionPanel.Controls.Add(radButton_Confirm, 1, 0);
tableLayoutPanel_ActionPanel.Controls.Add(radButton_Cancel, 2, 0);
// tableLayoutPanel_TitlePanel
tableLayoutPanel_TitlePanel = new()
{
Name = "tableLayoutPanel_TitlePanel",
Dock = DockStyle.Top,
TabStop = false,
Visible = false,
ColumnCount = 1,
RowCount = 1
};
tableLayoutPanel_TitlePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Controls.Add(radLabel_Title, 0, 0);
tableLayoutPanel_TitlePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Size = new Size(300, 30);
// RadFlyoutBase
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel_TitlePanel);
Controls.Add(tableLayoutPanel_ActionPanel);
Size = new Size(300, 150);
} }
protected virtual void FlyoutDialogBase_ParentChanged(object? sender, EventArgs e) protected virtual void FlyoutDialogBase_ParentChanged(object? sender, EventArgs e)
@@ -117,13 +222,13 @@ public partial class RadFlyoutBase : UserControl
tableLayoutPanel_TitlePanel.Visible = !string.IsNullOrWhiteSpace(radLabel_Title.Text) || radLabel_Title.SvgImage != null; tableLayoutPanel_TitlePanel.Visible = !string.IsNullOrWhiteSpace(radLabel_Title.Text) || radLabel_Title.SvgImage != null;
} }
protected virtual void RadButton_Confirm_Click(object sender, EventArgs e) protected virtual void RadButton_Confirm_Click(object? sender, EventArgs e)
{ {
if (ValidateOK()) if (ValidateOK())
Close(DialogResult.OK); Close(DialogResult.OK);
} }
protected virtual void RadButton_Cancel_Click(object sender, EventArgs e) protected virtual void RadButton_Cancel_Click(object? sender, EventArgs e)
{ {
Close(DialogResult.Cancel); Close(DialogResult.Cancel);
} }

View File

@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -1,122 +0,0 @@
namespace Pilz.UI.Dialogs;
partial class FlyoutBase
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Komponenten-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
tableLayoutPanel_TitlePanel = new System.Windows.Forms.TableLayoutPanel();
label_Title = new System.Windows.Forms.Label();
tableLayoutPanel_ActionPanel = new System.Windows.Forms.TableLayoutPanel();
button_Accept = new System.Windows.Forms.Button();
button_Cancel = new System.Windows.Forms.Button();
tableLayoutPanel_TitlePanel.SuspendLayout();
tableLayoutPanel_ActionPanel.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel_TitlePanel
//
tableLayoutPanel_TitlePanel.ColumnCount = 1;
tableLayoutPanel_TitlePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Controls.Add(label_Title, 0, 0);
tableLayoutPanel_TitlePanel.Dock = System.Windows.Forms.DockStyle.Top;
tableLayoutPanel_TitlePanel.Location = new System.Drawing.Point(0, 0);
tableLayoutPanel_TitlePanel.Name = "tableLayoutPanel_TitlePanel";
tableLayoutPanel_TitlePanel.RowCount = 1;
tableLayoutPanel_TitlePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Size = new System.Drawing.Size(300, 29);
tableLayoutPanel_TitlePanel.TabIndex = 2147483647;
//
// label_Title
//
label_Title.Dock = System.Windows.Forms.DockStyle.Fill;
label_Title.Location = new System.Drawing.Point(3, 0);
label_Title.Name = "label_Title";
label_Title.Size = new System.Drawing.Size(294, 29);
label_Title.TabIndex = 2147483646;
label_Title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tableLayoutPanel_ActionPanel
//
tableLayoutPanel_ActionPanel.AutoSize = true;
tableLayoutPanel_ActionPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
tableLayoutPanel_ActionPanel.ColumnCount = 3;
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
tableLayoutPanel_ActionPanel.Controls.Add(button_Cancel, 2, 0);
tableLayoutPanel_ActionPanel.Controls.Add(button_Accept, 1, 0);
tableLayoutPanel_ActionPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
tableLayoutPanel_ActionPanel.Location = new System.Drawing.Point(0, 121);
tableLayoutPanel_ActionPanel.Name = "tableLayoutPanel_ActionPanel";
tableLayoutPanel_ActionPanel.RowCount = 1;
tableLayoutPanel_ActionPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
tableLayoutPanel_ActionPanel.Size = new System.Drawing.Size(300, 29);
tableLayoutPanel_ActionPanel.TabIndex = 2147483645;
tableLayoutPanel_ActionPanel.Visible = false;
//
// button_Accept
//
button_Accept.Location = new System.Drawing.Point(141, 3);
button_Accept.Name = "button_Accept";
button_Accept.Size = new System.Drawing.Size(75, 23);
button_Accept.TabIndex = 2147483640;
button_Accept.Text = "Accept";
button_Accept.UseVisualStyleBackColor = true;
button_Accept.Click += Button_Accept_Click;
//
// button_Cancel
//
button_Cancel.Location = new System.Drawing.Point(222, 3);
button_Cancel.Name = "button_Cancel";
button_Cancel.Size = new System.Drawing.Size(75, 23);
button_Cancel.TabIndex = 2147483641;
button_Cancel.Text = "Cancel";
button_Cancel.UseVisualStyleBackColor = true;
button_Cancel.Click += Button_Cancel_Click;
//
// FlyoutBase
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
Controls.Add(tableLayoutPanel_ActionPanel);
Controls.Add(tableLayoutPanel_TitlePanel);
Name = "FlyoutBase";
Size = new System.Drawing.Size(300, 150);
tableLayoutPanel_TitlePanel.ResumeLayout(false);
tableLayoutPanel_ActionPanel.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel_TitlePanel;
private System.Windows.Forms.Label label_Title;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel_ActionPanel;
private System.Windows.Forms.Button button_Cancel;
private System.Windows.Forms.Button button_Accept;
}

View File

@@ -1,35 +1,66 @@
namespace Pilz.UI.Dialogs; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
namespace Pilz.UI.Dialogs;
public partial class FlyoutBase : UserControl public partial class FlyoutBase : UserControl
{ {
private TableLayoutPanel tableLayoutPanel_TitlePanel;
private Label label_Title;
private TableLayoutPanel tableLayoutPanel_ActionPanel;
private Button button_Cancel;
private Button button_Accept;
public DialogResult Result { get; protected set; } public DialogResult Result { get; protected set; }
public bool RegisterDialogAccept { get; set; } = true; public bool RegisterDialogAccept { get; set; } = true;
public bool RegisterDialogCancel { get; set; } = false; public bool RegisterDialogCancel { get; set; } = false;
[DefaultValue(true)]
protected bool ActionPanelVisible protected bool ActionPanelVisible
{ {
get => tableLayoutPanel_ActionPanel.Visible; get => tableLayoutPanel_ActionPanel.Visible;
set => tableLayoutPanel_ActionPanel.Visible = value; set => tableLayoutPanel_ActionPanel.Visible = value;
} }
[DefaultValue(true)]
protected bool CancelButtonVisible protected bool CancelButtonVisible
{ {
get => button_Cancel.Visible; get => button_Cancel.Visible;
set => button_Cancel.Visible = value; set => button_Cancel.Visible = value;
} }
[DefaultValue(true)]
protected bool CancelButtonEnable protected bool CancelButtonEnable
{ {
get => button_Cancel.Enabled; get => button_Cancel.Enabled;
set => button_Cancel.Enabled = value; set => button_Cancel.Enabled = value;
} }
[DefaultValue(true)]
protected bool ConfirmButtonEnable protected bool ConfirmButtonEnable
{ {
get => button_Accept.Enabled; get => button_Accept.Enabled;
set => button_Accept.Enabled = value; set => button_Accept.Enabled = value;
} }
[Localizable(true)]
[DefaultValue("Okay")]
public string ConfirmButtonText
{
get => button_Accept.Text;
set => button_Accept.Text = value;
}
[Localizable(true)]
[DefaultValue("Cancel")]
public string CancelButtonText
{
get => button_Cancel.Text;
set => button_Cancel.Text = value;
}
[Localizable(true)]
[DefaultValue("")]
public string Title public string Title
{ {
get => label_Title.Text; get => label_Title.Text;
@@ -44,11 +75,92 @@ public partial class FlyoutBase : UserControl
{ {
InitializeComponent(); InitializeComponent();
ParentChanged += FlyoutBase_ParentChanged; ParentChanged += FlyoutBase_ParentChanged;
}
// Change TabIndex to a very high value [MemberNotNull(nameof(tableLayoutPanel_TitlePanel))]
// -> prevent conflicts with controls based on this class [MemberNotNull(nameof(label_Title))]
button_Cancel.TabIndex = int.MaxValue - 1; [MemberNotNull(nameof(tableLayoutPanel_ActionPanel))]
button_Cancel.TabIndex = int.MaxValue; [MemberNotNull(nameof(button_Cancel))]
[MemberNotNull(nameof(button_Accept))]
private void InitializeComponent()
{
SuspendLayout();
// button_Accept
button_Accept = new Button
{
Name = "button_Accept",
Size = new Size(75, 23),
TabIndex = int.MaxValue - 1,
Text = "Accept",
UseVisualStyleBackColor = true
};
button_Accept.Click += Button_Accept_Click;
// button_Cancel
button_Cancel = new Button
{
Name = "button_Cancel",
Size = new Size(75, 23),
TabIndex = int.MaxValue,
Text = "Cancel",
UseVisualStyleBackColor = true
};
button_Cancel.Click += Button_Cancel_Click;
// label_Title
label_Title = new Label
{
Name = "label_Title",
Dock = DockStyle.Fill,
TextAlign = ContentAlignment.MiddleLeft
};
// tableLayoutPanel_TitlePanel
tableLayoutPanel_TitlePanel = new TableLayoutPanel
{
Name = "tableLayoutPanel_TitlePanel",
Dock = DockStyle.Top,
Size = new Size(ClientSize.Width, 29),
Visible = false,
ColumnCount = 1,
RowCount = 1
};
tableLayoutPanel_TitlePanel.SuspendLayout();
tableLayoutPanel_TitlePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel_TitlePanel.Controls.Add(label_Title, 0, 0);
// tableLayoutPanel_ActionPanel
tableLayoutPanel_ActionPanel = new TableLayoutPanel
{
Name = "tableLayoutPanel_ActionPanel",
AutoSize = true,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
Dock = DockStyle.Bottom,
Size = new Size(ClientSize.Width, 29),
ColumnCount = 3,
RowCount = 1
};
tableLayoutPanel_ActionPanel.SuspendLayout();
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel_ActionPanel.RowStyles.Add(new RowStyle());
tableLayoutPanel_ActionPanel.Controls.Add(button_Cancel, 2, 0);
tableLayoutPanel_ActionPanel.Controls.Add(button_Accept, 1, 0);
// FlyoutBase
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel_ActionPanel);
Controls.Add(tableLayoutPanel_TitlePanel);
Size = new Size(300, 150);
tableLayoutPanel_TitlePanel.ResumeLayout(false);
tableLayoutPanel_ActionPanel.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
} }
private void FlyoutBase_ParentChanged(object? sender, EventArgs e) private void FlyoutBase_ParentChanged(object? sender, EventArgs e)
@@ -81,13 +193,13 @@ public partial class FlyoutBase : UserControl
tableLayoutPanel_TitlePanel.Visible = !string.IsNullOrWhiteSpace(label_Title.Text); tableLayoutPanel_TitlePanel.Visible = !string.IsNullOrWhiteSpace(label_Title.Text);
} }
protected virtual void Button_Accept_Click(object sender, System.EventArgs e) protected virtual void Button_Accept_Click(object? sender, EventArgs e)
{ {
if (ValidateOK()) if (ValidateOK())
Close(DialogResult.OK); Close(DialogResult.OK);
} }
protected virtual void Button_Cancel_Click(object sender, System.EventArgs e) protected virtual void Button_Cancel_Click(object? sender, EventArgs e)
{ {
Close(DialogResult.Cancel); Close(DialogResult.Cancel);
} }

View File

@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>