// modify a certain state on a certain script public static void modifyStateOnCertainScript(StateView stateView, bool makeHistory) { if (CurrentSelectedScriptIndex < 0) { return; } string origContentText = ""; if (!(mOpenedScriptList[CurrentSelectedScriptIndex].getStateModelById(stateView.Id) is null)) { origContentText = mOpenedScriptList[CurrentSelectedScriptIndex].getStateModelById(stateView.Id).ContentText; } mOpenedScriptList[CurrentSelectedScriptIndex].modifyState(stateView); mOpenedScriptList[CurrentSelectedScriptIndex].HaveUnsavedChanges = true; // add a record in its own history management if (makeHistory) { HistoryManager.Do(mOpenedScriptList[CurrentSelectedScriptIndex]); } Program.form.MarkUnsavedScript(); // update the cbb at from as well if (!(mOpenedScriptList[CurrentSelectedScriptIndex].getStateModelById(stateView.Id) is null) && origContentText != stateView.StateContent) { Program.form.updateExistedObject(getStateModelByIdAtCurrentScript(stateView.Id)); } // debugPrint(); }
// 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(); }