コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: NTIA/p528-gui
        public MainWindow()
        {
            InitializeComponent();

            PlotModel = new PlotModel()
            {
                Title = "P.528 Prediction Results"
            };

            // configure x-axis
            _xAxis                    = new LinearAxis();
            _xAxis.Title              = "Distance (km)";
            _xAxis.Minimum            = Constants.XAXIS_MIN_DEFAULT;;
            _xAxis.Maximum            = Constants.XAXIS_MAX_DEFAULT__KM;
            _xAxis.MajorGridlineStyle = OxyPlot.LineStyle.Dot;
            _xAxis.Position           = AxisPosition.Bottom;
            _xAxis.AxisChanged       += XAxis_Changed;

            // configure y-axis
            _yAxis       = new LinearAxis();
            _yAxis.Title = "Basic Transmission Loss (dB)";
            _yAxis.MajorGridlineStyle = OxyPlot.LineStyle.Dot;
            _yAxis.Position           = AxisPosition.Left;
            _yAxis.StartPosition      = 1;
            _yAxis.EndPosition        = 0;
            _yAxis.Minimum            = Constants.YAXIS_MIN_DEFAULT;
            _yAxis.Maximum            = Constants.YAXIS_MAX_DEFAULT;

            // add axis' to plot
            PlotModel.Axes.Add(_xAxis);
            PlotModel.Axes.Add(_yAxis);

            // enable data binding
            DataContext = this;

            tb_ConsistencyWarning.Text     = Messages.ModelConsistencyWarning;
            tb_Terminal1HeightWarning.Text = Messages.Terminal1HeightWarining;
            tb_Terminal2HeightWarning.Text = Messages.Terminal2HeightWarining;

            SetUnits();

            Render = RenderSingleCurve;

            InitializeLineSeries();

            _isWorkingBinding        = new Binding("IsWorking");
            _isWorkingBinding.Source = this;
            _isWorkingBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            _isWorkingBinding.Converter           = new BooleanInverterConverter();

            // set up the background worker for P528 data generation
            _worker         = new BackgroundWorker();
            _worker.DoWork += Worker_RunP528;
            _worker.WorkerReportsProgress      = true;
            _worker.ProgressChanged           += Worker_ProgressChanged;
            _worker.WorkerSupportsCancellation = true;
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            tb_ConsistencyWarning.Text = Messages.ModelConsistencyWarning;
            tb_FrequencyWarning.Text   = Messages.LowFrequencyWarning;

            SetUnits();

            Render = RenderSingleCurve;
        }
コード例 #3
0
        private void Mi_PlotMode_MultipleLowHeights_Click(object sender, RoutedEventArgs e)
        {
            Render = RenderMultipleLowHeights;

            mi_PlotMode_SingleCurve.IsChecked             = false;
            mi_PlotMode_MultipleLowHeights.IsChecked      = true;
            mi_PlotMode_MultipleHighHeights.IsChecked     = false;
            mi_PlotMode_MultipleTimePercentages.IsChecked = false;

            grid_Controls.Children.Clear();
            grid_Controls.Children.Add(new MultipleLowHeightsInputsControl()
            {
                Units = _units
            });
            PlotData.Clear();
            mi_View.Visibility       = Visibility.Collapsed;
            mi_ModeOfProp.Visibility = Visibility.Visible;
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: NTIA/p528-gui
        /// <summary>
        /// Controls the application mode with respect to the type of plot generated
        /// </summary>
        void Command_PlotMode(object sender, ExecutedRoutedEventArgs e)
        {
            // grab the command parameter
            var plotMode = (PlotMode)e.Parameter;

            // set the appropriate menu check
            foreach (MenuItem mi in mi_Mode.Items)
            {
                mi.IsChecked = (PlotMode)mi.CommandParameter == plotMode;
            }

            // if the background worker is busy, cancel its job
            if (_worker.IsBusy)
            {
                _worker.CancelAsync();
            }

            // reset the UI
            grid_InputControls.Children.Clear();
            PlotModel.Series.Clear();
            plot.InvalidatePlot();

            UserControl userControl = null;

            // set the application with the correct UI elements and configuration
            switch (plotMode)
            {
            case PlotMode.Single:
                Render = RenderSingleCurve;
                Export = CsvExport_SingleCurveInit;

                userControl = new SingleCurveInputsControl();

                IsModeOfPropEnabled = true;
                IsModeOfPropChecked = true;
                break;

            case PlotMode.MultipleLowTerminals:
                Render = RenderMultipleLowHeights;
                Export = CsvExport_MultipleLowTerminals;

                userControl = new MultipleLowHeightsInputsControl();

                IsModeOfPropEnabled = false;
                IsModeOfPropChecked = false;
                break;

            case PlotMode.MultipleHighTerminals:
                Render = RenderMultipleHighHeights;
                Export = CsvExport_MultipleHighTerminals;

                userControl = new MultipleHighHeightsInputsControl();

                IsModeOfPropEnabled = false;
                IsModeOfPropChecked = false;
                break;

            case PlotMode.MultipleTimes:
                Render = RenderMultipleTimes;
                Export = CsvExport_MultipleTimePercentages;

                userControl = new MultipleTimeInputsControl();

                IsModeOfPropEnabled = false;
                IsModeOfPropChecked = false;
                break;
            }

            grid_InputControls.Children.Add(userControl);

            // define binding for input validation errors
            Binding inputErrorBinding = new Binding("ErrorCnt");

            inputErrorBinding.Source = userControl;
            inputErrorBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            inputErrorBinding.Converter           = new IntegerToBooleanConverter();

            // define multibinding for Render button to both input validation and background worker status
            MultiBinding multiBinding = new MultiBinding();

            multiBinding.Bindings.Add(inputErrorBinding);
            multiBinding.Bindings.Add(_isWorkingBinding);
            multiBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            multiBinding.Converter           = new MultipleBooleanAndConverter();

            // set bindings
            BindingOperations.SetBinding(userControl, IsEnabledProperty, _isWorkingBinding);
            BindingOperations.SetBinding(btn_Render, IsEnabledProperty, multiBinding);

            // force update the view
            PlotModel.Series.Clear();
            plot.InvalidatePlot();
            GlobalState.Units = GlobalState.Units;
        }