code optimization
This commit is contained in:
@@ -1,39 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI
|
||||
[Flags]
|
||||
public enum FeatureInsertMode
|
||||
{
|
||||
[Flags]
|
||||
public enum FeatureInsertMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Features will be inserted at the end of the collection.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
/// <summary>
|
||||
/// Features will be inserted at the end of the collection.
|
||||
/// This is the default behavior and equals <see cref="Default"/>. Will only be used if not set <see cref="UseCustomDefault"/>.
|
||||
/// </summary>
|
||||
DefaultEnd = Default,
|
||||
/// <summary>
|
||||
/// Features will be inserted at the start of the collection.
|
||||
/// Will only be used if not set <see cref="UseCustomDefault"/>.
|
||||
/// </summary>
|
||||
DefaultStart = 1,
|
||||
/// <summary>
|
||||
/// Features with prioritization <see cref="FeaturePrioritization.High"/> will be inserted at the top (or left).
|
||||
/// </summary>
|
||||
InsertTop = 1 << 2,
|
||||
/// <summary>
|
||||
/// Features with prioritization <see cref="FeaturePrioritization.Low"/> will be inserted at the bottom (or right).
|
||||
/// </summary>
|
||||
InsertBottom = 1 << 3,
|
||||
/// <summary>
|
||||
/// Features with prioritization other then <see cref="FeaturePrioritization.Default"/> will be inserted at the top or bottom.
|
||||
/// </summary>
|
||||
InsertTopAndBottom = InsertTop | InsertBottom,
|
||||
}
|
||||
/// <summary>
|
||||
/// Features will be inserted at the end of the collection.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
/// <summary>
|
||||
/// Features will be inserted at the end of the collection.
|
||||
/// This is the default behavior and equals <see cref="Default"/>. Will only be used if not set <see cref="UseCustomDefault"/>.
|
||||
/// </summary>
|
||||
DefaultEnd = Default,
|
||||
/// <summary>
|
||||
/// Features will be inserted at the start of the collection.
|
||||
/// Will only be used if not set <see cref="UseCustomDefault"/>.
|
||||
/// </summary>
|
||||
DefaultStart = 1,
|
||||
/// <summary>
|
||||
/// Features with prioritization <see cref="FeaturePrioritization.High"/> will be inserted at the top (or left).
|
||||
/// </summary>
|
||||
InsertTop = 1 << 2,
|
||||
/// <summary>
|
||||
/// Features with prioritization <see cref="FeaturePrioritization.Low"/> will be inserted at the bottom (or right).
|
||||
/// </summary>
|
||||
InsertBottom = 1 << 3,
|
||||
/// <summary>
|
||||
/// Features with prioritization other then <see cref="FeaturePrioritization.Default"/> will be inserted at the top or bottom.
|
||||
/// </summary>
|
||||
InsertTopAndBottom = InsertTop | InsertBottom,
|
||||
}
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI
|
||||
[Flags]
|
||||
public enum FeatureInsertPosition
|
||||
{
|
||||
[Flags]
|
||||
public enum FeatureInsertPosition
|
||||
{
|
||||
None = 0,
|
||||
Default = 1,
|
||||
Top = 2,
|
||||
Bottom = 3,
|
||||
}
|
||||
None = 0,
|
||||
Default = 1,
|
||||
Top = 2,
|
||||
Bottom = 3,
|
||||
}
|
||||
|
||||
@@ -1,48 +1,44 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI
|
||||
public abstract class PluginModule<TPluginModuleUI> : PluginModuleBase where TPluginModuleUI : Control
|
||||
{
|
||||
public abstract class PluginModule<TPluginModuleUI> : PluginModuleBase where TPluginModuleUI : Control
|
||||
public delegate void PluginModuleUIEventHandler(PluginModuleBase module, TPluginModuleUI ui);
|
||||
|
||||
/// <summary>
|
||||
/// Fires when a <see cref="PluginModuleUI"/> instance has been created.
|
||||
/// </summary>
|
||||
public static event PluginModuleUIEventHandler? OnUICreated;
|
||||
|
||||
public bool Visible { get; set; } = true;
|
||||
public bool AllowEmbedding { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for the <see cref="PluginFeature.Icon"/> property to directly use it as <see cref="System.Drawing.Image"/>.
|
||||
/// </summary>
|
||||
public Image? Image
|
||||
{
|
||||
public delegate void PluginModuleUIEventHandler(PluginModuleBase module, TPluginModuleUI ui);
|
||||
|
||||
/// <summary>
|
||||
/// Fires when a <see cref="PluginModuleUI"/> instance has been created.
|
||||
/// </summary>
|
||||
public static event PluginModuleUIEventHandler? OnUICreated;
|
||||
|
||||
public bool Visible { get; set; } = true;
|
||||
public bool AllowEmbedding { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for the <see cref="PluginFeature.Icon"/> property to directly use it as <see cref="System.Drawing.Image"/>.
|
||||
/// </summary>
|
||||
public Image? Image
|
||||
{
|
||||
get => base.Icon as Image;
|
||||
set => base.Icon = value;
|
||||
}
|
||||
|
||||
protected PluginModule(string moduleType, string moduleIdentifier) : base(moduleType, moduleIdentifier)
|
||||
{
|
||||
}
|
||||
|
||||
protected PluginModule(string moduleType, string moduleIdentifier, string moduleName) : base(moduleType, moduleIdentifier, moduleName)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ShowUI()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI()
|
||||
{
|
||||
var ui = CreateNewUI();
|
||||
OnUICreated?.Invoke(this, ui);
|
||||
return ui;
|
||||
}
|
||||
|
||||
protected abstract TPluginModuleUI CreateNewUI();
|
||||
get => base.Icon as Image;
|
||||
set => base.Icon = value;
|
||||
}
|
||||
|
||||
protected PluginModule(string moduleType, string moduleIdentifier) : base(moduleType, moduleIdentifier)
|
||||
{
|
||||
}
|
||||
|
||||
protected PluginModule(string moduleType, string moduleIdentifier, string moduleName) : base(moduleType, moduleIdentifier, moduleName)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ShowUI()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI()
|
||||
{
|
||||
var ui = CreateNewUI();
|
||||
OnUICreated?.Invoke(this, ui);
|
||||
return ui;
|
||||
}
|
||||
|
||||
protected abstract TPluginModuleUI CreateNewUI();
|
||||
}
|
||||
Reference in New Issue
Block a user