示例#1
0
        public PlotViewModel(Models.PlotModel plotModel)
        {
            _uiVisualizerService = ServiceLocator.Default.ResolveType <IUIVisualizerService>();
            _logService          = ServiceLocator.Default.ResolveType <ILoggingService>();
            _kserv       = ServiceLocator.Default.ResolveType <IKmotionService>();
            _plotService = ServiceLocator.Default.ResolveType <IAvailablePlotsService>();
            Messages     = new List <string[]>(1024);
            _dataLog     = new List <string[]>(20000);

            OxyPlotModel = new OxyPlot.PlotModel();
            PlotModel    = plotModel;

            StartStopCommand = new TaskCommand <bool>(OnStartStopCommandExecuteAsync, OnStartStopCommandCanExecute);
            Clear            = new TaskCommand(OnClearExecute);
            ZeroCommand      = new TaskCommand(OnZeroCommandExecuteAsync, OnZeroCommandCanExecute);
            SaveCommand      = new TaskCommand(OnSaveCommandExecuteAsync, OnSaveCommandCanExecute);
            LoadCommand      = new TaskCommand(OnLoadCommandExecuteAsync, OnLoadCommandCanExecute);
            ConfigCommand    = new TaskCommand(OnConfigCommandExecuteAsync, OnConfigCommandCanExecute);
            ExportPngCommand = new TaskCommand(OnExportPngCommandExecute);

            // this instance is created on the UI thread
            //_context = SynchronizationContext.Current;

            _userInterfaceDispatcher = Dispatcher.CurrentDispatcher;
            _cancelSource            = new CancellationTokenSource();

            //syncing plots
            _plotService.AvailablePlots.Add(OxyPlotModel);

            //messages strings or hex dump of memory
            FromHex = false;
        }
示例#2
0
 /// <summary>
 /// Method to invoke when the NewPlotCommand command is executed.
 /// </summary>
 private async Task OnNewPlotCommandExecuteAsync()
 {
     try
     {
         var plotmodel = new Models.PlotModel();
         Plots.Add(plotmodel);
         var viewModel = new PlotViewModel(plotmodel);
         viewModel.ClosedAsync += PlotViewModel_ClosedAsync;
         ServiceLocator.Default.ResolveType <IUIVisualizerService>().Show(viewModel);
     }
     catch (Exception ex)
     {
         string errmsg = string.Format("Error creating new plot: {0}", ex.Message);
         LogTo.Error(errmsg);
         await Shared.Utility.ShowErrorMsgAsync(this, errmsg);
     }
 }