当前位置: 首页>>代码示例>>C#>>正文


C# Part.SetAdornment方法代码示例

本文整理汇总了C#中Part.SetAdornment方法的典型用法代码示例。如果您正苦于以下问题:C# Part.SetAdornment方法的具体用法?C# Part.SetAdornment怎么用?C# Part.SetAdornment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Part的用法示例。


在下文中一共展示了Part.SetAdornment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateAdornments

 /// <summary>
 /// Show an <see cref="Adornment"/> with resize handles at points along the edge of bounds of the <see cref="AdornedElement"/>,
 /// if the node is selected and visible and if <see cref="Northwoods.GoXam.Part.CanResize"/> is true.
 /// </summary>
 /// <param name="part"></param>
 /// <remarks>
 /// You can change the template used to create the adornment by setting <see cref="Part.ResizeAdornmentTemplate"/>.
 /// If that property is null, this uses a default template with eight resize handles
 /// at the four corners and at the middles of the four sides.
 /// </remarks>
 public override void UpdateAdornments(Part part) {
   if (part == null || part is Link) return;  // can't resize links
   Adornment adornment = null;
   if (part.IsSelected) {
     FrameworkElement selelt = part.SelectionElement;
     if (selelt != null && part.CanResize() && Part.IsVisibleElement(selelt)) {
       adornment = part.GetAdornment(ToolCategory);
       if (adornment == null) {
         DataTemplate template = part.ResizeAdornmentTemplate;
         if (template == null) template = Diagram.FindDefault<DataTemplate>("DefaultResizeAdornmentTemplate");
         adornment = part.MakeAdornment(selelt, template);
         if (adornment != null) {
           adornment.Category = ToolCategory;
           adornment.LocationSpot = Spot.TopLeft;
         }
       }
       if (adornment != null) {
         Point loc = part.GetElementPoint(selelt, Spot.TopLeft);
         double angle = part.GetAngle(selelt);
         UpdateResizeHandles(adornment.VisualElement, angle);
         adornment.Location = loc;
         adornment.RotationAngle = angle;
         adornment.Remeasure();
       }
     }
   }
   part.SetAdornment(ToolCategory, adornment);
 }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:38,代码来源:ResizingTool.cs

示例2: UpdateAdornments

 /// <summary>
 /// Show an <see cref="Adornment"/> with resize handles at points along the edge of bounds of the <see cref="AdornedElement"/>,
 /// if the node is selected and visible and if <see cref="Northwoods.GoXam.Part.CanResize"/> is true.
 /// </summary>
 /// <param name="part"></param>
 /// <remarks>
 /// <para>
 /// First this finds the element in the visual tree of the <paramref name="part"/> that should
 /// get the resize adornment and that the user will be able to resize interactively.
 /// It finds the element that has the <see cref="Part.ResizeElementName"/> property of the part.
 /// If the <see cref="Part.ResizeElementName"/> property is null, as it is by default, it uses
 /// the part's <see cref="Part.SelectionElement"/>.
 /// </para>
 /// <para>
 /// It then constructs the adornment template, associating it with the chosen resize element.
 /// </para>
 /// <para>
 /// You can change the template used to create the adornment by setting <see cref="Part.ResizeAdornmentTemplate"/>.
 /// If that property is null, this uses a default template with eight resize handles
 /// at the four corners and at the middles of the four sides.
 /// </para>
 /// <para>
 /// This only gives a resize adornment to <see cref="Node"/>s, not to <see cref="Link"/>s.
 /// </para>
 /// </remarks>
 public override void UpdateAdornments(Part part) {
   if (part == null || part is Link) return;  // can't resize links
   Adornment adornment = null;
   if (part.IsSelected) {
     FrameworkElement selelt = null;
     String eltname = part.ResizeElementName;
     if (eltname != null) selelt = part.FindNamedDescendant(eltname);
     if (selelt == null) selelt = part.SelectionElement;
     if (selelt != null && part.CanResize() && Part.IsVisibleElement(selelt)) {
       adornment = part.GetAdornment(ToolCategory);
       if (adornment == null) {
         DataTemplate template = part.ResizeAdornmentTemplate;
         if (template == null) template = Diagram.FindDefault<DataTemplate>("DefaultResizeAdornmentTemplate");
         adornment = part.MakeAdornment(selelt, template);
         if (adornment != null) {
           adornment.Category = ToolCategory;
           adornment.LocationSpot = Spot.TopLeft;
         }
       }
       if (adornment != null) {
         Node node = (Node)part;
         Point loc = part.GetElementPoint(selelt, Spot.TopLeft);
         // use the node's angle, not part.GetAngle(selelt)
         //?? this can be wrong if there are additional rotational transforms in the tree
         double angle = node.RotationAngle;
         UpdateResizeHandles(adornment.VisualElement, angle);
         adornment.Location = loc;
         adornment.RotationAngle = angle;
         adornment.Remeasure();
       }
     }
   }
   part.SetAdornment(ToolCategory, adornment);
 }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:59,代码来源:ResizingTool.cs

