small improvements to RadFlyoutBase & RadDialogBase
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
namespace Pilz.UI.Telerik.Dialogs;
|
using Telerik.WinControls;
|
||||||
|
|
||||||
|
namespace Pilz.UI.Telerik.Dialogs;
|
||||||
|
|
||||||
partial class RadDialogBase
|
partial class RadDialogBase
|
||||||
{
|
{
|
||||||
@@ -8,43 +10,43 @@ partial class RadDialogBase
|
|||||||
public static event DialogLoadingEventHandler? DialogLoading;
|
public static event DialogLoadingEventHandler? DialogLoading;
|
||||||
public static event DialogClosedEventHandler? DialogClosed;
|
public static event DialogClosedEventHandler? DialogClosed;
|
||||||
|
|
||||||
public static T Show<T>(string title, Icon icon, object? tag = null) where T : RadFlyoutBase
|
public static T Show<T>(string? title, object? icon, object? tag = null) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
return Show<T>(null, title, icon, tag);
|
return Show<T>(null, title, icon, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T ShowDialog<T>(string title, Icon icon, object? tag = null) where T : RadFlyoutBase
|
public static T ShowDialog<T>(string? title, object? icon, object? tag = null) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
return ShowDialog<T>(null, title, icon, tag);
|
return ShowDialog<T>(null, title, icon, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Show<T>(IWin32Window? parent, string title, Icon icon, object? tag = null) where T : RadFlyoutBase
|
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);
|
return Show(CreatePanelInstance<T>(tag), parent, title, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T ShowDialog<T>(IWin32Window? parent, string title, Icon icon, object? tag = null) where T : RadFlyoutBase
|
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);
|
return ShowDialog(CreatePanelInstance<T>(tag), parent, title, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Show<T>(T dialogPanel, string title, Icon icon) where T : RadFlyoutBase
|
public static T Show<T>(T dialogPanel, string? title, object? icon) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
return Show(dialogPanel, null, title, icon);
|
return Show(dialogPanel, null, title, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T ShowDialog<T>(T dialogPanel, string title, Icon icon) where T : RadFlyoutBase
|
public static T ShowDialog<T>(T dialogPanel, string? title, object? icon) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
return ShowDialog(dialogPanel, null, title, icon);
|
return ShowDialog(dialogPanel, null, title, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Show<T>(T dialogPanel, IWin32Window? parent, string title, Icon icon) where T : RadFlyoutBase
|
public static T Show<T>(T dialogPanel, IWin32Window? parent, string? title, object? icon) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
CreateForm(dialogPanel, parent, title, icon).Show();
|
CreateForm(dialogPanel, parent, title, icon).Show();
|
||||||
return dialogPanel;
|
return dialogPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T ShowDialog<T>(T dialogPanel, IWin32Window? parent, string title, Icon icon) where T : RadFlyoutBase
|
public static T ShowDialog<T>(T dialogPanel, IWin32Window? parent, string? title, object? icon) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
CreateForm(dialogPanel, parent, title, icon).ShowDialog();
|
CreateForm(dialogPanel, parent, title, icon).ShowDialog();
|
||||||
return dialogPanel;
|
return dialogPanel;
|
||||||
@@ -57,14 +59,19 @@ partial class RadDialogBase
|
|||||||
return dialogPanel;
|
return dialogPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RadDialogBase CreateForm<T>(T dialogPanel, IWin32Window? parent, string title, Icon icon) where T : RadFlyoutBase
|
private static RadDialogBase CreateForm<T>(T dialogPanel, IWin32Window? parent, string? title, object? icon) where T : RadFlyoutBase
|
||||||
{
|
{
|
||||||
dialogPanel.Dock = DockStyle.Fill;
|
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)
|
var dialog = new RadDialogBase(dialogPanel)
|
||||||
{
|
{
|
||||||
Text = title,
|
Text = title,
|
||||||
Icon = icon,
|
Icon = icon as Icon,
|
||||||
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
|
||||||
ClientSize = dialogPanel.Size
|
ClientSize = dialogPanel.Size
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Telerik.WinControls.UI;
|
using Telerik.WinControls;
|
||||||
|
using Telerik.WinControls.Svg;
|
||||||
|
using Telerik.WinControls.UI;
|
||||||
using Telerik.WinControls.UI.SplashScreen;
|
using Telerik.WinControls.UI.SplashScreen;
|
||||||
|
|
||||||
namespace Pilz.UI.Telerik.Dialogs;
|
namespace Pilz.UI.Telerik.Dialogs;
|
||||||
@@ -24,6 +26,9 @@ partial class RadFlyoutBase
|
|||||||
private static readonly List<FlyoutClosedEventHandler> flyoutCloseHandlers = new();
|
private static readonly List<FlyoutClosedEventHandler> flyoutCloseHandlers = new();
|
||||||
|
|
||||||
private static object? tagToAssign = null;
|
private static object? tagToAssign = null;
|
||||||
|
private static string? titleToAssing = null;
|
||||||
|
private static RadSvgImage? iconToAssign = null;
|
||||||
|
|
||||||
public static Control? ParentContext { get; private set; } = null;
|
public static Control? ParentContext { get; private set; } = null;
|
||||||
|
|
||||||
static RadFlyoutBase()
|
static RadFlyoutBase()
|
||||||
@@ -39,6 +44,12 @@ partial class RadFlyoutBase
|
|||||||
if (tagToAssign != null)
|
if (tagToAssign != null)
|
||||||
dialogBase.Tag = tagToAssign;
|
dialogBase.Tag = tagToAssign;
|
||||||
|
|
||||||
|
if (titleToAssing != null)
|
||||||
|
dialogBase.Title = titleToAssing;
|
||||||
|
|
||||||
|
if (iconToAssign != null)
|
||||||
|
dialogBase.TitleIcon = iconToAssign;
|
||||||
|
|
||||||
var eventArgs = new FlyoutCreatedEventArgs(dialogBase);
|
var eventArgs = new FlyoutCreatedEventArgs(dialogBase);
|
||||||
|
|
||||||
if (dialogBase is ILoadContent iLoadContent)
|
if (dialogBase is ILoadContent iLoadContent)
|
||||||
@@ -74,12 +85,19 @@ partial class RadFlyoutBase
|
|||||||
|
|
||||||
public static void Show<T>(Control controlToAssociate, object? tag = null)
|
public static void Show<T>(Control controlToAssociate, object? tag = null)
|
||||||
{
|
{
|
||||||
Show(controlToAssociate, typeof(T), tag);
|
Show<T>(controlToAssociate, tag: tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Show(Control controlToAssociate, Type flyoutContentType, object? tag = null)
|
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;
|
tagToAssign = tag;
|
||||||
|
titleToAssing = title;
|
||||||
|
iconToAssign = icon;
|
||||||
ParentContext = controlToAssociate;
|
ParentContext = controlToAssociate;
|
||||||
RadFlyoutManager.Show(controlToAssociate, flyoutContentType);
|
RadFlyoutManager.Show(controlToAssociate, flyoutContentType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Drawing;
|
using Telerik.WinControls;
|
||||||
using Telerik.WinControls;
|
|
||||||
using Telerik.WinControls.Svg;
|
using Telerik.WinControls.Svg;
|
||||||
|
|
||||||
namespace Pilz.UI.Telerik;
|
namespace Pilz.UI.Telerik;
|
||||||
Reference in New Issue
Block a user