本文整理汇总了C#中Point.Offseted方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Offseted方法的具体用法?C# Point.Offseted怎么用?C# Point.Offseted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.Offseted方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChildDropRegions
public IEnumerable<DropRegion> ChildDropRegions(Point origin)
{
int y = 0;
for (int i = 0; i < elements.Count; ++i)
{
foreach (DropRegion dr in elements[i].ChildDropRegions(origin.Offseted(0, y)))
{
yield return dr;
}
y += elementBitmaps[i].Height - BlockStackView.NotchHeight;
}
}
示例2: EdgeDropRegions
public static IEnumerable<DropRegion> EdgeDropRegions(
this IInvokationBlockView view,
Point origin, Size size)
{
BlockAttributes Attribute = view.Attribute;
int Width = size.Width;
int Height = size.Height;
if (Attribute == BlockAttributes.Stack)
{
yield return new DropRegion(DropType.Above, new Rectangle(origin.Offseted(0, -2), new Size(Width, 5)), view);
yield return new DropRegion(DropType.Below, new Rectangle(origin.Offseted(0, Height - 2), new Size(Width, 5)), view);
}
else if (Attribute == BlockAttributes.Hat)
{
yield return new DropRegion(DropType.Below, new Rectangle(origin.Offseted(0, Height - 2), new Size(Width, 5)), view);
}
else if (Attribute == BlockAttributes.Cap)
{
yield return new DropRegion(DropType.Above, new Rectangle(origin.Offseted(0, -2), new Size(Width, 5)), view);
}
}
示例3: TestRender
public void TestRender(Graphics g, Point p, Font f)
{
g.DrawImageUnscaled(A, p);
g.DrawImageUnscaled(B, p.Offseted(A.Width+5, 0));
g.DrawImageUnscaled(C, p.Offseted(A.Width + B.Width + 10, 0));
}
示例4: MouseDown
internal void MouseDown(Point p)
{
if (state == CanvasState.TextEditing)
{
// Since the mousedown registered, we've clicked outside the textbox
ResetTextEditState();
}
else if (state == CanvasState.Ready)
{
if (canvasView.PaletteRect.Contains(p))
{
int x = canvasView.PaletteRect.Left;
int y = canvasView.PaletteRect.Top;
IBlock[] defaultArgs;
string funcName = palette.HitTest(p.Offseted(-x, -y), out defaultArgs);
if (funcName != "")
{
IBlock b = blockSpace.makeNewBlock(funcName,defaultArgs);
TopLevelScript s = AddTopLevel(b, p.Offseted(-5, -5));
dragged = blockViews[b];
draggingOrigin = p;
draggedModel = s;
state = CanvasState.Dragging;
PrepareDropRegions(b);
Update(ViewBounds(dragged));
return;
}
}
IBlockView hit = HitTest(p);
if (hit == null)
return;
if (!allViews.ContainsKey(hit))
{
if (hit.Model.ParentRelationship.Type == ParentRelationshipType.Stack)
{
int i = hit.Model.ParentRelationship.Index;
Point np = hit.AbsolutePos();
Rectangle bounds = ViewBounds(hit.AbsoluteAncestor());
BlockStack parent = (BlockStack)hit.Model.ParentRelationship.Parent;
TopLevelScript splitted = SplitBlockStack(parent, i, np);
Update(bounds);
draggedModel = splitted;
hit = blockViews[splitted.Block];
}
else if (hit.Model.ParentRelationship.Type == ParentRelationshipType.Arg)
{
if (hit is ITextualView)
{
// We shouldn't detach e.g a number argument from its block
// but we should enable the user to edit it
SetEditState((ITextualView) hit);
return;
}
int i = hit.Model.ParentRelationship.Index;
Point np = hit.AbsolutePos();
Rectangle bounds = ViewBounds(hit.AbsoluteAncestor());
InvokationBlock parent = (InvokationBlock)hit.Model.ParentRelationship.Parent;
TopLevelScript splitted = TakeoutBlockArgument(parent, i, np);
Update(bounds);
draggedModel = splitted;
hit = blockViews[splitted.Block];
}
else if (hit.Model.ParentRelationship.Type == ParentRelationshipType.FormalParameter)
{
ProcDefBlock pd = (ProcDefBlock ) hit.Model.ParentRelationship.Parent;
VarAccessBlock va = new VarAccessBlock((VarDefBlock)pd.Bits[hit.Model.ParentRelationship.Index]);
TopLevelScript tls = AddTopLevel(va, p);
hit = ViewFromBlock(va);
draggedModel = tls;
}
else if (hit.Model.ParentRelationship.Type == ParentRelationshipType.None)
{
hit = null;
draggedModel = null;
}
}
else
{
draggedModel = blockSpace.FindScript(hit.Model);
}
if (hit != null)
{
dragged = hit;
draggingOrigin = p;
state = CanvasState.Dragging;
PrepareDropRegions(hit.Model);
}
Update();
}
}
示例5: ChildHasPoint
public IBlockView ChildHasPoint(Point p, Point origin)
{
for (int i = 0; i < Contents.Count; ++i)
{
IBlockView v = Contents[i];
Point rp = new Point(0, layoutOffsets[i*2]); // notice that contentOffsets also holds the offset
if (v.HasPoint(p, origin.Offseted(rp.X, rp.Y))) // of the "side" graphics, not just the content views
{
IBlockView chp = v.ChildHasPoint(p, origin.Offseted(rp.X, rp.Y));
if (chp == v)
return this;
else
return chp;
}
}
for (int i = 0; i < Scripts.Count; ++i)
{
IBlockView v = Scripts[i];
Point rp = scriptOffsets[i];
if (v.HasPoint(p, origin.Offseted(rp.X, rp.Y)))
return v.ChildHasPoint(p, origin.Offseted(rp.X, rp.Y));
}
return this;
}
示例6: ChildDropRegions
public IEnumerable<DropRegion> ChildDropRegions(Point origin)
{
int i = 0;
foreach (IBlockView c in Contents)
{
foreach (DropRegion dr in c.DropRegions(origin.Offseted(0, layoutOffsets[i*2])))
yield return dr;
i++;
}
i = 0;
foreach (IBlockView s in Scripts)
{
Point p = scriptOffsets[i];
if ((s.Model is BlockStack) && ((BlockStack)s.Model).Empty)
{
// It's just a placeholder, no 'real' BlockStackView here
// We assume here that each script is preceded by a content and that they strictly
// alternate, and thus we can set the width of the placeholder to be that of
// the previous content (Contents[i].Width)
yield return new DropRegion(DropType.AsArgument,
new Rectangle(origin.Offseted(p), new Size(Contents[i].Width, 5)),
this, scriptIndexes[i], DataType.Script);
}
else
{
foreach (DropRegion dr in s.DropRegions(origin.Offseted(p.X, p.Y)))
yield return dr;
}
i++;
}
}
示例7: ChildHasPoint
public IBlockView ChildHasPoint(Point p, Point origin)
{
int y = 0;
for (int i = 0; i < elements.Count; ++i)
{
IBlockView v = elements[i];
Point rp = new Point(0, y);
if (v.HasPoint(p, origin.Offseted(rp.X, rp.Y)))
{
IBlockView c = v.ChildHasPoint(p, origin.Offseted(rp.X, rp.Y));
if (i == 0 && c == v)
{
// selecting the first block-> select whole stack
// but selecting a proper child of the first block should
// go normally
return this;
}
else
{
return c;
}
}
y += elementBitmaps[i].Height - BlockStackView.NotchHeight;
}
return this;
}
示例8: DropRegions
public IEnumerable<DropRegion> DropRegions(Point origin)
{
if (elements.Count == 0)
{
yield break;
}
else
{
bool connectAbove = false, connectBelow = false;
IStackableBlockView first = (IStackableBlockView)elements[0];
IStackableBlockView last = (IStackableBlockView)elements.Last();
connectAbove = first.EffectiveAttribute()!= BlockAttributes.Hat;
connectBelow = last.EffectiveAttribute()!= BlockAttributes.Cap;
if(connectAbove)
yield return new DropRegion(DropType.Above, new Rectangle(origin.Offseted(0, -2), new Size(_cached.Width, 5)), this);
int y = origin.Y + elementBitmaps[0].Height - BlockStackView.NotchHeight;
for (int i = 1; i < elements.Count; ++i)
{
yield return new DropRegion(DropType.Between,
new Rectangle(origin.X, y - 2, elementBitmaps[i].Width, 5),
this,
i);
y += elementBitmaps[i].Height - BlockStackView.NotchHeight;
}
if(connectBelow)
yield return new DropRegion(DropType.Below, new Rectangle(origin.Offseted(0, _cached.Height - 2), new Size(_cached.Width, 5)), this);
foreach (DropRegion r in ChildDropRegions(origin))
yield return r;
}
}