Exemplo n.º 1
0
        // add new script, and return the re-adjusted script name
        public static ScriptModel addNewScript(string newScriptName, List <StateModel> stateModels = null)
        {
            // deal w/ duplicated script names
            string origNewScriptName = newScriptName;
            int    cnt = 2;

            while (mOpenedScriptList.Any(it => it.Name == newScriptName))
            {
                newScriptName = origNewScriptName + " (" + cnt + ")";
                ++cnt;
            }

            ScriptModel newScriptModel = new ScriptModel(newScriptName, stateModels);

            mOpenedScriptList.Add(newScriptModel);

            // start up its own history management
            HistoryManager.startScriptHistory(newScriptModel);

            // invalidate the start-state-view on the shell if needs
            Program.form.getCertainStateViewOnTheShell(0).Invalidate();

            // clear all of the existed objects in cbb's at the form
            Program.form.clearExistedObjects();

            // set operations which need at least a script exists into enabled
            Program.form.setOperationsWhichNeedScriptExists(true);

            return(newScriptModel);
        }
Exemplo n.º 2
0
        // open the saved script
        /// <summary>
        /// return true if added successfully
        /// </summary>
        /// <param name="scriptModel"></param>
        /// <returns></returns>
        public static bool openScript(ScriptModel scriptModel)
        {
            ScriptModel scriptModelInList = mOpenedScriptList.Find(it => it.Equals(scriptModel));

            // not in the opened script list, open it
            if (scriptModelInList is null)
            {
                mOpenedScriptList.Add(scriptModel);

                // start up its own history management
                HistoryManager.startScriptHistory(scriptModel);

                // 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
                Program.form.reloadExistedObjects(scriptModel.getStateList(), scriptModel.getAllLinksInWholeScript());

                // set operations which need at least a script exists into enabled
                Program.form.setOperationsWhichNeedScriptExists(true);

                return(true);
            }
            // already in the opened script list
            else
            {
                return(false);
            }
        }