/// <summary> /// Sets delegate according to checkboxes /// </summary> void createDelegate() { _draw -= drawLegend; _draw -= drawAxes; _draw -= drawGrid; _draw -= drawValues; if (checkBox3.Checked) { _draw += drawLegend; } _draw += drawValues; if (checkBox1.Checked) { _draw += drawGrid; } if (checkBox2.Checked) { _draw += drawAxes; } }
public Graph() { InitializeComponent(); _bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); _graph = Graphics.FromImage(_bitmap); _drawable.Clear(); _draw += drawValues; _legendBrushes = new SolidBrush[_colorsCount]; _legendPens = new Pen[_colorsCount]; pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; for (int i = 0; i < _colorsCount; i++) { _legendBrushes[i] = new SolidBrush(_legendColors[i]); _legendPens[i] = new Pen(_legendColors[i]); } }
public void draw(bool force) { lock (_accessChannelsLock) { if (_channels.Count == 0 || _channels[0].values.Count < 2) { return; } } if (force || !DrawThread.IsAlive) { if (DrawThread != null) { DrawThread.Abort(); try { DrawThread.Join(); } catch (Exception ex) { } DrawThread = null; } else { return; } DrawThread = new Thread(new ThreadStart(() => { try { _draw(); } catch (Exception ex) { } })); } else { return; } _draw -= Refresher; _draw += Refresher; limit = _channels[0].values.Count; //clear graphics, update status lock (_accessGraphicsLock) { _bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); _graph = Graphics.FromImage(_bitmap); _bitmapHeight = _bitmap.Height; _bitmapWidth = _bitmap.Width; _graph.Clear(Color.White); _graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; statusLabel.Text = "Updating"; } _scaleNeeded = true; DrawThread.Start(); }