示例#1
0
        public void Execute(object parameter)
        {
            //MessageBox.Show("HelloWorld");
            string writePath = LHregistry.GetFile(FileManager.currentFileId);

            AdvancedMode.inst.textEditor.Save(writePath);
            AdvancedMode.UnChangedFile(AdvancedMode.Listbox);
        }
示例#2
0
 /// <summary>
 /// creates new file, returns -1 if failed
 /// </summary>
 /// <param name="filepath">full path of </param>
 /// <returns></returns>
 public static void LoadAllFiles()
 {
     string[] filenames = LHregistry.GetAllFilenames();
     int[]    fileids   = LHregistry.GetAllFileIds();
     for (int i = 0; i < fileids.Length; i++)
     {
         files[fileids[i]] = LHregistry.GetFile(fileids[i]);
     }
 }
示例#3
0
        public static void SaveAll()
        {
            for (int i = 0; i < FileManager.isFileNotSaved.Length; i++)
            {
                if (FileManager.isFileNotSaved[i])
                {
                    File.WriteAllText(LHregistry.GetFile(i), FileCache[i]);
                }
            }

            AdvancedMode.inst.SaveTextEditor();
        }
示例#4
0
        private void SaveScript(object sender, EventArgs e)
        {
            string writePath = LHregistry.GetFile(FileManager.currentFileId);

            try
            {
                textEditor.Save(writePath);
            }
            catch (System.ArgumentException)
            { Debug.WriteLine("Caught Argument Exception error, propably that the file can't be empty string, so yeah..."); }

            UnChangedFile(Listbox);
            return;
        }
示例#5
0
        private void RunLuaScript(object sender, EventArgs e)
        {
            if (FileManager.currentFileId < 0)
            {
                return;
            }
            //check if files are saved
            bool unsavedFiles = false;

            for (int i = 0; i < FileManager.isFileNotSaved.Length; i++)
            {
                if (FileManager.isFileNotSaved[i])
                {
                    unsavedFiles = true;
                    break;
                }
            }
            if (unsavedFiles)
            {
                MessageBoxResult res = CustomMessageBox.ShowYesNoCancel(
                    "There are unsaved files, do you want to save all files?",
                    "Unsaved Files",
                    "Yes", "No", "Cancel", MessageBoxImage.Exclamation
                    );
                if (res == MessageBoxResult.Yes)
                {
                    string writePath = LHregistry.GetFile(FileManager.currentFileId);
                    textEditor.Save(writePath);
                    UnChangedFile(Listbox);
                }
                if (res == MessageBoxResult.Cancel)
                {
                    return;
                }
            }
            //load and run lua script

            Communicator.load(FileManager.files[FileManager.currentFileId]);
            Communicator.start();
            //start monitoring
            Startwindow sw = new Startwindow();

            sw.Show();

            LuaFileView.Items.Refresh();
            return;
        }
示例#6
0
        /*public static int Addfile(string filepath)
         * {
         *  for(int i = 0; i < 50; i++)
         *  {
         *      if (files[i] == null) {
         *          //open file
         *          //string[] pathparts = filepath.Split('\\');
         *          //string newFilePath = ".\\Resources\\LuaFiles\\" + pathparts[(pathparts.Length - 1)];
         *          //files[i] = File.Create(newFilePath);
         *          //LHregistry.SetFile(newFilePath, i);
         *          return i;
         *      }
         *  }
         *  return -1;
         * }*/

        public static string LoadFile(int id)
        {
            string fileContents = "";

            //check if file is cached
            if (!isFileNotSaved[id] && files[id] != null)
            {
                //load new file
                byte[] cont = new byte[files[id].Length];
                if (files[id] != null)
                {
                    if (File.Exists(LHregistry.GetFile(id)))
                    {
                        FileStream   stream = File.OpenRead(LHregistry.GetFile(id));
                        StreamReader reader = new StreamReader(stream);
                        fileContents = reader.ReadToEnd();
                        reader.Close();
                        stream.Close();


                        isFileNotSaved[id] = false;
                    }
                    else
                    {
                        var res = MessageBox.Show("The File in question was not found, delete reference?", "File Not Found", MessageBoxButton.YesNo, MessageBoxImage.Error);
                        if (res == MessageBoxResult.Yes)
                        {
                            //delete reference
                            Deletefile(id);
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                fileContents = FileCache[id];
            }
            currentFileId = id;
            return(fileContents);
        }
示例#7
0
        public void SaveTextEditor()
        {
            string writePath = LHregistry.GetFile(FileManager.currentFileId);

            textEditor.Save(writePath);
        }