LunarMind/Adorners/CommentBorderAdorner.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using SHomeWorkshop.LunarTools;
namespace SHomeWorkshop.LunarMind.Adorners
{
public class CommentBorderAdorner : Adorner
{
// Be sure to call the base class constructor.
/// <summary>
/// 用以表示Comment选取状态的装饰器。
/// </summary>
/// <param name="adornedElement">应传入Comment的“TextBlock”主子元素。</param>
public CommentBorderAdorner(UIElement adornedElement, Comment masterComment)
: base(adornedElement)
{
this.masterComment = masterComment;
//终于解决了选取装饰器中线条宽度为2而不是1像素的问题!!!
this.SnapsToDevicePixels = true;
this.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
this.MouseDown += new System.Windows.Input.MouseButtonEventHandler(CommentBorderAdorner_MouseDown);
this.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(CommentBorderAdorner_MouseRightButtonUp);
}
void CommentBorderAdorner_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Comment.S_ContextMenu.IsOpen = true;
e.Handled = true;
}
void CommentBorderAdorner_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (masterComment != null)
{
masterComment.SelectOnlySelf();
e.Handled = true;
}
}
private Comment masterComment;
public Comment mMasterComment
{
get { return masterComment; }
}
// A common way to implement an adorner's rendering behavior is to override the OnRender
// method, which is called by the layout system as part of a rendering pass.
protected override void OnRender(DrawingContext drawingContext)
{
if (masterComment == null) return;
Rect adornedElementRect = new Rect(this.AdornedElement.RenderSize);
//先画线。
Pen linePen = null;
if (this.masterComment != null && this.masterComment.Editor != null)
后面还有 102 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。