Skip to main content
Skip table of contents

SDK Guide (SPC UI Plugin)



Smart Print Controller v4.5.4216.0, Copyright (c) 2023 Global Graphics Software. All rights reserved.

Overview

Smart Print Controller (SPC) automatically loads a collection of plugin DLLs upon launch. These plugins extend the application's UI and influence its runtime behavior. They allow customers to track the status of their output hardware, import jobs using custom mechanisms, display their own UI content, and more.

Plugins for SPC are typically written in C# and utilize Microsoft's Managed Extensibility Framework (MEF), although most details are hidden by the SPC API. Each plugin must provide a human-readable name, icon, and a main WPF UI control.

For convenience, SPC includes a TemplateProject project that serves as a starting point for developing new UI plugins. See below for more details.

Getting Started

Interfaces: IBasicJobInfo, IExtendedConfigTokenSource, IJobNotifier, IPlugin, IPluginContext, IJobInfo, IOpcModel
Classes: LazyImageSourceToImageSourceConverter, PluginBase, PluginLogger, TemplatePlugin, TemplateViewModel, WebPlugin

Installing a Plugin

Smart Print Controller requires plugins to be located in the following directory:

C:\Program Files\Global Graphics\Smart Print Controller\UiPlugins

To install a plugin, follow these steps:

  1. Create a new folder within the UiPlugins directory with a unique name.
  2. The folder name and the prefix of the plugin DLL must match.
    For example, if your plugin DLL is named WebViewPane.UiPlugin.dll, create a folder named WebViewPane.
  3. Place your plugin DLL inside the created folder.
  4. If your plugin requires additional files, you can include them within or below the plugin folder.
    Note that Smart Print Controller ignores any files other than the plugin DLL itself.

Note It is recommended to install plugins using the main application installer or a plugin-specific installer. If you manually copy files into the plugin folder, Windows may block DLLs that it considers potentially downloaded from the internet. In such cases, you can unblock the DLLs using a PowerShell prompt or by right-clicking on the file, selecting Properties, and unblocking it.

Take care to ensure the proper installation of plugins to avoid any issues.

Creating a new UI Plugin

  1. Create a new Visual Studio C# Class Library (.NET Framework) project targeting .NET Framework 4.7.x

  2. Edit the project properties to set the Assembly name to include a .UiPlugin suffix. (Only DLLs of the form *.UiPlugin.dll are loaded by SPC.)

  3. Reference the following system assemblies:

    • PresentationCore
    • PresentationFramework
  4. Reference the following SPC assemblies (found in the SPC installation folder):

    • MaterialDesignThemes.Wpf.dll
    • CSharp.Framework.dll
    • CSharp.OPCUAServer.dll
    • CSharp.Wpf.dll
    • CSharp.Wpf.MaterialDesign.dll
    • Spc.UiPlugin.dll This provides access to SPC's IPlugin interface, which UI plugins must implement in order to be loaded by SPC.
  5. In some circumstances, these assemblies may also need to be referenced:

    • CSharp.HarlequinDirect.App.dll
    • CSharp.PrinterProfile.dll

For convenience, we recommend sub-classing PluginBase which implements IPlugin and defines a sensible set of default behavior for the majority of plugins. (See the WebPlugin equivalent for HTML-based plugins.)

Here is a minimal example of a UI plugin:

using Spc.UiPlugin;
using System.ComponentModel.Composition;
using System.Windows.Controls;
using CSharp.Framework;
using CSharp.OPCUAServer.Model;
using CSharp.Wpf.MaterialDesign;

namespace Template
{
    [Export(typeof(IPlugin))]
    public class TemplatePlugin : PluginBase
    {
        private UserControl m_uiComponent;

        internal TemplateViewModel ViewModel { get; private set; }

        public override string Name => "Custom Plugin";
        public override string Icon => PackIconKind.Tune.ToString();
        public override UserControl UiComponent => m_uiComponent ??= new TemplateView();

        public override PaneLocation PaneLocation => PaneLocation.InputArea;

