DeployLX Software Protection System

Creating an Editor for a Custom Limit

DeployLX creates a default editor for custom limits that exposes each of the properties directly like the property window in Visual Studio .NET. This topic discusses how to create a custom editor for use with the Advanced License Editor in the DeployLX Manager.

See the Creating a Custom Limit topic for information on creating the custom limit.

Creating the Class

Custom editors derive from DeployLX.Licensing.DlxAddIn.v5.LimitEditor in the DeployLX.Licensing.DlxAddIn.v5.dll found in the DeployLX application folder.

The LimitEditor class is a specialized UserControl so it can host any other child controls to be used when modifying the properties of the limit. For instance you might add a text box for each text property that the limit exposes. When the text box is modified the associated property of the license should also be updated. This will tell the Advanced License Editor that the document has changed and needs to be re-signed and saved.

When the custom limit is selected in the editor the DeployLX Manager will create an instance of the editor control and display it on the form. The same editor is used to edit all instances of the custom limit in the license file. Override the OnLimitChanged method to perform any per-limit initialization of the editor and to update the controls to reflect the properties of the current instance.

Example

This sample demonstrates an editor that uses a PropertyGrid to provide access to the limit properties.

Imports System

Public Class DefaultLimitEditor
    Inherits LimitEditor

    Private _properties As System.Windows.Forms.PropertyGrid

    Public Sub New(ByVal documentEditor As DeployLX.AppDom.v5.DocumentEditor)
        MyBase.New(documentEditor)
        InitializeComponent()
    End Sub

Private Sub InitializeComponent() Me._properties = New System.Windows.Forms.PropertyGrid() Me.SuspendLayout() ' ' _properties ' Me._properties.CommandsVisibleIfAvailable = False Me._properties.Dock = System.Windows.Forms.DockStyle.Fill Me._properties.Location = New System.Drawing.Point(0, 0) Me._properties.Name = "_properties" Me._properties.Size = New System.Drawing.Size(419, 287) Me._properties.TabIndex = 0 ' ' DefaultLimitEditor ' Me.Controls.Add(Me._properties) Me.Name = "DefaultLimitEditor" Me.Size = New System.Drawing.Size(419, 287) Me.ResumeLayout(False) End Sub
Protected Overrides Sub OnLimitChanged(ByVal e As EventArgs) MyBase.OnLimitChanged(e) _properties.SelectedObject = Limit End Sub End Class
using System;

public class DefaultLimitEditor : LimitEditor
{
    
    private System.Windows.Forms.PropertyGrid _properties;

    public DefaultLimitEditor( DeployLX.AppDom.v5.DocumentEditor documentEditor ) : 
    	base( documentEditor )
    {
        InitializeComponent();
    }
    
private void InitializeComponent() { this._properties = new System.Windows.Forms.PropertyGrid(); this.SuspendLayout(); // // _properties // this._properties.CommandsVisibleIfAvailable = false; this._properties.Dock = System.Windows.Forms.DockStyle.Fill; this._properties.Location = new System.Drawing.Point( 0, 0 ); this._properties.Name = "_properties"; this._properties.Size = new System.Drawing.Size( 419, 287 ); this._properties.TabIndex = 0; // // DefaultLimitEditor // this.Controls.Add( this._properties ); this.Name = "DefaultLimitEditor"; this.Size = new System.Drawing.Size( 419, 287 ); this.ResumeLayout( false ); }
protected override void OnLimitChanged( EventArgs e ) { base.OnLimitChanged( e ); _properties.SelectedObject = Limit; } }

Integrating Help

You can provide context sensitive help and reference documentation for your custom limit. When the limit is selected in the designer the context help will be shown directly in an embedded browser window. The reference may point to any valid HTML resource.

Set the ContextHelp and ReferenceHelp properties of the editor class to provide the HTML resource addresses of the context help. If these properties are not set then DeployLX will check the ContextHelp and ReferenceHelp properties of the LimitEditorAttribute.

Associating the Editor with the Custom Limit

The LimitEditorAttribute associates the custom editor class with the custom limit. The assembly that implements the editor must be installed in the GAC or in the same folder as the assembly that implements the custom limit.

Imports DeployLX.Licensing.v5

<LimitEditor("MyNamespace.EnvironmentCheckLimitEditor,MyAssembly")> _
Public Class EnvironmentCheckLimit
    Inherits Limit
using DeployLX.Licensing.v5;

[LimitEditor( "MyNamespace.EnvironmentCheckLimitEditor,MyAssembly" )]
public class EnvironmentCheckLimit : Limit

See Also