packages/MaterialDesignThemes.2.5.1/src/net45/TreeHelper.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Windows;
using System.Windows.Media;
namespace MaterialDesignThemes.Wpf
{
internal static class TreeHelper
{
public static double GetVisibleWidth(FrameworkElement element, UIElement parent)
{
if (element == null) throw new ArgumentNullException(nameof(element));
if (parent == null) throw new ArgumentNullException(nameof(parent));
var location = element.TransformToAncestor(parent).Transform(new Point(0, 0));
int width = (int) Math.Floor(element.ActualWidth);
var hitTest = parent.InputHitTest(new Point(location.X + width, location.Y));
if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
{
return width;
}
//BinarySearch here
int end = (int) Math.Floor(element.ActualWidth);
int start = 0;
while (start < end)
{
width = (end + start)/2;
hitTest = parent.InputHitTest(new Point(location.X + width, location.Y));
if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
{
//Speed tweak
hitTest = parent.InputHitTest(new Point(location.X + width + 1, location.Y));
if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
{
start = width;
}
else
{
return width;
}
}
else
{
end = width;
}
}
//for (int width = (int) Math.Floor(element.ActualWidth); width >= 0; width--)
//{
// var hitTest = parent.InputHitTest(new Point(location.X + width, location.Y));
//
// if (hitTest == null) continue;
//
// if (IsAncestorTill(hitTest as FrameworkElement, element, parent))
后面还有 38 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
