76 lines
1.7 KiB
C#
76 lines
1.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using JD.Interfaces.Remoting;
|
|
using JD.Remoting;
|
|
|
|
namespace MaterialEditor
|
|
{
|
|
|
|
/// <summary>
|
|
/// Plugin specified for file oriented editors.
|
|
/// </summary>
|
|
public class OfflineToolPlugin : JD.Remoting.Plugin
|
|
{
|
|
|
|
#region Constructors
|
|
|
|
public OfflineToolPlugin(string name, IConnection connection)
|
|
: base(name, connection)
|
|
{
|
|
RegisterHandler("openFile", OnOpenFileReceived, false);
|
|
}
|
|
|
|
public OfflineToolPlugin(IConnection connection)
|
|
: this("OfflineTool_Plugin", connection)
|
|
{
|
|
|
|
}
|
|
|
|
public OfflineToolPlugin(string name)
|
|
: this(name, null)
|
|
{
|
|
|
|
}
|
|
|
|
public OfflineToolPlugin()
|
|
: this("OfflineTool_Plugin",null)
|
|
{
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Triggered when an "open file" command is received.
|
|
/// </summary>
|
|
/// <param name="blob">Blob containing the file name.</param>
|
|
protected virtual void OnOpenFileReceived(IBlob blob)
|
|
{
|
|
if (blob != null)
|
|
{
|
|
// Triggers event if filename is found.
|
|
var handler = OpenFileRequest;
|
|
if (handler != null)
|
|
{
|
|
string filename = blob.ExtractString();
|
|
handler(filename);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
/// <summary>
|
|
/// Event triggered when a file should open.
|
|
/// </summary>
|
|
public event Action<string> OpenFileRequest;
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|