/// <summary>
        /// Generate the time line general stuff (lines, axis, line annotation and so on..)
        /// </summary>
        /// <returns></returns>
        public void GenerateTimelineTemplate()
        {
            // Generate Axis
            model.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Minimum  = -20,
                Maximum  = 80
                           //IsAxisVisible = false
            });

            model.Axes.Add(new LinearAxis
            {
                Position           = AxisPosition.Left,
                Minimum            = -10,
                Maximum            = 10,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot
                                     //IsAxisVisible = false
            });


            var la = new LineAnnotation {
                Type = LineAnnotationType.Vertical, X = 4
            };

            la.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                la.StrokeThickness *= 5;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            la.MouseMove += (s, e) =>
            {
                la.X = la.InverseTransform(e.Position).X;
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            la.MouseUp += (s, e) =>
            {
                la.StrokeThickness /= 5;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(la);
        }
Exemplo n.º 2
0
        private void SetUpTimePicker(bool reset)
        {
            if (reset)
            {
                timePickerAnnotation                 = new LineAnnotation();
                timePickerAnnotation.Type            = LineAnnotationType.Vertical;
                timePickerAnnotation.Selectable      = true;
                timePickerAnnotation.TextOrientation = AnnotationTextOrientation.Horizontal;
                timePickerAnnotation.Layer           = AnnotationLayer.AboveSeries;
                timePickerAnnotation.TextMargin      = 20;
                timePickerAnnotation.TextPadding     = 10;
                timePickerAnnotation.X               = DateTimeAxis.ToDouble(DateTime.Now);
            }

            _timePickerDownHandler = (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }
                timePickerAnnotation.StrokeThickness = 5;
                timePickerAnnotation.Text            = DateTimeAxis.ToDateTime(timePickerAnnotation.X).ToString(timePickerDateTimeFormat);
                PlotModel.RefreshPlot(false);
                e.Handled = true;
            };
            _timePickerMoveHandler = (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }
                timePickerAnnotation.X    = timePickerAnnotation.InverseTransform(e.Position).X;
                timePickerAnnotation.Text = DateTimeAxis.ToDateTime(timePickerAnnotation.X).ToString(timePickerDateTimeFormat);
                PlotModel.RefreshPlot(false);
                e.Handled = true;
            };
            _timePickerUpHandler = (s, e) =>
            {
                timePickerAnnotation.StrokeThickness = 1;
                timePickerAnnotation.Text            = "";
                PlotModel.RefreshPlot(false);
                e.Handled = true;
            };

            timePickerAnnotation.MouseDown += _timePickerDownHandler;
            timePickerAnnotation.MouseMove += _timePickerMoveHandler;
            timePickerAnnotation.MouseUp   += _timePickerUpHandler;
        }
