/// <summary> /// Adds/Udates a face to the cube /// </summary> /// <param name="face">The face to be added/Udated</param> public void AddFace(VisualCubeFace face) { int foundIndex = -1; for (int i = 0; i < _faces.Count; i++) { if (_faces[i].FaceType == face.FaceType) { foundIndex = i; break; } } if (foundIndex == -1) _faces.Add(face.Clone()); else { _faces[foundIndex] = face.Clone(); } }
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(); }