private void scale_ValueChanged(object sender, EventArgs e) { Draft = new Bitmap(sheet.Width, sheet.Height); builder = new Builder(Draft, pixelcoeff * Convert.ToSingle(scale.Value)); builder.Clear(); builder.BuildNet(); builder.BuildAxes(); builder.BuildSection(); builder.BuildCoordinates(); Image = Draft; if (Functions.Count != 0) { foreach (Function function in Functions) { Pen pen = new Pen(function.color, 2); pen.DashStyle = function.LineStyle; builder.DrawFunction(function); } } else { ; } }
private void toolStripButton6_Click(object sender, EventArgs e) { try { Function function = new Function(new StringBuilder(firstFunctionBox.Text), p.Color, p.DashStyle, 'x'); RPN_Box.ResetText(); foreach (string symbol in function.RPNsequence) { RPN_Box.Text += " " + symbol; } if (Functions.Contains(function) == true)//It works! { return; } else { Functions.Add(function); builder.DrawFunction(function); Image = Draft; } } catch (IndexOutOfRangeException) { MessageBox.Show("Error in syntax (1)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (NullReferenceException) { MessageBox.Show("Error in syntax (2). Perhaps you enter a wrong symbol", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (ArithmeticException) { MessageBox.Show("Function cannot exist with double argument ", "ErrorInSyntaxException", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } bool repetition = false; foreach (ListViewItem func in FunctionList.Items) { if (func.Text == firstFunctionBox.Text) { repetition = true; } } ColorFunction = new Bitmap(imageList1.ImageSize.Width, imageList1.ImageSize.Height); Graphics DrawColor = Graphics.FromImage(ColorFunction); SolidBrush color = new SolidBrush(p.Color); if (repetition != true) { DrawColor.FillRectangle(color, 0, 0, imageList1.ImageSize.Width, imageList1.ImageSize.Height); imageList1.Images.Add(ColorFunction); FunctionList.Items.Add(firstFunctionBox.Text, imageList1.Images.Count - 1); repetition = false; } }