Exemplo n.º 1
0
        private void Save(object sender, EventArgs e)
        {
            if (ErrorInFields())
            {
                return;
            }

            string currentFolderPath = mainFolderPath + @"\" + FormVariables.TitleInput.Text.Replace(" ", "_");

            if (!Directory.Exists(currentFolderPath))
            {
                Directory.CreateDirectory(currentFolderPath);
            }
            else
            {
                MessageBox.Show(@"There is already saved code with this title!");
                return;
            }

            string language = string.Empty;

            switch (languageMenu.SelectedIndex)
            {
            case 0:
                language = ".txt";
                break;

            case 1:
                language = ".cs";
                break;

            case 2:
                language = ".js";
                break;

            case 3:
                language = ".java";
                break;
            }

            File.WriteAllText(currentFolderPath + @"\Code" + language, FormVariables.ContentInput.Text);

            string description = $"Description: {FormVariables.DescriptionInput.Text}";
            string unfinished  = FormVariables.UnfinishedCheckBox.Checked ? "Finished: False" : "Finished: True";
            string errors      = IsEmptyString(FormVariables.ErrorInput.Text) ? "Errors: None" : $"Errors: {FormVariables.ErrorInput.Text}";

            var buildInfo = new StringBuilder();

            buildInfo.AppendLine(description);
            buildInfo.AppendLine(unfinished);
            buildInfo.AppendLine(errors);


            File.WriteAllText(currentFolderPath + @"\Info.txt", buildInfo.ToString().Trim());

            OldFields.GetFormData();
            FormVariables.ClearValues();

            MessageBox.Show(@"Saved!");
        }
Exemplo n.º 2
0
 private void UndoClear(object sender, EventArgs e)
 {
     if (OldFields.HasBeenFilled)
     {
         OldFields.FillFormData();
     }
     else
     {
         MessageBox.Show(@"There is nothing to undo!");
     }
 }
Exemplo n.º 3
0
 private void Clear(object sender, EventArgs e)
 {
     OldFields.GetFormData();
     FormVariables.ClearValues();
 }