Changes

HowTo:Inject UI into UBIK Studio

123 bytes removed, Wednesday at 13:11
Since version 5.2 {{Version/ServerSince|5.2}} it is possible to inject UI into {{UBIK}} Studio.<br>
The injected UI can be displayed inside a User Control and or Window.<br>
This article will help you to inject your UI!.<br>
<!-- DO NOT REMOVE THIS -->{{Template:HowTo/Begin}}<!-- DO NOT REMOVE THIS -->
= User Control =
[[File:InjectedUserControl.png|thumb|300px|Extended user control list]]
===Goal===
The goal is to extend the existing user control list with the injected user control.<br>
The mentioned list pops up every time you drag an instance to a new tab header.
[[File:InjectedUserControl.png|thumb|left|735px|Extended user control list]]
<br clear="all" />
=== Implementation ===
# Create or reuse a vs .NET library (DLL) project - it doesn't have to be a {{UBIK}} Module.<br># Add the designated control as a class deriving from System.Windows.Forms.UserControl to the project.<br># Implement the interface IUBIKEnvironmentControl for the control.<br># For automatic injection, add the "Export" Attribute with the "IUBIKControl" type parameter to the designated control.<br>#;<syntaxhighlight lang="csharp">
[Export(typeof(IUBIKControl))]
public partial class TestUserControl: UserControl, IUBIKEnvironmentControl
</syntaxhighlight>
# The user control now has a property Description and Image.<br>
# 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.
#;<syntaxhighlight lang="csharp">
public TestUserControl()
{
}
</syntaxhighlight>
# Provide the updated DLL containing your user control in UBIK® Studio's [[Injection_Management#Injection_Folder.28s.29|Injection]] folder.<br># 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.<br><br>
= Window =
In addition, the “View” menu will be extended with a new entry that also opens the window.<br>
[[File:InjectedButton.png|thumb|left|298px|Injected button]]
[[File:InjectedMenuEntry.png|thumb|left|508px|Injected menu entry]]<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><brclear="all" />
=== Implementation ===
# Create or reuse a vs .NET library (DLL) project - it doesn't have to be a {{UBIK}} Module.<br># Add the designated window as a class deriving from System.Windows.Window to the project.<br># Create a new class.<br># Implement the inferface IUBIKWindowFactory for the new class.<br># For automatic injection, add the "Export" Attribute with the "IUBIKWindowFactory" type parameter to the designated class.<br>#;<syntaxhighlight lang="csharp">
[Export(typeof(IUBIKWindowFactory))]
public class TestWindowFactory : IUBIKWindowFactory
}
</syntaxhighlight>
# The class now has a Icon and Label property.<br># 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.<br># In the GetWindow method, return your window (step 2).<br># Provide the updated DLL containing your window in UBIK® Studio's [[Injection_Management#Injection_Folder.28s.29|Injection]] folder.<br># 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.<br><br>
<!-- DO NOT REMOVE THIS -->{{Template:HowTo/End}}<!-- DO NOT REMOVE THIS -->
283
edits