private void _ErrorGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { int fileLine = int.Parse(_ErrorGrid.Rows[e.RowIndex].Cells["Line"].Value.ToString()); try { string fileName = _ErrorGrid.Rows[e.RowIndex].Cells["File"].Value.ToString(); DocTabPage tab = GetTabByFilename(fileName, true); if (tab != null) { tab.CodeEditor.GotoLine(fileLine - 1); tab.CodeEditor.HighLightActiveLine = true; tab.CodeEditor.HighLightedLineColor = Color.FromArgb(255, 230, 230); tab.CodeEditor.Focus(); _TabDocs.SelectedTab = tab; } } catch { } } }
bool SaveTab(DocTabPage tabToSave) { try { if (tabToSave != null) { if (tabToSave.CodeEditor.FileName == null || tabToSave.CodeEditor.FileName == "") { string fileName = NewSaveFileName(tabToSave.Text); if (fileName != "") { SaveTabAs(tabToSave, fileName); } } else { tabToSave.CodeEditor.Save(); } return(tabToSave.CodeEditor.Saved); } } catch (Exception ex) { MessageBox.Show("Failed to save the file: " + ex.Message); } return(false); }
public frmExport(DocTabPage docTabPage) { InitializeComponent(); _DocTabPage = docTabPage; if (docTabPage.CodeEditor.FileName != null && docTabPage.CodeEditor.FileName.Trim().Length > 0) { txtExportLocation.Text = Path.GetDirectoryName(docTabPage.CodeEditor.FileName) + "\\" + Path.GetFileNameWithoutExtension(docTabPage.CodeEditor.FileName) + ".htm"; } else { txtExportLocation.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + Path.GetFileNameWithoutExtension(_DocTabPage.Text) + ".htm"; } txtExportLocation.Text = RemoveExcessBackslashes(txtExportLocation.Text); txtRelativeImageURI.Text = global.GetRegistryString("IDE", "LastExportImagesURI"); if (txtRelativeImageURI.Text.Trim().Length == 0) { txtRelativeImageURI.Text = "/images"; } }
bool SaveTabAs(DocTabPage tabToSave, string newFileName) { if (tabToSave != null) { tabToSave.CodeEditor.Save(newFileName); tabToSave.Text = System.IO.Path.GetFileName(newFileName); } return(tabToSave.CodeEditor.Saved); }
void SetUserDefinedTabOptions(DocTabPage tabPage) { tabPage.CodeEditor.ShowLineNumbers = _IDEOptions.ShowLineNumbers; tabPage.CodeEditor.ShowGutterMargin = _IDEOptions.ShowGutterMargin; tabPage.CodeEditor.ShowEOLMarker = _IDEOptions.ShowEOLMarker; tabPage.CodeEditor.ShowWhitespace = _IDEOptions.ShowWhitespace; tabPage.CodeEditor.ShowScopeIndicator = _IDEOptions.ShowScopeIndicator; tabPage.CodeEditor.BracketMatching = _IDEOptions.BracketMatching; tabPage.CodeEditor.Document.Folding = _IDEOptions.EnableCodeFolding; tabPage.CodeEditor.AllowDrop = false; }
void SetTabImage(DocTabPage tab) { if (tab.CodeEditor.Document.Modified) { tab.ImageKey = "Modified"; } else { tab.ImageKey = "Saved"; } }
private void libraryToolStripMenuItem_Click(object sender, EventArgs e) { string filePath = global.GetRegistryString("", "Path"); frmCodeBrowser form = new frmCodeBrowser(filePath + "\\Library", false, "Standard Library", "This is the Simple Scriping Engine standard abstraction library. These scripts can be included into your projects " + " to provide a seamless interface between the standard windows API and the scripting engine."); if (form.ShowDialog() == DialogResult.OK) { DocTabPage tabPage = AddNewTab(form.Filename); } }
private void examplesToolStripMenuItem_Click(object sender, EventArgs e) { string filePath = global.GetRegistryString("", "Path"); frmCodeBrowser form = new frmCodeBrowser(filePath + "\\IDE\\Examples", false, "Examples", "These are functionality examples and can be used to learn, study and save large portions of code."); if (form.ShowDialog() == DialogResult.OK) { DocTabPage tabPage = AddNewTab(); tabPage.CodeEditor.Document.Text = form.CodeText; } }
bool CloseTab(DocTabPage tabToClose) { if (tabToClose != null) { if (_RunningApplication.IsRunning) { DialogResult result = MessageBox.Show("An application is currently being debugged.\r\nWould you like to stop it?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == System.Windows.Forms.DialogResult.Yes) { Debug_Stop(); } else { return(false); //Cant close the tab while it is running. } } if (tabToClose.CodeEditor.Saved == false) { DialogResult msgResult = MessageBox.Show("File [" + tabToClose.Text + "] is modified. Save changes?", "Save Changed File?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); if (msgResult == System.Windows.Forms.DialogResult.Yes) { if (!SaveTab(tabToClose)) { return(false); } } else if (msgResult == System.Windows.Forms.DialogResult.Cancel) { return(false); } } this._OutputSplitter.Panel1.Controls.Remove(tabToClose.CodeEditor); _TabDocs.TabPages.Remove(tabToClose); tabToClose.CodeEditor.AutoListVisible = false; return(true); } return(true); }
void _FilesGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { try { string fileName = _FilesGrid.Rows[e.RowIndex].Cells["Name"].Value.ToString(); DocTabPage tab = GetTabByFilename(fileName, true); if (tab != null) { tab.CodeEditor.Focus(); _TabDocs.SelectedTab = tab; } } catch { } } }
private void _ProjectTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (!IsProjectOpen()) { return; } ProjectTreeNode node = (ProjectTreeNode)e.Node; if (node.NodeType == ProjectTreeNode.NodeTypes.CodeFile || node.NodeType == ProjectTreeNode.NodeTypes.CodeFileDefault || node.NodeType == ProjectTreeNode.NodeTypes.BatchFile || node.NodeType == ProjectTreeNode.NodeTypes.JavaScript || node.NodeType == ProjectTreeNode.NodeTypes.StyleFile || node.NodeType == ProjectTreeNode.NodeTypes.TextFile || node.NodeType == ProjectTreeNode.NodeTypes.XMLFile || node.NodeType == ProjectTreeNode.NodeTypes.HTMLFile) { string fileLineage = (Path.GetDirectoryName(ProjectFileName) + "\\" + ((ProjectTreeNode)e.Node).FileLineage()).Replace("\\\\", "\\"); if (System.IO.File.Exists(fileLineage)) { DocTabPage docTabPage = GetTabByFilename(fileLineage); if (docTabPage != null) { docTabPage.CodeEditor.Focus(); _TabDocs.SelectedTab = docTabPage; } else { AddNewTab(fileLineage); } } else { MessageBox.Show("This file does not exist or cannot be found: \"" + fileLineage + "\"."); } } }
private void Run_Menu_Click(object sender, EventArgs e) { ProjectTreeNode projectNode = FindDefaultRunProjectFile(); if (projectNode != null) { string defaultRunFileName = projectNode.LogicalPath(); DocTabPage defaultTab = GetTabByFilename(defaultRunFileName); if (defaultTab == null) { defaultTab = AddNewTab(defaultRunFileName); } if (defaultTab != null) { defaultTab.CodeEditor.Focus(); _TabDocs.SelectedTab = defaultTab; } } Debug_Start(CurrentTab); }
void CodeEditorTabs_ToolStripItemClickedEventHandler(object sender, ToolStripItemClickedEventArgs e) { ContextMenuStrip senderMenu = (ContextMenuStrip)sender; DocTabPage tab = (DocTabPage)senderMenu.Tag; if (e.ClickedItem.Text == "Explore to") { try { if (tab.CodeEditor.FileName != string.Empty && tab.CodeEditor.FileName != null) { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.UseShellExecute = true; process.StartInfo.FileName = "explorer"; process.StartInfo.Arguments = Path.GetDirectoryName(tab.CodeEditor.FileName); process.Start(); } } catch { } } else if (e.ClickedItem.Text == "Close") { CloseTab(tab); } else if (e.ClickedItem.Text == "Close all but this") { foreach (DocTabPage tabPage in _TabDocs.TabPages) { if (tabPage != tab) { CloseTab(tabPage); } } } }
bool CloseAffectedProjectTabs(ProjectTreeNode node) { string nodePath = node.LogicalPath(); if (node.BasicNodeType == ProjectTreeNode.BasicNodeTypes.File) { DocTabPage docTabPag = GetTabByFilename(nodePath); if (docTabPag != null) { return(CloseTab(docTabPag)); } } else if (node.BasicNodeType == ProjectTreeNode.BasicNodeTypes.Folder) { for (int tabIndex = 0; tabIndex < _TabDocs.TabPages.Count; tabIndex++) { DocTabPage tabPage = (DocTabPage)_TabDocs.TabPages[tabIndex]; if (tabPage.CodeEditor.FileName != null && tabPage.CodeEditor.FileName.ToLower().StartsWith(nodePath.ToLower())) { if (!CloseTab(tabPage)) { return(false); } } else if (tabPage.TempFileName != null && tabPage.TempFileName.ToLower().StartsWith(nodePath.ToLower())) { if (!CloseTab(tabPage)) { return(false); } } } } return(true); }
void ShowTabEditor(DocTabPage tabToShow) { if (CurrentTab != null) { CurrentTab.CodeEditor.AutoListVisible = false; } if (tabToShow != null) { foreach (DocTabPage tab in _TabDocs.TabPages) { if (tab == tabToShow) { tab.CodeEditor.Visible = true; } else { tab.CodeEditor.Visible = false; } } tabToShow.CodeEditor.Focus(); } }
void Debug_Start(DocTabPage currentTab) { lock (this) { if (currentTab == null) { return; } if (_RunningApplication.IsRunning) { //Code is already running but the run icon was enabled... must be a debug continue. Debug_Break_Continue(); return; } _RunningApplication = new RunningApplication(); _RunningApplication.OriginalTab = currentTab; _RunningApplication.Form = this; _RunningApplication.InstanceId = "IDE_" + Guid.NewGuid().ToString(); _RunningApplication.IsRunning = true; _RunningApplication.WasAttach = false; _RunningApplication.AttachProcessId = 0; _RunningApplication.pAddErrorToList = AddErrorToList; _RunningApplication.pAddOutputToList = AddOutputToList; _RunningApplication.pExecutionBegin = ExecutionBegin; _RunningApplication.pExecutionComplete = ExecutionComplete; _RunningApplication.pBreakPointHit = BreakPointHit; _RunningApplication.pUpdateWatchValue = UpdateWatchValue; _RunningApplication.pQuickWatchInfo = QuickWatchInfo; _RunningApplication.pAddImmediateInfo = AddImmediateInfo; _RunningApplication.pUpdateLocalsValue = UpdateLocalsValue; _RunningApplication.pAddFileToGrid = AddFileToGrid; _RunningApplication.pAutosizeFileGrid = AutosizeFileGrid; _RunningApplication.pClearFilesGrid = ClearFilesGrid; _RunningApplication.pRemoveNonUpdatedLocals = RemoveNonUpdatedLocals; _RunningApplication.pToolTipSymbolInfo = ToolTipSymbolInfo; _RunningApplication.pImmediateAutoListBegin = ImmediateAutoListBegin; _RunningApplication.pImmediateAutoListEnd = ImmediateAutoListEnd; _RunningApplication.pImmediateAutoListAddWord = ImmediateAutoListAddWord; DeleteAllSystemAddedWatchValues(); SetIconsRunning(); if (currentTab != null) { _ErrorGrid.Rows.Clear(); if (_OutputSplitter.Panel2Collapsed) { _OutputSplitter.Panel2Collapsed = false; } _OutputBox.Text = ""; bool isTempFile = false; string scriptFileName = ""; if (currentTab.CodeEditor.FileName == "" || currentTab.CodeEditor.FileName == null) { string tabText = currentTab.Text; System.Random rand = new System.Random(); Double randomValue = rand.NextDouble() * 1234.0; scriptFileName = System.IO.Path.GetTempPath() + "\\Script_" + randomValue + global.CodeFileExtension; scriptFileName = scriptFileName.Replace("/", "\\"); scriptFileName = scriptFileName.Replace("\\\\", "\\"); currentTab.CodeEditor.Save(scriptFileName); currentTab.Text = tabText; isTempFile = true; } else { scriptFileName = currentTab.CodeEditor.FileName; if (!SaveTab(currentTab)) { _RunningApplication.IsRunning = false; SetIconsStopped(); return; } } _RunningApplication.Engine = global.GetRegistryString("", "Engine"); _RunningApplication.Script = scriptFileName; if (isTempFile) { currentTab.TempFileName = scriptFileName; } else { currentTab.TempFileName = null; } if (_RunningApplication.Engine != "" && _RunningApplication.Engine != null) { if (System.IO.File.Exists(_RunningApplication.Engine)) { _RunningApplication.ProcessMonitorThread = new System.Threading.Thread(ProcessMonitorThread); _RunningApplication.ProcessMonitorThread.Start(); } else { MessageBox.Show("Cannot find the scripting engine. Is it installed?"); } } else { MessageBox.Show("Cannot find the scripting engine. Is it installed?"); } } //Somthing went wrong if the thread was not started, reset everyting back to a non-running state. if (_RunningApplication.ProcessMonitorThread == null) { _RunningApplication.IsRunning = false; SetIconsStopped(); _RunningApplication.Form.Invoke(_RunningApplication.pExecutionComplete); } } }
public DocTabPage AddNewTab(string fileName) { if (CurrentTab != null) { CurrentTab.CodeEditor.AutoListVisible = false; } string tabText = string.Empty; DocTabPage tabPage = new DocTabPage(); _TabDocs.TabPages.Add(tabPage); string syntaxHighlighter = null; if (fileName != null) { string fileExtension = Path.GetExtension(fileName).ToLower(); if (fileExtension == global.CodeFileExtension) { syntaxHighlighter = "SSE"; } else if (fileExtension == ".html" || fileExtension == ".htm" || fileExtension == ".shtml" || fileExtension == ".ssi") { syntaxHighlighter = "HTML"; } else if (fileExtension == ".css") { syntaxHighlighter = "CSS"; } else if (fileExtension == ".js") { syntaxHighlighter = "JavaScript"; } else if (fileExtension == ".xml" || fileExtension == ".xsl") { syntaxHighlighter = "XML"; } else if (fileExtension == ".bat") { syntaxHighlighter = "BatchFile"; } else if (fileExtension == ".txt") { syntaxHighlighter = "TextFile"; } tabText = fileName.Substring(fileName.LastIndexOf("\\") + 1); } else { syntaxHighlighter = "SSE"; tabText = "Untitled " + ++_CreateCount; } CodeEditor codeEditor = new CodeEditor(this, tabPage, tabText); _OutputSplitter.Panel1.Controls.Add(codeEditor); codeEditor.Dock = DockStyle.Fill; tabPage.CodeEditor = codeEditor; if (syntaxHighlighter != null) { tabPage.CodeEditor.SetSyntaxHighlighter(syntaxHighlighter); } _TabDocs.SelectedTab = tabPage; SetUserDefinedTabOptions(tabPage); tabPage.CodeEditor.Document.BreakPointAdded += new NTDLS.Syntax.RowEventHandler(Document_BreakPointAdded); tabPage.CodeEditor.Document.BreakPointRemoved += new NTDLS.Syntax.RowEventHandler(Document_BreakPointRemoved); tabPage.CodeEditor.RowMouseUp += new NTDLS.Windows.Forms.CodeEditor.RowMouseHandler(CodeEditor_RowMouseUp); tabPage.CodeEditor.DragDrop += new System.Windows.Forms.DragEventHandler(this.frmMain_DragDrop); tabPage.CodeEditor.DragEnter += new System.Windows.Forms.DragEventHandler(this.frmMain_DragEnter); tabPage.CodeEditor.KeyUp += new KeyEventHandler(CodeEditor_KeyUp); tabPage.CodeEditor.Leave += new EventHandler(tabPage_Leave); tabPage.CodeEditor.MouseDown += new MouseEventHandler(CodeEditor_MouseDown); tabPage.CodeEditor.FindReplaceTextNotFound += new NTDLS.Windows.Forms.CodeEditor.FindReplaceTextNotFoundHandler(CodeEditor_FindReplaceTextNotFound); tabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.frmMain_DragDrop); tabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.frmMain_DragEnter); tabPage.CodeEditor.Document.ModifiedChanged += new EventHandler(Document_ModifiedChanged); tabPage.CodeEditor.ScrollIntoView(0); tabPage.CodeEditor.Caret.Position.X = _IDEOptions.DefaultCaretX; tabPage.CodeEditor.Caret.Position.Y = _IDEOptions.DefaultCaretY; tabPage.CodeEditor.Saved = true; tabPage.CodeEditor.ReadOnly = _RunningApplication.IsRunning; tabPage.CodeEditor.CopyAsRTF = true; if (fileName != null) { tabText = fileName.Substring(fileName.LastIndexOf("\\") + 1); try { tabPage.CodeEditor.Open(fileName); } catch { tabPage.CodeEditor.FileName = fileName; } } else { tabPage.CodeEditor.Document.Text = _IDEOptions.DefaultText; tabPage.CodeEditor.Saved = true; } try { Application.DoEvents(); } catch { } return(tabPage); }