LunarMind/Adorners/CommentAdorner.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace SHomeWorkshop.LunarMind.Adorners
{
public class CommentAdorner : Adorner
{
/// <summary>
/// 用在标题备注文本显示时的装饰器。
/// </summary>
/// <param name="adornedElement">应传入备注文本块。</param>
public CommentAdorner(Title masterTitle, UIElement adornedElement)
: base(adornedElement)
{
commentTextBlock = adornedElement as TextBlock;
this.masterTitle = masterTitle;
//this.Opacity = 0.5;
//终于解决了选取装饰器中线条宽度为2而不是1像素的问题!!!
this.SnapsToDevicePixels = true;
this.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
}
private Title masterTitle;
private TextBlock commentTextBlock;
protected override void OnRender(DrawingContext drawingContext)
{
if (masterTitle == null) return;
Brush renderBrush = LunarConcept.Tools.BrushManager.SevenColors; //commentTextBlock.Foreground;
Pen renderPen = new Pen(commentTextBlock.Foreground, 1);
double fontSize = commentTextBlock.FontSize;
double ptaY = commentTextBlock.ActualHeight / 2;
if (Globals.MainWindow.View != ViewMode.Default || masterTitle.Direction == TitleDirection.Right)//只有导图会分左右。
{
Rect newRect = new Rect(-fontSize, ptaY - fontSize / 2, fontSize * 0.8, fontSize);
double width = newRect.Width;
double height = newRect.Height;
double halfHeight = height / 2;
int quarterHeight = (int)height / 4;
Point pta = new Point(newRect.Right, ptaY);
Point ptb = new Point(newRect.BottomRight.X - halfHeight, newRect.Bottom);
Point ptc = new Point(newRect.TopRight.X - halfHeight, pta.Y + quarterHeight);
Point ptd = new Point(newRect.Left, ptc.Y);
Point pte = new Point(ptd.X, pta.Y - quarterHeight + 1);
Point ptf = new Point(ptb.X, pte.Y);
Point ptg = new Point(ptb.X, newRect.Top);
PathGeometry pathGeometry = new PathGeometry();
PathFigure pf = new PathFigure() { StartPoint = pta, IsClosed = true, IsFilled = true };
后面还有 43 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。