Пример #1
0
        private void Select()
        {
            var index = Display.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            IsEnabled = false;

            var result = InternalModel.Data[InternalModel.Data.IndexOf((Model.ModelElement)Display.SelectedItem)].Data;

            if (result is Project)
            {
                MainWindow.SetStatusText("Loading Project...");
            }
            else
            {
                MainWindow.SetStatusText("Loading Model System...");
            }
            LoadTask = Task.Factory.StartNew(() =>
            {
                if (result is Project)
                {
                    ProjectSession = PEditSession = Runtime.ProjectController.EditProject(result as Project);
                }
                else
                {
                    ModelSystemSession = MSEditSession = Runtime.ModelSystemController.EditModelSystem(result as ModelSystem);
                }
            });
            Close();
        }
Пример #2
0
 private void EditProject(ProjectEditingSession projectSession)
 {
     if (projectSession != null)
     {
         Dispatcher.BeginInvoke(new Action(() =>
         {
             var display = new ProjectDisplay()
             {
                 Session = projectSession,
             };
             display.InitiateModelSystemEditingSession += (editingSession) => EditModelSystem(editingSession);
             var doc        = AddNewWindow("Project - " + projectSession.Project.Name, display, () => { projectSession.Dispose(); });
             doc.IsSelected = true;
             PropertyChangedEventHandler onRename = (o, e) =>
             {
                 doc.Title = "Project - " + projectSession.Project.Name;
             };
             projectSession.NameChanged += onRename;
             display.RequestClose       += (ignored) =>
             {
                 doc.Close();
                 display.Model.Unload();
                 projectSession.NameChanged -= onRename;
             };
             display.Focus();
             SetStatusText("Ready");
         }
                                           ));
     }
 }
Пример #3
0
                internal bool SetName(ProjectEditingSession session, string newName, ref string error)
                {
                    var ret = session.RenameModelSystem(Root, newName, ref error);

                    ModelHelper.PropertyChanged(PropertyChanged, this, "Name");
                    return(ret);
                }
Пример #4
0
        private void LoadCurrentProject()
        {
            var project = Display.SelectedItem as Project;

            if (project != null)
            {
                ProjectEditingSession session     = null;
                OperationProgressing  progressing = new OperationProgressing()
                {
                    Owner = GetWindow()
                };
                var loadingTask = Task.Run(() =>
                {
                    session = Runtime.ProjectController.EditProject(project);
                });
                MainWindow.Us.Dispatcher.BeginInvoke(new Action(() =>
                {
                    progressing.ShowDialog();
                }));
                loadingTask.Wait();
                if (session != null)
                {
                    MainWindow.Us.EditProject(session);
                }
                MainWindow.Us.Dispatcher.BeginInvoke(new Action(() =>
                {
                    progressing.Close();
                }));
            }
        }
Пример #5
0
 public void RefreshPastRuns(ProjectEditingSession session)
 {
     if (PreviousRuns == null)
     {
         PreviousRuns = new List <PreviousRun>();
     }
     else
     {
         PreviousRuns.Clear();
     }
     Task.Factory.StartNew(() =>
     {
         var list = new List <PreviousRun>();
         PreviousRuns.Clear();
         foreach (var pastRun in session.GetPreviousRuns())
         {
             DirectoryInfo info = new DirectoryInfo(pastRun);
             list.Add(new PreviousRun()
             {
                 Name      = info.Name,
                 Path      = pastRun,
                 TimeStamp = info.CreationTime.ToString()
             });
         }
         lock (PreviousRuns)
         {
             PreviousRuns.AddRange(list);
         }
         ModelHelper.PropertyChanged(PropertyChanged, this, "PreviousRuns");
     });
 }
Пример #6
0
 public ProjectModel(IProject project, ProjectEditingSession session)
 {
     Session = session;
     Project = project;
     session.ProjectWasExternallySaved += Session_ProjectWasExternallySaved;
     RefreshModelSystems();
     RefreshPastRuns(session);
 }
