本文整理汇总了C#中Dataweb.NShape.Advanced.Template.CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Template.CopyFrom方法的具体用法?C# Template.CopyFrom怎么用?C# Template.CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataweb.NShape.Advanced.Template
的用法示例。
在下文中一共展示了Template.CopyFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
/// <summary>
/// Calling this method initializes the <see cref="T:Dataweb.NShape.Controllers.TemplateController" />.
/// </summary>
public void Initialize(Project project, Template template)
{
if (isInitializing) {
Debug.Fail("Already initializing");
return;
}
try {
isInitializing = true;
if (project == null) throw new ArgumentNullException("project");
if (this.project != project) Project = project;
#if DEBUG_DIAGNOSTICS
if (template != null)
template.Tag = template.Name;
#endif
// Check if there are shape types supporting templating
bool templateSupportingShapeTypeFound = false;
foreach (ShapeType shapeType in project.ShapeTypes) {
if (shapeType.SupportsAutoTemplates) {
templateSupportingShapeTypeFound = true;
break;
}
}
if (!templateSupportingShapeTypeFound)
throw new NShapeException("No template supporting shape types found. Load a shape library first.");
// Create a copy of the template
if (template != null) {
editMode = TemplateControllerEditMode.EditTemplate;
originalTemplate = template;
workTemplate = new Template(originalTemplate.Name, originalTemplate.Shape.Clone());
workTemplate.CopyFrom(originalTemplate);
workTemplate.Shape.DisplayService = this;
}
else {
// Create a new Template
editMode = TemplateControllerEditMode.CreateTemplate;
originalTemplate = null;
// As a shape is mandatory for every template, find a shape first
Shape shape = FindFirstShapeOfType(typeof (IPlanarShape));
if (shape == null) shape = FindFirstShapeOfType(typeof (Shape)); // if no planar shape was found, get the first one
int templateCnt = 1;
foreach (Template t in project.Repository.GetTemplates()) ++templateCnt;
workTemplate = new Template(string.Format("Template {0}", templateCnt), shape);
shape.DisplayService = this;
}
// Disable all controls if the user has not the appropriate access rights
if (!project.SecurityManager.IsGranted(Permission.Templates)) {
// ToDo: implement access right restrictions
}
InitShapeList();
InitModelObjectList();
isInitialized = true;
if (Initializing != null) {
TemplateControllerInitializingEventArgs eventArgs = new TemplateControllerInitializingEventArgs(editMode, template);
Initializing(this, eventArgs);
}
}
finally {
isInitializing = false;
}
}
示例2: Clone
/// <summary>
/// Creates a new <see cref="T:Dataweb.NShape.Advanced.Template" /> that is a copy of the current instance.
/// </summary>
public Template Clone() {
Template result = new Template();
result.CopyFrom(this);
return result;
}