Exemplo n.º 3
0
        public static PlotModel LineAnnotation()
        {
            var model = new PlotModel {
                Title = "LineAnnotation", Subtitle = "Click and drag the annotation line."
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 80
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10
            });
            var la = new LineAnnotation {
                Type = LineAnnotationType.Vertical, X = 4
            };

            la.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                la.StrokeThickness *= 5;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            la.MouseMove += (s, e) =>
            {
                la.X = la.InverseTransform(e.Position).X;
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            la.MouseUp += (s, e) =>
            {
                la.StrokeThickness /= 5;
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            model.Annotations.Add(la);
            return(model);
        }
Exemplo n.º 4
0
        private void InitializeChromatogramPlot()
        {
            chromatogram = new PlotModel();

            chromatogram.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, AbsoluteMinimum = 0
            });
            chromatogram.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, AbsoluteMinimum = 0, AbsoluteMaximum = TotalTime
            });
            chromatogram.Axes[x].MajorGridlineStyle = LineStyle.Solid;
            chromatogram.Axes[y].MajorGridlineStyle = LineStyle.Solid;
            //chromatogram.Axes[y].IsZoomEnabled = false;

            var currentScanLine = new LineAnnotation()
            {
                Type  = LineAnnotationType.Vertical,
                X     = 0,
                Color = OxyColors.Black
            };

            var mouseLocationLine = new LineAnnotation()
            {
                Type  = LineAnnotationType.Vertical,
                X     = 0,
                Color = OxyColors.DimGray
            };

            var chroSeries = new AreaSeries();

            chroSeries.Color = Colors.ColorBrewer8ClassSet2(255).Last();

            for (int i = 0; i < ChromatogramData.PositionsArray[0].Length; i++)
            {
                chroSeries.Points.Add(new DataPoint(ChromatogramData.PositionsArray[0][i], ChromatogramData.IntensitiesArray[0][i]));
            }

            chromatogram.Series.Add(chroSeries);

            double max = (from i in ChromatogramData.IntensitiesArray[0] select i).Max() * 1.5;

            if (max <= 0)
            {
                max = 1000;
            }

            chromatogram.Axes[y].AbsoluteMaximum = max;
            chromatogram.Axes[y].Maximum         = chromatogram.Axes[y].AbsoluteMaximum;
            chromatogram.Axes[y].MajorStep       = chromatogram.Axes[y].Maximum / 3;
            chromatogram.Axes[y].StringFormat    = "0.00E00";

            chromatogram.Axes[y].TransformChanged += (object sender, EventArgs e) =>
            {
                chromatogram.Axes[y].MajorStep = (chromatogram.Axes[y].ActualMaximum - chromatogram.Axes[y].ActualMinimum) / 3;
            };

            plotViewChromatogram.MouseEnter += (s, e) =>
            {
                plotViewChromatogram.Cursor = Cursors.Cross;
            };

            chromatogram.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    double rt = chromatogram.Axes[x].InverseTransform(e.Position.X, e.Position.Y, chromatogram.Axes[y]).X;

                    scanNumber.Text = RawData.ScanNumberFromRetentionTime(rt).ToString();

                    currentScanLine.X = RawData.RetentionTimeFromScanNumber(Convert.ToInt32(scanNumber.Text));

                    e.Handled = true;
                    chromatogram.InvalidatePlot(false);
                }
            };

            chromatogram.MouseMove += (s, e) =>
            {
                try
                {
                    mouseLocationLine.X = currentScanLine.InverseTransform(e.Position).X;
                }
                catch (Exception)
                {
                    //do nothing
                }

                e.Handled = false;
                chromatogram.InvalidatePlot(false);
            };


            chromatogram.MouseUp += (s, e) =>
            {
                plotViewChromatogram.Cursor = Cursors.Cross;
                chromatogram.InvalidatePlot(true);
                e.Handled = false;
            };

            chromatogram.MouseLeave += (s, e) =>
            {
                mouseLocationLine.X = 0;

                chromatogram.InvalidatePlot(false);
                e.Handled = true;
            };

            chromatogram.Annotations.Add(currentScanLine);
            chromatogram.Annotations.Add(mouseLocationLine);

            currentScanLine.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                plotViewChromatogram.Cursor = Cursors.SizeWE;
                chromatogram.InvalidatePlot(false);
                e.Handled = true;
            };

            currentScanLine.MouseMove += (s, e) =>
            {
                double rt = currentScanLine.InverseTransform(e.Position).X;

                currentScanLine.X   = rt;
                mouseLocationLine.X = rt;

                scanNumber.Text = RawData.ScanNumberFromRetentionTime(rt).ToString();

                chromatogram.InvalidatePlot(false);
                e.Handled = true;
            };

            currentScanLine.MouseUp += (s, e) =>
            {
                plotViewChromatogram.Cursor = Cursors.Cross;
                e.Handled = true;
            };


            chromatogram.InvalidatePlot(true);
        }
        public static PlotModel LineAnnotation()
        {
            var model = new PlotModel("LineAnnotation", "Click and drag the annotation line.");
            model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 80));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
            var la = new LineAnnotation { Type = LineAnnotationType.Vertical, X = 4 };
            la.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }

                    la.StrokeThickness *= 5;
                    model.RefreshPlot(false);
                    e.Handled = true;
                };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            la.MouseMove += (s, e) =>
                {
                    la.X = la.InverseTransform(e.Position).X;
                    model.RefreshPlot(false);
                    e.Handled = true;
                };
            la.MouseUp += (s, e) =>
                {
                    la.StrokeThickness /= 5;
                    model.RefreshPlot(false);
                    e.Handled = true;
                };
            model.Annotations.Add(la);
            return model;
        }
