当前位置: 首页>>代码示例>>C#>>正文


C# Point.Offseted方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:andyhebear,项目名称:kitsune,代码行数:12,代码来源:BlockStackView.cs

示例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);
     }
 }
开发者ID:andyhebear,项目名称:kitsune,代码行数:21,代码来源:ViewExtensions.cs

示例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));
 }
开发者ID:andyhebear,项目名称:kitsune,代码行数:6,代码来源:BlockImgParts.cs

示例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();
            }
        }
开发者ID:andyhebear,项目名称:kitsune,代码行数:95,代码来源:BlockController.cs

示例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;
        }
开发者ID:andyhebear,项目名称:kitsune,代码行数:25,代码来源:CBlockView.cs

示例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++;
            }
        }
开发者ID:andyhebear,项目名称:kitsune,代码行数:32,代码来源:CBlockView.cs

示例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;
        }
开发者ID:andyhebear,项目名称:kitsune,代码行数:28,代码来源:BlockStackView.cs

示例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;
            }
        }
开发者ID:andyhebear,项目名称:kitsune,代码行数:36,代码来源:BlockStackView.cs


注:本文中的Point.Offseted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。