LunarPresentation/Adorners/BaseTextCommentAdorner.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace SHomeWorkshop.LunarPresentation.Adorners
{
public class BaseTextCommentAdorner : Adorner
{
/// <summary>
/// 用在文本块备注文本显示时的装饰器。
/// </summary>
/// <param name="adornedElement">应传入文本块内部的备注TextBlock。</param>
public BaseTextCommentAdorner(UIElement adornedElement)
: base(adornedElement)
{
commentTextBlock = adornedElement as TextBlock;
this.Opacity = 0.75;
//终于解决了选取装饰器中线条宽度为2而不是1像素的问题!!!
this.SnapsToDevicePixels = true;
this.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
}
private TextBlock commentTextBlock;
protected override void OnRender(DrawingContext drawingContext)
{
//Rect rect = new Rect(this.AdornedElement.RenderSize);
Brush renderBrush = commentTextBlock.Foreground;
Pen renderPen = new Pen(commentTextBlock.Foreground, 1);
double fontSize = commentTextBlock.FontSize;
double ptaY = commentTextBlock.ActualHeight / 2;
Rect newRect = new Rect(-fontSize * 0.8, 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, newRect.Bottom - halfHeight);
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 };
PolyLineSegment pls = new PolyLineSegment(
new List<Point>()
{
pta,ptb,ptc,ptd,pte,ptf,ptg,pta,
后面还有 18 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。