/// <summary> /// Initializes an instance of this class. /// </summary> /// <param name="viewModel">The viewmodel represented by this view.</param> /// <param name="builder">The Gtk# builder used to build this view.</param> /// <param name="handle">The handle of the main widget.</param> private ScopeScreenView(IScopeScreenViewModel viewModel, Builder builder, IntPtr handle) : base(handle) { _viewModel = viewModel; builder.Autoconnect(this); // === Create sub-views. === // === Register event handlers. === scopeDrawingArea.Drawn += ScopeDrawingArea_DrawnEventHandler; // Raise motion events even if no button is pressed. scopeEventBox.Events |= Gdk.EventMask.PointerMotionMask; scopeEventBox.MotionNotifyEvent += ScopeEventBox_MotionNotifyEventHandler; scopeEventBox.ButtonPressEvent += ScopeEventBox_ButtonPressEventHandler; scopeEventBox.ButtonReleaseEvent += ScopeEventBox_ButtonReleaseEventHandler; // === Create value converters. === // === Create bindings. === // === Do some additional stuff. === _scopeGraphics = new ScopeGraphics(ScopeStretchMode.Stretch, _xMinimumGraticuleUnits, _yMinimumGraticuleUnits); // Allow shrinking the drawing area completely. scopeDrawingArea.HeightRequest = 0; scopeDrawingArea.WidthRequest = 0; InitializeGraphics(); RefreshData(); }
/// <summary> /// Configures the main scope screen viewmodel. /// </summary> private void ConfigureMainScopeScreenVM(IScopeScreenViewModel scopeScreenVM, IEnumerable <SampleSequence> sampleSequences) { // === Channels configuration === var timeScaleFactor = 1; var channelVMs = new[] { new ChannelViewModel("V", new Position(0, 1), timeScaleFactor, 1, BuildChannelCaptionFromIndex(0), _channelColors[0]), new ChannelViewModel("V", new Position(0, -2), timeScaleFactor, 1, BuildChannelCaptionFromIndex(1), _channelColors[1]), }; var index = 0; channelVMs[index].MeasurementCursor1VM.Visible = true; channelVMs[index].MeasurementCursor2VM.Visible = true; channelVMs[index].MeasurementCursor1VM.Value = 2.0; channelVMs[index].MeasurementCursor2VM.Value = 3.0; // index++; // channelVMs[index].MeasurementCursor1VM.Visible = true; // channelVMs[index].MeasurementCursor2VM.Visible = true; // channelVMs[index].MeasurementCursor1VM.Value = -0.5; // channelVMs[index].MeasurementCursor2VM.Value = 0.5; scopeScreenVM.ChannelVMs = channelVMs; // === Graphbase configuration === var graphbaseVM = new GraphbaseViewModel("s", 1, _baseColor); var trigger = new LevelTrigger(LevelTriggerMode.RisingEdge, 0.5); var triggerChannelIndex = 0; graphbaseVM.TriggerVM = new LevelTriggerViewModel(trigger, channelVMs[triggerChannelIndex]); graphbaseVM.MeasurementCursor1VM.Visible = true; graphbaseVM.MeasurementCursor2VM.Visible = true; graphbaseVM.MeasurementCursor1VM.Value = 2.0; graphbaseVM.MeasurementCursor2VM.Value = 3.0; scopeScreenVM.GraphbaseVM = graphbaseVM; // === Sample Sequences === var sampleSequenceProviders = sampleSequences.Select(ss => new Func <SampleSequence>(() => ss)); var sampler = new Sampler(sampleSequenceProviders, trigger, triggerChannelIndex); scopeScreenVM.SampleSequenceProviders = sampler.SampleSequenceProviders; }
/// <summary> /// Configures the FFT scope screen viewmodel. /// </summary> private void ConfigureFFTScopeScreenVM(IScopeScreenViewModel scopeScreenVM, IEnumerable <SampleSequence> sampleSequences) { // === Channels configuration === var frequencyScaleFactor = 1; var channelVMs = new[] { new ChannelViewModel("dB?", new Position(0, 1), frequencyScaleFactor, 0.5, BuildChannelCaptionFromIndex(0), _channelColors[0]), //TODO Unit new ChannelViewModel("dB?", new Position(0, -2), frequencyScaleFactor, 0.5, BuildChannelCaptionFromIndex(1), _channelColors[1]), //TODO Unit }; var index = 0; channelVMs[index].MeasurementCursor1VM.Visible = true; channelVMs[index].MeasurementCursor2VM.Visible = true; channelVMs[index].MeasurementCursor1VM.Value = -0.5; channelVMs[index].MeasurementCursor2VM.Value = 0.5; // index++; // channelVMs[index].MeasurementCursor1VM.Visible = true; // channelVMs[index].MeasurementCursor2VM.Visible = true; // channelVMs[index].MeasurementCursor1VM.Value = -0.5; // channelVMs[index].MeasurementCursor2VM.Value = 0.5; scopeScreenVM.ChannelVMs = channelVMs; // === Graphbase configuration === var graphbaseVM = new GraphbaseViewModel("Hz", 0.2, _baseColor); graphbaseVM.MeasurementCursor1VM.Visible = true; graphbaseVM.MeasurementCursor2VM.Visible = true; graphbaseVM.MeasurementCursor1VM.Value = 2.0; graphbaseVM.MeasurementCursor2VM.Value = 3.0; scopeScreenVM.GraphbaseVM = graphbaseVM; // === Sample Sequences === var sampleSequenceProviders = sampleSequences.Select(ss => { var fftSamples = DoFourierTransform(ss); return(new Func <SampleSequence>(() => fftSamples)); }); scopeScreenVM.SampleSequenceProviders = sampleSequenceProviders; }
/// <summary> /// Creates a new instance of this class. /// </summary> /// <param name="viewModel">The viewmodel represented by the instance created.</param> public static ScopeScreenView Create(IScopeScreenViewModel viewModel) { var builder = new Builder(null, "ScopeScreenView.glade", null); return(new ScopeScreenView(viewModel, builder, builder.GetObject("mainWidget").Handle)); }