public void AddFile(String FilePath, String FileContent, String fileName, Language l) { SaveCurrTab(); MMTabItem ti = new MMTabItem { Header = fileName, filePath = FilePath, rtf = FileContent, fileName = fileName, unSavedChanges = false, fileLanguage = l }; tabs.Add(ti); TabBar.Items.Add(ti); CurrentFilePath = FilePath; CurrIndex = tabs.IndexOf(ti); bNewFile = true; if (!TextField.IsEnabled) { TextField.IsEnabled = true; } ti.IsSelected = true; }
private void RunClick(object sender, RoutedEventArgs e) { if (TabBar.HasItems) { MMTabItem ti = TabBar.SelectedItem as MMTabItem; string currDirectory = System.IO.Path.GetDirectoryName(ti.filePath); SaveCurrTab(); SaveFile(ti.filePath, ti.rtf, TabBar.SelectedIndex); switch (ti.fileLanguage) { case The_Learning_IDE.Language.Python: case The_Learning_IDE.Language.Ruby: string strCmdText = $"/K cd {currDirectory} && {ti.fileName}"; System.Diagnostics.Process.Start("CMD.exe", strCmdText); break; case The_Learning_IDE.Language.Java: string fileNameNoJava = System.IO.Path.GetFileNameWithoutExtension(ti.fileName); string javaText = $"/K cd {currDirectory} && javac {ti.fileName} && java {fileNameNoJava}"; System.Diagnostics.Process.Start("CMD.exe", javaText); break; case The_Learning_IDE.Language.JavaScript: JavaScript js = new JavaScript(); js.Show(); break; case The_Learning_IDE.Language.Csharp: string fileNameNoCS = System.IO.Path.GetFileNameWithoutExtension(ti.fileName); string csText = $"/K cd {currDirectory} && csc {ti.fileName} && {fileNameNoCS}.exe"; System.Diagnostics.Process.Start("CMD.exe", csText); break; default: Debug.WriteLine($"Error language {ti.fileLanguage} {ti.filePath}"); break; } } }