Exemplo n.º 6
0
        private void MakeAnalogSignalsGraphic(List <List <List <string> > > analogSignals, List <DateTime> dateTimes)
        {
            this.Invoke((MethodInvoker) delegate
            {
                plotAnalogSignals = new OxyPlot.WindowsForms.Plot {
                    Model = new PlotModel(), Dock = DockStyle.Fill
                };
                panel1.Controls.Clear();
                plotAnalogSignals.Model.PlotType = PlotType.XY;
                int oc = comboBoxOC.SelectedIndex;

                //Legend
                //Axis
                plotAnalogSignals.Model.Axes.Clear();
                var xAxis = new DateTimeAxis(AxisPosition.Bottom, dateTimes[0], dateTimes[dateTimes.Count - 1], null, null, DateTimeIntervalType.Auto)
                {
                    MajorGridlineStyle = LineStyle.Solid,
                    MinorGridlineStyle = LineStyle.Dot,
                    //Title = "Дата",
                    StringFormat  = "dd-MM-yyyy HH:mm:ss",
                    FontSize      = 10,
                    IsZoomEnabled = true,
                    MajorStep     = 1.0 / 24 / 60 / 2,
                    MinorStep     = 1.0 / 24 / 60 / 12,
                    Minimum       = DateTimeAxis.ToDouble(dateTimes[0]),
                    Maximum       = DateTimeAxis.ToDouble(dateTimes[dateTimes.Count - 1])
                };
                plotAnalogSignals.Model.Axes.Add(xAxis);
                var yAxis = new LinearAxis(AxisPosition.Left, 0)
                {
                    MajorGridlineStyle = LineStyle.Solid,
                    MinorGridlineStyle = LineStyle.Dot,
                    Title   = "%",
                    Minimum = -100,
                    Maximum = 100
                };
                plotAnalogSignals.Model.Axes.Add(yAxis);
                plotAnalogSignals.Model.Axes[0].AxisChanged += new EventHandler <AxisChangedEventArgs>(xAxis_AxisChanged);
                //annotations
                lineAnnotationVertical = new LineAnnotation {
                    Type = LineAnnotationType.Vertical, Color = OxyColors.Brown, Layer = AnnotationLayer.BelowSeries
                };
                lineAnnotationVertical.X          = DateTimeAxis.ToDouble(dateTimes[1]);
                lineAnnotationVertical.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationVertical.StrokeThickness *= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                        if (_plotsSynchronized == 1)
                        {
                            for (int i = 0; i < _checkedIOIndexes.Count; i++)
                            {
                                lineAnnotationsIO[i].StrokeThickness *= 3;
                                plotIOSignals[i].Model.InvalidatePlot(false);
                            }
                        }
                    }
                };
                lineAnnotationVertical.MouseMove += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationVertical.X = lineAnnotationVertical.InverseTransform(e.Position).X;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                        if (_plotsSynchronized == 1)
                        {
                            for (int i = 0; i < _checkedIOIndexes.Count; i++)
                            {
                                lineAnnotationsIO[i].X = lineAnnotationVertical.X;
                                plotIOSignals[i].Model.InvalidatePlot(false);
                            }
                        }
                    }
                };
                lineAnnotationVertical.MouseUp += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationVertical.StrokeThickness /= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                        if (_plotsSynchronized == 1)
                        {
                            for (int i = 0; i < _checkedIOIndexes.Count; i++)
                            {
                                lineAnnotationsIO[i].StrokeThickness /= 3;
                                plotIOSignals[i].Model.InvalidatePlot(false);
                            }
                        }
                    }
                };
                lineAnnotationHorizontal = new LineAnnotation {
                    Type = LineAnnotationType.Horizontal, Color = OxyColors.Brown, Layer = AnnotationLayer.BelowSeries
                };
                lineAnnotationHorizontal.Y          = 90;
                lineAnnotationHorizontal.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationHorizontal.StrokeThickness *= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                    }
                };
                lineAnnotationHorizontal.MouseMove += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationHorizontal.Y = lineAnnotationHorizontal.InverseTransform(e.Position).Y;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                    }
                };
                lineAnnotationHorizontal.MouseUp += (s, e) =>
                {
                    if (_isMarkersActive == 1)
                    {
                        lineAnnotationHorizontal.StrokeThickness /= 3;
                        plotAnalogSignals.Model.InvalidatePlot(false);
                        e.Handled = true;
                    }
                };
                plotAnalogSignals.Model.Annotations.Add(lineAnnotationVertical);
                plotAnalogSignals.Model.Annotations.Add(lineAnnotationHorizontal);
                // Create Line series
                var s1 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Blue, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Blue, MarkerFill = OxyColors.Blue, MarkerSize = 2
                };
                var s2 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Magenta, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Magenta, MarkerFill = OxyColors.Magenta, MarkerSize = 2
                };
                var s3 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Green, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Green, MarkerFill = OxyColors.Green, MarkerSize = 2
                };
                var s4 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.IndianRed, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.IndianRed, MarkerFill = OxyColors.IndianRed, MarkerSize = 2
                };
                var s5 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.DarkOrange, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.DarkOrange, MarkerFill = OxyColors.DarkOrange, MarkerSize = 2
                };
                var s6 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Yellow, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Yellow, MarkerFill = OxyColors.Yellow, MarkerSize = 2
                };
                var s7 = new LineSeries {
                    StrokeThickness = 1, Color = OxyColors.Red, MarkerType = MarkerType.Circle, MarkerStroke = OxyColors.Red, MarkerFill = OxyColors.Red, MarkerSize = 2
                };
                for (int i = 0; i < dateTimes.Count; i++)
                {
                    s1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][0][i]) / ((_mineConfig.MainViewConfig.Distance.Value + 10) / 100)));
                    s2.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][1][i]) / ((_mineConfig.MainViewConfig.Distance.Value + 10) / 100)));
                    s3.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][2][i]) / (_mineConfig.MainViewConfig.MaxSpeed.Value / 100)));
                    s4.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][3][i]) / (_maxSpeedUp / 100)));
                    s5.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][4][i]) / (_mineConfig.MainViewConfig.MaxTokAnchor.Value / 100)));
                    s6.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][5][i]) / (_mineConfig.MainViewConfig.MaxTokExcitation.Value / 100)));
                    s7.Points.Add(new DataPoint(DateTimeAxis.ToDouble(dateTimes[i]), Convert.ToDouble(analogSignals[oc][6][i]) / (_mineConfig.MainViewConfig.MaxSpeed.Value / 100)));
                }
                //Series
                plotAnalogSignals.Model.Series.Add(s1);
                plotAnalogSignals.Model.Series.Add(s2);
                plotAnalogSignals.Model.Series.Add(s3);
                plotAnalogSignals.Model.Series.Add(s4);
                plotAnalogSignals.Model.Series.Add(s5);
                plotAnalogSignals.Model.Series.Add(s6);
                plotAnalogSignals.Model.Series.Add(s7);
                int j = 0;
                foreach (ListViewItem item in listViewAnalogSignals.Items)
                {
                    plotAnalogSignals.Model.Series[j].IsVisible = listViewAnalogSignals.CheckedItems.Contains(item);
                    j++;
                }
                plotAnalogSignals.InvalidatePlot(true);
                panel1.Controls.Add(plotAnalogSignals);
            });
        }