ContainsPoint() публичный Метод

public ContainsPoint ( RectangleInt rectangle ) : RegionOverlap
rectangle RectangleInt
Результат RegionOverlap
Пример #1
0
        protected override void OnMouseDown(Document document, ToolMouseEventArgs e)
        {
            var pos = e.Point;

            // Don't do anything if we're outside the canvas
            if (pos.X < 0 || pos.X >= document.ImageSize.Width)
            {
                return;
            }
            if (pos.Y < 0 || pos.Y >= document.ImageSize.Height)
            {
                return;
            }

            base.OnMouseDown(document, e);

            using (var currentRegion = new Cairo.Region(document.GetSelectedBounds(true).ToCairoRectangleInt())) {
                // See if the mouse click is valid
                if (!currentRegion.ContainsPoint(pos.X, pos.Y) && LimitToSelection)
                {
                    return;
                }

                var surface       = document.Layers.CurrentUserLayer.Surface;
                var stencilBuffer = new BitMask(surface.Width, surface.Height);
                var tol           = (int)(Tolerance * Tolerance * 256);

                Rectangle boundingBox;

                if (IsContinguousMode)
                {
                    CairoExtensions.FillStencilFromPoint(surface, stencilBuffer, pos, tol, out boundingBox, currentRegion, LimitToSelection);
                }
                else
                {
                    CairoExtensions.FillStencilByColor(surface, stencilBuffer, surface.GetColorBgraUnchecked(pos.X, pos.Y), tol, out boundingBox, currentRegion, LimitToSelection);
                }

                OnFillRegionComputed(document, stencilBuffer);

                // If a derived tool is only going to use the stencil,
                // don't waste time building the polygon set
                if (CalculatePolygonSet)
                {
                    var polygonSet = stencilBuffer.CreatePolygonSet(boundingBox, 0, 0);
                    OnFillRegionComputed(document, polygonSet);
                }
            }
        }