📄 reorderlistdesigner.cs
字号:
groups.AddRange(_templateGroups);
return groups;
}
}
protected override bool UsePreviewControl
{
get
{
return true;
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
private EditableDesignerRegion BuildRegion()
{
EditableDesignerRegion region = new ReorderListDesignerRegion(CurrentObject, CurrentTemplate, CurrentTemplateDescriptor, TemplateDefinition);
region.Description = CurrentViewName;
return region;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public override string GetDesignTimeHtml()
{
string designTimeHtml = String.Empty;
if (CurrentViewControlTemplate != null)
{
ReorderList ReorderList = (ReorderList)ViewControl;
IDictionary param = new HybridDictionary(1);
param["TemplateIndex"] = CurrentView;
((IControlDesignerAccessor)ReorderList).SetDesignModeState(param);
//ReorderList.DataBind();
designTimeHtml = base.GetDesignTimeHtml();
}
return designTimeHtml;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public override string GetDesignTimeHtml(DesignerRegionCollection regions)
{
string content = String.Empty;
regions.Add(BuildRegion());
StringBuilder sb = new StringBuilder(1024);
if (CurrentTemplate == null)
{
sb.Append(String.Format(CultureInfo.InvariantCulture,
_designtimeHTML,
ColorTranslator.ToHtml(SystemColors.ControlText),
ColorTranslator.ToHtml(SystemColors.Control),
ReorderList.ID,
DesignerRegion.DesignerRegionAttributeName,
content));
}
else
{
DataList dl = new DataList();
sb.Append(String.Format(CultureInfo.InvariantCulture,
_designtimeHTML_Template,
CurrentViewName,
dl.HeaderStyle,
ReorderList.ControlStyle,
DesignerRegion.DesignerRegionAttributeName,
content,
ColorTranslator.ToHtml(SystemColors.ControlText),
ColorTranslator.ToHtml(SystemColors.Control),
ReorderList.ID,
ReorderList.GetType().Name));
dl.Dispose();
}
return sb.ToString();
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public override string GetEditableDesignerRegionContent(EditableDesignerRegion region)
{
ReorderListDesignerRegion rldRegion = region as ReorderListDesignerRegion;
if (null != rldRegion)
{
ITemplate template = rldRegion.Template;
if (template != null)
{
IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
return ControlPersister.PersistTemplate(template, host);
}
}
return base.GetEditableDesignerRegionContent(region);
}
/// <include file='doc\ReorderListDesigner.uex' path='docs/doc[@for="ReorderListDesigner.GetEmptyDesignTimeHtml"]/*' />
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
protected override string GetEmptyDesignTimeHtml()
{
string templateEmpty = "<br />Empty " + TemplateItems[CurrentView].Name + "<br />";
return CreatePlaceHolderDesignTimeHtml(templateEmpty);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
protected override string GetErrorDesignTimeHtml(Exception e)
{
return CreatePlaceHolderDesignTimeHtml("Error rendering ReorderList:<br />" + e.Message);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content)
{
ReorderListDesignerRegion lvRegion = region as ReorderListDesignerRegion;
if (lvRegion == null) return;
IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
Debug.Assert(host != null, "IDesignerHost is null.");
ITemplate template = ControlParser.ParseTemplate(host, content);
using (DesignerTransaction transaction = host.CreateTransaction("SetEditableDesignerRegionContent"))
{
lvRegion.PropertyDescriptor.SetValue(lvRegion.Object, template);
transaction.Commit();
}
lvRegion.Template = template;
}
private class ReorderListDesignerRegion : TemplatedEditableDesignerRegion
{
ITemplate _template;
public ITemplate Template
{
get { return _template; }
set { _template = value; }
}
object _object;
public object Object { get { return _object; } }
PropertyDescriptor _prop;
public PropertyDescriptor PropertyDescriptor { get { return _prop; } }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public ReorderListDesignerRegion(object obj, ITemplate template, PropertyDescriptor descriptor, TemplateDefinition definition)
: base(definition)
{
_template = template;
_object = obj;
_prop = descriptor;
EnsureSize = true;
}
}
private class ReorderListDesignerActionList : DesignerActionList
{
private ReorderListDesigner _designer;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
public ReorderListDesignerActionList(ReorderListDesigner designer)
: base(designer.Component)
{
_designer = designer;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods", Justification = "Security handled by base class")]
[TypeConverter(typeof(ReorderListViewTypeConverter))]
public string View
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by VS designer")]
get
{
return _designer.CurrentViewName;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by VS designer")]
set
{
int index = Array.FindIndex<TemplateItem>(TemplateItems, delegate(TemplateItem t) { return t.Name == value; });
Debug.Assert(index != -1, "Invalid template name: " + value);
if (index != -1)
{
_designer.CurrentView = index;
}
_designer.UpdateDesignTimeHtml();
}
}
private class ReorderListViewTypeConverter : TypeConverter
{
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
string[] templateNames = new string[TemplateItems.Length];
for (int i = 0; i < templateNames.Length; i++)
{
templateNames[i] = TemplateItems[i].Name;
}
return new StandardValuesCollection(templateNames);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -