This page describes how to add new placeholders and document types.
Add new Placeholders
- Adapt Placeholders.cs (Vereinsmeisterschaften.Core > Documents):
- Add new list with placeholders: e.g.
public static List<string> Placeholders_Name = new List<string>() { "Name", "N" };
- Add new placeholder key: e.g.
public const string PLACEHOLDER_KEY_NAME = "Name";
- Add the new placeholder combination in the PlaceholderDict: e.g.
{ PLACEHOLDER_KEY_NAME, (PLACEHOLDER_GROUP_NAME, Placeholders_Name) }
- Add following resources to the PlaceholderResources.resx (Vereinsmeisterschaften > Properties):
- PlaceholderName<PlaceholderKey> (e.g. PlaceholderNameName): Name for the placeholder that is shown in the UI
- PlaceholderInfo<PlaceholderKey> (e.g. PlaceholderInfoName): Description for the placeholder that is shown in the UI
- If the placeholder should be always supported:
- If the placeholder usage depends on the type of data:
- Adapt corresponding DocumentPlaceholderResolvers (Vereinsmeisterschaften.Core > Documents > DocumentPlaceholderResolvers):
- Add the placeholder key to the SupportedPlaceholderKeys list
- Implement the logic in the ResolveTextPlaceholders method
Add new Placeholder Group
- Adapt Placeholders.cs (Vereinsmeisterschaften.Core > Documents):
- Add a new placeholder group: e.g.
public const string PLACEHOLDER_GROUP_NAME = "Group";
- Add following resources to the PlaceholderResources.resx (Vereinsmeisterschaften > Properties):
- PlaceholderGroup<PLACEHOLDER_GROUP_NAME> (e.g. PlaceholderGroupGeneral): Name for the placeholder group
Add new document type
- Add a new enum value to
DocumentCreationTypes in DocumentCreationTypes.cs (Vereinsmeisterschaften.Core > Models)
- Add a new class inheriting from DocumentStrategyBase in the DocumentStrategies folder (Vereinsmeisterschaften.Core > Documents > DocumentStrategies)
- Add the new strategy to the
ConfigureServices() method in App (Vereinsmeisterschaften > App.xaml.cs):
e.g. services.AddSingleton<IDocumentStrategy, YourNewDocumentStrategy>)
- Add a new case to the
CreateDocumentCommand in CreateDocumentViewModel.cs (Vereinsmeisterschaften > ViewModels):
e.g. await _documentService.CreateDocument(DocumentCreationTypes.NewDocument);
- Add following resources to the Resources.resx (Vereinsmeisterschaften > Properties):
- Create<DocumentType>String (e.g. CreateCertificatesString): Button text for creating the document
- Create<DocumentType>ResultString (e.g. CreateCertificatesResultString): Result message after creating the document
- Extend the CreateDocumentsPage.xaml (Vereinsmeisterschaften > Views)
- Add a new column to the Grid
- Add a new CreateDocumentUserControl
- Extend the Placeholder Info and add a new
GridViewColumn for the new document type
Add new document file converter
A document file converter is used to convert a .docx file to a .pdf file. Different applications can be used to do this conversion (e.g. Microsoft Word or Libre Office). To add a new converter:
- Add a new class inheriting from IDocumentFileConverter in the DocumentFileConverters folder (Vereinsmeisterschaften.Core > Documents > DocumentFileConverters)
- The
IsAvailable property should return a flag if the converter application is available (e.g. Microsoft Word is not installed on all computers)
- The
bool Convert(string inputFile, string outputFile) method will perform the conversion. Call the corresponding conversion logic for the converter application here.
- The
bool IsDocxCreateWithThisConverter(string docxFile) method will return true, when the .docx file was created using this converter application (e.g. Microsoft Word converter will return true, when the .docx file was created using Microsoft Word).
- The document file converter must be added to the services (App.xaml.cs):
services.AddSingleton<IDocumentFileConverter, YourDocumentFileConverter>();