示例#1
0
 public void RenameMethod(string name, string newName)
 {
     if (!Sources.ContainsKey(name))
     {
         throw new ArgumentException("Unknown method name");
     }
     if (Sources.ContainsKey(newName))
     {
         throw new ArgumentException("Method " + newName + " already exists.");
     }
     if (newName.Length != name.Length)
     {
         throw new ArgumentException("New method name must have same number of symbols as old name");
     }
     if (newName.Length != 1 && newName.Length != 4)
     {
         throw new ArgumentException("Incorrect length of new method name");
     }
     if (newName.Length == 1 && (!System.Text.RegularExpressions.Regex.IsMatch(newName, "[B-Za-z]") || newName == "A" || newName == "V"))
     {
         throw new ArgumentException("Incorrect method name.\nMethod name must be 1 Latin character except 'A' or 'V'");
     }
     ProjectChanged = true;
     Sources.Add(newName, Sources[name]);
     Sources.Remove(name);
     FileNames.Add(newName, FileNames[name]);
     FileNames.Remove(name);
     FilesChanged.Add(newName, FilesChanged[name]);
     FilesChanged.Remove(name);
     Comments.Add(newName, Comments[name]);
     Comments.Remove(name);
     if (name.Length == 1)
     {
         char old = name[0];
         char nw  = newName[0];
         foreach (var a in Sources.Keys)
         {
             for (int i = 0; i < 16; i++)
             {
                 for (int j = 0; j < 16; j++)
                 {
                     if (Sources[a][i, j] == old)
                     {
                         Sources[a][i, j] = nw;
                     }
                 }
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// Add new method with zero source code
 /// </summary>
 /// <param name="name">Name of new method</param>
 /// <param name="path">Path of file with source</param>
 public void AddMethod(string name, string path)
 {
     ProjectChanged = true;
     FileNames.Add(name, path);
     Comments.Add(name, "");
     char[,] source = new char[16, 16];
     for (int i = 0; i < 16; i++)
     {
         for (int j = 0; j < 16; j++)
         {
             source[i, j] = '0';
         }
     }
     source[0, 0] = '#';// Empty method immediately ends running
     Sources.Add(name, source);
     FilesChanged.Add(name, true);
 }
示例#3
0
 private void RecordFileChanged(string file) => FilesChanged.Add(file);