private ContextMenu CreateMenu() { ContextMenu menu = new ContextMenu(); MenuItem stackedAxesMenuItem = new MenuItem("Stacked Axes"); stackedAxes = new UserOption("stackedAxes", true, stackedAxesMenuItem, settings); stackedAxes.Changed += (sender, e) => { UpdateAxesPosition(); InvalidatePlot(); }; menu.MenuItems.Add(stackedAxesMenuItem); MenuItem axisLabelsMenuItem = new MenuItem("Axis Labels"); axisLabels = new UserOption("axisLabels", true, axisLabelsMenuItem, settings); axisLabels.Changed += (sender, e) => { model.PlotMargins = ((UserOption)sender).Value ? new OxyThickness(double.NaN) : new OxyThickness(0); }; menu.MenuItems.Add(axisLabelsMenuItem); MenuItem timeWindow = new MenuItem("Time Window"); MenuItem[] timeWindowMenuItems = { new MenuItem("Auto", (s, e) => { timeAxis.Zoom(0, double.NaN); InvalidatePlot(); }), new MenuItem("5 min", (s, e) => { timeAxis.Zoom(0, 5 * 60); InvalidatePlot(); }), new MenuItem("10 min", (s, e) => { timeAxis.Zoom(0, 10 * 60); InvalidatePlot(); }), new MenuItem("20 min", (s, e) => { timeAxis.Zoom(0, 20 * 60); InvalidatePlot(); }), new MenuItem("30 min", (s, e) => { timeAxis.Zoom(0, 30 * 60); InvalidatePlot(); }), new MenuItem("45 min", (s, e) => { timeAxis.Zoom(0, 45 * 60); InvalidatePlot(); }), new MenuItem("1 h", (s, e) => { timeAxis.Zoom(0, 60 * 60); InvalidatePlot(); }), new MenuItem("1.5 h", (s, e) => { timeAxis.Zoom(0, 1.5 * 60 * 60); InvalidatePlot(); }), new MenuItem("2 h", (s, e) => { timeAxis.Zoom(0, 2 * 60 * 60); InvalidatePlot(); }), new MenuItem("3 h", (s, e) => { timeAxis.Zoom(0, 3 * 60 * 60); InvalidatePlot(); }), new MenuItem("6 h", (s, e) => { timeAxis.Zoom(0, 6 * 60 * 60); InvalidatePlot(); }), new MenuItem("12 h", (s, e) => { timeAxis.Zoom(0, 12 * 60 * 60); InvalidatePlot(); }), new MenuItem("24 h", (s, e) => { timeAxis.Zoom(0, 24 * 60 * 60); InvalidatePlot(); }) }; foreach (MenuItem mi in timeWindowMenuItems) { timeWindow.MenuItems.Add(mi); } menu.MenuItems.Add(timeWindow); return(menu); }
private ContextMenu CreateMenu() { ContextMenu menu = new ContextMenu(); MenuItem stackedAxesMenuItem = new MenuItem("堆叠轴"); stackedAxes = new UserOption("stackedAxes", true, stackedAxesMenuItem, settings); stackedAxes.Changed += (sender, e) => { UpdateAxesPosition(); InvalidatePlot(); }; menu.MenuItems.Add(stackedAxesMenuItem); MenuItem timeWindow = new MenuItem("时间窗"); MenuItem[] timeWindowMenuItems = { new MenuItem("Auto", (s, e) => { timeAxis.Zoom(0, double.NaN); InvalidatePlot(); }), new MenuItem("5 分钟", (s, e) => { timeAxis.Zoom(0, 5 * 60); InvalidatePlot(); }), new MenuItem("10 分钟", (s, e) => { timeAxis.Zoom(0, 10 * 60); InvalidatePlot(); }), new MenuItem("20 分钟", (s, e) => { timeAxis.Zoom(0, 20 * 60); InvalidatePlot(); }), new MenuItem("30 分钟", (s, e) => { timeAxis.Zoom(0, 30 * 60); InvalidatePlot(); }), new MenuItem("45 分钟", (s, e) => { timeAxis.Zoom(0, 45 * 60); InvalidatePlot(); }), new MenuItem("1 小时", (s, e) => { timeAxis.Zoom(0, 60 * 60); InvalidatePlot(); }), new MenuItem("1.5 小时", (s, e) => { timeAxis.Zoom(0, 1.5 * 60 * 60); InvalidatePlot(); }), new MenuItem("2 小时", (s, e) => { timeAxis.Zoom(0, 2 * 60 * 60); InvalidatePlot(); }), new MenuItem("3 小时", (s, e) => { timeAxis.Zoom(0, 3 * 60 * 60); InvalidatePlot(); }), new MenuItem("6 小时", (s, e) => { timeAxis.Zoom(0, 6 * 60 * 60); InvalidatePlot(); }), new MenuItem("12 小时", (s, e) => { timeAxis.Zoom(0, 12 * 60 * 60); InvalidatePlot(); }), new MenuItem("24 小时", (s, e) => { timeAxis.Zoom(0, 24 * 60 * 60); InvalidatePlot(); }) }; foreach (MenuItem mi in timeWindowMenuItems) { timeWindow.MenuItems.Add(mi); } menu.MenuItems.Add(timeWindow); return(menu); }
private ContextMenuStrip CreateMenu() { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem stackedAxesMenuItem = new ToolStripMenuItem("Stacked Axes"); stackedAxes = new UserOption("stackedAxes", true, stackedAxesMenuItem, settings); stackedAxes.Changed += (sender, e) => { UpdateAxesPosition(); InvalidatePlot(); }; menu.Items.Add(stackedAxesMenuItem); ToolStripMenuItem timeWindow = new ToolStripMenuItem("Time Window"); ToolStripMenuItem[] timeWindowMenuItems = { new ToolStripMenuItem("Auto", null, (s, e) => { timeAxis.Zoom(0,double.NaN); InvalidatePlot(); }), new ToolStripMenuItem("5 min", null, (s, e) => { timeAxis.Zoom(0, 5 * 60); InvalidatePlot(); }), new ToolStripMenuItem("10 min", null, (s, e) => { timeAxis.Zoom(0,10 * 60); InvalidatePlot(); }), new ToolStripMenuItem("20 min", null, (s, e) => { timeAxis.Zoom(0,20 * 60); InvalidatePlot(); }), new ToolStripMenuItem("30 min", null, (s, e) => { timeAxis.Zoom(0,30 * 60); InvalidatePlot(); }), new ToolStripMenuItem("45 min", null, (s, e) => { timeAxis.Zoom(0,45 * 60); InvalidatePlot(); }), new ToolStripMenuItem("1 h", null, (s, e) => { timeAxis.Zoom(0,60 * 60); InvalidatePlot(); }), new ToolStripMenuItem("1.5 h", null, (s, e) => { timeAxis.Zoom(0,1.5 * 60 * 60); InvalidatePlot(); }), new ToolStripMenuItem("2 h", null, (s, e) => { timeAxis.Zoom(0,2 * 60 * 60); InvalidatePlot(); }), new ToolStripMenuItem("3 h", null, (s, e) => { timeAxis.Zoom(0,3 * 60 * 60); InvalidatePlot(); }), new ToolStripMenuItem("6 h", null, (s, e) => { timeAxis.Zoom(0,6 * 60 * 60); InvalidatePlot(); }), new ToolStripMenuItem("12 h", null, (s, e) => { timeAxis.Zoom(0,12 * 60 * 60); InvalidatePlot(); }), new ToolStripMenuItem("24 h", null, (s, e) => { timeAxis.Zoom(0,24 * 60 * 60); InvalidatePlot(); }) }; foreach (ToolStripMenuItem mi in timeWindowMenuItems) { timeWindow.DropDownItems.Add(mi); } menu.Items.Add(timeWindow); return(menu); }
private PlotModel CreatePlotModel() { _timeAxis.Position = AxisPosition.Bottom; _timeAxis.MajorGridlineStyle = LineStyle.Solid; _timeAxis.MajorGridlineThickness = 1; _timeAxis.MajorGridlineColor = OxyColor.FromRgb(192, 192, 192); _timeAxis.MinorGridlineStyle = LineStyle.Solid; _timeAxis.MinorGridlineThickness = 1; _timeAxis.MinorGridlineColor = OxyColor.FromRgb(232, 232, 232); _timeAxis.StartPosition = 1; _timeAxis.EndPosition = 0; _timeAxis.MinimumPadding = 0; _timeAxis.MaximumPadding = 0; _timeAxis.AbsoluteMinimum = 0; _timeAxis.Minimum = 0; _timeAxis.AbsoluteMaximum = 24 * 60 * 60; _timeAxis.Zoom( _settings.GetValue("plotPanel.MinTimeSpan", 0.0f), _settings.GetValue("plotPanel.MaxTimeSpan", 10.0f * 60)); _timeAxis.StringFormat = "h:mm"; var units = new Dictionary <SensorType, string> { { SensorType.Voltage, "V" }, { SensorType.Clock, "MHz" }, { SensorType.Temperature, "°C" }, { SensorType.Load, "%" }, { SensorType.Fan, "RPM" }, { SensorType.Flow, "L/h" }, { SensorType.Control, "%" }, { SensorType.Level, "%" }, { SensorType.Factor, "1" }, { SensorType.Power, "W" }, { SensorType.Data, "GB" }, { SensorType.Frequency, "Hz" } }; foreach (SensorType type in Enum.GetValues(typeof(SensorType))) { string typeName = type.ToString(); var axis = new LinearAxis { Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1, MajorGridlineColor = _timeAxis.MajorGridlineColor, MinorGridlineStyle = LineStyle.Solid, MinorGridlineThickness = 1, MinorGridlineColor = _timeAxis.MinorGridlineColor, AxislineStyle = LineStyle.Solid, Title = typeName, Key = typeName, }; var annotation = new LineAnnotation { Type = LineAnnotationType.Horizontal, ClipByXAxis = false, ClipByYAxis = false, LineStyle = LineStyle.Solid, Color = OxyColors.Black, YAxisKey = typeName, StrokeThickness = 2, }; axis.AxisChanged += (sender, args) => annotation.Y = axis.ActualMinimum; axis.TransformChanged += (sender, args) => annotation.Y = axis.ActualMinimum; axis.Zoom(_settings.GetValue("plotPanel.Min" + axis.Key, float.NaN), _settings.GetValue("plotPanel.Max" + axis.Key, float.NaN)); if (units.ContainsKey(type)) { axis.Unit = units[type]; } _axes.Add(type, axis); _annotations.Add(type, annotation); } var model = new ScaledPlotModel(_dpiXScale, _dpiYScale); model.Axes.Add(_timeAxis); foreach (LinearAxis axis in _axes.Values) { model.Axes.Add(axis); } model.IsLegendVisible = false; return(model); }