public LinkedParameterModel(ILinkedParameter linkedParameter, ModelSystemEditingSession session, ModelSystemModel modelSystem) { Session = session; ModelSystem = modelSystem; ParameterModels = CreateInitialParameterModels(linkedParameter, ModelSystem); RealLinkedParameter = linkedParameter as LinkedParameter; }
/// <summary> /// Create a model editing session for a previous run. This will be read-only! /// </summary> /// <param name="runtime">A link to the XTMFRuntime</param> /// <param name="projectSession">The project this is for.</param> /// <param name="runFile">The location of the previous run.</param> public ModelSystemEditingSession(XTMFRuntime runtime, ProjectEditingSession projectSession, string runFile) { _Runtime = runtime; ProjectEditingSession = projectSession; _ModelSystemIndex = -1; ModelSystemModel = new ModelSystemModel(_Runtime, this, projectSession.Project, runFile); }
/// <summary> /// Exports the model system model to a string. /// </summary> /// <param name="ms">The model system model to export</param> /// <param name="modelSystemAsString">The string to store the results into.</param> /// <param name="error">A description of the error if there is one.</param> /// <returns>True if successful, false otherwise with description.</returns> public bool ExportModelSystemAsString(ModelSystemModel ms, out string modelSystemAsString, ref string error) { var modelSystem = ms.CloneAsModelSystem(Runtime.Configuration); return(Runtime.ModelSystemController.ExportModelSystemAsString(modelSystem, out modelSystemAsString, ref error)); }
/// <summary> /// Export the model system as a string. /// </summary> /// <param name="ms">The model system to export</param> /// <param name="modelSystemAsString">The string to export the model system to.</param> /// <param name="error">A description of the error if one occurs</param> /// <returns>True if successful, false with a description of the error.</returns> public bool ExportModelSystemAsString(ModelSystemModel ms, out string modelSystemAsString, ref string error) { lock (_EditingSessionsLock) { return(_Runtime.ProjectController.ExportModelSystemAsString(ms, out modelSystemAsString, ref error)); } }
public LinkedParametersModel(ModelSystemEditingSession session, ModelSystemModel modelSystem, List <ILinkedParameter> realLinkedParameters) { _Session = session; _ModelSystem = modelSystem; _RealLinkedParameters = realLinkedParameters; LinkedParameters = CreateLinkedParameters(_RealLinkedParameters, _Session, _ModelSystem); }
public LinkedParametersModel(ModelSystemEditingSession session, ModelSystemModel modelSystem, List<ILinkedParameter> realLinkedParameters) { Session = session; ModelSystem = modelSystem; RealLinkedParameters = realLinkedParameters; LinkedParameters = CreateLinkedParameters(RealLinkedParameters, Session, ModelSystem); }
/// <summary> /// Create a new session to edit a model system /// </summary> /// <param name="modelSystem">The model system to edit</param> public ModelSystemEditingSession(XTMFRuntime runtime, ModelSystem modelSystem) { Runtime = runtime; ModelSystem = modelSystem; ModelSystemModel = new ModelSystemModel(this, modelSystem); ModelSystemModel.PropertyChanged += ModelSystemModel_PropertyChanged; }
/// <summary> /// Create a new session to edit a model system /// </summary> /// <param name="modelSystem">The model system to edit</param> public ModelSystemEditingSession(XTMFRuntime runtime, ModelSystem modelSystem) { _Runtime = runtime; _ModelSystem = modelSystem; ModelSystemModel = new ModelSystemModel(this, modelSystem); ModelSystemModel.PropertyChanged += ModelSystemModel_PropertyChanged; _saveSemaphor = new Semaphore(1, 1); }
/// <summary> /// Add a model system to the project /// </summary> /// <param name="modelSystem">The model system to add to the project</param> /// <param name="error">An error message in case of failure</param> /// <returns>True if the model system was added successfully</returns> public bool AddModelSystem(ModelSystemModel modelSystem, ref string error) { if (modelSystem == null) { throw new ArgumentNullException("modelSystem"); } return(AddModelSystem(modelSystem.ModelSystem, ref error)); }
/// <summary> /// Add a model system to the project /// </summary> /// <param name="modelSystem">The model system to add to the project</param> /// <param name="newName">The name to use for this new model system</param> /// <param name="error">An error message in case of failure</param> /// <returns>True if the model system was added successfully</returns> public bool AddModelSystem(ModelSystemModel modelSystem, string newName, ref string error) { if (modelSystem == null) { throw new ArgumentNullException(nameof(modelSystem)); } return(AddModelSystem(modelSystem.ModelSystem, newName, ref error)); }
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(); }
/// <summary> /// Rebuild the model system session by recreating the model system model /// </summary> private void Reload() { if (ModelSystemModel != null) { ModelSystemModel.PropertyChanged -= ModelSystemModel_PropertyChanged; RedoStack.Clear(); UndoStack.Clear(); HasChanged = false; } ModelSystemModel = new ModelSystemModel(this, this.ProjectEditingSession.Project, ModelSystemIndex); ModelSystemModel.PropertyChanged += ModelSystemModel_PropertyChanged; }
/// <summary> /// Save the session. /// </summary> /// <param name="error">If there is an error it will provide a message as to why.</param> /// <returns>If we were able to save or not.</returns> public bool Save(ref string error) { lock (SessionLock) { if (!ModelSystemModel.Save(ref error)) { return(false); } HasChanged = false; return(true); } }
/// <summary> /// Save the session. /// </summary> /// <param name="error">If there is an error it will provide a message as to why.</param> /// <returns>If we were able to save or not.</returns> public bool Save(ref string error) { lock (_SessionLock) { if (!ModelSystemModel.Save(ref error)) { return(false); } Saved?.Invoke(this, new EventArgs()); HasChanged = false; return(true); } }
public bool RevertToLastSave(ref string error) { error = null; lock (_SessionLock) { if (ModelSystemModel.RevertToLastSave(this, ref error)) { _UndoStack.Clear(); _RedoStack.Clear(); return(true); } error = "Feature is not available yet."; return(false); } }
/// <summary> /// Save the session. /// </summary> /// <param name="error">If there is an error it will provide a message as to why.</param> /// <returns>If we were able to save or not.</returns> public bool Save(ref string error) { lock (SessionLock) { if (!ModelSystemModel.Save(ref error)) { return(false); } var e = Saved; if (e != null) { e(this, new EventArgs()); } HasChanged = false; return(true); } }
public ModelSystemStructureModel GetModelSystemStructureModel(ModelSystemStructure modelSystemStructure) { return(ModelSystemModel.GetModelFor(modelSystemStructure)); }
public static XTMFRun CreateLocalRun(Project project, int modelSystemIndex, ModelSystemModel root, Configuration config, string runName, bool overwrite = false) { return(new XTMFRunLocal(project, modelSystemIndex, root, config, runName, overwrite)); }
public static XTMFRun CreateRemoteHost(Project project, int modelSystemIndex, ModelSystemModel root, Configuration config, string runName, bool overwrite = false) { return(new XTMFRunRemoteHost(config, root.Root, project.LinkedParameters[modelSystemIndex], runName, Path.Combine(config.ProjectDirectory, project.Name, runName), overwrite)); }
private static ObservableCollection<LinkedParameterModel> CreateLinkedParameters(List<ILinkedParameter> linkedParameters, ModelSystemEditingSession session, ModelSystemModel ModelSystem) { var ret = new ObservableCollection<LinkedParameterModel>(); if(linkedParameters == null) return ret; for(int i = 0; i < linkedParameters.Count; i++) { ret.Add(new LinkedParameterModel(linkedParameters[i], session, ModelSystem)); } return ret; }
/// <summary> /// Create a new session to edit a model system /// </summary> /// <param name="modelSystem">The model system to edit</param> public ModelSystemEditingSession(XTMFRuntime runtime, ModelSystem modelSystem) { Runtime = runtime; ModelSystem = modelSystem; ModelSystemModel = new ModelSystemModel(this, modelSystem); }
/// <summary> /// /// </summary> /// <param name="model"></param> public ProjectWasExternallySavedEventArgs(ModelSystemModel model) { this.ModelSystem = model; }
/// <summary> /// Create a new editing session to edit a project's model system /// </summary> /// <param name="ProjectEditingSession">The editing session to read from</param> /// <param name="modelSystemIndex">The model system's index inside of the project</param> public ModelSystemEditingSession(XTMFRuntime runtime, ProjectEditingSession ProjectEditingSession, int modelSystemIndex) { Runtime = runtime; this.ProjectEditingSession = ProjectEditingSession; ModelSystemIndex = modelSystemIndex; ModelSystemModel = new ModelSystemModel(this, this.ProjectEditingSession.Project, modelSystemIndex); }
private static ObservableCollection <LinkedParameterModel> CreateLinkedParameters(List <ILinkedParameter> linkedParameters, ModelSystemEditingSession session, ModelSystemModel ModelSystem) { var ret = new ObservableCollection <LinkedParameterModel>(); if (linkedParameters == null) { return(ret); } for (int i = 0; i < linkedParameters.Count; i++) { ret.Add(new LinkedParameterModel(linkedParameters[i], session, ModelSystem)); } return(ret); }
/// <summary> /// Create a model editing session for a previous run. This will be read-only! /// </summary> /// <param name="runtime">A link to the XTMFRuntime</param> /// <param name="projectSession">The project this is for.</param> /// <param name="runFile">The location of the previous run.</param> public ModelSystemEditingSession(XTMFRuntime runtime, ProjectEditingSession projectSession, string runFile) { this.Runtime = runtime; ProjectEditingSession = projectSession; ModelSystemIndex = -1; ModelSystemModel = new ModelSystemModel(Runtime, this, projectSession.Project, runFile); }
public ModelSystemStructureModel GetParent(ModelSystemStructureModel currentModule) { return(ModelSystemModel.GetModelFor( currentModule.RealModelSystemStructure.GetParent(ModelSystemModel.Root.RealModelSystemStructure))); }
private static ObservableCollection <ParameterModel> CreateInitialParameterModels(ILinkedParameter linkedParameter, ModelSystemModel modelSystem) { var ret = new ObservableCollection <ParameterModel>(); var real = linkedParameter.Parameters; if (real != null) { for (int i = 0; i < real.Count; i++) { ParameterModel pm = modelSystem.GetParameterModel(real[i]); if (pm != null) { ret.Add(pm); } } } return(ret); }
/// <summary> /// Add a model system to the project /// </summary> /// <param name="modelSystem">The model system to add to the project</param> /// <param name="newName">The name to use for this new model system</param> /// <param name="error">An error message in case of failure</param> /// <returns>True if the model system was added successfully</returns> public bool AddModelSystem(ModelSystemModel modelSystem, string newName, ref string error) { if (modelSystem == null) { throw new ArgumentNullException("modelSystem"); } return AddModelSystem(modelSystem.ModelSystem, newName, ref error); }
private static ObservableCollection<ParameterModel> CreateInitialParameterModels(ILinkedParameter linkedParameter, ModelSystemModel modelSystem) { var ret = new ObservableCollection<ParameterModel>(); var real = linkedParameter.Parameters; if(real != null) { for(int i = 0; i < real.Count; i++) { ParameterModel pm = modelSystem.GetParameterModel(real[i]); if(pm != null) { ret.Add(pm); } } } return ret; }