public SoundSpeedProfileViewModel(IHRCSaveFileService saveFile) { _saveFileService = saveFile; _propertyObserver = new PropertyObserver<SoundSpeedProfileViewModel>(this) .RegisterHandler(p => p.SoundSpeedProfile, SoundSpeedProfileChanged); var axisRanges = new RangeCollection(); axisRanges.Add(new Range(0.1, 10)); DesignTimeData = new SoundSpeedProfileViewModel { FourAxisSeriesViewModel = new FourAxisSeriesViewModel { BottomAxis = { Visibility = Visibility.Visible, Label = "Sound speed (m/s)", }, LeftAxis = { Visibility = Visibility.Visible, Label = "Depth (m)", IsInverted = true, }, TopAxis = { Visibility = Visibility.Collapsed }, RightAxis = { Visibility = Visibility.Collapsed }, }, }; DesignTimeData.FourAxisSeriesViewModel.BottomAxis.DataRange = axisRanges; DesignTimeData.FourAxisSeriesViewModel.LeftAxis.DataRange = axisRanges; }
public MainWindowViewModel([NotNull] IViewAwareStatus viewAwareStatus, IMessageBoxService messageBox, IUIVisualizerService visualizer, IHRCSaveFileService saveFile) { _viewAwareStatus = viewAwareStatus; _messageBox = messageBox; _visualizer = visualizer; _saveFile = saveFile; _viewAwareStatus.ViewLoaded += () => _visualizer.ShowWindow("PSMBrowserView", new PSMBrowserViewModel(),false,(s, e) => Application.Current.Shutdown()); }
public MainViewModel(IHRCSaveFileService saveFileService, IViewAwareStatus viewAwareStatus, IMasterDatabaseService database) { ESME.Globals.SaveFileService = saveFileService; ESME.Globals.ViewAwareStatusService = viewAwareStatus; ESME.Globals.MasterDatabaseService = database; if (!Designer.IsInDesignMode) { viewAwareStatus.ViewLoaded += () => { TransmissionLossViewModel.RadialViewModel = new RadialViewModel { RadialView = ((Window)viewAwareStatus.View).FindChildren<RadialView>().First() }; TransmissionLossViewModel.SaveFileService = saveFileService; TransmissionLossViewModel.RadialViewModel.WaitToRenderText = "No Scenario Selected"; }; viewAwareStatus.ViewActivated += () => ESME.Globals.MasterDatabaseService.Refresh(); } }
public SimulationLogAnalysisMainViewModel(IViewAwareStatus viewAwareStatus, IMessageBoxService messageBox, IUIVisualizerService visualizer, IHRCSaveFileService saveFile) { _viewAwareStatus = viewAwareStatus; _messageBox = messageBox; _visualizer = visualizer; _saveFile = saveFile; _simulationStartTime = new TimeSpan(0); _simulationEndTime = new TimeSpan(0); _viewAwareStatus.ViewLoaded += () => { _dispatcher = ((Window)_viewAwareStatus.View).Dispatcher; SelectedFileName = (string)Application.Current.Properties["SelectedFileName"]; }; _propertyObserver = new PropertyObserver<SimulationLogAnalysisMainViewModel>(this) .RegisterHandler(p => p.SelectedFileName, SelectedFileNameChanged) .RegisterHandler(p => p.AreAnyPlatformsSelected, CommandManager.InvalidateRequerySuggested) .RegisterHandler(p => p.AreAnyModesSelected, CommandManager.InvalidateRequerySuggested) .RegisterHandler(p => p.AreAnySpeciesSelected, CommandManager.InvalidateRequerySuggested) .RegisterHandler(p => p.PerformOurOnlyAnalysis, CommandManager.InvalidateRequerySuggested) .RegisterHandler(p => p.StartTimeString, StartOrStopTimeStringsChanged) .RegisterHandler(p => p.StopTimeString, StartOrStopTimeStringsChanged) .RegisterHandler(p => p.AllTimes, () => { if (!AllTimes || SelectedFileName == null || !File.Exists(SelectedFileName)) return; _filterStartTime = new TimeSpan(_simulationStartTime.Ticks); _filterEndTime = new TimeSpan(_simulationEndTime.Ticks); StartTimeString = _filterStartTime.ToString(TimeSpanFormatString); StopTimeString = _filterEndTime.ToString(TimeSpanFormatString); }); AddValidationRules(new ValidationRule<SimulationLogAnalysisMainViewModel> { PropertyName = "StartTimeString", Description = "Must be a valid, non-negative time span value in the format hh:mm:ss where 00 <= hh <= 23; 00 <= mm <= 59; 00 <= ss <= 59", IsRuleValid = (target, rule) => { if (AllTimes) return true; if (string.IsNullOrEmpty(target.StartTimeString)) return false; TimeSpan timeSpan; var isOK = TimeSpan.TryParseExact(target.StartTimeString, TimeSpanFormatString, null, out timeSpan); return isOK && timeSpan.Ticks >= 0; }, }, new ValidationRule<SimulationLogAnalysisMainViewModel> { PropertyName = "StopTimeString", Description = "Must be a valid, non-negative time span value in the format hh:mm:ss where 00 <= hh <= 23; 00 <= mm <= 59; 00 <= ss <= 59", IsRuleValid = (target, rule) => { if (AllTimes) return true; if (string.IsNullOrEmpty(target.StopTimeString)) return false; TimeSpan timeSpan; var isOK = TimeSpan.TryParseExact(target.StopTimeString, TimeSpanFormatString, null, out timeSpan); return isOK && timeSpan.Ticks > 0; }, }); _startTimeValidationRule = new ValidationRule<SimulationLogAnalysisMainViewModel> { PropertyName = "StartTimeString", Description = string.Format("Must be between {0} and {1}", _simulationStartTime.ToString(TimeSpanFormatString), _filterEndTime.ToString(TimeSpanFormatString)), IsRuleValid = (target, rule) => { if (AllTimes) return true; if (_simulationStartTime.Ticks == 0 && _simulationEndTime.Ticks == 0) return true; if (string.IsNullOrEmpty(target.StartTimeString)) return false; TimeSpan timeSpan; var isOK = TimeSpan.TryParseExact(target.StartTimeString, TimeSpanFormatString, null, out timeSpan); return isOK && timeSpan >= _simulationStartTime && timeSpan < _filterEndTime; }, }; _endTimeValidationRule = new ValidationRule<SimulationLogAnalysisMainViewModel> { PropertyName = "StopTimeString", Description = string.Format("Must be between {0} and {1}", _filterStartTime.ToString(TimeSpanFormatString), _simulationEndTime.ToString(TimeSpanFormatString)), IsRuleValid = (target, rule) => { if (AllTimes) return true; if (_simulationStartTime.Ticks == 0 && _simulationEndTime.Ticks == 0) return true; if (string.IsNullOrEmpty(target.StopTimeString)) return false; TimeSpan timeSpan; var isOK = TimeSpan.TryParseExact(target.StopTimeString, TimeSpanFormatString, null, out timeSpan); return isOK && timeSpan > _filterStartTime && timeSpan <= _simulationEndTime; }, }; AddValidationRules(_startTimeValidationRule, _endTimeValidationRule); }
public MainViewModel(IViewAwareStatus viewAwareStatus, IMasterDatabaseService database, IMessageBoxService messageBox, IUIVisualizerService visualizer, IHRCSaveFileService saveFile, IHRCOpenFileService openFile, TransmissionLossCalculatorService transmissionLoss, IPluginManagerService plugins, EnvironmentalCacheService cache) { try { Mediator.Instance.Register(this); } catch (Exception ex) { Debug.WriteLine("***********\nMainViewModel: Mediator registration failed: " + ex.Message + "\n***********"); throw; } Cursor = Cursors.Arrow; ESME.Data.AppSettings.ApplicationName = App.Name; Globals.AppSettings = ESME.Data.AppSettings.Load(ESME.Data.AppSettings.AppSettingsFile); Globals.AppSettings.Save(); Globals.PluginManagerService = plugins; Globals.TransmissionLossCalculatorService = transmissionLoss; Globals.MasterDatabaseService = database; Globals.VisualizerService = visualizer; Globals.SaveFileService = saveFile; Globals.OpenFileService = openFile; Globals.EnvironmentalCacheService = cache; Globals.ViewAwareStatusService = viewAwareStatus; Globals.MessageBoxService = messageBox; MapViewModel = new MapViewModel(this); Globals.TransmissionLossCalculatorService.WorkQueue.PropertyChanged += (s, e) => { if (e.PropertyName == "Count") { TransmissionLossActivity = Globals.TransmissionLossCalculatorService.WorkQueue.Keys.Count > 0 ? string.Format("Acoustic Simulator: {0} items", Globals.TransmissionLossCalculatorService.WorkQueue.Keys.Count) : "Acoustic Simulator: idle"; // Debug.WriteLine(string.Format("TransmissionLossActivity: {0}", TransmissionLossActivity)); var isBusy = Globals.TransmissionLossCalculatorService.WorkQueue.Keys.Count > 0; IsTransmissionLossBusy = isBusy; if (!isBusy && IsSaveSampleDataRequested) { Globals.MasterDatabaseService.SaveChanges(); IsSaveSampleDataRequested = false; } } }; if (Designer.IsInDesignMode) return; Globals.ViewAwareStatusService.ViewLoaded += ViewLoaded; //_appTracker = new ApplicationTracker("UA-44329261-1", "TestWPFApp"); //_appTracker.StartSession(); //_appTracker.TrackEvent(ApplicationTrackerCategories.Command, "ApplicationStartup"); }