Beispiel #1
0
 private void SetupRunButton(LayoutDocument document)
 {
     var modelSystem = document.Content as ModelSystemDisplay;
     RunMenu.IsEnabled = false;
     if(modelSystem != null)
     {
         var session = modelSystem.Session;
         if(session.CanRun)
         {
             RunMenu.IsEnabled = true;
             _CurrentRun = () =>
             {
                 RunWindow window = new RunWindow(session);
                 var doc = AddNewWindow("New Run", window);
                 doc.CanClose = true;
                 doc.IsSelected = true;
                 Keyboard.Focus(window);
                 window.Focus();
             };
         }
     }
 }
Beispiel #2
0
 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);
                     }
                 }
             };
         }
     }
 }