예제 #1
0
 void RedrawGrid()
 {
     if (img != null)
     {
         img.Dispose();
     }
     img = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     using (Graphics g = Graphics.FromImage(img))
     {
         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
         using (Brush back = new SolidBrush(BackColor))
             g.FillRectangle(back, 0, 0, Width, Height);
         if (grid != null)
         {
             PaintContext pc = new PaintContext(grid, g);
             grid.Paint(pc, SolutionColor, WallColor, CellColor);
         }
     }
     Invalidate();
 }
예제 #2
0
 public void DrawWalls(PaintContext pc, Pen pe)
 {
     foreach (KeyValuePair <Pt, int> kvp in _walls)
     {
         Pt   pt0 = kvp.Key;
         int  w   = kvp.Value;
         Pt[] vs  = Vertices(pt0);
         Pt[] ns  = Neighbours(pt0);
         for (int i = 0; i < vs.Length; ++i)
         {
             Pt pt1 = ns[i];
             //if (pt0.CompareTo(pt1) >= 0)
             if (GetBit(w, i))
             {
                 Pt v0 = vs[i];
                 Pt v1 = vs[(i + 1) % vs.Length];
                 pc.Graphics.DrawLine(pe, pc.Point(v0), pc.Point(v1));
             }
         }
     }
 }
예제 #3
0
 //public void FillCell(PaintContext pc, Pt pt)
 //{
 //    FillCell(pc, pt, GetCell(pt) == 0 ? Brushes.Red : Brushes.Green);
 //}
 public void FillCell(PaintContext pc, Pt pt, Color cellColor)
 {
     using (Brush br = new SolidBrush(cellColor))
         using (Pen pe = new Pen(cellColor))
             FillCell(pc, pt, pe, br);
 }