Files
Christoph Schwörer f045b99a25 Codebasis als Dateien ins Arbeitsrepo statt als Gitlink
QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142)
getrackt, ohne .gitmodules und ohne erreichbares Remote. Der
Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar
gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege
der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen.

Umstellung:
- Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert
  (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6)
- Gitlink aus dem Index entfernt
- Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB

Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte
bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
2026-08-26 07:43:51 +02:00

116 lines
4.8 KiB
Markdown

# How to create a module in c-entron.NET
A module in the c-entron<span>.NET is just a view that can be displayed in the main window. It can show up in the module list on the left and can be docked and undocked from the main window.
We'll be using a module to manage our `Thingies` again. If you want to know how to create webservice methods for our thingies check out [this](How-to-add-webservice-methods.md).
## ICentronAppModuleController
The first class to create is a `..AppModuleController`. For us this will be named `ThingiesAppModuleController`.
This class needs to implement the `ICentronAppModuleController` interface. If you go to the `ICentronAppModuleController.cs` file there are summaries for each property and how to fill them properly.
``` csharp
public class TicketListAppModuleController : ICentronAppModuleController
{
public string ModuleName => "Dinge-Liste";
public BitmapImage ImageSmall => new BitmapImage(new Uri("pack://application:,,,/c-entron 2.0;component/Images/Icons/16x16/Thingies_16x16.png"));
public BitmapImage ImageLarge => new BitmapImage(new Uri("pack://application:,,,/c-entron 2.0;component/Images/Icons/32x32/Thingies_32x32_32x32.png"));
public string Description => "Alle Ihre Dinge auf einen Blick";
public CentronModuleCategory MainCategory => CentronModuleCategory.MyCentron;
public string ID => "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}";
public string ReportGroupGuid => null;
public CentronConnectionType[] SupportsConnectionTypes => new[] { ronConnectionType.CentronWebServices, entronConnectionType.SqlServer }
public BaseModule CreateModuleInstance(params object[] param)
{
var viewModel = new ThingiesViewModel();
return new ThingiesView
{
DataContext = viewModel
};
}
public IList<ICentronAppModuleSettingController> GetSettings() => new <ICentronAppModuleSettingController>
{
new ThingiesSettingsController()
};
public void Dispose()
{
}
}
```
## BaseModule (View)
Next we'll create the view and as we've already seen in our `AppModuleController.CreateModuleInstance(..)` it will be called `ThingiesView`. The easiest way to create it, is just to let VisualStudio create a `User Control(WPF)` then change it's type to `BaseModule`. To do this go to the `ThingiesView.xaml.cs` and delete the inheritance of `UserControl`. Next go to `ThingiesView.xaml` and replace `UserControl` with ` controls:BaseModule`, then add this namespace: `xmlns:controls="clr-namespace:CentronSoftware.Centron.WPF.UI.Extension.Controls;assembly=Centron.WPF.UI.Extension"`
*Pro tip: add `d:DataContext="{d:DesignInstance module:TicketListModuleViewModel}"` for intelisense in xaml.*
As all our modules need a ribbon you'll need to implement one of 3 interfaces in your code-behind (`Thingies.xaml.cs`):
interface|function
--|--
IRibbonControlModule|Adds the GetRibonControl() method where your ribbon gets returned
IRibbonControlModuleWithDefaultButtons|Same as above, but also adds our default buttons (Save layout, reset layout, settings, videoportal, reports)
IRibbonControlModuleWithDefaultButtonsAndPreferredSendType|Same as above, but also adds buttons for send type for reports.
``` csharp
public partial class ThingiesView : IRibbonControlModuleWithDefaultButtons
{
public ThingiesView()
{
this.InitializeComponent();
}
public RibbonControl GetRibbonControl()
{
return this.Ribbon;
}
}
```
``` xml
<controls:BaseModule x:Class="CentronSoftware.Centron.WPF.UI.Modules.Helpdesk.TicketDetails.TicketDetailView"
xmlns:controls="clr-namespace:CentronSoftware.Centron.WPF.UI.Extension.Controls;assembly=Centron.WPF.UI.Extension"
[..]
>
[..]
<dxb:RibbonControl x:Name="Ribbon">
[..]
</dxb:RibbonControl>
[..]
</controls:BaseModule>
```
If you want to display a message box on closing or cancel closing, you can override `public override void FormClosing(out bool cancel)` and cancel the close by settings the boolean to **true**.
## ViewModel
At last we will create our viewmodel aptly named `ThingiesViewModel`. It doesnt really need anything, just implement `BindableBase` like every other viewmodel and set it as datacontext for the view in your appmodulecontroller.
## ModuleRegistration
If your module is supposed to be available via the module list on the left, then we also need to register it in `ModuleRegistration.cs`. Simply go to the constructor and add your module to the _module list like this:
``` csharp
ModuleRegistrationItem.For<ThingiesAppModuleController>(
() => Helper.NoRightCheck(),
() => ModuleFeatures.IsThingiesAvailable),
```
The first parameter allows you to check if the user has the specified rights.
The second allows you to hide your module until it is ready to be released. Simply create an entry in `ModuleFeatures.cs`.