Sample .NET projects
Our Finsemble .NET Seed Repository contains three example .NET projects:
- The WPF Example project contains a Finsemble-aware .NET application that has the WPF Window Title Bar user control, accepts drag and drop from Finsemble, and communicates over linker channels.
- The Authentication Example project contains an example of authenticating with a .NET application.
- The Windowless Example project contains an example of how to work with a .NET application without a window: for example, to allow it to function as a service within Finsemble, which can communicate over the Router.
- The Multi-Window Example project demonstrates how to create multiple .NET windows that run in the same process thread. This allows you to have a .NET application with child windows in Finsemble.
- The Winform Example project contains a Finsemble-aware .NET winform application accepts drag and drop from Finsemble, and communicates over linker channels , and able to spawn other components.
Here is a sample configuration to use the .NET seed project with the Finsemble seed project:
"WPFExample": {
"window": {
"id": "WPFExample",
"windowType": "native",
"path": "PATH_TO_WPFExample.exe",
"autoShow": true,
"addToWorkspace": true
},
"foreign": {
"services": {
"workspaceService": {
"isArrangable": true
}
},
"components": {
"App Launcher": {
"launchableByUser": true
},
"Window Manager": {
"showLinker": true
},
"Toolbar": {
"iconURL": "URL_TO_ICON"
}
}
}
}
Using the WPF Window Title Bar
The WPF Example project provides the WPF Window Title Bar UI component. This component gives Finsemble's built-in window management functionality to .NET components. By using this component, .NET windows can participate in snapping and docking, linking and drag and drop data sharing.
Scrim
When data to be shared in Finsemble is dragged, a scrim is displayed on top of all components denoting whether or not the component can receive that data. You must create a control (generally a label) that occupies the entire space of the component, sits on top of all other controls, and is hidden. This is the control that will accept the dragged data from other components. Here is how to provide this control to Finsemble:
// Assuming the control is called Scrim
FSBL.DragAndDropClient.SetScrim(Scrim);
Styling the Window Title Bar
You can change the background and button hover colors using the functions below. All the buttons are styled identically except the "close" button and the docked state background of the "docking" button.
// FinsembleHeader is the name of the WPFWindowTitleBar Control
//Set title bar background colors
FinsembleHeader.SetActiveBackground(new SolidColorBrush(Colors.Red));
FinsembleHeader.SetInactiveBackground(new SolidColorBrush(Colors.DarkRed));
//Set button backgrounds on hover
FinsembleHeader.SetButtonHoverBackground(new SolidColorBrush(Colors.Purple));
FinsembleHeader.SetInactiveButtonHoverBackground(new SolidColorBrush(Colors.Yellow));
FinsembleHeader.SetCloseButtonHoverBackground(new SolidColorBrush(Colors.SeaShell));
FinsembleHeader.SetInactiveCloseButtonHoverBackground(new SolidColorBrush(Colors.BurlyWood));
//Set docking button background when docked
FinsembleHeader.SetDockingButtonDockedBackground(new SolidColorBrush(Colors.BlanchedAlmond));
//Set text colors
FinsembleHeader.SetTitleForeground(new SolidColorBrush(Colors.LightGoldenrodYellow));
FinsembleHeader.SetButtonForeground(new SolidColorBrush(Colors.LightSalmon));
//Set Fonts for title and buttons.
//Use null for fontFamily, fontStyle and fontWeight to not change. Use 0 for fontSize to not change.
FinsembleHeader.SetTitleFont(fontFamily, fontSize, fontStyle, fontWeight);
FinsembleHeader.SetButtonFont(fontFamily, fontSize, fontStyle, fontWeight);
Authenticating with a .NET application
The main window of the
Authentication Example application
needs to be initialized. However, this authentication window cannot use the WPF Window Title Bar because the services
are not available until authenticated. Once the user is authenticated, you need to call PublishAuthorization
:
FSBL.RPC("AuthenticationClient.publishAuthorization", new JArray { username, credentials});
Getting user credentials
If your application requires credentials from Finsemble, you can call GetCurrentCredentials
:
FSBL.RPC("AuthenticationClient.getCurrentCredentials", new List<JObject>(), (err, credentials) => {
});
Using a .NET application as a service
You can also have .NET applications that do not display a window to interoperate with other components via the Router. This allows for the integration of a .NET application as a service within Finsemble. An example of such an integration is provided in the Windowless Example project.
Desktop services created from .NET applications currently need to be added to the Finsemble component configuration and will always be started after all other services have been initialized. To add a .NET service (i.e., windowless component) to Finsemble, add it to the appd.json file as normal and ensure that you set:
window.windowType
to"native"
- a
window.name
field to help you identify the component in the Central Logger window.autoShow
tofalse
as no window should be displayedwindow.addToWorkspace
tofalse
to disable any state capture and lifecycle eventscomponent.spawnOnStartup
totrue
to ensure that the component is auto-startedforeign.components["App Launcher"].launchableByUser
tofalse
to stop the component appearing in the launcher menu.
The component may be launched using a path
or alias
and can be passed arguments
in the same way as any other
native component.
For example:
"WindowlessExample": {
"window": {
"id": "Windowless",
"name": "winlessSeed",
"windowType": "native",
"alias": "windowlessExample",
"arguments": "arg1 arg2 arg3",
"autoShow": false,
"addToWorkspace": false
},
"component": {
"spawnOnStartup": true
},
"foreign": {
"components": {
"App Launcher": {
"launchableByUser": false
}
}
}
}
See also
The basics of integrating native components is covered in this tutorial.
For information about authentication, check out the [Authentication tutorial](/docs/7.x/enterprise/authentication/Authentication.
Understanding how the Linker Client and Drag and Drop Client work is important for understanding this tutorial.