Пример #1
0
        public void PushClippingRectangle(int x, int y, int width, int height)
        {
            VerifyAccess();

            if (width < 0 || height < 0)
            {
                throw new ArgumentException();
            }

            ClipRectangle rect = new ClipRectangle(_x + x, _y + y, width, height);

            if (_clippingRectangles.Count > 0)
            {
                // Intersect with the existing clip bounds
                ClipRectangle previousRect = (ClipRectangle)_clippingRectangles.Peek();
                //need to evaluate performance differences of inlining Min & Max.
                int x1 = System.Math.Max(rect.X, previousRect.X);
                int x2 = System.Math.Min(rect.X + rect.Width, previousRect.X + previousRect.Width);
                int y1 = System.Math.Max(rect.Y, previousRect.Y);
                int y2 = System.Math.Min(rect.Y + rect.Height, previousRect.Y + previousRect.Height);

                rect.X      = x1;
                rect.Y      = y1;
                rect.Width  = x2 - x1;
                rect.Height = y2 - y1;
            }

            _clippingRectangles.Push(rect);

            _bitmap.SetClippingRectangle(rect.X, rect.Y, rect.Width, rect.Height);
            EmptyClipRect = (rect.Width == 0 && rect.Height == 0);
        }
Пример #2
0
 void OnGraphicsViewTouchUp(object sender, EventArgs e)
 {
     if (ClipRectangle == RectangleF.Zero || ClipRectangle.Contains(TouchPoint))
     {
         AnimateDrawRipple();
     }
 }
Пример #3
0
        public void PopClippingRectangle()
        {
            VerifyAccess();

            int n = _clippingRectangles.Count;

            if (n > 0)
            {
                _clippingRectangles.Pop();

                ClipRectangle rect;

                if (n == 1) // in this case, at this point the stack is empty
                {
                    rect = new ClipRectangle(0, 0, _bitmap.Width, _bitmap.Height);
                }
                else
                {
                    rect = (ClipRectangle)_clippingRectangles.Peek();
                }

                _bitmap.SetClippingRectangle(rect.X, rect.Y, rect.Width, rect.Height);

                EmptyClipRect = (rect.Width == 0 && rect.Height == 0);
            }
        }
Пример #4
0
        public override bool OnPointerMove(AnnContainer sender, AnnPointerEventArgs e)
        {
            bool handled = false;

            if (TargetObject != null && HasStarted)
            {
                LeadPointD pt = ClipPoint(e.Location, ClipRectangle);

                if (!LeadPoint.Equals(pt, _end))
                {
                    _end = pt;
                    LeadPointCollection points = TargetObject.Points;

                    if (points.Count > 1)
                    {
                        if (_clickCount % 2 != 0)
                        {
                            points[points.Count - 1] = pt; // end point
                        }
                    }

                    AnnIntersectionPointObject intersectionPointObject = TargetObject as AnnIntersectionPointObject;
                    if (intersectionPointObject != null)
                    {
                        intersectionPointObject.IntersectionInsideContainer = ClipRectangle.ContainsPoint(intersectionPointObject.IntersectionPoint);
                    }

                    Working();
                }

                handled = true;
            }

            return(handled);
        }
Пример #5
0
        public void PushClippingRectangle(int x, int y, int width, int height)
        {
            base.VerifyAccess();
            if ((width < 0) || (height < 0))
            {
                throw new ArgumentException();
            }
            ClipRectangle rectangle = new ClipRectangle(this._x + x, this._y + y, width, height);

            if (this._clippingRectangles.Count > 0)
            {
                ClipRectangle rectangle2 = (ClipRectangle)this._clippingRectangles.Peek();
                int           num        = Math.Max(rectangle.X, rectangle2.X);
                int           num2       = Math.Min((int)(rectangle.X + rectangle.Width), (int)(rectangle2.X + rectangle2.Width));
                int           num3       = Math.Max(rectangle.Y, rectangle2.Y);
                int           num4       = Math.Min((int)(rectangle.Y + rectangle.Height), (int)(rectangle2.Y + rectangle2.Height));
                rectangle.X      = num;
                rectangle.Y      = num3;
                rectangle.Width  = num2 - num;
                rectangle.Height = num4 - num3;
            }
            this._clippingRectangles.Push(rectangle);
            this._bitmap.SetClippingRectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
            this.EmptyClipRect = (rectangle.Width <= 0) || (rectangle.Height <= 0);
        }
