protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (_serScrolling != eScrolling.None) { this.Refresh(); _serScrolling = eScrolling.None; //_serScrollingAxis = -1; } if (Legend.Enabled) { Legend.X_Percent = Legend.X_Percent > 1 ? 1 : Legend.X_Percent; Legend.X_Percent = Legend.X_Percent < 0 ? 0 : Legend.X_Percent; Legend.Y_Percent = Legend.Y_Percent > 1 ? 1 : Legend.Y_Percent; Legend.Y_Percent = Legend.Y_Percent < 0 ? 0 : Legend.Y_Percent; float legend_x = _pointBottomLeft.X + (_pointBottomRight.X - _pointBottomLeft.X) * Legend.X_Percent; float legend_y = _plotUpperPoint.Y + (_pointBottomLeft.Y - _plotUpperPoint.Y) * Legend.Y_Percent; for (int i = 0; i < Series.Length; i++) { if (Series[i].Data == null) continue; float stringwidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(Series[i].Name, Legend.Font).Width; if (stringwidth + legend_x + _pointBottomRight_RightOffset > this.Width) legend_x = this.Width - _pointBottomRight_RightOffset - stringwidth; if (legend_x < _pointBottomLeft_LeftOffset) legend_x = _pointBottomLeft_LeftOffset; if (e.X > legend_x - 24 && e.X < legend_x - 12 && e.Y > legend_y + 2 + i * Legend.ItemDistance && e.Y < legend_y + 2 + i * Legend.ItemDistance + 12) { ColorDialog cd = new ColorDialog(); if (cd.ShowDialog() == DialogResult.OK) { Series[i].Color = cd.Color; Refresh(); } } else { if (e.X > legend_x && e.X < legend_x + Series[i].Name.Length * 14 && e.Y > legend_y + i * Legend.ItemDistance && e.Y < legend_y + 2 + i * Legend.ItemDistance + Legend.Font.Height) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { Series[i].Type++; if ((int)Series[i].Type >= Enum.GetNames(typeof(cSeries.eType)).Length) Series[i].Type = (cSeries.eType)0; Refresh(); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { Series[i].Type--; if ((int)Series[i].Type <= 0) Series[i].Type = (cSeries.eType)(Enum.GetNames(typeof(cSeries.eType)).Length - 1); Refresh(); } } } } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); // Check scrollbar. if (_serScale[_serScrollingAxis] != -1) for (int i = 0; i < xAxis.Length; i++) if (e.Location.Y > _pointBottomLeft.Y - 8 + i * 24 && e.Location.Y < _pointBottomLeft.Y + 8 + i * 24) { _serScrollingPrevMouseX = e.Location.X; _serScrolling = eScrolling.Horizontal; _serScrollingAxis = i; break; } else { _serScrollingPrevMouseX = e.Location.X; _serScrolling = eScrolling.HorizonatlReversed; //_serScrollingAxis = 0; } }