Click or drag to resize

RelaxISOnlyPlugin General Example

The example class below is intended to serve as an illustration of properties common to the RelaxISOnlyPlugin class. This is the base class that RelaxIS plugins that are only used inside of RelaxIS itself inherit from.

Requirements
  • Reference to the RelaxIS_SDK.dll

  • .NET Framework 4.7.2 target (class library)

  • Recommended: Development environment with compiler e.g. RelaxIS SDK Code Editor, Microsoft Visual Studio

Demonstrates

This examples illustrates the common properties and methods in the RelaxISOnlyPlugin class.

Example
C#
// <copyright file="RelaxISOnlyPluginGeneral.cs" company="rhd instruments GmbH and Co. KG">
// Copyright (c) rhd instruments GmbH and Co. KG. All rights reserved.
// Licensed under the MIT No Attribution (MIT-0) license. See section 'License' in the 'SDK Examples / Tutorials' topic for full license information.
// </copyright>

namespace RelaxIS_SDK_Examples.Plugins
{
    using System;

    /***
     * RelaxISOnlyPlugin is a base-class for plugin types that are only used in RelaxIS and not in e.g. the
     * CircuitSimulator.
     * The class has additional properties over the parent class RelaxISPlugin that are shown in this example.
     */

    /// <summary>
    /// Shows the functions and properties common to all <see cref="RelaxIS_SDK.Plugins.RelaxISOnlyPlugin"/> plugins.
    /// </summary>
    public abstract class RelaxISOnlyPluginGeneral
        : RelaxIS_SDK.Plugins.RelaxISOnlyPlugin
    {
        /***
         * This function illustrates the use of the two additional properties RelaxISWCFInterface and
         * RelaxISProgramInterface that allow access to RelaxIS program functions.
         */

        /// <summary>
        /// Illustrates the use of properties exclusive to RelaxISOnlyPlugin types.
        /// </summary>
        protected void IllustrateProperties()
        {
            // The plugin contains a direct reference the the WCF Link implementation of the
            // RelaxIS instance it is running in. This allows the plugin to call RelaxIS functions
            // specifically in the running instance, even if the external WCF Link is disabled here.
            var wcfInterface = this.RelaxISWCFInterface;
            var names = wcfInterface.GetParameterNames("R-(R)(C)");
            foreach (var n in names)
            {
                Console.WriteLine(n);
            }

            // The program interface allows access to functions not available via the WCF Link.
            // This is mainly a data-changed event and functions to manipulate the ribbon buttons.
            var programInterface = this.RelaxISProgramInterface;
            var selectedSpectra = programInterface.SelectSpectra(RelaxIS_SDK.Plugins.SpectraSelectionMethod.CurrentlySelected);
            Console.WriteLine(string.Format("{0} spectra are currently selected!", selectedSpectra.Count));
        }
    }
}
See Also