change UI to UI.WinForms
This commit is contained in:
14
Pilz.UI.WinForms.Telerik/Dialogs/DialogClosedEventArgs.cs
Normal file
14
Pilz.UI.WinForms.Telerik/Dialogs/DialogClosedEventArgs.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
namespace Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
|
||||
public class DialogClosedEventArgs : EventArgs
|
||||
{
|
||||
public RadDialogBase Parent { get; private set; }
|
||||
public RadFlyoutBase? Content => Parent?.DialogPanel;
|
||||
|
||||
public DialogClosedEventArgs(RadDialogBase dialog)
|
||||
{
|
||||
Parent = dialog;
|
||||
}
|
||||
}
|
||||
14
Pilz.UI.WinForms.Telerik/Dialogs/DialogLoadingEventArgs.cs
Normal file
14
Pilz.UI.WinForms.Telerik/Dialogs/DialogLoadingEventArgs.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
namespace Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
|
||||
public class DialogLoadingEventArgs : EventArgs
|
||||
{
|
||||
public RadDialogBase Parent { get; private set; }
|
||||
public RadFlyoutBase? Content => Parent?.DialogPanel;
|
||||
|
||||
public DialogLoadingEventArgs(RadDialogBase dialog)
|
||||
{
|
||||
Parent = dialog;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
namespace Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
|
||||
public class FlyoutClosedEventArgs(RadFlyoutBase content) : global::Telerik.WinControls.UI.SplashScreen.FlyoutClosedEventArgs(content)
|
||||
{
|
||||
public new RadFlyoutBase? Content => base.Content as RadFlyoutBase;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Telerik.WinControls.UI.SplashScreen;
|
||||
|
||||
namespace Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
|
||||
public class FlyoutCreatedEventArgs(RadFlyoutBase content) : ContentCreatedEventArgs(content)
|
||||
{
|
||||
public new RadFlyoutBase? Content => base.Content as RadFlyoutBase;
|
||||
}
|
||||
86
Pilz.UI.WinForms.Telerik/Dialogs/RadDialogBase.Statics.cs
Normal file
86
Pilz.UI.WinForms.Telerik/Dialogs/RadDialogBase.Statics.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using Pilz.UI.WinForms.Extensions;
|
||||
using Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
using Pilz.UI.WinForms.Telerik.Extensions;
|
||||
using Telerik.WinControls;
|
||||
|
||||
namespace Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
partial class RadDialogBase
|
||||
{
|
||||
public delegate void DialogLoadingEventHandler(DialogLoadingEventArgs e);
|
||||
public delegate void DialogClosedEventHandler(DialogClosedEventArgs e);
|
||||
|
||||
public static event DialogLoadingEventHandler? DialogLoading;
|
||||
public static event DialogClosedEventHandler? DialogClosed;
|
||||
|
||||
public static T Show<T>(string? title, object? icon, object? tag = null) where T : RadFlyoutBase
|
||||
{
|
||||
return Show<T>(null, title, icon, tag);
|
||||
}
|
||||
|
||||
public static T ShowDialog<T>(string? title, object? icon, object? tag = null) where T : RadFlyoutBase
|
||||
{
|
||||
return ShowDialog<T>(null, title, icon, tag);
|
||||
}
|
||||
|
||||
public static T Show<T>(IWin32Window? parent, string? title, object? icon, object? tag = null) where T : RadFlyoutBase
|
||||
{
|
||||
return Show(CreatePanelInstance<T>(tag), parent, title, icon);
|
||||
}
|
||||
|
||||
public static T ShowDialog<T>(IWin32Window? parent, string? title, object? icon, object? tag = null) where T : RadFlyoutBase
|
||||
{
|
||||
return ShowDialog(CreatePanelInstance<T>(tag), parent, title, icon);
|
||||
}
|
||||
|
||||
public static T Show<T>(T dialogPanel, string? title, object? icon) where T : RadFlyoutBase
|
||||
{
|
||||
return Show(dialogPanel, null, title, icon);
|
||||
}
|
||||
|
||||
public static T ShowDialog<T>(T dialogPanel, string? title, object? icon) where T : RadFlyoutBase
|
||||
{
|
||||
return ShowDialog(dialogPanel, null, title, icon);
|
||||
}
|
||||
|
||||
public static T Show<T>(T dialogPanel, IWin32Window? parent, string? title, object? icon) where T : RadFlyoutBase
|
||||
{
|
||||
CreateForm(dialogPanel, parent, title, icon).Show();
|
||||
return dialogPanel;
|
||||
}
|
||||
|
||||
public static T ShowDialog<T>(T dialogPanel, IWin32Window? parent, string? title, object? icon) where T : RadFlyoutBase
|
||||
{
|
||||
CreateForm(dialogPanel, parent, title, icon).ShowDialog();
|
||||
return dialogPanel;
|
||||
}
|
||||
|
||||
private static T CreatePanelInstance<T>(object? tag) where T : RadFlyoutBase
|
||||
{
|
||||
T dialogPanel = Activator.CreateInstance<T>();
|
||||
dialogPanel.Tag = tag;
|
||||
return dialogPanel;
|
||||
}
|
||||
|
||||
private static RadDialogBase CreateForm<T>(T dialogPanel, IWin32Window? parent, string? title, object? icon) where T : RadFlyoutBase
|
||||
{
|
||||
dialogPanel.Dock = DockStyle.Fill;
|
||||
|
||||
if (icon is RadSvgImage svg)
|
||||
icon = svg.ToImage();
|
||||
if (icon is Image img)
|
||||
icon = img.ToIcon();
|
||||
|
||||
var dialog = new RadDialogBase(dialogPanel)
|
||||
{
|
||||
Text = title,
|
||||
Icon = icon as Icon,
|
||||
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
||||
ClientSize = dialogPanel.Size
|
||||
};
|
||||
|
||||
dialog.Controls.Add(dialogPanel);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
35
Pilz.UI.WinForms.Telerik/Dialogs/RadDialogBase.cs
Normal file
35
Pilz.UI.WinForms.Telerik/Dialogs/RadDialogBase.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Pilz.UI.WinForms;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
public partial class RadDialogBase : RadForm
|
||||
{
|
||||
public RadFlyoutBase? DialogPanel { get; private set; }
|
||||
|
||||
private RadDialogBase()
|
||||
{
|
||||
Load += DialogBaseForm_Load;
|
||||
FormClosed += DialogBaseForm_FormClosed;
|
||||
}
|
||||
|
||||
public RadDialogBase(RadFlyoutBase dialogPanel) : this()
|
||||
{
|
||||
DialogPanel = dialogPanel;
|
||||
}
|
||||
|
||||
private void DialogBaseForm_Load(object? sender, EventArgs e)
|
||||
{
|
||||
if (DialogPanel is ILoadContent iLoadContent)
|
||||
iLoadContent.LoadContent();
|
||||
else if (DialogPanel is ILoadContentAsync iLoadContentAsync)
|
||||
Task.Run(iLoadContentAsync.LoadContentAsync).Wait();
|
||||
|
||||
DialogLoading?.Invoke(new DialogLoadingEventArgs(this));
|
||||
}
|
||||
|
||||
private void DialogBaseForm_FormClosed(object? sender, FormClosedEventArgs e)
|
||||
{
|
||||
DialogClosed?.Invoke(new DialogClosedEventArgs(this));
|
||||
}
|
||||
}
|
||||
115
Pilz.UI.WinForms.Telerik/Dialogs/RadFlyoutBase.Statics.cs
Normal file
115
Pilz.UI.WinForms.Telerik/Dialogs/RadFlyoutBase.Statics.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Pilz.UI.WinForms;
|
||||
using Pilz.UI.WinForms.Telerik.Dialogs;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
using Telerik.WinControls.UI.SplashScreen;
|
||||
|
||||
namespace Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
partial class RadFlyoutBase
|
||||
{
|
||||
public delegate void FlyoutCreatedEventHandler(FlyoutCreatedEventArgs e);
|
||||
public delegate void FlyoutClosedEventHandler(FlyoutClosedEventArgs e);
|
||||
|
||||
public static event FlyoutCreatedEventHandler FlyoutCreated
|
||||
{
|
||||
add => flyoutCreatedHandlers.Add(value);
|
||||
remove => flyoutCreatedHandlers.Remove(value);
|
||||
}
|
||||
|
||||
public static event FlyoutClosedEventHandler FlyoutClosed
|
||||
{
|
||||
add => flyoutCloseHandlers.Add(value);
|
||||
remove => flyoutCloseHandlers.Remove(value);
|
||||
}
|
||||
|
||||
private static readonly List<FlyoutCreatedEventHandler> flyoutCreatedHandlers = [];
|
||||
private static readonly List<FlyoutClosedEventHandler> flyoutCloseHandlers = [];
|
||||
|
||||
private static object? tagToAssign = null;
|
||||
private static string? titleToAssing = null;
|
||||
private static RadSvgImage? iconToAssign = null;
|
||||
|
||||
public static Control? ParentContext { get; private set; } = null;
|
||||
|
||||
static RadFlyoutBase()
|
||||
{
|
||||
RadFlyoutManager.ContentCreated += RadFlyoutManager_ContentCreated;
|
||||
RadFlyoutManager.FlyoutClosed += RadFlyoutManager_FlyoutClosed;
|
||||
}
|
||||
|
||||
private static void RadFlyoutManager_ContentCreated(ContentCreatedEventArgs e)
|
||||
{
|
||||
if (e.Content is RadFlyoutBase dialogBase)
|
||||
{
|
||||
if (tagToAssign != null)
|
||||
dialogBase.Tag = tagToAssign;
|
||||
|
||||
if (titleToAssing != null)
|
||||
dialogBase.Title = titleToAssing;
|
||||
|
||||
if (iconToAssign != null)
|
||||
dialogBase.TitleIcon = iconToAssign;
|
||||
|
||||
var eventArgs = new FlyoutCreatedEventArgs(dialogBase);
|
||||
|
||||
if (dialogBase is ILoadContent iLoadContent)
|
||||
iLoadContent.LoadContent();
|
||||
else if (dialogBase is ILoadContentAsync iLoadContentAsync)
|
||||
Task.Run(iLoadContentAsync.LoadContentAsync).Wait();
|
||||
|
||||
foreach (var args in flyoutCreatedHandlers.ToArray())
|
||||
{
|
||||
if (ParentContext != null)
|
||||
ParentContext?.Invoke(args, eventArgs);
|
||||
else
|
||||
args.Invoke(eventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void RadFlyoutManager_FlyoutClosed(global::Telerik.WinControls.UI.SplashScreen.FlyoutClosedEventArgs e)
|
||||
{
|
||||
if (e.Content is RadFlyoutBase dialogBase)
|
||||
{
|
||||
var eventArgs = new FlyoutClosedEventArgs((RadFlyoutBase)e.Content);
|
||||
|
||||
foreach (var args in flyoutCloseHandlers.ToArray())
|
||||
{
|
||||
if (ParentContext != null)
|
||||
ParentContext?.Invoke(args, eventArgs);
|
||||
else
|
||||
args.Invoke(eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
ParentContext = null;
|
||||
}
|
||||
|
||||
public static void Show<T>(Control controlToAssociate, object? tag = null)
|
||||
{
|
||||
Show<T>(controlToAssociate, null, null, tag: tag);
|
||||
}
|
||||
|
||||
public static void Show<T>(Control controlToAssociate, string? title, RadSvgImage? icon, object? tag = null)
|
||||
{
|
||||
Show(controlToAssociate, typeof(T), title, icon, tag: tag);
|
||||
}
|
||||
|
||||
public static void Show(Control controlToAssociate, Type flyoutContentType, string? title, RadSvgImage? icon, object? tag = null)
|
||||
{
|
||||
tagToAssign = tag;
|
||||
titleToAssing = title;
|
||||
iconToAssign = icon;
|
||||
ParentContext = controlToAssociate;
|
||||
CloseFlyout(); // Ensure it's closed!
|
||||
RadFlyoutManager.Show(controlToAssociate, flyoutContentType);
|
||||
}
|
||||
|
||||
protected static void CloseFlyout()
|
||||
{
|
||||
if (typeof(RadFlyoutManager).GetField("flyoutInstance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).GetValue(null) is FlyoutScreen instance
|
||||
&& instance.IsActive)
|
||||
RadFlyoutManager.Close();
|
||||
}
|
||||
}
|
||||
291
Pilz.UI.WinForms.Telerik/Dialogs/RadFlyoutBase.cs
Normal file
291
Pilz.UI.WinForms.Telerik/Dialogs/RadFlyoutBase.cs
Normal file
@@ -0,0 +1,291 @@
|
||||
using Pilz.UI.WinForms.Telerik.Controls.RadValidationProvider;
|
||||
using System.ComponentModel;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.Data;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
public partial class RadFlyoutBase : UserControl
|
||||
{
|
||||
private bool addedControlsToUi;
|
||||
|
||||
protected RadButton radButton_Cancel;
|
||||
protected RadButton radButton_Confirm;
|
||||
protected TableLayoutPanel tableLayoutPanel_ActionPanel;
|
||||
protected TableLayoutPanel tableLayoutPanel_TitlePanel;
|
||||
protected RadLabel radLabel_Title;
|
||||
|
||||
public static RadSvgImage? CancelSvg { get; set; } = null;
|
||||
public static RadSvgImage? ConfirmSvg { get; set; } = null;
|
||||
|
||||
[Browsable(false)]
|
||||
public RadValidationProviderEx ValidationProvider { get; } = new()
|
||||
{
|
||||
AllowCancelControlEvents = false,
|
||||
};
|
||||
|
||||
[ReadOnly(true)]
|
||||
public DialogResult Result { get; protected set; }
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool RegisterDialogAccept { get; set; } = true;
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool RegisterDialogCancel { get; set; } = true;
|
||||
|
||||
public new Size PreferredSize { get; set; } = Size.Empty;
|
||||
|
||||
[DefaultValue(true)]
|
||||
public virtual bool ActionPanelVisible
|
||||
{
|
||||
get => tableLayoutPanel_ActionPanel.Visible;
|
||||
set => tableLayoutPanel_ActionPanel.Visible = value;
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public virtual bool CancelButtonVisible
|
||||
{
|
||||
get => radButton_Cancel.Visible;
|
||||
set => radButton_Cancel.Visible = value;
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public virtual bool CancelButtonEnable
|
||||
{
|
||||
get => radButton_Cancel.Enabled;
|
||||
set => radButton_Cancel.Enabled = value;
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public virtual bool ConfirmButtonEnable
|
||||
{
|
||||
get => radButton_Confirm.Enabled;
|
||||
set => radButton_Confirm.Enabled = value;
|
||||
}
|
||||
|
||||
[Localizable(true)]
|
||||
[DefaultValue("Okay")]
|
||||
public virtual string ConfirmButtonText
|
||||
{
|
||||
get => radButton_Confirm.Text;
|
||||
set => radButton_Confirm.Text = value;
|
||||
}
|
||||
|
||||
[Localizable(true)]
|
||||
[DefaultValue("Cancel")]
|
||||
public virtual string CancelButtonText
|
||||
{
|
||||
get => radButton_Cancel.Text;
|
||||
set => radButton_Cancel.Text = value;
|
||||
}
|
||||
|
||||
[Localizable(true)]
|
||||
[DefaultValue("")]
|
||||
public virtual string Title
|
||||
{
|
||||
get => radLabel_Title.Text;
|
||||
set
|
||||
{
|
||||
radLabel_Title.Text = value;
|
||||
SetShowTitlePanel();
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
public virtual RadSvgImage TitleIcon
|
||||
{
|
||||
get => radLabel_Title.SvgImage;
|
||||
set
|
||||
{
|
||||
radLabel_Title.SvgImage = value;
|
||||
SetShowTitlePanel();
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(ValidationMode), "OnValidating")]
|
||||
public ValidationMode ValidationMode
|
||||
{
|
||||
get => ValidationProvider.ValidationMode;
|
||||
set => ValidationProvider.ValidationMode = value;
|
||||
}
|
||||
|
||||
protected RadFlyoutBase()
|
||||
{
|
||||
InitializeComponent();
|
||||
ParentChanged += FlyoutDialogBase_ParentChanged;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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.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(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.SuspendLayout();
|
||||
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;
|
||||
Size = new Size(300, 150);
|
||||
|
||||
tableLayoutPanel_TitlePanel.ResumeLayout(false);
|
||||
tableLayoutPanel_ActionPanel.ResumeLayout(false);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
if (!addedControlsToUi && !DesignMode)
|
||||
{
|
||||
SuspendLayout();
|
||||
Controls.Add(tableLayoutPanel_ActionPanel);
|
||||
tableLayoutPanel_ActionPanel.SendToBack();
|
||||
Controls.Add(tableLayoutPanel_TitlePanel);
|
||||
tableLayoutPanel_TitlePanel.SendToBack();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
SetShowTitlePanel();
|
||||
addedControlsToUi = true;
|
||||
}
|
||||
base.OnLoad(e);
|
||||
}
|
||||
|
||||
protected virtual 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;
|
||||
radButton_Cancel.DialogResult = DialogResult.None;
|
||||
}
|
||||
|
||||
if (AutoSize)
|
||||
{
|
||||
frm.AutoSize = true;
|
||||
frm.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
}
|
||||
else
|
||||
{
|
||||
frm.ClientSize = Size;
|
||||
}
|
||||
|
||||
frm.Shown += Form_Shown;
|
||||
}
|
||||
}
|
||||
|
||||
private void Form_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
if (FindForm() is not Form frm)
|
||||
return;
|
||||
|
||||
if (!AutoSize && !PreferredSize.IsEmpty)
|
||||
frm.ClientSize = PreferredSize;
|
||||
}
|
||||
|
||||
protected void Close(DialogResult result)
|
||||
{
|
||||
Result = result;
|
||||
|
||||
if (FindForm() is RadDialogBase dialogForm)
|
||||
dialogForm.Close();
|
||||
else
|
||||
CloseFlyout();
|
||||
}
|
||||
|
||||
protected virtual bool ValidateOK()
|
||||
{
|
||||
return ValidationProvider.ValidateAll();
|
||||
}
|
||||
|
||||
protected virtual void SetShowTitlePanel()
|
||||
{
|
||||
tableLayoutPanel_TitlePanel.Visible = !string.IsNullOrWhiteSpace(radLabel_Title.Text) || radLabel_Title.SvgImage != null;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Close(DialogResult.Cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user