public Puzzle(int pscale,Graphics pg,int pmargin,int pwidth,int pheight)
 {
     g = pg;
       scale = pscale;
       blackPen = new Pen(Color.Black);
       whitePen = new Pen(Color.White);
       bluePen = new Pen(Color.Blue);
       greenPen = new Pen(Color.Green);
       width = pwidth;
       height = pheight;
       margin = pmargin;
       lenth = Math.Min(width, height);
       lenth /= scale;
       Cells = new Cell[scale, scale];
       for(int i=0;i<scale ;i++)
       {
       for (int j = 0; j < scale; j++)
           Cells[i, j] = new Cell(i, j,this,g);
       }
       for (int i = 0; i < scale;i++ )
       {
      for (int j = 0; j < scale; j++)
          Cells[i, j].setNeighbours();
       }
 }
 /// <summary>
 /// 设置起点
 /// </summary>
 /// <param name="c"></param>
 public void SetStart(Cell c)
 {
     if (this.Start != null)
       Start.Start = false;
       Start = c;
       Start.Start = true;
 }
 /// <summary>
 /// 设置终点
 /// </summary>
 /// <param name="c"></param>
 public void SetEnd(Cell c)
 {
     if (this.End != null)
       End.End = false;
       End = c;
       End.End = true;
 }
Exemplo n.º 4
0
 /// <summary>
 /// 在(相邻的)两个格子之间取消画线。
 /// </summary>
 /// <param name="cell"></param>
 public void UnConnect2(Cell cell)
 {
     g.DrawLine(whitePen, this.CenterX, this.CenterY, cell.CenterX, cell.CenterY);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 在(相邻的)两个格子之间画线。
 /// </summary>
 /// <param name="cell"></param>
 public void Connect2(Cell cell)
 {
     g.DrawLine(bluePen, this.CenterX, this.CenterY, cell.CenterX, cell.CenterY);
 }
 private void Form1_MouseDown(object sender, MouseEventArgs e)
 {
     CurrentMouseCell = p.CheckMouse(e.X, e.Y);
 }
Exemplo n.º 7
0
 public Node(Cell pcell)
 {
     cell = pcell;
        Children = new List<Node>();
 }