private void ToolStripComboBoxITEM_SelectedIndexChanged(object sender, EventArgs e) { // update with selected snapsots items' SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory; var xaxis = SSCat != null ? SSCat.XAxis : null; var yaxis = SSCat != null ? SSCat.YAxis : null; if (SSCat != null) { SSCat.Selected = toolStripComboBoxITEM.SelectedItem as SnapshotItem; } SnapshotItem sItem = SSCat != null?SSCat.GetSelectedItem() : null; if (sItem != null) { toolStripComboBoxX.ComboBox.DataSource = sItem.GetHeaderTitles(); toolStripComboBoxX.SelectedItem = xaxis; toolStripComboBoxY.ComboBox.DataSource = sItem.GetHeaderTitles(); toolStripComboBoxY.SelectedItem = yaxis; } else { toolStripComboBoxX.ComboBox.DataSource = null; toolStripComboBoxX.SelectedItem = null; toolStripComboBoxY.ComboBox.DataSource = null; toolStripComboBoxY.SelectedItem = null; } _getPlotData(); chartViewer1.Redraw(); }
private void DeleteCategoryToolStripMenuItem_Click(object sender, EventArgs e) { // delete category Snapshot.Delete(SSCat); toolStripComboBoxCATEGORY.SelectedItem = null; SSCat = null; _refresh(); }
private void _drawPoints(Graphics graphics, List <PointF> pts, SnapshotCategory sc, Brush br) { graphics.TranslateTransform(-sc.PointSize / 2, -sc.PointSize / 2); float sz = sc.PointSize; foreach (var point in pts) { graphics.FillRectangle(br, point.X, point.Y, sz, sz); } graphics.ResetTransform(); }
private void ToolStripComboBoxCATEGORY_SelectedIndexChanged(object sender, EventArgs e) { SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory; var xaxis = SSCat != null ? SSCat.XAxis : null; var yaxis = SSCat != null ? SSCat.YAxis : null; var fullName = (SSCat != null && SSCat.Selected != null) ? SSCat.Selected.FullName : null; toolStripComboBoxITEM.ComboBox.DisplayMember = "Name"; toolStripComboBoxITEM.ComboBox.ValueMember = "FullName"; toolStripComboBoxITEM.ComboBox.DataSource = (SSCat != null) ? SSCat.Collection : null; toolStripComboBoxITEM.SelectedItem = (SSCat != null) ? SSCat.GetSnapshotItem(fullName) : null; toolStripComboBoxX.SelectedItem = xaxis; toolStripComboBoxY.SelectedItem = yaxis; _getPlotData(); chartViewer1.Redraw(); }
private void UpdateSnapshots() { var filter = Filter; var allSnapshots = _snapshotManager.Snapshots; HasSnapshots = allSnapshots.Any(); var finalItems = new List <SnapshotCategory>(); var groupedSnapshots = allSnapshots.OrderBy(x => x.Category).GroupBy(x => x.Category); foreach (var category in groupedSnapshots) { var snapshotCategory = new SnapshotCategory { Category = category.Key }; var categoryItems = category.Select(x => x); if (!string.IsNullOrWhiteSpace(filter)) { categoryItems = category.Where(x => x.Title.ContainsIgnoreCase(filter)); } snapshotCategory.Snapshots.AddRange(categoryItems.OrderByDescending(x => x.Created)); if (snapshotCategory.Snapshots.Count > 0) { finalItems.Add(snapshotCategory); } } Log.Debug($"Updating available snapshots using snapshot manager with scope '{_snapshotManager?.Scope}', '{finalItems.Count}' snapshot categories available"); SnapshotCategories = finalItems; }
private void _getPlotData() { SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory; if (SSCat != null) { SnapshotItem sItem = SSCat.GetSelectedItem(); xTitle = toolStripComboBoxX.SelectedItem as string; yTitle = toolStripComboBoxY.SelectedItem as string; dxList = sItem != null?sItem.GetDoubleArray(xTitle) : null; dyList = sItem != null?sItem.GetDoubleArray(yTitle) : null; SSCat.XAxis = xTitle; SSCat.YAxis = yTitle; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; if (dxList != null) { foreach (var v in dxList) { if (chkNum(v)) { minX = Math.Min(minX, v); maxX = Math.Max(maxX, v); } } } if (dyList != null) { foreach (var v in dyList) { if (chkNum(v)) { minY = Math.Min(minY, v); maxY = Math.Max(maxY, v); } } } if (minX == double.MaxValue) { minX = 0; maxX = 1; } if (minY == double.MaxValue) { minY = 0; maxY = 1; } if (minX == maxX) { minX -= 1; maxX += 1; } else { var d = (maxX - minX) / 10; minX -= d; maxX += d; } if (minY == maxY) { minY -= 1; maxY += 1; } { var d = (maxY - minY) / 10; minY -= d; maxY += d; } chartViewer1.XAuto = false; chartViewer1.YAuto = false; if (SSCat.XAxisAuto) { if (SSCat.XPolarity == Polarity.Normal) { chartViewer1.XLeft = minX; chartViewer1.XRight = maxX; } else { chartViewer1.XLeft = maxX; chartViewer1.XRight = minX; } } else { if (SSCat.XPolarity == Polarity.Normal) { chartViewer1.XLeft = SSCat.XAxisMin; chartViewer1.XRight = SSCat.XAxisMax; } else { chartViewer1.XLeft = SSCat.XAxisMax; chartViewer1.XRight = SSCat.XAxisMin; } } if (SSCat.YAxisAuto) { if (SSCat.YPolarity == Polarity.Normal) { chartViewer1.YTop = maxY; chartViewer1.YBottom = minY; } else { chartViewer1.YTop = minY; chartViewer1.YBottom = maxY; } } else { if (SSCat.YPolarity == Polarity.Normal) { chartViewer1.YTop = SSCat.YAxisMax; chartViewer1.YBottom = SSCat.YAxisMin; } else { chartViewer1.YTop = SSCat.YAxisMin; chartViewer1.YBottom = SSCat.YAxisMax; } } chartViewer1.XAxisTitle = xTitle; chartViewer1.YAxisTitle = yTitle; chartViewer1.Title = SSCat.Name + " : " + (sItem != null ? sItem.FormattedTime : "*"); chartViewer1.Title2 = yTitle + " vs " + xTitle; SSCat.WriteSettings(); } }