示例#1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            Point point = e.Location;

            point.Offset(-(int)xOffset_, -(int)yOffset_);
            GoCoord coord = cb.hitTest(point, 10);

            if (coord != null)
            {
                x_print          = coord.Row;
                y_print          = coord.Col;
                cb.SelectedCoord = coord;
                int qi = cb.Layout.GetQi(coord.Row, coord.Col);
                this.Invalidate();
                //mode.o;
            }
            else
            {
                if (cb.SelectedCoord != null)
                {
                    cb.SelectedCoord = null;
                    this.Invalidate();
                }
            }
        }
示例#2
0
        public GoCoord hitTest(int x, int y, int precision = 5)
        {
            if (precision <= 0 || canvas_ == null)
            {
                return(null);
            }
            int col = x / (int)step_;
            int row = y / (int)step_;

            Point point = new Point(x, y);

            point.Offset(-(int)borderTopLeft.X, -(int)borderTopLeft.Y);
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    GoCoord coord = hitTest(point.X, point.Y, col + j, row + i, precision);
                    if (coord != null)
                    {
                        return(coord);
                    }
                }
            }
            return(null);
        }
示例#3
0
        public bool OnMouseClick(MouseEventArgs e)
        {
            if (cb_.Layout == null)
            {
                return(false);
            }
            GoCoord coord = cb_.hitTest(e.X, e.Y, 10);

            if (coord != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    cb_.Layout.SetupPoint(coord, GoPointType.BLACK);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    cb_.Layout.SetupPoint(coord, GoPointType.WHITE);
                }
            }
            return(true);
        }
示例#4
0
 private PointF GetCenter(GoCoord coord)
 {
     return(new PointF(borderTopLeft.X + coord.Col * step_, borderTopLeft.Y + coord.Row * step_));
 }
示例#5
0
 public Pieces(int row, int col, GoPointType type)
 {
     coord_ = new GoCoord(row, col);
     type_  = type;
 }
示例#6
0
 public void OnClickDian(GoCoord coord)
 {
     //layout_.SetDian(coord.Row, coord.Col, GoDianType.BLACK);
 }
示例#7
0
 public void OnSelectDian(GoCoord coord)
 {
 }