public void CreateTabOpenFile(string fileToOpen) { var fileParts = fileToOpen.Split('\\'); var tabText = fileParts[fileParts.Count() - 1]; MainTabControl.TabPages.Add(new TabPage(tabText) { Name = fileToOpen }); MainTabControl.SuspendLayout(); MainTabControl.TabPages[fileToOpen].Controls.Add(DashGlobal.EditorHelper.CreateEditor(fileToOpen)); MainTabControl.ResumeLayout(); MainTabControl.SelectTab(fileToOpen); DashGlobal.SetWindowTitle(fileToOpen); Main.Lang = DashGlobal.FilesHelper.GetLangFromFile(fileToOpen); DashGlobal.EditorHelper.ActiveEditor.OpenFile(fileToOpen); MainTabControl.TabPages[fileToOpen].Tag = new FileInfo() { Dirty = false, CrcHash = "TODO" }; DashGlobal.EditorHelper.PerformSyntaxHighlighting(null, Main.Lang, true); }
public void CreateNewTab(string FileName, ProjectFile projectFile = null, bool PopulateTreeView = false) { if (!MainTabControl.TabPages.ContainsKey(FileName)) { MainTabControl.TabPages.Add(new TabPage(FileName) { Name = FileName, Tag = projectFile }); MainTabControl.SuspendLayout(); bool add = true; FastColoredTextBox workspace = FrostbyteCore.Workspace.CreateWorkspace(); if (projectFile != null) { try { workspace.Text = File.ReadAllText(projectFile.GetLocation(FrostbyteCore.MainForm.project)); add = workspace.Text.Length == 0; new Syntax(workspace, projectFile.getFileType()); } catch { } } else { new Syntax(workspace, FileType.UNKNOWN); } if (add && Properties.Settings.Default.TopFileComment.Length > 0) { string comment = Properties.Settings.Default.TopFileComment; ProjectMeta meta = new ProjectMeta(FrostbyteCore.MainForm.project, FileName); foreach (string replace in meta.variables.Keys) { comment = comment.Replace(replace, meta.variables[replace]); } workspace.Text = comment + '\n' + workspace.Text; } MainTabControl.TabPages[FileName].Controls.Add(workspace); MainTabControl.ResumeLayout(); MainTabControl.SelectTab(FileName); } else { MainTabControl.SelectedTab = MainTabControl.TabPages[FileName]; } FrostbyteCore.MainForm.toolStripStatusLabel1.Text = FrostbyteCore.Tabs.MainTabControl.SelectedTab.Name; FrostbyteCore.MainForm.toolStripStatusLabel2.Text = "Current Length: " + FrostbyteCore.Workspace.GetActiveWorkspace().Text.Length.ToString(); if (PopulateTreeView) { FrostbyteCore.TreeViewer.PopulateTreeView(); } }
public void CreateBlankTab(FileType fileType = FileType.Sqf, string filename = "New File") { var cleanName = filename + MainTabControl.TabPages.Count; MainTabControl.TabPages.Add(new TabPage(filename) { Name = cleanName }); MainTabControl.SuspendLayout(); MainTabControl.TabPages[cleanName].Controls.Add(DashGlobal.EditorHelper.CreateEditor()); MainTabControl.TabPages[cleanName].Tag = new FileInfo() { Dirty = false }; MainTabControl.ResumeLayout(); MainTabControl.SelectTab(cleanName); }