98 lines
2.4 KiB
C#
98 lines
2.4 KiB
C#
using Telerik.WinControls;
|
|
|
|
namespace Pilz.UI.Telerik.Dialogs;
|
|
|
|
public partial class RadFlyoutBase : UserControl
|
|
{
|
|
public static RadSvgImage? CancelSvg { get; set; } = null;
|
|
public static RadSvgImage? ConfirmSvg { get; set; } = null;
|
|
|
|
public DialogResult Result { get; protected set; }
|
|
public bool RegisterDialogAccept { get; set; } = true;
|
|
public bool RegisterDialogCancel { get; set; } = false;
|
|
|
|
protected bool ActionPanelVisible
|
|
{
|
|
get => tableLayoutPanel_ActionPanel.Visible;
|
|
set => tableLayoutPanel_ActionPanel.Visible = value;
|
|
}
|
|
|
|
protected bool CancelButtonVisible
|
|
{
|
|
get => radButton_Cancel.Visible;
|
|
set => radButton_Cancel.Visible = value;
|
|
}
|
|
|
|
protected bool CancelButtonEnable
|
|
{
|
|
get => radButton_Cancel.Enabled;
|
|
set => radButton_Cancel.Enabled = value;
|
|
}
|
|
|
|
protected bool ConfirmButtonEnable
|
|
{
|
|
get => radButton_Confirm.Enabled;
|
|
set => radButton_Confirm.Enabled = value;
|
|
}
|
|
|
|
public string Title
|
|
{
|
|
get => radLabel_Title.Text;
|
|
set => radLabel_Title.Text = value;
|
|
}
|
|
|
|
public RadSvgImage TitleIcon
|
|
{
|
|
get => radLabel_Title.SvgImage;
|
|
set => radLabel_Title.SvgImage = value;
|
|
}
|
|
|
|
protected RadFlyoutBase()
|
|
{
|
|
InitializeComponent();
|
|
ParentChanged += FlyoutDialogBase_ParentChanged;
|
|
|
|
// SVG Symbols
|
|
radButton_Cancel.SvgImage = CancelSvg;
|
|
radButton_Confirm.SvgImage = ConfirmSvg;
|
|
}
|
|
|
|
private void FlyoutDialogBase_ParentChanged(object? sender, EventArgs e)
|
|
{
|
|
var frm = FindForm();
|
|
if (frm != null)
|
|
{
|
|
if (RegisterDialogAccept)
|
|
frm.AcceptButton = radButton_Confirm;
|
|
if (RegisterDialogCancel)
|
|
frm.CancelButton = radButton_Cancel;
|
|
}
|
|
}
|
|
|
|
protected void Close(DialogResult result)
|
|
{
|
|
Result = result;
|
|
|
|
if (FindForm() is RadDialogBase dialogForm)
|
|
dialogForm.Close();
|
|
else
|
|
CloseFlyout();
|
|
}
|
|
|
|
private void RadButton_Confirm_Click(object sender, EventArgs e)
|
|
{
|
|
if (ValidateOK())
|
|
Close(DialogResult.OK);
|
|
}
|
|
|
|
private void RadButton_Cancel_Click(object sender, EventArgs e)
|
|
{
|
|
Close(DialogResult.Cancel);
|
|
}
|
|
|
|
protected virtual bool ValidateOK()
|
|
{
|
|
return true;
|
|
}
|
|
}
|