add support for REST-ful API building
- allow parameters within url - allow different methods other then just POST -> still needs to be tested!
This commit is contained in:
10
Pilz.UI/Controls/ConfigurationManager/ConfigurationEntry.cs
Normal file
10
Pilz.UI/Controls/ConfigurationManager/ConfigurationEntry.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pilz.UI.Controls.ConfigurationManager;
|
||||
|
||||
public class ConfigurationEntry(string name, string title, ConfigurationValueListener Listener)
|
||||
{
|
||||
public event EventHandler? OnValueChanged;
|
||||
|
||||
public string Name { get; } = name;
|
||||
public string Title { get; } = title;
|
||||
public ConfigurationValueListener Listener { get; } = Listener;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Pilz.UI.Controls.ConfigurationManager;
|
||||
|
||||
public class ConfigurationManager
|
||||
{
|
||||
private readonly List<ConfigurationPanel> panels = [];
|
||||
|
||||
public void Register(ConfigurationPanel panel)
|
||||
{
|
||||
panels.Add(panel);
|
||||
}
|
||||
|
||||
public IEnumerable<Control> Build()
|
||||
{
|
||||
foreach (var panel in panels)
|
||||
{
|
||||
panel.Build(this);
|
||||
yield return panel;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Pilz.UI/Controls/ConfigurationManager/ConfigurationPanel.cs
Normal file
32
Pilz.UI/Controls/ConfigurationManager/ConfigurationPanel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace Pilz.UI.Controls.ConfigurationManager;
|
||||
|
||||
public class ConfigurationPanel : TableLayoutPanel
|
||||
{
|
||||
private readonly List<ConfigurationEntry> entries = [];
|
||||
|
||||
public ConfigurationEntry CreateEntry(string name, string title)
|
||||
{
|
||||
return CreateEntry(name, title, null);
|
||||
}
|
||||
|
||||
public ConfigurationEntry CreateEntry(string name, string title, Action? create)
|
||||
{
|
||||
return CreateEntry(new(name, title, ));
|
||||
}
|
||||
|
||||
public ConfigurationEntry CreateEntry(ConfigurationEntry entry)
|
||||
{
|
||||
entries.Add(entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
internal protected void Build(ConfigurationManager manager)
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var control = ;
|
||||
entry.Listener.Initialize();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Pilz.UI.Controls.ConfigurationManager;
|
||||
|
||||
public abstract class ConfigurationValueListener : IDisposable
|
||||
{
|
||||
public event EventHandler? ValueChanged;
|
||||
|
||||
protected virtual void OnValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
ValueChanged?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
internal protected abstract void Initialize(Control control);
|
||||
|
||||
public abstract void Dispose();
|
||||
}
|
||||
Reference in New Issue
Block a user