// rename the current working-on script public static void renameScript(string newScriptName, bool isSaving) { if (CurrentSelectedScriptIndex < 0) { return; } mOpenedScriptList[CurrentSelectedScriptIndex].Name = newScriptName; mOpenedScriptList[CurrentSelectedScriptIndex].HaveUnsavedChanges = !isSaving; // add a record in its own history management HistoryManager.Do(mOpenedScriptList[CurrentSelectedScriptIndex]); if (!isSaving) { Program.form.MarkUnsavedScript(); } }
// remove a link between two states public static void removeLinkBetween2StatesOnCertainScript(StateModel from, PortType fromPortType, StateModel to, PortType toPortType, LinkModel linkModel) { if (CurrentSelectedScriptIndex < 0) { return; } mOpenedScriptList[CurrentSelectedScriptIndex].getStateModelById(from.Id).deleteLinkAtCertainPort(linkModel, fromPortType, true); mOpenedScriptList[CurrentSelectedScriptIndex].getStateModelById(to.Id).deleteLinkAtCertainPort(linkModel, toPortType, false); mOpenedScriptList[CurrentSelectedScriptIndex].HaveUnsavedChanges = true; // add a record in its own history management HistoryManager.Do(mOpenedScriptList[CurrentSelectedScriptIndex]); Program.form.MarkUnsavedScript(); // remove from cbb at the form as well Program.form.removeExistedObject(linkModel); }
// add new state on a certain script public static void addNewStateOnCertainScript(StateModel newStateModel) { if (CurrentSelectedScriptIndex < 0 || (newStateModel is null)) { return; } mOpenedScriptList[CurrentSelectedScriptIndex].addNewState(newStateModel); mOpenedScriptList[CurrentSelectedScriptIndex].HaveUnsavedChanges = true; Program.form.MarkUnsavedScript(); // add a record in its own history management HistoryManager.Do(mOpenedScriptList[CurrentSelectedScriptIndex]); // add into cbb at the form as well Program.form.addExistedObject(newStateModel); // debugPrint(); }
// close the current working-on script public static void closeScript() { if (CurrentSelectedScriptIndex < 0) { return; } // remove the script-model from the list mOpenedScriptList.RemoveAt(CurrentSelectedScriptIndex); // close and remove its history management as well HistoryManager.closeAndRemoveScriptHistoryByIdx(CurrentSelectedScriptIndex); // and re-adjust the current-selected-script-index if (CurrentSelectedScriptIndex >= mOpenedScriptList.Count) { CurrentSelectedScriptIndex = mOpenedScriptList.Count - 1; } // invalidate the start-state-view on the shell if needs Program.form.getCertainStateViewOnTheShell(0).Invalidate(); // re-load all existed objects into cbb's at the form if (CurrentSelectedScriptIndex >= 0 && CurrentSelectedScriptIndex < mOpenedScriptList.Count) { Program.form.reloadExistedObjects( mOpenedScriptList[CurrentSelectedScriptIndex].getStateList(), mOpenedScriptList[CurrentSelectedScriptIndex].getAllLinksInWholeScript() ); } // disable all operations that need at least one script opened if (mOpenedScriptList.Count == 0) { Program.form.setOperationsWhichNeedScriptExists(false); } }