/// <summary> /// Expand up to path of given problem number and select top file inside that folder /// Prompt for new file if none exist /// </summary> /// <param name="pnum">Problem number</param> public void ShowCode(object pnum) { if (!Directory.Exists(RegistryAccess.CodesPath)) { return; } if (!IsReady || folderTreeView.Nodes.Count == 0) { if (this.IsDisposed) { return; } TaskQueue.AddTask(ShowCode, pnum, 1000); return; } //create code file if doesn't exist string path = LocalDirectory.GetCodesPath((long)pnum); if (!Directory.Exists(path) || Directory.GetFiles(path).Length == 0) { this.BeginInvoke((MethodInvoker)(() => AddProblem((long)pnum))); return; } this.BeginInvoke((MethodInvoker) delegate { //select code file path TreeNode tn = GetNode(new DirectoryInfo(path)); CodesBrowser.ExpandAndSelect(tn, CodesBrowser.ExpandSelectType.SelecFirstChild); }); }
// // Open File // public void OpenFile(FileInfo file, bool history = true) { //check if file is okay, manage history keeping and clear data if (!PrecheckOpenFile(file, history)) { return; } //open file normally OpenCodeFile(file.FullName); codeTextBox.ReadOnly = false; CurrentFile = file; //set current file info fileNameLabel.Text = file.Name; //load code text box SetLanguage(file.Extension); HighlightCodebox(codeTextBox.Range); //highlight immediately after loading language MakeAutoCompleteMenu(); //select and expand to opened node if not already selected CodesBrowser.ExpandAndSelect(Interactivity.codesBrowser.GetNode(file)); //set problem number if (CanHaveIOFiles(codeTextBox.Language)) { SelectedPNUM = LocalDatabase.GetProblemNumber(file.Name); } //open input-output for valid problem number if (SelectedPNUM == -1) { return; } //change file name label text to include problem number and title fileNameLabel.Text = string.Format("Problem {0} - {1} ({2})", SelectedPNUM, LocalDatabase.GetTitle(SelectedPNUM), fileNameLabel.Text); //as there are IO files we can run tests runtestToolButton.Enabled = true; //make input output files MakeInputOutput(file.DirectoryName); //set runtime limit long timelim = LocalDatabase.GetProblem(SelectedPNUM).rtl; timeLimitCombo.Text = (timelim / 1000.0).ToString("F2"); }