Пример #7
0
 public ProjectEditingSession OpenProject(XTMFRuntime runtime)
 {
     ExportButton.IsEnabled = false;
     Runtime      = runtime;
     PEditSession = null;
     InternalModel.Initialize(runtime.ProjectController.GetProjects());
     DataContext = InternalModel;
     lock (InternalModel.Data)
     {
         Display.ItemsSource = InternalModel.Data;
     }
     FilterBox.Display = Display;
     FilterBox.Filter  = Filter;
     ShowDialog();
     return(PEditSession);
 }
Пример #8
0
 private static void Run(int index, ProjectEditingSession projectSession, string runName)
 {
     using (var modelSystemSession = projectSession.EditModelSystem(index))
     {
         XTMFRun run;
         string  error = null;
         if ((run = modelSystemSession.Run(runName, ref error, true, true, true)) == null)
         {
             Console.WriteLine("Unable to run \r\n" + error);
             return;
         }
         modelSystemSession.ExecuteRun(run, true);
         run.RunCompleted += Run_RunComplete;
         run.Wait();
     }
 }
Пример #9
0
 internal bool CloneModelSystemToProject(ProjectEditingSession session, string name, ref string error)
 {
     return(session.CloneModelSystemToProjectAs(Root, name, ref error));
 }
Пример #10
0
 private void EditProject(ProjectEditingSession projectSession)
 {
     if (projectSession != null)
     {
         Dispatcher.BeginInvoke(new Action(() =>
         {
             var display = new ProjectDisplay()
             {
                 Session = projectSession,
             };
             display.InitiateModelSystemEditingSession += (editingSession) => EditModelSystem(editingSession);
             var doc = AddNewWindow("Project - " + projectSession.Project.Name, display, () => { projectSession.Dispose(); });
             doc.IsSelected = true;
             PropertyChangedEventHandler onRename = (o, e) =>
             {
                 doc.Title = "Project - " + projectSession.Project.Name;
             };
             projectSession.NameChanged += onRename;
             display.RequestClose += (ignored) =>
             {
                 doc.Close();
                 display.Model.Unload();
                 projectSession.NameChanged -= onRename;
             };
             display.Focus();
             SetStatusText("Ready");
         }
         ));
     }
 }
Пример #11
0
 public ProjectEditingSession OpenProject(XTMFRuntime runtime)
 {
     ExportButton.IsEnabled = false;
     Runtime = runtime;
     PEditSession = null;
     InternalModel.Initialize(runtime.ProjectController.GetProjects());
     DataContext = InternalModel;
     lock (InternalModel.Data)
     {
         Display.ItemsSource = InternalModel.Data;
     }
     FilterBox.Display = Display;
     FilterBox.Filter = Filter;
     ShowDialog();
     return PEditSession;
 }
Пример #12
0
        private void Select()
        {
            var index = Display.SelectedIndex;
            if (index < 0) return;
            IsEnabled = false;

            var result = InternalModel.Data[InternalModel.Data.IndexOf((Model.ModelElement)Display.SelectedItem)].Data;
            if (result is Project)
            {
                MainWindow.SetStatusText("Loading Project...");
            }
            else
            {
                MainWindow.SetStatusText("Loading Model System...");
            }
            LoadTask = Task.Factory.StartNew(() =>
                {
                    if (result is Project)
                    {
                        ProjectSession = PEditSession = Runtime.ProjectController.EditProject(result as Project);
                    }
                    else
                    {
                        ModelSystemSession = MSEditSession = Runtime.ModelSystemController.EditModelSystem(result as ModelSystem);
                    }
                });
            Close();
        }
Пример #13
0
 public ProjectEditingSession OpenProject(XTMFRuntime runtime)
 {
     Runtime = runtime;
     PEditSession = null;
     InternalModel.Initialize(runtime.ProjectController.GetProjects());
     DataContext = InternalModel;
     Display.ItemsSource = InternalModel.Data;
     FilterBox.Display = Display;
     FilterBox.Filter = Filter;
     ShowDialog();
     return PEditSession;
 }