示例#1
0
 override protected void OnPress(IntCoordinate c)
 {
     _x          = c.X;
     _y          = c.Y;
     _rectangle  = SliceData.FindRectangle(c);
     _slice      = _rectangle.CreateHorizontalSlice(_y);
     _horizontal = true;
     Preview.Renderer.Function = Gdk.Function.Equiv;
     _slice.Draw(Preview.Renderer);
 }
示例#2
0
        override protected void OnMove(IntCoordinate c)
        {
            var coordinate = (_horizontal) ? new IntCoordinate(c.X, _y)
        : new IntCoordinate(_x, c.Y);
            var rectangle = SliceData.FindRectangle(coordinate);

            bool rectangleChanged = rectangle != _endRectangle;

            _endRectangle = rectangle;

            bool horizontal         = Math.Abs(c.X - _x) > Math.Abs(c.Y - _y);
            bool orientationChanged = horizontal != _horizontal;

            _horizontal = horizontal;

            if (orientationChanged || rectangleChanged)
            {
                _slice.Draw(Preview.Renderer);
                if (_horizontal)
                {
                    if (rectangle.X1 <= _rectangle.X1)
                    {
                        _slice = new HorizontalSlice(rectangle.Left,
                                                     _rectangle.Right, _y);
                    }
                    else
                    {
                        _slice = new HorizontalSlice(_rectangle.Left,
                                                     rectangle.Right, _y);
                    }
                }
                else
                {
                    if (rectangle.Y1 <= _rectangle.Y1)
                    {
                        _slice = new VerticalSlice(rectangle.Top,
                                                   _rectangle.Bottom, _x);
                    }
                    else
                    {
                        _slice = new VerticalSlice(_rectangle.Top,
                                                   rectangle.Bottom, _x);
                    }
                }
                _slice.Draw(Preview.Renderer);
            }
        }