private void SierpinskiTriangleButton_Click(object sender, EventArgs e) { //Configurations of input boxes RowsUpDown.Enabled = false; DepthUpDown.Enabled = true; ColourComboBox.Enabled = false; drawSierpinskiAsPyramid = false; //regular Sierpinski Triangle foreach (Label label in dictOfLabels.Values) //Pascal's Triangle labels not needed { label.SendToBack(); } Graphics sierpinskiTriangle = Graphics.FromImage(trianglesBitmap); //graphics object to draw on bitmap sierpinskiTriangle.Clear(TrianglePictureBox.BackColor); DrawSierpinskiTriangle(sierpinskiTriangle, (int)DepthUpDown.Value, new Point(285, 12), new Point(61, 388), new Point(511, 388), new SolidBrush(ChooseColour(false)), ChoosePen()); TrianglePictureBox.Refresh(); //raise paint event of picture box sierpinskiTriangle.Dispose(); //release graphics object }
private void SierpinskiPyramidsButton_Click(object sender, EventArgs e) { //Configurations of input boxes RowsUpDown.Enabled = false; DepthUpDown.Enabled = true; ColourComboBox.Enabled = true; drawPascalAsCombinedTriangle = false; //Sierpinski Triangle as pyramids drawSierpinskiAsPyramid = true; foreach (Label label in dictOfLabels.Values) //Pascal's Triangle labels not needed { label.SendToBack(); } Graphics sierpinskiPyramid = Graphics.FromImage(trianglesBitmap); //graphics object to draw on bitmap sierpinskiPyramid.Clear(TrianglePictureBox.BackColor); //Pyramid 1 DrawSierpinskiTriangle(sierpinskiPyramid, (int)DepthUpDown.Value, new Point(390, 120), new Point(230, 350), new Point(460, 350), new SolidBrush(ChooseColour(false)), ChoosePen()); DrawSierpinskiTriangle(sierpinskiPyramid, (int)DepthUpDown.Value, new Point(390, 120), new Point(460, 350), new Point(510, 290), new SolidBrush(ChooseColour(false)), ChoosePen()); //Pyramid 2 DrawSierpinskiTriangle(sierpinskiPyramid, (int)DepthUpDown.Value, new Point(140, 70), new Point(80, 210), new Point(220, 210), new SolidBrush(ChooseColour(false)), ChoosePen()); DrawSierpinskiTriangle(sierpinskiPyramid, (int)DepthUpDown.Value, new Point(140, 70), new Point(60, 190), new Point(80, 210), new SolidBrush(ChooseColour(false)), ChoosePen()); TrianglePictureBox.Refresh(); //raise paint event of picture box sierpinskiPyramid.Dispose(); //release graphics object }
private void PascalsTriangleButton_Click(object sender, EventArgs e) { //Configurations of input boxes RowsUpDown.Enabled = true; DepthUpDown.Enabled = false; ColourComboBox.Enabled = false; drawPascalAsCombinedTriangle = false; //regular Pascal's Triangle Graphics pascalsTriangle = Graphics.FromImage(trianglesBitmap); //graphics object to draw on bitmap pascalsTriangle.Clear(TrianglePictureBox.BackColor); DrawPascalsTriangle(pascalsTriangle, new SolidBrush(ChooseColour(true)), new SolidBrush(ChooseColour(false)), ChoosePen()); TrianglePictureBox.Refresh(); //raise paint event of picture box pascalsTriangle.Dispose(); //release graphics object }