public Form1() { InitializeComponent(); chart = new YGraph(pictureBox1, log); stamp = new double[maxPoints]; temp = new double[maxPoints]; rawW = new double[maxPoints]; avgTemp = new double[maxPoints]; deltaTemp = new double[maxPoints]; pred = new double[maxPoints]; YAxis s0 = chart.addYAxis(); s0.showGrid = true; YAxis s1 = chart.addYAxis(); s1.position = YAxis.HrzPosition.RIGHT; chart.navigator.enabled = true; chart.navigator.relativeheight = 10; chart.xAxis.showGrid = true; chart.legendPanel.enabled = true; chart.dataTracker.enabled = true; chart.navigator.yAxisHandling = Navigator.YAxisHandling.INHERIT; openFileDialog1.ShowDialog(); }
public GraphForm(StartForm parent, XmlNode initData) { InitializeComponent(); seriesProperties = new List <ChartSerie>(); _cartesianChart = new YGraph(rendererCanvas, LogManager.Log); _cartesianChart.getCaptureParameters = constants.getCaptureParametersCallback; _cartesianChart.DisableRedraw(); noDataSourcepanel = _cartesianChart.addMessagePanel(); noDataSourcepanel.text = "No data source configured\n" + " 1 - Make sure you have a Yoctopuce sensor connected.\n" + " 2 - Do a right-click on this window.\n" + " 3 - Choose \"Configure this graph\" to bring up the properties editor.\n" + " 4 - Choose a data source\n"; offLineSourcesPanel = _cartesianChart.addMessagePanel(); offLineSourcesPanel.bgColor = System.Drawing.Color.FromArgb(192, 255, 192, 192); offLineSourcesPanel.borderColor = System.Drawing.Color.DarkRed; offLineSourcesPanel.font.color = System.Drawing.Color.DarkRed; offLineSourcesPanel.panelHrzAlign = MessagePanel.HorizontalAlignPos.RIGHT; offLineSourcesPanel.panelVrtAlign = MessagePanel.VerticalAlignPos.TOP; captureRunningPanel = _cartesianChart.addMessagePanel(); captureRunningPanel.bgColor = System.Drawing.Color.FromArgb(240, 200, 255, 193);; captureRunningPanel.borderColor = System.Drawing.Color.DarkGreen; captureRunningPanel.font.color = System.Drawing.Color.DarkGreen; captureRunningPanel.panelHrzAlign = MessagePanel.HorizontalAlignPos.LEFT; captureRunningPanel.panelVrtAlign = MessagePanel.VerticalAlignPos.TOP; _cartesianChart.setPatchAnnotationCallback(AnnotationCallback); foreach (var p in typeof(YaxisDescription).GetProperties()) { if (p.Name.StartsWith("zones")) { ZoneCountPerYaxis++; } } foreach (var p in typeof(XaxisDescription).GetProperties()) { if (p.Name.StartsWith("markers")) { MarkerCountPerXaxis++; } } foreach (var p in typeof(GraphFormProperties).GetProperties()) { string name = p.Name; if (name.StartsWith("Graph_series")) { SeriesCount++; } } if (YAxisCount == 0) { AnnotationPanelCount = 0; foreach (var p in typeof(GraphFormProperties).GetProperties()) { string name = p.Name; if (name.StartsWith("Graph_yAxes")) { YAxisCount++; } if (name.StartsWith("Graph_annotationPanel")) { AnnotationPanelCount++; } } } for (int i = 0; i < YAxisCount; i++) { YAxis axis = _cartesianChart.addYAxis(); for (int j = 0; j < ZoneCountPerYaxis; j++) { axis.AddZone(); } } markers = new List <Marker>(); for (int i = 0; i < MarkerCountPerXaxis; i++) { Marker m = _cartesianChart.xAxis.AddMarker(); m.xposition = TimeConverter.ToUnixTime(DateTime.UtcNow) + i * 60; markers.Add(m); } for (int i = 0; i < AnnotationPanelCount; i++) { _cartesianChart.addAnnotationPanel(); } prop = new GraphFormProperties(initData, this); for (int i = 0; i < SeriesCount; i++) { seriesProperties.Add((ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null)); _cartesianChart.addSerie(); } _cartesianChart.yAxes[0].visible = true; offlineMessages = new String[SeriesCount]; showOffline = new bool[SeriesCount]; manager = new formManager(this, parent, initData, "graph", prop); mainForm = parent; initDataNode = initData; prop.ApplyAllProperties(this); if (!manager.initForm()) { Rectangle s = Screen.FromControl(this).Bounds; this.Location = new Point((s.Width - this.Width) >> 1, (s.Height - this.Height) >> 1); } YDataRenderer.minMaxCheckDisabled = true; try { prop.ApplyAllProperties(_cartesianChart); } catch (TargetInvocationException e) { LogManager.Log("Graph initialization raised an exception (" + e.InnerException.Message + ")"); } YDataRenderer.minMaxCheckDisabled = false; manager.configureContextMenu(this, contextMenuStrip1, showConfiguration, switchConfiguration, capture); _cartesianChart.proportionnalValueChangeCallback = manager.proportionalValuechanged; for (int i = 0; i < SeriesCount; i++) { ChartSerie s = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null); s.Init(this, i); if (s.DataSource_source != null) { SourceChanged(i, s.DataSource_source); } } for (int i = 0; i < YAxisCount; i++) { _cartesianChart.yAxes[i].AxisChanged = AxisParamtersChangedAutomatically; _cartesianChart.yAxes[i].AllowAutoShow = true; } _cartesianChart.resetRefrenceSize(); _cartesianChart.AllowPrintScreenCapture = true; _cartesianChart.proportionnalValueChangeCallback = manager.proportionalValuechanged; _cartesianChart.setMarkerCaptureCallbacks(MarkedCaptureStarted, MarkedCaptureStopped); _cartesianChart.AllowRedraw(); deleteMarkeOption = new ToolStripMenuItem("Disable all markers", Resources.disable_marker, disableAllMarkers); contextMenuStrip1.Items.Insert(2, deleteMarkeOption); markersMenu = new ToolStripMenuItem("Place markers", Resources.add_marker); contextMenuStrip1.Items.Insert(2, markersMenu); Pen pIcon = new Pen(Color.DarkRed); SolidBrush bIcon = new SolidBrush(Color.LightYellow); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; Font font1 = new Font("Arial", 9, FontStyle.Regular, GraphicsUnit.Pixel); for (int i = 0; i < markers.Count; i++) { int index = i; Bitmap bm = new Bitmap(16, 16); Graphics gr = Graphics.FromImage(bm); gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; gr.FillEllipse(bIcon, new Rectangle(1, 1, 14, 14)); gr.DrawEllipse(pIcon, new Rectangle(1, 1, 14, 14)); gr.DrawString((i + 1).ToString(), font1, Brushes.Black, new Rectangle(1, 1, 16, 16), stringFormat); markersMenu.DropDownItems.Add(new ToolStripMenuItem("Place marker #" + (i + 1).ToString(), bm, (object sender, EventArgs e) => { startMarkerCapture(index); })); gr.Dispose(); } pIcon.Dispose(); bIcon.Dispose(); markersMenu.DropDownOpening += updateMakerList; contextMenuStrip1.Items.Insert(2, new ToolStripSeparator()); contextMenuStrip1.Items.Insert(2, new ToolStripMenuItem("Clear dataloggers", Resources.cleardatalogger, clearDataLogger)); contextMenuStrip1.Items.Insert(2, new ToolStripMenuItem("Reset data view", Resources.resetdataview, resetDataView)); contextMenuStrip1.Items.Insert(2, new ToolStripSeparator()); contextMenuStrip1.Opening += ContextMenuStrip1_Opening; _cartesianChart.OnDblClick += rendererCanvas_DoubleClick; if (constants.OSX_Running) { _cartesianChart.OnRightClick += rendererCanvas_RightClick; } }
public void MonitorPanelDrawPanel() { int tabIndex = 0; SuspendLayout(); // // WarningResetMessage1 // if (MonitorMessage1 == null) { MonitorMessage1 = new System.Windows.Forms.Label(); } MonitorMessage1.Name = "MonitorMessage1"; MonitorMessage1.AutoSize = false; MonitorMessage1.TabIndex = tabIndex++; MonitorMessage1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); MonitorMessage1.Text = "Your device is gathering data at 0.1Hz, let the process run for several days to make sure that day/night temperature cycles are captured, then use this utility to analyze it and compute Temperature compensation. " + (RadioBtMonitor.Checked? " Once datalogger is loaded, you can export data at any time. ":"") + "Click on next to go back to the welcome page. You can also close this application, the capture process will still run in background."; MonitorMessage1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Controls.Add(MonitorMessage1); if (MonitorGraphContainer == null) { MonitorGraphContainer = new PictureBox(); } MonitorGraphContainer.Name = "MonitorGraphContainer"; MonitorGraphContainer.TabIndex = tabIndex++; Controls.Add(MonitorGraphContainer); // // Export button // if (ExportButton == null) { ExportButton = new Button(); } this.ExportButton.Name = "ExportButton"; this.ExportButton.AutoSize = false; this.ExportButton.Size = new Size(75, 23); this.ExportButton.TabIndex = tabIndex++; this.ExportButton.Text = "Export.."; this.ExportButton.UseVisualStyleBackColor = true; this.ExportButton.Click += ExportButton_Click; ExportButton.Enabled = false; Controls.Add(ExportButton); ResumeLayout(false); NextButton.Visible = true; NextButton.Enabled = true; PrevButton.Visible = false; PrevButton.TabIndex = tabIndex++; NextButton.TabIndex = tabIndex++; MonitorPanelResize(); MonitorGraph = new YGraph(MonitorGraphContainer, null); MonitorGraph.DisableRedraw(); YAxis wAxis = MonitorGraph.addYAxis(); wAxis.showGrid = true; wAxis.visible = true; wAxis.legend.title = "Weight (" + ChoosedWeighScale.sensor.get_unit() + ")"; wAxis.highlightZero = true; YAxis tAxis = MonitorGraph.addYAxis(); tAxis.visible = true; tAxis.legend.title = "Temperature (" + ChoosedWeighScale.tsensor.get_unit() + ")"; tAxis.position = YAxis.HrzPosition.RIGHT; MonitorGraph.navigator.enabled = true; MonitorGraph.navigator.relativeheight = 12; MonitorGraph.xAxis.showGrid = true; monitor_wData = MonitorGraph.addSerie(); monitor_wData.yAxisIndex = wAxis.index; monitor_wData.color = Color.DarkBlue; wAxis.legend.font.color = monitor_wData.color; monitor_tData = MonitorGraph.addSerie(); monitor_tData.yAxisIndex = tAxis.index; monitor_tData.color = Color.DarkRed; tAxis.legend.font.color = monitor_tData.color; progressPanel = MonitorGraph.addDataPanel(); progressPanel.horizontalPosition = DataPanel.HorizontalPosition.RIGHTBORDER; progressPanel.verticalPosition = DataPanel.VerticalPosition.TOPBORDER; progressPanel.horizontalMargin = 5; progressPanel.verticalMargin = 5; progressPanel.panelHrzAlign = DataPanel.HorizontalAlign.LEFTOF; progressPanel.panelVrtAlign = DataPanel.VerticalAlign.BELOW; progressPanel.borderColor = Color.Black; progressPanel.borderthickness = 1; progressPanel.enabled = true; MonitorGraph.AllowRedraw(); WeightData = new List <pointXY>(); TempData = new List <pointXY>(); ChoosedWeighScale.genericSensor.registerTimedReportCallback(newGenericSensorData); ChoosedWeighScale.tsensor.registerTimedReportCallback(newTempSensorData); //MonitorLoadProgress(0); ChoosedWeighScale.LoadDataLogger(MonitorLoadCompleted, MonitorLoadProgress, true); }