You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
185 lines
4.6 KiB
C#
185 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using ICSharpCode.Core;
|
|
|
|
namespace Mesnac.PlugIn.Pad
|
|
{
|
|
/// <summary>
|
|
/// 面板描述符类
|
|
/// </summary>
|
|
public class PadDescriptor : IDisposable
|
|
{
|
|
#region 定义变量
|
|
|
|
private Codon codon; //密码子
|
|
private IPadContent padContent; //面板对象
|
|
private bool padContentCreated; //面板是否创建
|
|
|
|
#endregion
|
|
|
|
#region 构造方法
|
|
|
|
/// <summary>
|
|
/// 构造方法
|
|
/// </summary>
|
|
/// <param name="codon"></param>
|
|
public PadDescriptor(Codon codon)
|
|
{
|
|
this.codon = codon;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 定义属性
|
|
/// <summary>
|
|
/// 面板ID
|
|
/// </summary>
|
|
public string ID
|
|
{
|
|
get { return this.codon.Properties["id"]; }
|
|
}
|
|
/// <summary>
|
|
/// 面板标题
|
|
/// </summary>
|
|
public string Title
|
|
{
|
|
get { return this.codon.Properties["title"]; }
|
|
}
|
|
/// <summary>
|
|
/// 面板图标,如果没有定义图标,允许为空
|
|
/// </summary>
|
|
public string Icon
|
|
{
|
|
get { return this.codon.Properties["icon"]; }
|
|
}
|
|
/// <summary>
|
|
/// 面板类别(用于菜单分类)
|
|
/// </summary>
|
|
public string Category
|
|
{
|
|
get { return this.codon.Properties["category"]; }
|
|
}
|
|
/// <summary>
|
|
/// 菜单快捷键
|
|
/// </summary>
|
|
public string Shortcut
|
|
{
|
|
get { return this.codon.Properties["shortcut"]; }
|
|
}
|
|
/// <summary>
|
|
/// 关联类
|
|
/// </summary>
|
|
public string Class
|
|
{
|
|
get { return this.codon.Properties["class"]; }
|
|
}
|
|
|
|
public string DockState
|
|
{
|
|
get { return this.codon.Properties["dockState"]; }
|
|
}
|
|
/// <summary>
|
|
/// 是否显示
|
|
/// </summary>
|
|
public bool IsVisible
|
|
{
|
|
get
|
|
{
|
|
string isVisible = this.codon.Properties["isVisible"];
|
|
if (!String.IsNullOrEmpty(isVisible))
|
|
{
|
|
bool result = true;
|
|
if (bool.TryParse(isVisible, out result))
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取焦点
|
|
/// </summary>
|
|
public bool HasFocus
|
|
{
|
|
//get { return (this.padContent != null) ? this.padContent.Control.ContainsFocus : false; }
|
|
get
|
|
{
|
|
if (this.padContent != null && this.padContent.Control != null)
|
|
{
|
|
return this.padContent.Control.ContainsFocus;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取面板对象
|
|
/// </summary>
|
|
public IPadContent PadContent
|
|
{
|
|
get { this.CreatePad(); return this.padContent; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 定义方法
|
|
|
|
/// <summary>
|
|
/// 创建面板
|
|
/// </summary>
|
|
public void CreatePad()
|
|
{
|
|
if (!this.padContentCreated)
|
|
{
|
|
this.padContentCreated = true;
|
|
this.padContent = this.codon.AddIn.CreateObject(this.Class) as IPadContent;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 面板上移
|
|
/// </summary>
|
|
public void BringPadToFront()
|
|
{
|
|
this.CreatePad();
|
|
if (this.padContent == null) return;
|
|
//触发事件
|
|
if (BringPadToFrontEvent != null)
|
|
BringPadToFrontEvent(this);
|
|
}
|
|
/// <summary>
|
|
/// 重绘面板
|
|
/// </summary>
|
|
public void RedrawConent()
|
|
{
|
|
if (this.padContent != null)
|
|
{
|
|
this.padContent.RedrawContent();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 释放面板对象
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
if (this.padContent != null)
|
|
{
|
|
this.padContent.Dispose();
|
|
this.padContent = null;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 定义委托和事件
|
|
|
|
public delegate void BringPadToFrontHnd(PadDescriptor padDesc);
|
|
|
|
public static event BringPadToFrontHnd BringPadToFrontEvent;
|
|
|
|
#endregion
|
|
}
|
|
}
|