protected override void RenderClientContent(DrawBoard d, UpdateArea updateArea)
        {
            //1. save canvas origin, (don't forget to restore this)
            int enter_canvas_x = d.OriginX;
            int enter_canvas_y = d.OriginY;

            //d.FillRectangle(Color.FromArgb(100, Color.Yellow),
            //    _approxRectBounds.Left,
            //    _approxRectBounds.Top,
            //    _approxRectBounds.Width,
            //    _approxRectBounds.Height);

            foreach (CustomRenderBox renderE in _controlPoints)
            {
                int x = renderE.X;
                int y = renderE.Y;

                //2. set canvas origin
                d.SetCanvasOrigin(enter_canvas_x + x, enter_canvas_y + y);
                //3. offset update area (see opposite direction)
                updateArea.Offset(-x, -y);
                //4.
                RenderElement.Render(renderE, d, updateArea);
                //5. restore only update area back
                updateArea.Offset(x, y);
            }
            //restore enter canvas x, y
            d.SetCanvasOrigin(enter_canvas_x, enter_canvas_y);

            ////lets draw lines that link  control points
            int j = _controlPoints.Count;

            float strokeW     = d.StrokeWidth;
            Color strokeColor = d.StrokeColor;

            d.StrokeWidth = 2;
            d.StrokeColor = Color.Black;


            for (int i = 1; i < j; ++i)
            {
                CustomRenderBox b_0 = _controlPoints[i - 1];
                CustomRenderBox b_1 = _controlPoints[i];
                d.DrawLine(b_0.X, b_0.Y, b_1.X, b_1.Y);
            }
            {
                CustomRenderBox b_0 = _controlPoints[j - 1];
                CustomRenderBox b_1 = _controlPoints[0];
                d.DrawLine(b_0.X, b_0.Y, b_1.X, b_1.Y);
            }
            //and the last one
            d.StrokeColor = strokeColor;
            d.StrokeWidth = strokeW;
        }
示例#2
0
        public static void DrawChildContent(HitTestHint hitTestHint, IEnumerable <RenderElement> drawingIter, DrawBoard d, UpdateArea updateArea)
        {
            int enter_canvas_x = d.OriginX;
            int enter_canvas_y = d.OriginY;

            switch (hitTestHint)
            {
            default:
            {
                foreach (RenderElement child in drawingIter)
                {
                    if (child.IntersectsWith(updateArea) ||
                        !child.NeedClipArea)
                    {
                        //if the child not need clip
                        //its children (if exist) may intersect
                        int x = child.X;
                        int y = child.Y;

                        d.SetCanvasOrigin(enter_canvas_x + x, enter_canvas_y + y);
                        updateArea.Offset(-x, -y);
                        RenderElement.Render(child, d, updateArea);
                        updateArea.Offset(x, y);
                    }
                }

                //restore
                d.SetCanvasOrigin(enter_canvas_x, enter_canvas_y);
            }
            break;

            case HitTestHint.HorizontalRowNonOverlap:
            {
                bool found = false;
                foreach (RenderElement child in drawingIter)
                {
                    if (child.IntersectsWith(updateArea))
                    {
                        found = true;
                        //if the child not need clip
                        //its children (if exist) may intersect
                        int x = child.X;
                        int y = child.Y;

                        d.SetCanvasOrigin(enter_canvas_x + x, enter_canvas_y + y);
                        updateArea.Offset(-x, -y);
                        RenderElement.Render(child, d, updateArea);
                        updateArea.Offset(x, y);
                    }
                    else if (found)
                    {
                        break;
                    }
                }

                //restore
                d.SetCanvasOrigin(enter_canvas_x, enter_canvas_y);
            }
            break;

            case HitTestHint.VerticalColumnNonOverlap:
            {
                bool found = false;
                foreach (RenderElement child in drawingIter)
                {
                    if (child.IntersectsWith(updateArea))
                    {
                        found = true;
                        //if the child not need clip
                        //its children (if exist) may intersect
                        int x = child.X;
                        int y = child.Y;

                        d.SetCanvasOrigin(enter_canvas_x + x, enter_canvas_y + y);
                        updateArea.Offset(-x, -y);
                        RenderElement.Render(child, d, updateArea);
                        updateArea.Offset(x, y);
                    }
                    else if (found)
                    {
                        break;
                    }
                }
                d.SetCanvasOrigin(enter_canvas_x, enter_canvas_y);
            }
            break;
            }
        }