private void chartTrends_MouseDown(object sender, MouseEventArgs e) { var result = chartTrends.HitTest(e.X, e.Y); if (result.ChartElementType != ChartElementType.DataPoint) { return; } var index = result.PointIndex; var pt = result.Series.Points[index]; CursorPosition = DateTime.FromOADate(pt.XValue); var lvi = lvTrends.FindItemWithText(result.Series.Name); if (lvi != null) { lvTrends.FocusedItem = lvi; lvi.Selected = true; lvTrends.EnsureVisible(lvi.Index); _lastSelected = result.Series.Name; } // заполнение остальных значений FillCursorsData(CursorPosition); tslCursorPositionDate.Text = @"Позиция курсора: " + CursorPosition.ToString("dd.MM.yy HH:mm.ss.fff"); AddCursorLinePoints(CursorPosition); tsbZoomIn.Enabled = true; tsbZoomOut.Enabled = true; }
public void Loaded() { Data.UpdateProductTree(tvNavigator, DisplayIndex); UpdateChart(); InitTrendsList(); fileSystemWatcher1.Path = Data.HistoryFolder; _minutes = Data.Session.ReadInteger("TrendShowed" + DisplayIndex, "TimeRange", 20); tsbNextTime.Enabled = false; foreach (var dropitem in tsbTimeSelect.DropDownItems.Cast <ToolStripDropDownItem>() .Where(dropitem => dropitem.Tag != null && (string)dropitem.Tag == _minutes.ToString("0"))) { tsbTimeSelect.Text = dropitem.Text; break; } _offset = Data.Session.ReadInteger("TrendShowed" + DisplayIndex, "TimeOffset", 0); if (_offset > 0) { tsbNextTime.Enabled = true; } _cursorPosition = Data.Session.ReadDateTime("TrendShowed" + DisplayIndex, "TimePosition", DateTime.MinValue); if (_cursorPosition == DateTime.MinValue) { ClearDateCursor(); } else { tslCursorPositionDate.Text = @"Позиция курсора: " + CursorPosition.ToString("dd.MM.yy HH:mm.ss.fff"); } _zoomminutes = Data.Session.ReadInteger("TrendShowed" + DisplayIndex, "TimeZoom", _minutes); if (_zoomminutes < _minutes && _cursorPosition > DateTime.MinValue) { tsbNoZoom.Enabled = true; var dateHighRange = CursorPosition.AddMinutes(_zoomminutes); var dateLowRange = CursorPosition.AddMinutes(-_zoomminutes); UpdateChart(dateLowRange, dateHighRange); FillCursorsData(CursorPosition); tsbZoomIn.Enabled = true; tsbZoomOut.Enabled = true; } else { UpdateChart(); } }