Beispiel #1
0
        InitPlotModel()
        {
            this.PlotModel                     = new PlotModel();
            this.PlotModel.Background          = OxyColors.Black;
            this.PlotModel.PlotAreaBorderColor = OxyColors.White;

            LogarithmicAxis yAxis = new LogarithmicAxis
            {
                TextColor          = OxyColors.White,
                Position           = AxisPosition.Left,
                Base               = 10,
                Maximum            = 1,
                Minimum            = 0.00001, // peakVal * 10 ^ (dB / 20)
                MajorGridlineStyle = LineStyle.Dot,
                MajorGridlineColor = OxyColors.White,
            };

            // Window of 10 seconds
            LinearAxis xAxis = new LinearAxis
            {
                TextColor          = OxyColors.White,
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Dot,
                MajorGridlineColor = OxyColors.White,
            };

            this.PlotModel.Axes.Add(yAxis);
            this.PlotModel.Axes.Add(xAxis);

            LineSeries data = new LineSeries
            {
                LineStyle       = LineStyle.Solid,
                Color           = OxyColors.Red,
                StrokeThickness = 1
            };

            this.PlotModel.Series.Add(data);

            this.PlotModel.MouseDown += (t, e) =>
            {
                double y = yAxis.InverseTransform(e.Position.Y);

                if (_soundAdjuster != null)
                {
                    _soundAdjuster.SetTargetVolume((float)y);
                }

                _pressed = true;
            };

            this.PlotModel.MouseMove += (t, e) =>
            {
                if (_pressed)
                {
                    double y = yAxis.InverseTransform(e.Position.Y);

                    if (_soundAdjuster != null)
                    {
                        _soundAdjuster.SetTargetVolume((float)y);
                    }
                }
            };

            this.PlotModel.MouseUp += (t, e) =>
            {
                _pressed = false;
            };
        }