Пример #6
0
        protected override void MoveThumb(int thumbIndex, LeadPointD offset)
        {
            AnnObject  targetObject = TargetObject;
            LeadPointD point        = targetObject.Points[thumbIndex];

            targetObject.Points[thumbIndex] = ClipPoint(AnnTransformer.TranslatePoint(point, offset.X, offset.Y), ClipRectangle);

            AnnIntersectionPointObject intersectionPointObject = targetObject as AnnIntersectionPointObject;

            if (intersectionPointObject != null)
            {
                intersectionPointObject.IntersectionInsideContainer = ClipRectangle.ContainsPoint(intersectionPointObject.IntersectionPoint);
            }

            base.MoveThumb(thumbIndex, offset);
        }
        public override void Draw(ICanvas canvas, RectF dirtyRect)
        {
            if ((ClipRectangle == RectF.Zero || ClipRectangle.Contains(TouchPoint)) && RippleEffectSize > 0)
            {
                canvas.SaveState();

                if (ClipRectangle == RectF.Zero)
                    ClipRectangle = dirtyRect;

                canvas.ClipRectangle(ClipRectangle);

                canvas.FillColor = RippleColor;
                canvas.Alpha = 0.25f;
                canvas.FillCircle((float)TouchPoint.X, (float)TouchPoint.Y, RippleEffectSize);

                canvas.RestoreState();
            }
        }
Пример #8
0
 public void GetClippingRectangle(out int x, out int y, out int width, out int height)
 {
     if (_clippingRectangles.Count == 0)
     {
         x      = 0;
         y      = 0;
         width  = _bitmap.Width - _x;
         height = _bitmap.Height - _y;
     }
     else
     {
         ClipRectangle rect = (ClipRectangle)_clippingRectangles.Peek();
         x      = rect.X - _x;
         y      = rect.Y - _y;
         width  = rect.Width;
         height = rect.Height;
     }
 }
Пример #9
0
 public void GetClippingRectangle(out int x, out int y, out int width, out int height)
 {
     if (this._clippingRectangles.Count == 0)
     {
         x      = 0;
         y      = 0;
         width  = this._bitmap.Width - this._x;
         height = this._bitmap.Height - this._y;
     }
     else
     {
         ClipRectangle rectangle = (ClipRectangle)this._clippingRectangles.Peek();
         x      = rectangle.X - this._x;
         y      = rectangle.Y - this._y;
         width  = rectangle.Width;
         height = rectangle.Height;
     }
 }
Пример #10
0
        public void PopClippingRectangle()
        {
            base.VerifyAccess();
            int count = this._clippingRectangles.Count;

            if (count > 0)
            {
                ClipRectangle rectangle;
                this._clippingRectangles.Pop();
                if (count == 1)
                {
                    rectangle = new ClipRectangle(0, 0, this._bitmap.Width, this._bitmap.Height);
                }
                else
                {
                    rectangle = (ClipRectangle)this._clippingRectangles.Peek();
                }
                this._bitmap.SetClippingRectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                this.EmptyClipRect = (rectangle.Width == 0) && (rectangle.Height == 0);
            }
        }
