Sample .NET Projects

Our Finsemble .NET Seed Repository contains three example .NET projects:

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.

Microservices 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 components.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 to false as no window should be displayed
  • window.addToWorkspace to false to disable any state capture and lifecycle events
  • component.spawnOnStartup to true to ensure that the component is auto-started
  • foreign.components["App Launcher"].launchableByUser to false 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
            }
        }
    }
}

check   The .NET Seed Repository contains several ways to integrate an .NET app with Finsemble.
 


Further reading

The basics of integrating native components is covered in this tutorial.

For information about authentication, check out the Authentication tutorial.

Understanding how the Linker Client and Drag and Drop Client work is important for understanding this tutorial.