Since version 5.2 it is possible to inject UI into UBIK® Studio.
The injected UI can be displayed inside a User Control and or Window.
This article will help you to inject your UI!
User Control
Goal
The goal is to extend the existing user control list with the injected user control.
The mentioned list pops up every time you drag an instance to a new window.
Implementation
1. Create or reuse a .Net library (DLL) project - it doesn't have to be a UBIK® Module.
2. Add the designated control as a class deriving from System.Windows.Forms.UserControl to the project.
3. Implement the interface IUBIKEnvironmentControl for the control.
4. For automatic injection, add the "Export" Attribute with the "IUBIKControl" type parameter to the designated control.
public partial class TestUserControl: UserControl, IUBIKEnvironmentControl
5. The user control now has a property Description and Image.
6. Set the properties in the user control's constructor. The image and description can be loaded directly from the .NET project's resources. These values will then be displayed in the User Control list.
{
InitializeComponent();
Description = Properties.Resources.Description;
Image = Properties.Resources.MyImage;
}
7. Provide the updated DLL containing your UserControl in UBIK® Studio's Injection folder.
8. After connecting to a database with UBIK® Studio, the new control can be accessed by right-clicking or dragging a UBIK® object on a tab header - it should appear in the list of possible controls.
Window
Goal
The goal is to extend the toolbar by injecting a button that opens the desired window.
In addition, the “View” menu will be extended with a new entry that also opens the window.
Implementation
1. Create or reuse a .Net library (DLL) project - it doesn't have to be a UBIK® Module.
2. Add the designated window as a class deriving from System.Windows.Window to the project.
3. Create a new class.
4. Implement the inferface IUBIKWindowFactory for the new class.
5. For automatic injection, add the "Export" Attribute with the "IUBIKWindowFactory" type parameter to the designated class.
public class TestWindowFactory : IUBIKWindowFactory
{
public Bitmap Icon =>Properties.Resources.IntelligentAtelierImage;
public string Label => Properties.Resources.IntelligentAtelierLabel;
public Window GetWindow(UBIKEnvironment env)
{
return new TestWindow(env);
}
}
6. The class now has a Icon and Label property.
7. Set the values for both properties. The icon and label can be loaded directly from the .NET project's resources (example above). The button and the menu entry will display the values.
8. In the GetWindow method, return your window (step 2).
9. Provide the updated DLL containing your window in UBIK® Studio's Injection folder.
10. After connecting to a database with UBIK® Studio, the new window can be accessed with the new button in the toolbar as well as under the "View" menu.


