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); ms.ModelSystemStructure.Name = req.Answer; EditModelSystem(EditorController.Runtime.ModelSystemController.EditModelSystem(ms)); } }
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)); } }
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); } } }; } } }