add Pilz.UI & Pilz.UI.Gtk
This commit is contained in:
14
Pilz.UI/Pilz.UI.csproj
Normal file
14
Pilz.UI/Pilz.UI.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>3.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
29
Pilz.UI/Symbols/BaseSymbolFactory.cs
Normal file
29
Pilz.UI/Symbols/BaseSymbolFactory.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pilz.UI.Symbols;
|
||||
|
||||
public abstract class BaseSymbolFactory<TSymbols> : IBaseSymbolFactory<TSymbols>
|
||||
{
|
||||
public abstract string GetImageRessourcePath(TSymbols svgImage);
|
||||
public abstract Assembly GetImageResourceAssembly();
|
||||
|
||||
protected virtual Size ResolveCommonSize(SymbolSize size)
|
||||
{
|
||||
return size switch
|
||||
{
|
||||
SymbolSize.Default => Size.Empty,
|
||||
SymbolSize.Small => new Size(16, 16),
|
||||
SymbolSize.Medium => new Size(20, 20),
|
||||
SymbolSize.Large => new Size(32, 32),
|
||||
_ => new Size((int)size, (int)size),
|
||||
};
|
||||
}
|
||||
|
||||
public virtual Stream? GetImageRessourceStream(TSymbols svgImage)
|
||||
{
|
||||
var asm = GetImageResourceAssembly();
|
||||
var path = GetImageRessourcePath(svgImage);
|
||||
return asm.GetManifestResourceStream(path);
|
||||
}
|
||||
}
|
||||
9
Pilz.UI/Symbols/IBaseSymbolFactory.cs
Normal file
9
Pilz.UI/Symbols/IBaseSymbolFactory.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Pilz.UI.Symbols;
|
||||
public interface IBaseSymbolFactory<TSymbols>
|
||||
{
|
||||
Assembly GetImageResourceAssembly();
|
||||
string GetImageRessourcePath(TSymbols svgImage);
|
||||
Stream? GetImageRessourceStream(TSymbols svgImage);
|
||||
}
|
||||
72
Pilz.UI/Symbols/SymbolSize.cs
Normal file
72
Pilz.UI/Symbols/SymbolSize.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
namespace Pilz.UI.Symbols;
|
||||
|
||||
public enum SymbolSize
|
||||
{
|
||||
/// <summary>
|
||||
/// Don't resize and just returns the original size.
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 16 x 16 pixels.
|
||||
/// <br/><b>Deprecated!</b> This is just present due legacy reasons. Use <see cref="x16"/> instead.
|
||||
/// </summary>
|
||||
Small,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 20 x 20 pixels.
|
||||
/// <br/><b>Deprecated!</b> This is just present due legacy reasons. Use <see cref="x20"/> instead.
|
||||
/// </summary>
|
||||
Medium,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 32 x 32 pixels.
|
||||
/// <br/><b>Deprecated!</b> This is just present due legacy reasons. Use <see cref="x32"/> instead.
|
||||
/// </summary>
|
||||
Large,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 8 x 8 pixels.
|
||||
/// </summary>
|
||||
x8 = 8,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 12 x 12 pixels.
|
||||
/// </summary>
|
||||
x12 = 12,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 16 x 16 pixels.
|
||||
/// </summary>
|
||||
x16 = 16,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 20 x 20 pixels.
|
||||
/// </summary>
|
||||
x20 = 20,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 32 x 32 pixels.
|
||||
/// </summary>
|
||||
x32 = 32,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 48 x 48 pixels.
|
||||
/// </summary>
|
||||
x48 = 48,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 64 x 64 pixels.
|
||||
/// </summary>
|
||||
x64 = 64,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 96 x 96 pixels.
|
||||
/// </summary>
|
||||
x96 = 96,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 128 x 128 pixels.
|
||||
/// </summary>
|
||||
x128 = 128,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 192 x 192 pixels.
|
||||
/// </summary>
|
||||
x192 = 192,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 256 x 256 pixels.
|
||||
/// </summary>
|
||||
x256 = 256,
|
||||
/// <summary>
|
||||
/// Resizes the symbol to 512 x 512 pixels.
|
||||
/// </summary>
|
||||
x512 = 512,
|
||||
}
|
||||
Reference in New Issue
Block a user