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