示例3: UpdateAdornments

 /// <summary>
 /// Show an <see cref="Adornment"/> with a rotate handle at a point to the side of the <see cref="AdornedElement"/>,
 /// if the node is selected and visible and if <see cref="Northwoods.GoXam.Part.CanRotate"/> is true.
 /// </summary>
 /// <param name="part"></param>
 /// <remarks>
 /// You can change the template used to create the adornment by setting <see cref="Part.RotateAdornmentTemplate"/>.
 /// If that property is null, this uses a default template that produces a small circle.
 /// </remarks>
 public override void UpdateAdornments(Part part) {
   if (part == null || part is Link) return;  // this tool never applies to Links
   Adornment adornment = null;
   if (part.IsSelected) {
     FrameworkElement selelt = part.SelectionElement;
     if (selelt != null && part.CanRotate() && Part.IsVisibleElement(selelt)) {
       adornment = part.GetAdornment(ToolCategory);
       if (adornment == null) {
         DataTemplate template = part.RotateAdornmentTemplate;
         if (template == null) template = Diagram.FindDefault<DataTemplate>("DefaultRotateAdornmentTemplate");
         adornment = part.MakeAdornment(selelt, template);
         if (adornment != null) {
           adornment.Category = ToolCategory;
           adornment.LocationSpot = Spot.Center;
         }
       }
       if (adornment != null) {
         adornment.Location = part.GetElementPoint(selelt, new Spot(1, 0.5, 30, 0));  //?? fixed distance from middle right side
       }
     }
   }
   part.SetAdornment(ToolCategory, adornment);
 }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:32,代码来源:RotatingTool.cs

示例4: UpdateAdornments

 /// <summary>
 /// Show an <see cref="Adornment"/> with a rotate handle at a point to the side of the <see cref="AdornedElement"/>,
 /// if the node is selected and visible and if <see cref="Northwoods.GoXam.Part.CanRotate"/> is true.
 /// </summary>
 /// <param name="part"></param>
 /// <remarks>
 /// You can change the template used to create the adornment by setting <see cref="Part.RotateAdornmentTemplate"/>.
 /// If that property is null, this uses a default template that produces a small circle.
 /// </remarks>
 public override void UpdateAdornments(Part part) {
   if (part == null || part is Link) return;  // this tool never applies to Links
   Adornment adornment = null;
   if (part.IsSelected) {
     FrameworkElement selelt = part.SelectionElement;
     if (selelt != null && part.CanRotate() && Part.IsVisibleElement(selelt)) {
       adornment = part.GetAdornment(ToolCategory);
       if (adornment == null) {
         DataTemplate template = part.RotateAdornmentTemplate;
         if (template == null) template = Diagram.FindDefault<DataTemplate>("DefaultRotateAdornmentTemplate");
         adornment = part.MakeAdornment(selelt, template);
         if (adornment != null) {
           adornment.Category = ToolCategory;
           adornment.LocationSpot = Spot.Center;
         }
       }
       if (adornment != null) {
         Rect rect = part.GetElementBounds(part.VisualElement);  //?? outside whole node
         Point center = Spot.Center.PointInRect(rect);
         double angle = part.GetAngle(selelt);
         adornment.Location = Geo.RotatePoint(new Point(rect.Right + 30, center.Y), center, angle);  //?? fixed distance
       }
     }
   }
   part.SetAdornment(ToolCategory, adornment);
 }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:35,代码来源:RotatingTool.cs


注:本文中的Part.SetAdornment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。