You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.4 KiB
84 lines
2.4 KiB
using Microsoft.VisualBasic;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing.Design;
|
|
using System.Windows.Forms.Design;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.Design;
|
|
using System.Reflection;
|
|
using System.Web.UI.Design.WebControls;
|
|
|
|
namespace OT.Controls.Toolbar
|
|
{
|
|
public class ToolbarItemCollectionEditor : CollectionEditor
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 建構函式。
|
|
/// </summary>
|
|
/// <param name="Type">型別。</param>
|
|
public ToolbarItemCollectionEditor(Type Type) : base(Type)
|
|
{
|
|
}
|
|
|
|
protected override bool CanSelectMultipleInstances()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 取得這個集合編輯器可包含的資料型別。
|
|
/// </summary>
|
|
/// <returns>這個集合可包含的資料型別陣列。</returns>
|
|
protected override System.Type[] CreateNewItemTypes()
|
|
{
|
|
System.Type[] ItemTypes = new System.Type[3];
|
|
ItemTypes[0] = typeof(ToolbarButton);
|
|
ItemTypes[1] = typeof(ToolbarTextbox);
|
|
ItemTypes[2] = typeof(ToolbarLabel);
|
|
return ItemTypes;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 取出指定清單項目的顯示文字。
|
|
/// </summary>
|
|
protected override string GetDisplayText(object value)
|
|
{
|
|
if (value is ToolbarButton) {
|
|
return string.Format("按鈕 - {0}", ((ToolbarButton)value).Key);
|
|
} else if (value is ToolbarTextbox) {
|
|
return "文字框";
|
|
} else if (value is ToolbarLabel) {
|
|
return string.Format("標籤 - {0}", ((ToolbarLabel)value).Text);
|
|
} else {
|
|
return value.GetType().Name;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 建立集合屬性編輯器表單。
|
|
/// </summary>
|
|
protected override System.ComponentModel.Design.CollectionEditor.CollectionForm CreateCollectionForm()
|
|
{
|
|
CollectionEditor.CollectionForm oForm = default(CollectionEditor.CollectionForm);
|
|
Type oType = null;
|
|
FieldInfo oFieldInfo = null;
|
|
System.Windows.Forms.PropertyGrid oPropertyGrid = null;
|
|
|
|
oForm = base.CreateCollectionForm();
|
|
oType = oForm.GetType();
|
|
oFieldInfo = oType.GetField("propertyBrowser", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
if (oFieldInfo != null) {
|
|
//取得屬性視窗控制項
|
|
oPropertyGrid = (System.Windows.Forms.PropertyGrid)oFieldInfo.GetValue(oForm);
|
|
//設定屬性視窗控制項的[說明]區域為可視
|
|
oPropertyGrid.HelpVisible = true;
|
|
}
|
|
return oForm;
|
|
}
|
|
}
|
|
}
|