        public override bool Init(IPluginContext pluginContext)
        {
            ViewModel = new TemplateViewModel(pluginContext.DialogService, pluginContext.OpcModel, Logger);
            UiComponent.DataContext = ViewModel;
            return true;
        }
    }
}
  • The [Export(typeof(IPlugin))] line indicates that the class represents a UI plugin that should be loaded by SPC.
  • The Name property must return a user-visible plugin name.
  • The Icon property must return the name of a valid Material Design icon.
  • The UiComponent must return a WPF UserControl containing the main plugin UI.
  • PaneLocation provides a hint to SPC as to where the plugin icon should be located.
  • The Init() method will be called by SPC when the plugin is loaded.

In the example above, we create an MVVM view model and pass it a reference to the DialogService (allowing for the presentation of UI prompts, message boxes, and user queries), OpcModel (the OPC data model), and the Logger object (allowing plugins to add messages into SPC's log). Real-world implementations will vary.

NOTE The example leaves the TemplateView and TemplateViewModel classes undefined. Implementing these is a plugin-specific task.

Once a successful build has been made, the plugin DLL must be copied under the SPC installation folder, as described above. Launching Smart Print Controller will load the new UI plugin, making it visible on the left-hand side of the application window, and the SPC log file will contain a line similar to: [UiPlugin:Custom Plugin] Successfully loaded.

For more details, see the IPlugin documentation.

Creating a UI Plugin from TemplateProject.

You can use the TemplateProject source code (TemplatePluginSource.zip) as a starting point for creating a UI plugin. The TemplateProject provides default values for various properties like name, icon, etc., and includes a simple UI control. It also references many of the required assemblies by default.

To create a UI plugin from the TemplateProject, follow these steps:

  1. Extract the contents of the TemplatePluginSource.zip file.
  2. Open the extracted project in Visual Studio.
  3. Modify the source code to meet your specific requirements. Customize the name, icon, and UI components of the plugin.
  4. Follow the previous section's instructions to build and install the plugin.

See Installing a Plugin, TemplatePlugin

Accessing the OPC Model

IPluginContext's OpcModel property provides access to SPC's OPC model (IOpcModel) - A collection of state relating to the entire application, mirroring the data model exposed over the OPC interface.

The UI plugin can use this object to:

  • Monitor the active job.
  • Manipulate the Waiting queue.
  • Control the print run.
  • Get details about the current/available media.
  • Get details about the RIP Servers.
  • ...and more.

Each IOpcModel property is an MVVM view model, making it simple to bind WPF UI control values to the required source. Changes to state can be detected from the code by subscribing to the INotifyPropertyChanged.PropertyChanged event.

See the OPC API Documentation for more information.

API

Interfaces

IBasicJobInfo

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin.Jobs
Extends: IDisposable, IJobInfo, IJobReference, ITrackedDisposable

Description

Interface defining the properties for a single job file (Extending IJobInfo).

Properties
NameTypeWritableDescription
IsLockedboolYesWhether modifying operations (changes to copy count, job editor, ...) are allowed or not.
JobIdstringYesThe job ID received from the .complete file.
JobLabelstringYesProperty the User can use to group Jobs.
JobPartIdstringYesThe job part ID received from the .complete file.
OriginalPageHeightMmdoubleYesThe height of the original/unprocessed job pages, if known. (Set by the job preprocessor.)

For multi-page jobs, this is set from the first page.
OriginalPageWidthMmdoubleYesThe width of the original/unprocessed job pages, if known. (Set by the job preprocessor.)

For multi-page jobs, this is set from the first page.
TargetMediaNamestringYesThe intended media to use when printing the job.
ThumbnailILazyImageSourceNoA lazy-loaded job thumbnail.

See also: LazyImageSourceToImageSourceConverter

IExtendedConfigTokenSource

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin.Commands

Description

Interface allowing UI plugins to provide token values than can be found/replaced in a config file.

Any IPlugin-based objects which implement this interface may define their own tokens in SPC's config file templates.

When SPC processes a config file template with an unknown token (E.g. $CustomToken$) UI plugins implementing IExtendedConfigTokenSource will be enumerated, allowing the Get() method to provide a plugin-specific value.

Methods
NameDescription
object Get(string name, IConfigTokens parentSource)Called when applying settings to a config template.

name - The name of the token.
parentSource - The default IConfigTokens source. (May be null)

Returns: Implementations must return a value for the specified token, or null if not handled.

IJobNotifier

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin

Description

Allows access to job-level events as they are being processed in the Print Queue.

Made available to the UI plugin via IPluginContext.

Events
NameDescription
JobCompletedCalled when a job has completed processing in the Print Queue, regardless of the final job status.

See also: IBasicJobInfo
JobStartedCalled when a job has started processing in the Print Queue.

See also: IBasicJobInfo

IPlugin

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin
See also: PluginBase, WebPlugin

Description

The base interface for any SPC UI plugin.

SPC will load any suitable IPlugin-based classes at start-up, reporting success/failure in the application log. The Init() method will be called early in the load cycle, allowing the plugin to initialize any state it requires. Implementations which implement IDisposable will be disposed when SPC is shut down.

Consider using PluginBase as a base class for any new custom plugins (or WebPlugin for HTML-based plugins).

Properties
NameTypeWritableDescription
CanVisitWithUnsavedSettingsboolNoWhether the pane can be displayed when modified settings have yet to be 'Applied' by the user.
EnableWithExternalControlboolNoWhether the pane UI should be enabled when external OPC control is active. (false by default.)
IconstringNoThe plugin icon displayed in the SPC UI. This much match an icon name defined in PackIconKind (from MaterialDesignThemes.Wpf.dll)
LoggerIBasicLoggerYesProvides access the message logger, allowing plugins to add messages into SPC's log.
NamestringNoThe plugin name displayed in the SPC UI.
PaneLocationPaneLocationNoImplementations must return the location at which their plugin icon will appear in the SPC UI.

Values: InputArea, OutputArea, SettingsArea, AfterNative, None
PluginDirDirectoryInfoYesThe directory containing this plugin (Automatically set by SPC).
UiComponentUserControlNoImplementations must return a UserControl for the content displayed within the plugin pane.

See also: IUiControlSource, IEngineerMediaTabSource
UiControlSourcesIEnumerable<IUiControlSource>NoA collection of objects which are used to inject UI content in the main application.
Methods
NameDescription
bool Init(IPluginContext pluginContext)Called by SPC to allow the plugin to initialize any state it requires.

pluginContext - Application context.

Returns: true if the plugin has initialized and should be loaded in the UI.
void OnStoppingPrinting(bool isPrintingDetected)Called when a request to stop the print run is triggered.

isPrintingDetected - true if anything was printed during the print run.

IPluginContext

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin

Description

Holds state which allows a UI plugin to interact with the SPC application.

Provided to the UI plugin when SPC calls its IPlugin.Init() method.

We recommend plugins use OpcModel as a source of information whenever possible.

Properties
NameTypeWritableDescription
DialogServiceIMaterialDesignDialogServiceNoAllows for the presentation of UI prompts, message boxes, and user queries.
JobNotifierIJobNotifierNoAn interface that notifies plugins of job-level events.
MultiPrinterInterfaceIMultiPrinterInterfaceNoAllows access to the collection of RIP Servers in use by SPC.
MutableIMutableNoAn object allowing detection of 'pending' changes made by the user in the SPC UI.
OpcModelIOpcModelNoCollection of state relating to the entire application, mirroring the data model exposed over the OPC interface.

See the OPC API Documentation for more information.
PageSetupViewModelIPageSetupViewModelNoAn interface allowing access to page setup properties.
ProfileSourceIProfileSourceNoAn interface allowing access to the active printer profile.
WaitingQueueJobsIEnumerable<IBasicJobInfo>NoA read-only collection of jobs currently held in the Waiting Queue.

IJobInfo

Assembly: CSharp.HarlequinDirect.App.dll
Namespace: CSharp.HarlequinDirect.App
Extends: IDisposable, IJobReference, ITrackedDisposable
See also: JobInfoBase

Description

Interface defining the properties for a single job file.

Properties
NameTypeWritableDescription
CopyCountintYesThe number of copies of the job to print.
CustomPostScriptstringYesProperty the OEM can use to pass custom PostScript to override default behavior.
EndTimeDateTimeNoThe time at which the job finished printing.
ExpectedStatusCountintYes
JobTagstringYesProperty the OEM can use to pass arbitrary job data to Harlequin Direct.
LocalFileFileInfoYes
NamestringNoThe user-visible name of the job.
PageCountintYesThe number of pages in the job to print (Unaffected by CopyCount).
RemoteFilesList<FileInfo>No
RipAheadRemoteFileSpecsList<string>No
RipModeRipModeYes
StartTimeDateTimeNoThe time at which the job started printing.
StatisticsJobStatisticsNo
StatusJobStatusYesThe current status of the job.
Methods
NameDescription
void SetStatus(JobStatus status)

IOpcModel

Assembly: CSharp.OPCUAServer.dll
Namespace: CSharp.OPCUAServer.Model
See also: OpcModel

Description

A representation of the SPC OPC UA data model.

See the OPC API Documentation for more information.

Properties
NameTypeWritableDescription
ActiveJobOpcActiveJobNodeNoState relating to the currently active job.
ActiveMediaOpcActiveMediaNoState relating to the currently active media.
AllJobsOpcAllJobsNodeNoState relating to all jobs in the Waiting/Print/Completed queues. This tree dynamically includes children named from the GUID of each known job.
AllMediaOpcAllMediaNoState relating to all available media.
AppOpcAppNoState relating to the entire application.
PrintBarGroupsOpcPrintBarGroupsNoState relating to the active print bars.
PrinterProfileOpcPrinterProfileNoState relating to the active printer profile.
PrintRunOpcPrintRunNoState relating to the print run.
PrintRunConfigOpcPrintRunConfigNoState relating to the print configuration (Applies to both media sides).
ServersOpcServerCollectionNoState relating to the collection of RIP Servers.
StreamlineDirectOpcStreamlineNoState relating to Streamline Direct technology.
WaitingQueueOptionsOpcWaitingQueueOptionsNoState relating to the behavior of the Waiting queue.

Classes

LazyImageSourceToImageSourceConverter

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin.Converters

Description

A WPF IValueConverter implementation that simplifies displaying job thumbnails in the UI.

For example: <Image Source="{Binding Thumbnail, Converter={Converters:LazyImageSourceToImageSourceConverter}}"/>

See also: IBasicJobInfo

Methods
NameDescription
object Convert(object value, Type targetType, object parameter, CultureInfo culture)Convert an ILazyImageSource to a WPF ImageSource.

PluginBase

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin
Extends: IPlugin

Description

Base class for UI plugins. Consider using this as a base class for any new custom plugins.

SPC will load any suitable IPlugin-based classes at start-up, reporting success/failure in the application log. The Init() method will be called early in the load cycle, allowing the plugin to initialize any state it requires. Implementations which implement IDisposable will be disposed when SPC is shut down.

Consider using PluginBase as a base class for any new custom plugins (or WebPlugin for HTML-based plugins).

Properties
NameTypeWritableDescription
CanVisitWithUnsavedSettingsboolNoWhether the pane can be displayed when modified settings have yet to be 'Applied' by the user.
EnableWithExternalControlboolNoWhether the pane UI should be enabled when external OPC control is active. (false by default.)
IconstringNoThe plugin icon displayed in the SPC UI. This much match an icon name defined in PackIconKind (from MaterialDesignThemes.Wpf.dll)
LoggerIBasicLoggerYesProvides access the message logger, allowing plugins to add messages into SPC's log.
NamestringNoThe plugin name displayed in the SPC UI.
PaneLocationPaneLocationNoImplementations must return the location at which their plugin icon will appear in the SPC UI.

Values: InputArea, OutputArea, SettingsArea, AfterNative, None
PluginDirDirectoryInfoYesThe directory containing this plugin (Automatically set by SPC).
UiComponentUserControlNoImplementations must return a UserControl for the content displayed within the plugin pane.

See also: IUiControlSource, IEngineerMediaTabSource
UiControlSourcesIEnumerable<IUiControlSource>NoA collection of objects which are used to inject UI content in the main application.
Methods
NameDescription
bool Init(IPluginContext pluginContext)Called by SPC to allow the plugin to initialize any state it requires.

pluginContext - Application context.

Returns: true if the plugin has initialized and should be loaded in the UI.
void OnStoppingPrinting(bool isPrintingDetected)Called when a request to stop the print run is triggered.

isPrintingDetected - true if anything was printed during the print run.

PluginLogger

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin
Extends: IBasicLogger

Description

Allows UI plugins to log application messages.

Made available to the UI plugin via IPluginContext.

Methods
NameDescription
void Error(string message)Write an error-level message to the SPC log.
void Exception(Exception ex)Write a formatted C# exception message to the SPC log.
void Info(string message)Write an information-level message to the SPC log.
void Warn(string message)Write a warning-level message to the SPC log.

TemplatePlugin

Assembly: Template.UiPlugin.dll
Namespace: Template
Extends: IDisposable, IPlugin

Description

An example implementation of a 'starting point' UI plugin.

SPC will load any suitable IPlugin-based classes at start-up, reporting success/failure in the application log. The Init() method will be called early in the load cycle, allowing the plugin to initialize any state it requires. Implementations which implement IDisposable will be disposed when SPC is shut down.

Consider using PluginBase as a base class for any new custom plugins (or WebPlugin for HTML-based plugins).

Properties
NameTypeWritableDescription
IconstringNoThe plugin icon displayed in the SPC UI. This much match an icon name defined in PackIconKind (from MaterialDesignThemes.Wpf.dll)
NamestringNoThe plugin name displayed in the SPC UI.
PaneLocationPaneLocationNoImplementations must return the location at which their plugin icon will appear in the SPC UI.

Values: InputArea, OutputArea, SettingsArea, AfterNative, None
UiComponentUserControlNoImplementations must return a UserControl for the content displayed within the plugin pane.

See also: IUiControlSource, IEngineerMediaTabSource
Methods
NameDescription
void Dispose()Performs cleanup when the plugin is disposed.
bool Init(IPluginContext pluginContext)Called by SPC to allow the plugin to initialize any state it requires.

pluginContext - Application context.

Returns: true if the plugin has initialized and should be loaded in the UI.

TemplateViewModel

Assembly: Template.UiPlugin.dll
Namespace: Template.ViewModels

Description

The MVVM view model backing the main UI control (TemplateView).

Properties
NameTypeWritableDescription
ExampleTextstringNo

WebPlugin

Assembly: Spc.UiPlugin.dll
Namespace: Spc.UiPlugin
Extends: IPlugin

Description

Base class for web-based UI plugins. Consider using this as a base class for any new HTML-based plugins.

A web-based UI plugin is one where the entire view is filled with a single control displaying the content of a web address.

The plugin Icon, Name, PaneLocation, and Url properties are obtained by parsing a JSON config file which must exist alongside the plugin DLL, with a name of the format <PluginName>.UiPlugin.json

For example:

	{
		"URL": ["https://globalgraphics.com", "ja:https://globalgraphics.com"],
		"Name": [ "Web View", "ja:Web View", "zh:网络视图" ],
		"Icon": ["Web"],
		"PaneLocation": "OutputArea"
	}

NOTE Locale-specific values can be specified using an array element with a valid prefix.

Properties
NameTypeWritableDescription
CanVisitWithUnsavedSettingsboolNoWhether the pane can be displayed when modified settings have yet to be 'Applied' by the user.
EnableWithExternalControlboolNoWhether the pane UI should be enabled when external OPC control is active. (false by default.)
IconstringYesThe plugin icon displayed in the SPC UI. This much match an icon name defined in PackIconKind (from MaterialDesignThemes.Wpf.dll)
LoggerIBasicLoggerYesProvides access the message logger, allowing plugins to add messages into SPC's log.
NamestringYesThe plugin name displayed in the SPC UI.
PaneLocationPaneLocationNoImplementations must return the location at which their plugin icon will appear in the SPC UI.

Values: InputArea, OutputArea, SettingsArea, AfterNative, None
PluginDirDirectoryInfoYesThe directory containing this plugin (Automatically set by SPC).
UiComponentUserControlNoImplementations must return a UserControl for the content displayed within the plugin pane.

See also: IUiControlSource, IEngineerMediaTabSource
UiControlSourcesIEnumerable<IUiControlSource>NoA collection of objects which are used to inject UI content in the main application.
UrlstringYes
Methods
NameDescription
bool Init(IPluginContext pluginContext)Called by SPC to allow the plugin to initialize any state it requires.

pluginContext - Application context.

Returns: true if the plugin has initialized and should be loaded in the UI.
void OnStoppingPrinting(bool isPrintingDetected)Called when a request to stop the print run is triggered.

isPrintingDetected - true if anything was printed during the print run.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.