Skip to main content
RSS feed Subscribe to feed

 

Table Cell Context Menu: Copy Structure

Chemical structures are loaded as binary values in Spotfire. This tool copies the structure to the clipboard.

/// <summary>
/// This sample tool copies a mol structure to the clipboard.
/// </summary>
internal sealed class CopyStructureTool : CustomTool<CopyCellValueContext>
{
    // use e.g. molfile clipboard format
    private string dataFormat = "chemical/x-mdl-molfile";

    internal CopyStructureTool() : base("Copy Structure")
    {
    }

    protected override void ExecuteCore(CopyCellValueContext context)
    {
        if (IsMolStructure(context))
        {
            Clipboard.SetData(dataFormat, context.Value);
        }
    }

    protected override bool IsVisibleCore(CopyCellValueContext context)
    {
        return IsMolStructure(context);
    }

    private bool IsMolStructure(CopyCellValueContext context)
    {
        // Verify that context contains a mol structure
        throw new NotImplementedException();
    }
}