예제 #1
0
        protected virtual bool TerminateDocument()
        {
            try
            {
                ContentChanged  = null;
                DiskFileChanged = null;
                ModifiedChanged = null;
                ReadOnlyChanged = null;
                _fileWatcher.Dispose();

                if (this.DockContent != null)
                {
                    this.DockContent.Close();
                }

                _terminated = true;
                RaiseDocumentTerminatedEvent();
                DocumentTerminated = null;
            }
            catch (Exception e)
            {
                string msg = string.Format("Error while closing document '{0}': {1}", this.FileName, e.Message);
                FrameworkManager.ShowMessageBox(msg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
예제 #2
0
        public override RPCCommand DoCommand()
        {
            // Open the document and break at the current line
            if (File.Exists(this.FileName))
            {
                DocumentsManager.Instance.OpenDocument(this.FileName, false);
            }

            string errFormatStr = string.Empty;
            string errMsg       = string.Empty;

            switch ((ErrorTypes)Enum.ToObject(typeof(ErrorTypes), this.ErrorType))
            {
            case ErrorTypes.SyntaxError: errFormatStr = "Syntax Error at line {0}: {1}"; break;

            case ErrorTypes.RuntimeError: errFormatStr = "Runtime Error at line {0}: {1}"; break;

            case ErrorTypes.MemoryError: errFormatStr = "Memory Error: {0}"; break;

            case ErrorTypes.Unhandled: errFormatStr = "Unhandled Error at line {0}: {1}"; break;
            }

            FrameworkManager.Instance.FlashMainDialog();

            if ((ErrorTypes)this.ErrorType == ErrorTypes.MemoryError)
            {
                errMsg = string.Format(errFormatStr, this.Message);
                FrameworkManager.ShowMessageBox(errMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if ((ErrorTypes)this.ErrorType == ErrorTypes.Unhandled)
            {
                errMsg = string.Format(errFormatStr, this.Line, this.Message);
                FrameworkManager.ShowMessageBox(errMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                errMsg = string.Format(errFormatStr, this.Line, this.Message);
                DialogResult dr = FrameworkManager.ShowMessageBox(errMsg, MessageBoxButtons.AbortRetryIgnore,
                                                                  MessageBoxIcon.Error);
                DebugAction debugAction = DebugAction.None;

                switch (dr)
                {
                case DialogResult.Retry: debugAction = DebugAction.Break; break;

                case DialogResult.Abort: debugAction = DebugAction.Stop; break;

                case DialogResult.Ignore: debugAction = DebugAction.Continue; break;
                }

                return(new DebugActionCommand(debugAction));
            }

            return(null);
        }
예제 #3
0
        public void DeleteAllBreakpoints()
        {
            if (FrameworkManager.ShowMessageBox("Do you want to delete all breakpoints?",
                                                MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Question) == DialogResult.Yes)
            {
                foreach (string fileName in _breakpoints.Keys)
                {
                    foreach (Breakpoint bp in _breakpoints[fileName].Values)
                    {
                        bp.BreakpointChanged -= OnBreakpointChanged;

                        if (BreakpointRemoved != null)
                        {
                            BreakpointRemoved(this, bp);
                        }
                    }

                    _breakpoints[fileName].Clear();
                }

                _breakpoints.Clear();
            }
        }
예제 #4
0
        private void solutionExplorerTreeView_ItemAfterEdit(object sender, TreeListViewAfterEditEventArgs e)
        {
            ILuaEditDocument doc = e.Item.Tag as ILuaEditDocument;

            if (doc == null)
            {
                e.Cancel = true;
            }
            else
            {
                bool isDir = false;

                try
                {
                    isDir = (File.GetAttributes(doc.FileName) & FileAttributes.Directory) == FileAttributes.Directory;
                }
                catch (Exception ex)
                {
                    string msg = string.Format("Error while trying to rename '{0}': {1}", doc.FileName, ex.Message);
                    FrameworkManager.ShowMessageBox(msg, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true;
                    return;
                }

                try
                {
                    string newFileName = null;

                    if (isDir)
                    {
                        newFileName = Path.Combine(Directory.GetParent(doc.FileName).FullName, e.NewValue);
                    }
                    else
                    {
                        if (e.Item.Tag is ILuaEditDocumentProject || e.Item.Tag is ILuaEditDocumentSolution)
                        {
                            newFileName = Path.Combine(Path.GetDirectoryName(doc.FileName), e.NewValue + Path.GetExtension(doc.FileName));
                        }
                        else
                        {
                            newFileName = Path.Combine(Path.GetDirectoryName(doc.FileName), e.NewValue);
                        }
                    }

                    if (newFileName != doc.FileName)
                    {
                        DocumentsManager.Instance.RenameDocument(doc, newFileName);

                        if (e.Item != null)
                        {
                            e.Item.ToolTip = doc.FileName;
                        }
                    }
                }
                catch (Exception ex)
                {
                    e.Cancel = true;
                    FrameworkManager.ShowMessageBox(ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #5
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (solutionExplorerTreeView.SelectedItems.Count > 0)
            {
                string confirmMsg = string.Empty;

                if (removeToolStripMenuItem.Text == "Remove")
                {
                    if (solutionExplorerTreeView.SelectedItems.Count == 1)
                    {
                        ILuaEditDocument doc = solutionExplorerTreeView.SelectedItems[0].Tag as ILuaEditDocument;
                        confirmMsg = string.Format("'{0}' will be removed.", doc);
                    }
                    else
                    {
                        confirmMsg = "The selected items will be removed.";
                    }

                    if (!string.IsNullOrEmpty(confirmMsg) &&
                        FrameworkManager.ShowMessageBox(confirmMsg, MessageBoxButtons.OKCancel,
                                                        MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        TreeListViewItem[] selectedItems = new TreeListViewItem[0];
                        Array.Resize <TreeListViewItem>(ref selectedItems, solutionExplorerTreeView.SelectedItems.Count);
                        solutionExplorerTreeView.SelectedItems.CopyTo(selectedItems, 0);

                        foreach (TreeListViewItem tlvi in selectedItems)
                        {
                            ILuaEditDocumentProject prjDoc = tlvi.Tag as ILuaEditDocumentProject;

                            if (prjDoc != null && prjDoc.ParentDocument != null)
                            {
                                if (DocumentsManager.Instance.CloseDocument(prjDoc))
                                {
                                    prjDoc.ParentDocument.RemoveDocument(prjDoc);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (solutionExplorerTreeView.SelectedItems.Count == 1)
                    {
                        ILuaEditDocument doc = solutionExplorerTreeView.SelectedItems[0].Tag as ILuaEditDocument;

                        if (doc != null && doc is ILuaEditDocumentFolder)
                        {
                            confirmMsg = string.Format("'{0}' and all its content will be deleted permanently.", doc);
                        }
                        else
                        {
                            confirmMsg = string.Format("'{0}' will be deleted permanently.", doc);
                        }
                    }
                    else
                    {
                        confirmMsg = "The selected items will be deleted permanently.";
                    }

                    if (!string.IsNullOrEmpty(confirmMsg) &&
                        FrameworkManager.ShowMessageBox(confirmMsg, MessageBoxButtons.OKCancel,
                                                        MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        TreeListViewItem[] selectedItems = new TreeListViewItem[0];
                        Array.Resize <TreeListViewItem>(ref selectedItems, solutionExplorerTreeView.SelectedItems.Count);
                        solutionExplorerTreeView.SelectedItems.CopyTo(selectedItems, 0);

                        foreach (TreeListViewItem tlvi in selectedItems)
                        {
                            ILuaEditDocument doc = tlvi.Tag as ILuaEditDocument;
                            DocumentsManager.Instance.DeleteDocument(doc);
                        }
                    }
                }
            }
        }