///
/// 编辑器对象必须实现这个接口
///
public interface IDocumentObject {
// 这些属性是 RichTextBox 控件的相应的属性映射
string SelectionText { get ; set ; }
Color SelectionColor { get ; set ; }
Font SelectionFont { get ; set ; }
int SelectionStart { get ; set ; }
int SelectionLength { get ; set ; }
string SelectionRTF { get ; set ; }
bool HasChanges { get ; }
void Select( int start , int length );
void AppendText( string str );
void SaveFile( string fileName );
void SaveFile();
void OpenFile( string fileName );
void CloseFile();
}
///
/// 用来指定一个插件的相关信息
///
public class PluginInfoAttribute : System.Attribute
{
///
/// Deprecated. Do not use.
///
public PluginInfoAttribute() {}
public PluginInfoAttribute(
string name , string version ,
string author , string webpage , bool loadWhenStart ) {
// 细节已略去
}
public string Name { get { return _Name; } }
public string Version { get { return _Version; } }
public string Author { get { return _Author; } }
public string Webpage { get { return _Webpage; } }
public bool LoadWhenStart { get { return _LoadWhenStart; } }
///
/// 用来存储一些有用的信息
///
public object Tag {
get { return _Tag; }
set { _Tag = value ; }
}
///
/// 用来存储序号
///
public int Index {
get { return _Index; }
set { _Index = value ; }
}
private string _Name = "";
private string _Version = "";
private string _Author = "";
private string _Webpage = "";
private object _Tag = null ;
private int _Index = 0;
// 暂时不会用
private bool _LoadWhenStart = true ;
}
用这个类修饰你的插件,并让他实现 IPlugin 接口:
///
/// My Pluging 1( Just for test )
///
[
PluginInfo(
"My Pluging 1( Just for test )" ,
"1.0" ,
"Jack H Hansen" ,
'javascript:void(0)' , true )
]
public class MyPlugin1 : IPlugin {
public MyPlugin1() { }
#region IPlugin 成员
// 细节已略去
#endregion
private IApplicationObject _App;
private IDocumentObject _CurDoc;
}