refactor flyoutbase and radflyoutbase
- hopefully fix problems with child classes and tabindex problems
This commit is contained in:
@@ -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;
|
||||
|
||||
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? ConfirmSvg { get; set; } = null;
|
||||
|
||||
@@ -11,30 +20,52 @@ public partial class RadFlyoutBase : UserControl
|
||||
public bool RegisterDialogAccept { get; set; } = true;
|
||||
public bool RegisterDialogCancel { get; set; } = false;
|
||||
|
||||
protected bool ActionPanelVisible
|
||||
[DefaultValue(true)]
|
||||
public bool ActionPanelVisible
|
||||
{
|
||||
get => tableLayoutPanel_ActionPanel.Visible;
|
||||
set => tableLayoutPanel_ActionPanel.Visible = value;
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
protected bool CancelButtonVisible
|
||||
{
|
||||
get => radButton_Cancel.Visible;
|
||||
set => radButton_Cancel.Visible = value;
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
protected bool CancelButtonEnable
|
||||
{
|
||||
get => radButton_Cancel.Enabled;
|
||||
set => radButton_Cancel.Enabled = value;
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
protected bool ConfirmButtonEnable
|
||||
{
|
||||
get => radButton_Confirm.Enabled;
|
||||
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
|
||||
{
|
||||
get => radLabel_Title.Text;
|
||||
@@ -45,6 +76,7 @@ public partial class RadFlyoutBase : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
public RadSvgImage TitleIcon
|
||||
{
|
||||
get => radLabel_Title.SvgImage;
|
||||
@@ -59,22 +91,95 @@ public partial class RadFlyoutBase : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
ParentChanged += FlyoutDialogBase_ParentChanged;
|
||||
}
|
||||
|
||||
// Change TabIndex to a very high value
|
||||
// -> prevent conflicts with controls based on this class
|
||||
radButton_Cancel.TabIndex = int.MaxValue - 1;
|
||||
[MemberNotNull(nameof(radButton_Cancel))]
|
||||
[MemberNotNull(nameof(radButton_Confirm))]
|
||||
[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.Click += RadButton_Cancel_Click;
|
||||
|
||||
// SVG Symbols
|
||||
radButton_Cancel.SvgImage = CancelSvg;
|
||||
radButton_Confirm.SvgImage = ConfirmSvg;
|
||||
// radButton_Confirm
|
||||
radButton_Confirm = new()
|
||||
{
|
||||
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
|
||||
//if (DesignMode)
|
||||
//{
|
||||
// tableLayoutPanel_ActionPanel.Visible = false;
|
||||
// tableLayoutPanel_TitlePanel.Visible = false;
|
||||
//}
|
||||
// radLabel_Title
|
||||
radLabel_Title = new()
|
||||
{
|
||||
Name = "radLabel_Title",
|
||||
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)
|
||||
@@ -117,13 +222,13 @@ public partial class RadFlyoutBase : UserControl
|
||||
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())
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user