本文整理汇总了C#中ICanvas.ToUnit方法的典型用法代码示例。如果您正苦于以下问题:C# ICanvas.ToUnit方法的具体用法?C# ICanvas.ToUnit怎么用?C# ICanvas.ToUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanvas
的用法示例。
在下文中一共展示了ICanvas.ToUnit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SnapPointBase
public SnapPointBase(ICanvas canvas, IDrawObject owner, UnitPoint snappoint)
{
m_owner = owner;
m_snappoint = snappoint;
float size = (float)canvas.ToUnit(14);
m_boundingRect.X = (float)(snappoint.X - size / 2);
m_boundingRect.Y = (float)(snappoint.Y - size / 2);
m_boundingRect.Width = size;
m_boundingRect.Height = size;
}
示例2: ThresholdWidth
public static float ThresholdWidth(ICanvas canvas, float objectwidth, float pixelwidth)
{
double minWidth = canvas.ToUnit(pixelwidth);
double width = Math.Max(objectwidth / 2, minWidth);
return (float)width;
}
示例3: ToUnitNormalized
public static RectangleF ToUnitNormalized(ICanvas canvas, Rectangle screenrect)
{
UnitPoint point = canvas.ToUnit(screenrect.Location);
SizeF size = new SizeF((float)canvas.ToUnit(screenrect.Width), (float)canvas.ToUnit(screenrect.Height));
RectangleF unitrect = new RectangleF(point.Point, size);
unitrect.Y = unitrect.Y - unitrect.Height; //
return unitrect;
}
示例4: SnapPoint
public ISnapPoint SnapPoint(ICanvas canvas, UnitPoint point, List<IDrawObject> otherobj)
{
if (Enabled == false)
return null;
UnitPoint snappoint = new UnitPoint();
UnitPoint mousepoint = point;
float gridX = Spacing.Width;
float gridY = Spacing.Height;
snappoint.X = (float)(Math.Round(mousepoint.X / gridX)) * gridX;
snappoint.Y = (float)(Math.Round(mousepoint.Y / gridY)) * gridY;
double threshold = canvas.ToUnit(/*ThresholdPixel*/6);
if ((snappoint.X < point.X - threshold) || (snappoint.X > point.X + threshold))
return null;
if ((snappoint.Y < point.Y - threshold) || (snappoint.Y > point.Y + threshold))
return null;
return new GridSnapPoint(canvas, snappoint);
}
示例5: StartAngleNodePoint
UnitPoint StartAngleNodePoint(ICanvas canvas)
{
double r = Radius + canvas.ToUnit(8);
return HitUtil.PointOncircle(m_center, r, HitUtil.DegressToRadians(StartAngle));
}
示例6: RadiusNodePoint
UnitPoint RadiusNodePoint(ICanvas canvas)
{
double r = Radius + canvas.ToUnit(8);
float angle = StartAngle + SweepAngle / 2;
return HitUtil.PointOncircle(m_center, r, HitUtil.DegressToRadians(angle));
}
示例7: GetBoundingRect
public RectangleF GetBoundingRect(ICanvas canvas)
{
float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);
if (thWidth < Width)
thWidth = Width;
RectangleF rect = RectangleF.Empty;
// if one of the points is empty, then a straight line is drawn, so return bounding rect for a line
if (m_p2.IsEmpty || m_p3.IsEmpty)
rect = ScreenUtils.GetRect(m_p1, m_lastPoint, thWidth);
if (rect.IsEmpty)
{
float r = m_radius + thWidth / 2;
rect = HitUtil.CircleBoundingRect(m_center, r);
if (Selected)
{
float w = (float)canvas.ToUnit(20); // include space for the 'extern' nodes
rect.Inflate(w, w);
}
}
// if drawing either angle then include the mouse point in the rectangle - this is to redraw (erase) the line drawn
// from center point to mouse point
//if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle)
if (m_lastPoint.IsEmpty == false)
rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0,0)));
return rect;
}