add Pilz.UI.Telerik & Pilz.UI.Telerik.SymbolFactory

This commit is contained in:
2023-08-29 13:25:11 +02:00
parent 743bd7f19c
commit d0ac4e3b84
17 changed files with 831 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Pilz.UI.Telerik.Dialogs
{
partial class DialogBaseForm
{
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 ShowDialog<T>(string title, Icon icon, object? tag = null) where T : FlyoutDialogBase
{
return ShowDialog<T>(null, title, icon, tag);
}
public static T ShowDialog<T>(IWin32Window? parent, string title, Icon icon, object? tag = null) where T : FlyoutDialogBase
{
var dialogPanel = Activator.CreateInstance<T>();
dialogPanel.Dock = DockStyle.Fill;
dialogPanel.Tag = tag;
var dialog = new DialogBaseForm
{
DialogPanel = dialogPanel,
Text = title,
Icon = icon,
StartPosition = parent == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent,
ClientSize = dialogPanel.Size
};
dialog.Controls.Add(dialogPanel);
dialog.ShowDialog(parent);
return dialogPanel;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;
namespace Pilz.UI.Telerik.Dialogs
{
public partial class DialogBaseForm : RadForm
{
public FlyoutDialogBase? DialogPanel { get; private set; }
private DialogBaseForm()
{
Load += DialogBaseForm_Load;
FormClosed += DialogBaseForm_FormClosed;
}
private void DialogBaseForm_Load(object? sender, EventArgs e)
{
if (DialogPanel is ILoadContent iLoadContent)
iLoadContent.LoadContent();
DialogLoading?.Invoke(new DialogLoadingEventArgs(this));
}
private void DialogBaseForm_FormClosed(object? sender, FormClosedEventArgs e)
{
DialogClosed?.Invoke(new DialogClosedEventArgs(this));
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Pilz.UI.Telerik.Dialogs
{
public class DialogClosedEventArgs : EventArgs
{
public DialogBaseForm Parent { get; private set; }
public FlyoutDialogBase? Content => Parent?.DialogPanel;
public DialogClosedEventArgs(DialogBaseForm dialog)
{
Parent = dialog;
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Pilz.UI.Telerik.Dialogs
{
public class DialogLoadingEventArgs : EventArgs
{
public DialogBaseForm Parent { get; private set; }
public FlyoutDialogBase? Content => Parent?.DialogPanel;
public DialogLoadingEventArgs(DialogBaseForm dialog)
{
Parent = dialog;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Pilz.UI.Telerik.Dialogs
{
public class FlyoutClosedEventArgs : global::Telerik.WinControls.UI.SplashScreen.FlyoutClosedEventArgs
{
public new FlyoutDialogBase? Content => base.Content as FlyoutDialogBase;
public FlyoutClosedEventArgs(FlyoutDialogBase content) : base(content)
{
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI.SplashScreen;
namespace Pilz.UI.Telerik.Dialogs
{
public class FlyoutCreatedEventArgs : ContentCreatedEventArgs
{
public new FlyoutDialogBase? Content => base.Content as FlyoutDialogBase;
public FlyoutCreatedEventArgs(FlyoutDialogBase content) : base(content)
{
}
}
}

View File

@@ -0,0 +1,77 @@
namespace Pilz.UI.Telerik.Dialogs
{
partial class FlyoutDialogBase
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FlyoutDialogBase));
radButton_Cancel = new global::Telerik.WinControls.UI.RadButton();
radButton_Confirm = new global::Telerik.WinControls.UI.RadButton();
panel_ActionButtons = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)radButton_Cancel).BeginInit();
((System.ComponentModel.ISupportInitialize)radButton_Confirm).BeginInit();
panel_ActionButtons.SuspendLayout();
SuspendLayout();
//
// radButton_Cancel
//
resources.ApplyResources(radButton_Cancel, "radButton_Cancel");
radButton_Cancel.Name = "radButton_Cancel";
radButton_Cancel.Click += RadButton_Cancel_Click;
//
// radButton_Confirm
//
resources.ApplyResources(radButton_Confirm, "radButton_Confirm");
radButton_Confirm.Name = "radButton_Confirm";
radButton_Confirm.Click += RadButton_Confirm_Click;
//
// panel_ActionButtons
//
panel_ActionButtons.Controls.Add(radButton_Cancel);
panel_ActionButtons.Controls.Add(radButton_Confirm);
resources.ApplyResources(panel_ActionButtons, "panel_ActionButtons");
panel_ActionButtons.Name = "panel_ActionButtons";
//
// FlyoutDialogBase
//
resources.ApplyResources(this, "$this");
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
Controls.Add(panel_ActionButtons);
Name = "FlyoutDialogBase";
((System.ComponentModel.ISupportInitialize)radButton_Cancel).EndInit();
((System.ComponentModel.ISupportInitialize)radButton_Confirm).EndInit();
panel_ActionButtons.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private global::Telerik.WinControls.UI.RadButton radButton_Cancel;
private global::Telerik.WinControls.UI.RadButton radButton_Confirm;
private System.Windows.Forms.Panel panel_ActionButtons;
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.WinControls.UI.SplashScreen;
using Telerik.WinControls.UI;
using System.Windows.Forms;
namespace Pilz.UI.Telerik.Dialogs
{
partial class FlyoutDialogBase
{
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 = new();
private static readonly List<FlyoutClosedEventHandler> flyoutCloseHandlers = new();
private static object? tagToAssign = null;
public static Control? ParentContext { get; private set; } = null;
static FlyoutDialogBase()
{
RadFlyoutManager.ContentCreated += RadFlyoutManager_ContentCreated;
RadFlyoutManager.FlyoutClosed += RadFlyoutManager_FlyoutClosed;
}
private static void RadFlyoutManager_ContentCreated(ContentCreatedEventArgs e)
{
if (e.Content is FlyoutDialogBase dialogBase)
{
if (tagToAssign != null)
dialogBase.Tag = tagToAssign;
var eventArgs = new FlyoutCreatedEventArgs((FlyoutDialogBase)e.Content);
if (dialogBase is ILoadContent iLoadContent)
iLoadContent.LoadContent();
foreach (var args in flyoutCreatedHandlers)
{
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 FlyoutDialogBase dialogBase)
{
var eventArgs = new FlyoutClosedEventArgs((FlyoutDialogBase)e.Content);
foreach (var args in flyoutCloseHandlers)
{
if (ParentContext != null)
ParentContext?.Invoke(args, eventArgs);
else
args.Invoke(eventArgs);
}
}
ParentContext = null;
}
public static void Show<T>(Control controlToAssociate, object? tag = null)
{
Show(controlToAssociate, typeof(T), tag);
}
public static void Show(Control controlToAssociate, Type flyoutContentType, object? tag = null)
{
tagToAssign = tag;
ParentContext = controlToAssociate;
RadFlyoutManager.Show(controlToAssociate, flyoutContentType);
}
protected static void CloseFlyout()
{
if (ParentContext == null)
throw new NullReferenceException(nameof(ParentContext));
ParentContext.BeginInvoke(RadFlyoutManager.Close);
}
}
}

View File

@@ -0,0 +1,86 @@
using Pilz.UI.Telerik;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
using Telerik.WinControls.UI.SplashScreen;
using static Telerik.WinControls.UI.PopupEditorNotificationData;
namespace Pilz.UI.Telerik.Dialogs
{
public partial class FlyoutDialogBase : UserControl
{
public static RadSvgImage? CancelSvg { get; set; } = null;
public static RadSvgImage? ConfirmSvg { get; set; } = null;
public DialogResult Result { get; protected set; }
protected bool ActionPanelVisible
{
get => panel_ActionButtons.Visible;
set => panel_ActionButtons.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;
}
protected FlyoutDialogBase()
{
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)
frm.AcceptButton = radButton_Confirm;
}
protected void Close(DialogResult result)
{
Result = result;
if (FindForm() is DialogBaseForm 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;
}
}
}

View File

@@ -0,0 +1,234 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="radButton_Cancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="radButton_Cancel.ImageAlignment" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="radButton_Cancel.Location" type="System.Drawing.Point, System.Drawing">
<value>187, 3</value>
</data>
<data name="radButton_Cancel.Size" type="System.Drawing.Size, System.Drawing">
<value>110, 24</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="radButton_Cancel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="radButton_Cancel.Text" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="radButton_Cancel.TextAlignment" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="radButton_Cancel.TextImageRelation" type="System.Windows.Forms.TextImageRelation, System.Windows.Forms">
<value>ImageBeforeText</value>
</data>
<data name="&gt;&gt;radButton_Cancel.Name" xml:space="preserve">
<value>radButton_Cancel</value>
</data>
<data name="&gt;&gt;radButton_Cancel.Type" xml:space="preserve">
<value>Telerik.WinControls.UI.RadButton, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e</value>
</data>
<data name="&gt;&gt;radButton_Cancel.Parent" xml:space="preserve">
<value>panel_ActionButtons</value>
</data>
<data name="&gt;&gt;radButton_Cancel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="radButton_Confirm.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="radButton_Confirm.ImageAlignment" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleRight</value>
</data>
<data name="radButton_Confirm.Location" type="System.Drawing.Point, System.Drawing">
<value>71, 3</value>
</data>
<data name="radButton_Confirm.Size" type="System.Drawing.Size, System.Drawing">
<value>110, 24</value>
</data>
<data name="radButton_Confirm.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="radButton_Confirm.Text" xml:space="preserve">
<value>Okay</value>
</data>
<data name="radButton_Confirm.TextAlignment" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="radButton_Confirm.TextImageRelation" type="System.Windows.Forms.TextImageRelation, System.Windows.Forms">
<value>ImageBeforeText</value>
</data>
<data name="&gt;&gt;radButton_Confirm.Name" xml:space="preserve">
<value>radButton_Confirm</value>
</data>
<data name="&gt;&gt;radButton_Confirm.Type" xml:space="preserve">
<value>Telerik.WinControls.UI.RadButton, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e</value>
</data>
<data name="&gt;&gt;radButton_Confirm.Parent" xml:space="preserve">
<value>panel_ActionButtons</value>
</data>
<data name="&gt;&gt;radButton_Confirm.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="panel_ActionButtons.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Bottom</value>
</data>
<data name="panel_ActionButtons.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 120</value>
</data>
<data name="panel_ActionButtons.Size" type="System.Drawing.Size, System.Drawing">
<value>300, 30</value>
</data>
<data name="panel_ActionButtons.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="&gt;&gt;panel_ActionButtons.Name" xml:space="preserve">
<value>panel_ActionButtons</value>
</data>
<data name="&gt;&gt;panel_ActionButtons.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;panel_ActionButtons.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;panel_ActionButtons.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>7, 15</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>300, 150</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>FlyoutDialogBase</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pilz.UI.Telerik.Dialogs
{
public interface ILoadContent
{
void LoadContent();
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="UI.for.WinForms.AllControls.Net60" Version="2023.1.117" />
</ItemGroup>
</Project>