Пример #11
0
        private void SetPixel(int x, int y, Color c)
        {
            x = (int)((float)x * Scale.X);
            y = (int)((float)y * Scale.Y);

            x += Transform.X;
            y += Transform.Y;

            if (c.A != 255)
            {
                //transparency needed
                var cn = new Color((int)Blend((uint)_canvas.GetPixel(x, y).ToHex(), (uint)c.ToHex(), (byte)c.A));


                if (ContainerFlag)
                {
                    if (Container.Intersects(x, y))
                    {
                        _canvas.SetPixel(x, y, cn);
                    }
                }
                else
                {
                    if (ClipingFlag)
                    {
                        if (ClipingIsInclude)
                        {
                            if (ClipRectangle.Intersects(x, y))
                            {
                                _canvas.SetPixel(x, y, cn);
                            }
                        }
                        else
                        {
                            if (!ClipRectangle.Intersects(x, y))
                            {
                                _canvas.SetPixel(x, y, cn);
                            }
                        }
                    }
                    else
                    {
                        _canvas.SetPixel(x, y, cn);
                    }
                }
            }
            else
            {
                if (ContainerFlag)
                {
                    if (Container.Intersects(x, y))
                    {
                        _canvas.SetPixel(x, y, c);
                    }
                }
                else
                {
                    if (ClipingFlag)
                    {
                        if (ClipingIsInclude)
                        {
                            if (ClipRectangle.Intersects(x, y))
                            {
                                _canvas.SetPixel(x, y, c);
                            }
                        }
                        else
                        {
                            if (!ClipRectangle.Intersects(x, y))
                            {
                                _canvas.SetPixel(x, y, c);
                            }
                        }
                    }
                    else
                    {
                        _canvas.SetPixel(x, y, c);
                    }
                }
            }
        }
Пример #12
0
 public void AcceptControlClipRectangle(ClipRectangle clipRectangle, PrintContext parameter)
 {
     parameter.WriteLine("Clip Rectangle: {0} - {1}", clipRectangle.FirstCorner, clipRectangle.SecondCorner);
 }
 public override void OnTouchUp(GPoint point)
 {
     if (ClipRectangle == RectF.Zero || ClipRectangle.Contains(TouchPoint))
         AnimateDrawRipple();
 }
Пример #14
0
 public virtual void AcceptControlClipRectangle(ClipRectangle clipRectangle, T parameter)
 {
     // intentionally left blank
 }
Пример #15
0
        public void PopClippingRectangle()
        {
            VerifyAccess();

            int n = _clippingRectangles.Count;
            
            if (n > 0)
            {
                _clippingRectangles.Pop();

                ClipRectangle rect;
                
                if (n == 1) // in this case, at this point the stack is empty
                {
                    rect = new ClipRectangle(0, 0, _bitmap.Width, _bitmap.Height);
                }
                else
                {
                    rect = (ClipRectangle)_clippingRectangles.Peek();
                }

                _bitmap.SetClippingRectangle(rect.X, rect.Y, rect.Width, rect.Height);
                
                EmptyClipRect = (rect.Width == 0 && rect.Height == 0);
            }
        }
Пример #16
0
        public void PushClippingRectangle(int x, int y, int width, int height)
        {
            VerifyAccess();

            if(width < 0 || height < 0)
            {
                throw new ArgumentException();
            }

            ClipRectangle rect = new ClipRectangle( _x + x, _y + y, width, height );

            if (_clippingRectangles.Count > 0)
            {
                // Intersect with the existing clip bounds
                ClipRectangle previousRect = (ClipRectangle)_clippingRectangles.Peek();
                //need to evaluate performance differences of inlining Min & Max.
                int x1 = System.Math.Max(rect.X, previousRect.X);
                int x2 = System.Math.Min(rect.X + rect.Width, previousRect.X + previousRect.Width);
                int y1 = System.Math.Max(rect.Y, previousRect.Y);
                int y2 = System.Math.Min(rect.Y + rect.Height, previousRect.Y + previousRect.Height);

                rect.X = x1;
                rect.Y = y1;
                rect.Width = x2 - x1;
                rect.Height = y2 - y1;
            }

            _clippingRectangles.Push(rect);

            _bitmap.SetClippingRectangle(rect.X, rect.Y, rect.Width, rect.Height);
            EmptyClipRect = (rect.Width <= 0 || rect.Height <= 0);
        }