Example #1
0
 public ProjectEditingSession(Project project, XTMFRuntime runtime)
 {
     Project = project;
     Runtime = runtime;
     EditingSessions = new SessionData[Project.ModelSystemStructure.Count];
     project.ExternallySaved += Project_ExternallySaved;
 }
Example #2
0
 /// <summary>
 /// Create a model system model for a previous run.
 /// </summary>
 /// <param name="modelSystemEditingSession">The session to use</param>
 /// <param name="project">The project the previous run is in.</param>
 /// <param name="runFile">The path to the run file.</param>
 public ModelSystemModel(XTMFRuntime runtime, ModelSystemEditingSession modelSystemEditingSession, Project project, string runFile)
 {
     Project = project;
     ModelSystemIndex = -1;
     Name = Path.GetFileName(runFile);
     _Description = "Previous run";
     Root = new ModelSystemStructureModel(modelSystemEditingSession, runtime.ModelSystemController.LoadFromRunFile(runFile));
 }
Example #3
0
 public ModelSystemModel(ModelSystemEditingSession session, Project project, int modelSystemIndex)
 {
     Project = project;
     ModelSystemIndex = modelSystemIndex;
     Name = project.ModelSystemStructure[modelSystemIndex].Name;
     _Description = project.ModelSystemDescriptions[modelSystemIndex];
     List<ILinkedParameter> editingLinkedParameters;
     Root = new ModelSystemStructureModel(session, (project.CloneModelSystemStructure(out editingLinkedParameters, modelSystemIndex) as ModelSystemStructure));
     _Description = Project.ModelSystemDescriptions[modelSystemIndex];
     LinkedParameters = new LinkedParametersModel(session, this, editingLinkedParameters);
 }
Example #4
0
 public XTMFRun(Project project, ModelSystemStructureModel root, Configuration configuration, string runName)
 {
     // we don't make a clone for this type of run
     Project = project;
     ModelSystemStructureModelRoot = root;
     var index = project.ModelSystemStructure.IndexOf(root.RealModelSystemStructure);
     if(index >= 0)
     Configuration = new XTMF.RunProxy.ConfigurationProxy(configuration, Project);
     RunName = runName;
     RunDirectory = Path.Combine(Configuration.ProjectDirectory, Project.Name, RunName);
 }
Example #5
0
 public XTMFRun(Project project, int modelSystemIndex, ModelSystemModel root, Configuration config, string runName)
 {
     Project = project;
     ModelSystemStructureModelRoot = root.Root;
     Configuration = new XTMF.RunProxy.ConfigurationProxy(config, Project);
     RunName = runName;
     RunDirectory = Path.Combine(Configuration.ProjectDirectory, Project.Name, RunName);
     ModelSystemIndex = modelSystemIndex;
     Project.ModelSystemStructure[ModelSystemIndex] = root.ClonedModelSystemRoot;
     Project.LinkedParameters[ModelSystemIndex] = root.LinkedParameters.GetRealLinkedParameters();
 }
Example #6
0
 public ProjectEditingSession(Project project, XTMFRuntime runtime)
 {
     Project = project;
     Runtime = runtime;
     EditingSessions = new SessionData[Project.ModelSystemStructure.Count];
 }
Example #7
0
 /// <summary>
 /// Create a cloned project of the given project
 /// </summary>
 /// <param name="project">The project to clone</param>
 /// <returns>An exact copy of the project, if it is saved it will overwrite</returns>
 internal Project CreateCloneProject(Project project)
 {
     return project.CreateCloneProject();
 }
Example #8
0
 private void FindAndLoadProjects()
 {
     if ( !Directory.Exists( this.Configuration.ProjectDirectory ) ) return;
     string[] subDirectories = Directory.GetDirectories( this.Configuration.ProjectDirectory );
     Parallel.For( 0, subDirectories.Length, (int i) =>
     {
         var files = Directory.GetFiles( subDirectories[i], "Project.xml", SearchOption.TopDirectoryOnly );
         if ( files != null && files.Length > 0 )
         {
             try
             {
                 Project p = new Project( Path.GetFileName( subDirectories[i] ), this.Configuration );
                 lock ( this )
                 {
                     if ( this.ValidateProjectName( p ) )
                     {
                         // If everything is good, add it to the list of projects
                         this.Projects.Add( p );
                     }
                 }
             }
             catch
             {
             }
         }
     } );
     lock ( this )
     {
         ( this.Projects as List<IProject> ).Sort( delegate(IProject first, IProject second)
         {
             return first.Name.CompareTo( second.Name );
         } );
     }
 }
Example #9
0
 /// <summary>
 /// This should be called if an project's clone gets saved, effectively removing the old project
 /// from existence.
 /// </summary>
 /// <param name="baseProject">The project to be replaced</param>
 /// <param name="replaceWith">The project to replace it with</param>
 internal void ReplaceProjectFromClone(Project baseProject, Project replaceWith)
 {
     lock(this)
     {
         var index = Projects.IndexOf(baseProject);
         if(index >= 0)
         {
             Projects[index] = replaceWith;
         }
     }
 }
Example #10
0
 internal void Project_ExternallySaved(object sender, ProjectExternallySavedEventArgs e)
 {
     if (Project == e.BaseProject)
     {
         // If our project was overwritten, dump everything and switch what the active project is.
         lock (EditingSessionsLock)
         {
             Project.ExternallySaved -= Project_ExternallySaved;
             Project = e.CloneProject;
             Project.ExternallySaved += Project_ExternallySaved;
             for (int i = 0; i < EditingSessions.Length; i++)
             {
                 var session = EditingSessions[i].Session;
                 if (session != null)
                 {
                     session.ProjectWasExternalSaved();
                 }
             }
         }
         var call = ProjectWasExternallySaved;
         if (call != null)
         {
             call(this, e);
         }
     }
 }
Example #11
0
 /// <summary>
 /// This constructo
 /// </summary>
 private Project(Project toClone)
 {
     IsLoaded = true;
     Name = toClone.Name;
     var numberOfModelSystems = toClone.ModelSystemStructure.Count;
     ModelSystemStructure = new List<IModelSystemStructure>(numberOfModelSystems);
     LinkedParameters = new List<List<ILinkedParameter>>(numberOfModelSystems);
     DirectoryLocation = toClone.DirectoryLocation;
     Configuration = toClone.Configuration;
     ClonedFrom = toClone;
     for (int i = 0; i < numberOfModelSystems; i++)
     {
         List<ILinkedParameter> lp;
         var mss = toClone.CloneModelSystemStructure(out lp, i);
         ModelSystemStructure.Add(mss);
         LinkedParameters.Add(lp);
     }
     ModelSystemDescriptions = toClone.ModelSystemDescriptions.ToList();
 }
Example #12
0
 /// <summary>
 /// This constructo
 /// </summary>
 private Project(Project toClone)
 {
     Name = toClone.Name;
     ModelSystemStructure = toClone.ModelSystemStructure.ToList();
     LinkedParameters = toClone.LinkedParameters.ToList();
     ModelSystemDescriptions = toClone.ModelSystemDescriptions.ToList();
     DirectoryLocation = toClone.DirectoryLocation;
     Configuration = toClone.Configuration;
     IsLoaded = true;
 }