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(); } } }
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); }
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); }
private PointF GetCenter(GoCoord coord) { return(new PointF(borderTopLeft.X + coord.Col * step_, borderTopLeft.Y + coord.Row * step_)); }
public Pieces(int row, int col, GoPointType type) { coord_ = new GoCoord(row, col); type_ = type; }
public void OnClickDian(GoCoord coord) { //layout_.SetDian(coord.Row, coord.Col, GoDianType.BLACK); }
public void OnSelectDian(GoCoord coord) { }