📄 reorderlistdesigner.cs
字号:
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.
namespace AjaxControlToolkit
{
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Design;
using System.Diagnostics;
using System.Globalization;
using System.Text;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Design;
using System.Web.UI.Design.Util;
using System.Web.UI.Design;
using System.Web.UI;
using System;
using System.Web.UI.Design.WebControls;
/// <summary>
/// The designer class for the ReorderList. It's main job in life is to display the
/// various edit modes for the templates as well as the dropdown in the DesignerActionList.
/// </summary>
internal class ReorderListDesigner : DataBoundControlDesigner
{
private const string _designtimeHTML =
@"<table cellspacing=0 cellpadding=0 border=0 style=""display:inline-block"">
<tr>
<td nowrap align=center valign=middle style=""color:{0}; background-color:{1}; "">{2}</td>
</tr>
<tr>
<td style=""vertical-align:top;"" {3}='0'>{4}</td>
</tr>
</table>";
private const string _designtimeHTML_Template =
@"
<table cellspacing=0 cellpadding=0 border=0 style=""display:inline-block;border:outset white 1px;"">
<tr>
<td nowrap align=center valign=middle style=""background-color:{6}; ""><span style=""font:messagebox;color:{5}""><b>{8}</b> - {7}</span></td>
</tr>
<tr>
<td>
<table cellspacing=0 cellpadding=2 border=0 style=""margin:2px;border:solid 1px buttonface"">
<tr style=""font:messagebox;background-color:lightblue;color:black"">
<td style=""border:solid 1px buttonshadow"">
{0}
</td>
</tr>
<tr style=""{1}"" height=100%>
<td style=""{2}"">
<div style=""width:100%;height:100%"" {3}='0'>{4}</div>
</td>
</tr>
</table>
</td>
</tr></table>";
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public ReorderListDesigner()
{
}
private TemplateGroupCollection _templateGroups;
private const int DefaultTemplateIndex = 0;
private struct TemplateItem
{
public readonly string Name;
public readonly bool SupportsDataBinding;
public TemplateItem(string name, bool supportsDataBinding)
{
Name = name;
SupportsDataBinding = supportsDataBinding;
}
}
private static TemplateItem[] TemplateItems = new TemplateItem[]{
new TemplateItem("ItemTemplate", true),
new TemplateItem("EditItemTemplate", true),
new TemplateItem("DragHandleTemplate", true),
new TemplateItem("ReorderTemplate", false),
new TemplateItem("InsertItemTemplate", true),
new TemplateItem("EmptyListTemplate", false)
};
/// <include file='doc\ReorderListDesigner.uex' path='docs/doc[@for="ReorderListDesigner.ActionLists"]/*' />
public override DesignerActionListCollection ActionLists
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
DesignerActionListCollection actionLists = new DesignerActionListCollection();
actionLists.AddRange(base.ActionLists);
actionLists.Add(new ReorderListDesignerActionList(this));
return actionLists;
}
}
private object CurrentObject
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
return Component;
}
}
private ITemplate CurrentTemplate
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
if (CurrentTemplateDescriptor != null) {
return (ITemplate)CurrentTemplateDescriptor.GetValue(Component);
}
Debug.Fail("Couldn't get current template descriptor");
return null;
}
}
private PropertyDescriptor CurrentTemplateDescriptor
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
string viewName = TemplateItems[CurrentView].Name;
PropertyDescriptor templateProp = TypeDescriptor.GetProperties(Component)[viewName];
Debug.Assert(templateProp != null, "couldn't find template prop '" + viewName + "'");
return templateProp;
}
}
// index of the view currently visible in the designer
private int CurrentView
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
object view = DesignerState["CurrentView"];
int index = (view == null) ? DefaultTemplateIndex : (int)view;
if (index >= TemplateItems.Length)
{
index = DefaultTemplateIndex;
}
return index;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
set
{
DesignerState["CurrentView"] = value;
}
}
private string CurrentViewName
{
get
{
return TemplateItems[CurrentView].Name;
}
}
private ITemplate CurrentViewControlTemplate
{
get
{
return CurrentTemplate;
}
}
private ReorderList ReorderList{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
return (ReorderList)Component;
}
}
private TemplateDefinition TemplateDefinition
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
TemplateDefinition td = new TemplateDefinition(this, CurrentViewName, ReorderList, CurrentViewName);
td.SupportsDataBinding = true;
return td;
}
}
public override TemplateGroupCollection TemplateGroups
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
get
{
TemplateGroupCollection groups = base.TemplateGroups;
if (_templateGroups == null)
{
_templateGroups = new TemplateGroupCollection();
foreach(TemplateItem ti in TemplateItems) {
TemplateGroup tg = new TemplateGroup(ti.Name);
TemplateDefinition td = new TemplateDefinition(this, ti.Name, ReorderList, ti.Name);
td.SupportsDataBinding = ti.SupportsDataBinding;
tg.AddTemplateDefinition(td);
_templateGroups.Add(tg);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -