private void CloneModelSystem_Click(object sender, RoutedEventArgs e) { var selected = ModelSystemDisplay.SelectedItem as ProjectModel.ContainedModelSystemModel; if (selected != null) { StringRequest sr = new StringRequest("Cloned Model System's Name?", (newName) => { return(Session.ValidateModelSystemName(newName)); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { string error = null; if (!selected.CloneModelSystemToProject(Session, sr.Answer, ref error)) { MessageBox.Show(error, "Unable to Clone Model System", MessageBoxButton.OK, MessageBoxImage.Error); } else { Model.RefreshModelSystems(); } } } }
private void NewLinkedParameter_Clicked(object obj) { var request = new StringRequest("Name the new Linked Parameter", (s) => true); if (request.ShowDialog() == true) { string error = null; if (!LinkedParameters.NewLinkedParameter(request.Answer, ref error)) { MessageBox.Show(MainWindow.Us, error, "Failed to create new Linked Parameter", MessageBoxButton.OK, MessageBoxImage.Error); return; } SetupLinkedParameters(LinkedParameters); } }
public RunWindow(ModelSystemEditingSession session) { InitializeComponent(); Session = session; session.SessionClosed += Session_SessionClosed; var runName = "Run Name"; StringRequest req = new StringRequest("Run Name", ValidateName); if(req.ShowDialog() == true) { runName = req.Answer; StartRun(session, runName); } else { MainWindow.Us.CloseWindow(this); } }
private void CloneProject_Clicked(object obj) { StringRequest sr = new StringRequest("Cloned Project's Name?", (newName) => { return(Session.ValidateModelSystemName(newName)); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { string error = null; if (!Session.CloneProjectAs(sr.Answer, ref error)) { MessageBox.Show(error, "Unable to Save Model System", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void CreateNewModelSystem() { StringRequest sr = new StringRequest("New Model System's Name?", (newName) => { return(Session.ValidateModelSystemName(newName)); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { string error = null; if (!Session.AddModelSystem(sr.Answer, ref error)) { MessageBox.Show(error, "Unable to create New Model System", MessageBoxButton.OK, MessageBoxImage.Error); } else { Model.RefreshModelSystems(); } } }
private void SaveCurrentAsModelSystem() { var selected = ModelSystemDisplay.SelectedItem as ProjectModel.ContainedModelSystemModel; if (selected != null) { StringRequest sr = new StringRequest("Save Model System As?", (newName) => { return(Session.ValidateModelSystemName(newName)); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { string error = null; if (!selected.CloneModelSystem(Session, sr.Answer, ref error)) { MessageBox.Show(error, "Unable to Save Model System", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
private void CloneCurrentProject() { var project = Display.SelectedItem as Project; if (project != null) { string error = null; StringRequest sr = new StringRequest("Clone Project As?", (newName) => { return(Runtime.ProjectController.ValidateProjectName(newName)); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { if (!Runtime.ProjectController.CloneProject(project, sr.Answer, ref error)) { MessageBox.Show(GetWindow(), error, "Unable to Clone Project", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); return; } RefreshProjects(); } } }
private void ImportModelSystem_Clicked(object obj) { var xtmf = Session.GetRuntime(); var openMS = new OpenWindow(); openMS.Owner = GetWindow(); using (var modelSystemSession = openMS.OpenModelSystem(xtmf)) { var loading = openMS.LoadTask; if (loading != null) { loading.Wait(); using (var realSession = openMS.ModelSystemSession) { if (realSession == null) { return; } string error = null; StringRequest sr = new StringRequest("Save Model System As?", (newName) => { return(Session.ValidateModelSystemName(newName)); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { if (!Session.AddModelSystem(realSession.ModelSystemModel, sr.Answer, ref error)) { MessageBox.Show(GetWindow(), error, "Unable to Import Model System", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); return; } Model.RefreshModelSystems(); } } } } }
private void CloneCurrentModelSystem() { if (Display.SelectedItem is ModelSystem modelSystem) { string error = null; StringRequest sr = new StringRequest("Clone Model System As?", newName => { string e = null; return(Runtime.ModelSystemController.ValidateModelSystemName(newName, ref e)); }) { Owner = GetWindow() }; if (sr.ShowDialog() == true) { if (!Runtime.ModelSystemController.CloneModelSystem(modelSystem, sr.Answer, ref error)) { MessageBox.Show(GetWindow(), error, "Unable to Clone Model System", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); return; } RefreshModelSystems(); } } }
private void SaveModelSystemAs_Click(object sender, RoutedEventArgs e) { var selected = ModelSystemDisplay.SelectedItem as ProjectModel.ContainedModelSystemModel; if (selected != null) { StringRequest sr = new StringRequest("Save Model System As?", (newName) => { return Session.ValidateModelSystemName(newName); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { string error = null; if (!selected.CloneModelSystem(Session, sr.Answer, ref error)) { MessageBox.Show(error, "Unable to Save Model System", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
private void RenameProject_Clicked(object obj) { StringRequest sr = new StringRequest("New Project Name?", (newName) => { return Session.ValidateModelSystemName(newName); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { string error = null; if (!Session.ReameProject(sr.Answer, ref error)) { MessageBox.Show(error, "Unable to Save Model System", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void ImportModelSystem_Clicked(object obj) { var xtmf = Session.GetRuntime(); var openMS = new OpenWindow(); openMS.Owner = GetWindow(); using (var modelSystemSession = openMS.OpenModelSystem(xtmf)) { var loading = openMS.LoadTask; if (loading != null) { loading.Wait(); using (var realSession = openMS.ModelSystemSession) { if (realSession == null) { return; } string error = null; StringRequest sr = new StringRequest("Save Model System As?", (newName) => { return Session.ValidateModelSystemName(newName); }); sr.Owner = GetWindow(); if (sr.ShowDialog() == true) { if (!Session.AddModelSystem(realSession.ModelSystemModel, sr.Answer, ref error)) { MessageBox.Show(GetWindow(), error, "Unable to Import Model System", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); return; } Model.RefreshModelSystems(); } } } } }
public void NewModelSystem() { StringRequest req = new StringRequest("Model System Name", ValidateName); if(req.ShowDialog() == true) { var name = req.Answer; var ms = EditorController.Runtime.ModelSystemController.LoadOrCreate(name); EditModelSystem(EditorController.Runtime.ModelSystemController.EditModelSystem(ms)); } }
private void NewLinkedParameter_Clicked(object obj) { var request = new StringRequest("Name the new Linked Parameter", (s) => true); if(request.ShowDialog() == true) { string error = null; if(!LinkedParameters.NewLinkedParameter(request.Answer, ref error)) { MessageBox.Show(MainWindow.Us, error, "Failed to create new Linked Parameter", MessageBoxButton.OK, MessageBoxImage.Error); return; } SetupLinkedParameters(LinkedParameters); } }
private void SetupRunButton(LayoutDocument document) { var modelSystem = document.Content as ModelSystemDisplay; RunMenu.IsEnabled = false; RunLabel.IsEnabled = false; if (modelSystem != null) { var session = modelSystem.Session; if (session.CanRun) { RunMenu.IsEnabled = true; RunLabel.IsEnabled = true; _CurrentRun = () => { var runName = "Run Name"; StringRequest req = new StringRequest("Run Name", ValidateName); var trueWindow = Window.GetWindow(document.Content as DependencyObject); var testWindow = GetWindow(document.Content as DependencyObject); var vis = document.Content as UserControl; if (vis != null && testWindow != trueWindow) { var topLeft = vis.PointToScreen(new Point()); // Since the string request dialog isn't shown yet we need to use some defaults as width and height are not available. req.Left = topLeft.X + ((vis.ActualWidth - StringRequest.DefaultWidth) / 2); req.Top = topLeft.Y + ((vis.ActualHeight - StringRequest.DefaultHeight) / 2); } else { req.Owner = trueWindow; } if (req.ShowDialog() == true) { runName = req.Answer; string error = null; var run = session.Run(runName, ref error); if (run != null) { RunWindow window = new RunWindow(session, run, runName); var doc = AddNewWindow("New Run", window); doc.Closing += (o, e) => { if (!window.CloseRequested()) { e.Cancel = true; return; } }; doc.CanClose = true; doc.IsSelected = true; Keyboard.Focus(window); window.Focus(); } else { MessageBox.Show(this, error, "Unable to run", MessageBoxButton.OK, MessageBoxImage.Error); } } }; } } }
public void NewProject() { StringRequest req = new StringRequest("Project Name", ValidateName) { Owner = this }; if (req.ShowDialog() == true) { var name = req.Answer; string error = null; var ms = EditorController.Runtime.ProjectController.LoadOrCreate(name, ref error); EditProject(EditorController.Runtime.ProjectController.EditProject(ms)); } }