LunarMind/ConceptWidgets/Tools/PointToRect.cs
(开头部分) 10KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace SHomeWorkshop.LunarConcept.Tools
{
/// <summary>
/// 创建时间:2012年1月26日
/// 创建者: 杨震宇
///
/// 主要用途:计算出矩形中心与一点的交点的坐标。——顺便计算在此方向上指向矩形中心的箭头的坐标。
/// </summary>
public static class PointToRect
{
/// <summary>
/// 求一个点与矩形中心点的连线与矩形的边缘的交点。
/// </summary>
/// <param name="rect">矩形</param>
/// <param name="point">矩形内部或外部一点。</param>
/// <returns></returns>
public static ArrowPoints GetCrossPointToRect(Rect rect, Point point)
{
Point center = new Point(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
ArrowPoints arrowPt = new ArrowPoints();
double arrowHeight = 10;
if (point.X == center.X)
{
if (point.Y < center.Y)//y轴正向。
{
arrowPt.Top = new Point(center.X, rect.Top);
arrowPt.Start = new Point(center.X + arrowHeight / Math.Sqrt(3), rect.Top - arrowHeight);
arrowPt.End = new Point(center.X - arrowHeight / Math.Sqrt(3), rect.Top - arrowHeight);
return arrowPt;
}
else if (point.Y == center.Y)//正好是Rect中心。这几乎不可能出现。
{
//为防止出现这一情况。
point.X += 1; point.Y += 1;
//arrowPt.Top = forceCenter;
//arrowPt.Start = forceCenter;
//arrowPt.End = forceCenter;
//return arrowPt;
}
else if (point.Y > center.Y)//y轴负向。
{
arrowPt.Top = new Point(center.X, rect.Bottom);
arrowPt.Start = new Point(center.X - arrowHeight / Math.Sqrt(3), rect.Bottom + arrowHeight);
arrowPt.End = new Point(center.X + arrowHeight / Math.Sqrt(3), rect.Bottom + arrowHeight);
return arrowPt;
}
}
后面还有 181 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。