pilzinsel64 deleted page: Pilz.UI.Telerik.SymbolFactory
@@ -1,73 +0,0 @@
|
|||||||
[[_TOC_]]
|
|
||||||
|
|
||||||
# SymbolFactor
|
|
||||||
|
|
||||||
## Setup SymbolFactory
|
|
||||||
|
|
||||||
Create a new directory, we call it `Symbols` here.
|
|
||||||
|
|
||||||
{width=188 height=275}
|
|
||||||
|
|
||||||
Ensure you add this to the project file. This will mark all SVG files within the Symbols folder as embedded resource.
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Symbols\*.svg" />
|
|
||||||
</ItemGroup>
|
|
||||||
```
|
|
||||||
|
|
||||||
Create a new enum. It may look like the following. Ensure you only add new values to the buttom as you will introduce a breaking change to your API otherwise.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
public enum GlobalSymbols
|
|
||||||
{
|
|
||||||
add,
|
|
||||||
administrative_tools,
|
|
||||||
billboard,
|
|
||||||
cancel,
|
|
||||||
delete,
|
|
||||||
edit,
|
|
||||||
home,
|
|
||||||
login,
|
|
||||||
logout,
|
|
||||||
product,
|
|
||||||
project,
|
|
||||||
remove,
|
|
||||||
save,
|
|
||||||
settings,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The class `GlobalsymbolFactory` need to inherit from `SymbolFactory<>`. Provide your symbols enum here. You will need to overwrite `GetSvgImageResourceAssembly` and `GetSvgImageRessourcePath` as this parts can't be done by the base class.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
public class GlobalSymbolFactory : SymbolFactory<GlobalSymbols>
|
|
||||||
{
|
|
||||||
private static readonly string? symbolsNamespace = typeof(GlobalSymbolFactory).Namespace + ".Symbols";
|
|
||||||
private static readonly string symbolsPathTemplate = "{0}.{1}.svg";
|
|
||||||
|
|
||||||
public override Assembly GetSvgImageResourceAssembly()
|
|
||||||
{
|
|
||||||
return Assembly.GetExecutingAssembly();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string GetSvgImageRessourcePath(GlobalSymbols svgImage)
|
|
||||||
{
|
|
||||||
return string.Format(symbolsPathTemplate, symbolsNamespace, svgImage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Access symbols
|
|
||||||
|
|
||||||
Accessing symbols esaily via an instance of your SymbolFactory implementation. You can either provide a static instance in `GlobalSymbolFactory` or create a new instance wherever you need it. Access via `GetSvgImage` or `GetImage`, decide wheneer you can use an `RadSvgImage` or need an `Image`.
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
// Static instance in GlobalSymbolFactory
|
|
||||||
public static GlobalSymbolFactory Instance { get; } = new();
|
|
||||||
var img = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.billboard, SvgImageSize.Small);
|
|
||||||
|
|
||||||
// Instance on-demand
|
|
||||||
var symbols = new GlobalSymbolFactory();
|
|
||||||
var img = symbols.GetSvgImage(GlobalSymbols.billboard, SvgImageSize.Small);
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user