/// <summary>
 /// Find the objects in the image.
 /// </summary>
 /// <param name="image">The image to search for objects</param>
 /// <param name="filter">The filter with color</param>
 /// <param name="g">The Graphics to draw the rectangles</param>
 /// <param name="analyser">The ImageAnalyser to analysis the image</param>
 private void FindObjectsOfImage(Image image, ColorFilter filter, List<Rectangle> blocksFace, Graphics g, ImageAnalyser analyser)
 {
     Pen p = new Pen(filter.BorderColor, 3.0F);
     foreach (Rectangle item in analyser.GetObjectsCoordinates(image, filter))
     {
         VisualCubeBlock newFacelet = new VisualCubeBlock();
         newFacelet.Color = ColorTranslate.getFaceColorByColor(p.Color);
         Rectangle coord = new Rectangle();
         if (HasParentBlock(blocksFace, item, out coord))
         {
             newFacelet.Rectangle = coord;
             this.CurrentFace.AddBlock(newFacelet.Clone(), true);
             g.DrawRectangle(p, coord);
         }
         newFacelet.Dispose();
     }
 }
 private void btnBuildDefaultCube_Click(object sender, EventArgs e)
 {
     Array facesArray = Enum.GetValues(typeof(CubeFaceType));
     Array squaresArray = Enum.GetValues(typeof(CubeFaceletType));
     CubeFaceColor[] colors = new CubeFaceColor[] { CubeFaceColor.R, CubeFaceColor.O, CubeFaceColor.B, CubeFaceColor.G, CubeFaceColor.W, CubeFaceColor.Y };
     for (int i = 0; i < facesArray.Length; i++)
     {
         VisualCubeFace face = new VisualCubeFace();
         face.FaceType = (CubeFaceType)facesArray.GetValue(i);
         foreach (CubeFaceletType item in squaresArray)
         {
             VisualCubeBlock block = new VisualCubeBlock();
             block.Square = item;
             block.Color = colors[i];
             face.AddBlock(block.Clone(), false);
             block.Dispose();
         }
         this.CurrentCube.AddFace(face.Clone());
         face.Dispose();
     }
     picbCubeDiagram.Invalidate();
 }