コード例 #1
0
ファイル: Program.cs プロジェクト: hebskjcc/OpenR8-1
        //20170929 leo: undo 與 redo 用,整個 R8 記錄下來
        public static void recordProgram(R8 r8, ToolStripMenuItem undoButton, ToolStripMenuItem redoButton)
        {
            /*
             * for (int i = recordList.Count - 1; i > undoRedoNowAt + 1; i--) {
             *  recordList.RemoveAt(i);
             * }
             */

            if (recordList.Count > 0)
            {
                for (int i = undoRedoNowAt - 1; i >= 0; i--)
                {
                    //MessageBox.Show("RemoveAt " + i);
                    recordList.RemoveAt(i);
                }
                undoRedoNowAt = 0;
            }


            recordList.Insert(undoRedoNowAt, r8.clone());

            if (recordList.Count > recordListMaxSize)
            {
                recordList.RemoveAt(recordList.Count - 1);
            }
            Program.undoRedoButtonSetEnableOrDisable(undoButton, redoButton);

            isFileChange = true;
            //MessageBox.Show("isFileChange = true");

            /*
             * if (false)
             * {
             *  String str = "recordProgram\r\n";
             *  for (int j = 0; j < recordList.Count; j++)
             *  {
             *      str += "at " + j + "\r\n";
             *      str += "undoRedoNowAt = " + undoRedoNowAt + "\r\n";
             *      str += "recordList Size = " + recordList.Count + "\r\n";
             *      //str += "getFunctionSnLast = " + r8.getFunctionSnLast() + "\r\n";
             *      //str += "getVariableSnLast = " + r8.getVariableSnLast() + "\r\n";
             *      for (int i = 0; i < recordList[j].getFunctionSnLast(); i++)
             *      {
             *          if (recordList[j].functions[i] != null)
             *          {
             *              str += "function " + recordList[j].functions[i] + "\r\n";
             *          }
             *      }
             *      str += "===\r\n";
             *      for (int i = 0; i < recordList[j].getVariableSnLast(); i++)
             *      {
             *          if (recordList[j].variables[i] != null)
             *          {
             *              str += "variables " + recordList[j].variables[i] + "\r\n";
             *          }
             *      }
             *      str += "\r\n";
             *  }
             *  MessageBox.Show(str);
             * }
             */

            /*
             * if (false)
             * {
             *  String str = "recordProgram\r\n";
             *
             *  str += "undoRedoNowAt = " + undoRedoNowAt + "\r\n";
             *  str += "recordList Size = " + recordList.Count + "\r\n";
             *  //str += "getFunctionSnLast = " + r8.getFunctionSnLast() + "\r\n";
             *  //str += "getVariableSnLast = " + r8.getVariableSnLast() + "\r\n";
             *  for (int i = 0; i < r8.getFunctionSnLast(); i++)
             *  {
             *      if (r8.functions[i] != null)
             *      {
             *          str += "function " + r8.functions[i] + "\r\n";
             *      }
             *  }
             *  str += "===\r\n";
             *  for (int i = 0; i < r8.getVariableSnLast(); i++)
             *  {
             *      if (r8.variables[i] != null)
             *      {
             *          str += "variables " + r8.variables[i] + "\r\n";
             *      }
             *  }
             *  str += "\r\n";
             *
             *  MessageBox.Show(str);
             * }
             */

            return;
        }