Example #1
0
        private void richTextBox1_TextChanged_1(object sender, EventArgs e)
        {
            var index = listBox1.SelectedIndex;

            OpenedFilesHandles.SaveText(index, richTextBox1.Text);
            toolStripStatusLabel1.Text = "Text changed, consider saving...";
        }
Example #2
0
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var index = listBox1.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            //Remove file from program
            OpenedFilesHandles.CloseFile(index);
            //Remove file from list
            listBox1.Items.Clear();
            foreach (string s in OpenedFilesHandles.OpenedFilesNames)
            {
                listBox1.Items.Add(s);
            }
            if (listBox1.Items.Count > 0)
            {
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
            }
            else
            {
                richTextBox1.Text = "";
            }
        }
Example #3
0
 private void SaveAll()
 {
     for (int i = 0; i < listBox1.Items.Count; i++)
     {
         FileHandler.CreateFileAbsolute(OpenedFilesHandles.GetFullName(i), OpenedFilesHandles.GetText(i));
     }
     toolStripStatusLabel1.Text = "Saved all changes successfully";
 }
Example #4
0
 /// <summary>
 /// This takes in the full path to the file including its name.
 /// This also adds the fullname to the opened files.
 /// </summary>
 /// <param name="fullname">Full path to file including nam e</param>
 /// <param name="text">The data inside the text file</param>
 public static void OpenFileAbsolute(string fullname, out string text)
 {
     text = "";
     using (var sr = File.OpenText(fullname))
     {
         text = sr.ReadToEnd();
     }
     OpenedFilesHandles.AddOpenFile(fullname, text);
 }
Example #5
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var index = listBox1.SelectedIndex;

            if (index == -1)
            {
                return;
            }
            else
            {
                richTextBox1.Text          = OpenedFilesHandles.GetText(index);
                toolStripStatusLabel1.Text = "Editing: " + OpenedFilesHandles.OpenedFilesNames[listBox1.SelectedIndex];
            }
        }
Example #6
0
        /// <summary>
        /// This will compile all the files found in OpenedFiles list.
        /// You must open all the files you want to compile before using this.
        /// </summary>
        public static void CompileAll(out int exitCode, out string errorsOutput)
        {
            //This is the object used to start the process
            ProcessStartInfo startInfo = new ProcessStartInfo();

            //Constructing compiler arguments
            string Arguments = "-o " + FullCompilerOutputPath + FullCompilerOutputName;

            for (int i = 0; i < OpenedFilesHandles.OpenedFilesCount; i++)
            {
                Arguments += " " + OpenedFilesHandles.GetFullName(i);
            }

            //Put in the object arguments as a full string
            startInfo.Arguments = Arguments;

            //The excutable to run, including the comlpete path
            startInfo.FileName = FullCompilerPath;

            //No window for compilation
            startInfo.WindowStyle    = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow = true;

            //Redirect errors to me
            startInfo.RedirectStandardError = true;
            startInfo.UseShellExecute       = false;

            using (Process process = Process.Start(startInfo))
            {
                StreamReader errors = process.StandardError;

                process.WaitForExit();

                errorsOutput = errors.ReadToEnd();
                exitCode     = process.ExitCode;
            }
        }