예제 #1
0
        /// <summary>
        /// Formats the code directory with default files and folders
        /// </summary>
        /// <param name="background">True to run this process on background</param>
        public void FormatCodeDirectory(object background)
        {
            if (!IsReady)
            {
                return;
            }

            //gather all files
            string path = RegistryAccess.CodesPath;

            if (!Directory.Exists(path))
            {
                return;
            }

            if ((bool)background)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(FormatCodeDirectory, false);
                return;
            }

            IsReady = false;

            Interactivity.SetStatus("Formatting code directory started...");

            this.BeginInvoke((MethodInvoker) delegate
            {
                selectDirectoryPanel.Visible = false;
                folderTreeView.UseWaitCursor = true;
            });

            //create codes-path and check them
            if (!LocalDatabase.IsReady)
            {
                Logger.Add("Problem Database is not ready.", "Codes | FormatCodeDirectory()");
                return;
            }

            //just call codesPath. it will create directory automatically
            foreach (Structures.ProblemInfo prob in LocalDatabase.problemList)
            {
                LocalDirectory.GetCodesPath(prob.pnum);
            }

            //now create files for precode
            LocalDirectory.GetPrecode(Structures.Language.C);
            LocalDirectory.GetPrecode(Structures.Language.CPP);
            LocalDirectory.GetPrecode(Structures.Language.Java);
            LocalDirectory.GetPrecode(Structures.Language.Pascal);

            IsReady = true;
            LoadCodeFolder(false);
            Interactivity.SetStatus("Formatting code directory finished.");
        }
예제 #2
0
 //
 // Precode
 //
 private void precodeToolButton_ButtonClick(object sender, EventArgs e)
 {
     if (CurrentFile == null)
     {
         MessageBox.Show("Create a code file first.");
     }
     else
     {
         string file = LocalDirectory.GetPrecode(CustomLang);
         codeTextBox.Text = File.ReadAllText(file);
     }
 }