private async Task PlotViewModel_ClosedAsync(object sender, ViewModelClosedEventArgs e) { PlotViewModel pvm = e.ViewModel as PlotViewModel; if (pvm == null) { return; } Plots.Remove(pvm.PlotModel); }
/// <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); } }
private void OpenConfiguration(string path) { using (var fileStream = File.Open(path, FileMode.Open)) { var configuration = new SerializationConfiguration { Culture = new System.Globalization.CultureInfo("en-US") }; WindowModel = MainWindowModel.Load(fileStream, SerializationMode.Xml, configuration); } //open the plots foreach (PlotModel pm in Plots) { var viewModel = new PlotViewModel(pm); viewModel.ClosedAsync += PlotViewModel_ClosedAsync; ServiceLocator.Default.ResolveType <IUIVisualizerService>().Show(viewModel); } SaveConfigPath = path; this.ClearIsDirtyOnAllChilds(); this.IsDirty = false; ViewModelCommandManager.InvalidateCommands(true); LogTo.Info("Loaded Plot configuration from: {0}", SaveConfigPath); }