private void excludeFromProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (solutionExplorerTreeView.SelectedItems.Count > 0)
            {
                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;

                    if (doc != null && doc.ParentDocument != null)
                    {
                        ILuaEditDocument currentDoc = doc;

                        while (!(currentDoc.ParentDocument is ILuaEditDocumentProject))
                        {
                            currentDoc = currentDoc.ParentDocument;
                        }

                        doc.ParentDocument.RemoveDocument(doc);
                    }
                }
            }
        }
Exemple #2
0
 private void AddItemRecursively(ILuaEditDocument doc, int level)
 {
     if (doc.IsModified)
     {
         lstItems.Items.Add(new CloseDialogItem(doc, level));
     }
 }
Exemple #3
0
        protected override bool TerminateDocument()
        {
            try
            {
                _terminating = true;

                while (_documentGroups.Count > 0)
                {
                    ILuaEditDocumentGroup childDocGrp = _documentGroups[_documentGroups.Count - 1];
                    RemoveDocument(childDocGrp);
                }

                while (_documents.Count > 0)
                {
                    ILuaEditDocument childDoc = _documents[_documents.Count - 1];
                    RemoveDocument(childDoc);
                }

                return(base.TerminateDocument());
            }
            finally
            {
                _terminating = false;
            }
        }
        public void Initialize(string initialText, ILuaEditDocument currentDoc)
        {
            if (_canInitialize)
            {
                _currentDoc = currentDoc;
                string currentLookIn = cboLookIn.Text;
                cboLookIn.Items.Clear();
                btnExpressionBuilder.Enabled = chkUseRegEx.Checked;

                if (_currentDoc is ILuaEditDocumentEditable)
                {
                    cboLookIn.Items.Add(CurrentDocumentString);
                }

                if (DocumentsManager.Instance.CurrentSolution != null && DocumentsManager.Instance.CurrentSolution.ActiveProject != null)
                {
                    cboLookIn.Items.Add(CurrentProjectString);
                }

                if (DocumentsManager.Instance.OpenedDocuments.Count > 0)
                {
                    cboLookIn.Items.Add(AllOpenDocumentsString);
                }

                if (cboLookIn.Items.Count > 0)
                {
                    if (currentLookIn == string.Empty && cboLookIn.Items.IndexOf(currentLookIn) >= 0)
                    {
                        cboLookIn.Text = currentLookIn;
                    }
                    else
                    {
                        cboLookIn.SelectedIndex = 0;
                    }
                }

                if (initialText == string.Empty)
                {
                    if (cboFindWhat.Text == string.Empty)
                    {
                        if (cboFindWhat.Items.Count > 0)
                        {
                            cboFindWhat.SelectedIndex = 0;
                        }
                        else
                        {
                            cboFindWhat.Text = string.Empty;
                        }
                    }
                }
                else
                {
                    cboFindWhat.Text = initialText;
                }

                ValidateButtons();
                cboFindWhat.Focus();
            }
        }
 public DebugInfo(IPAddress serverIP, int serverPort, string remotePath, List <ILuaEditDocument> scripts,
                  ILuaEditDocument startupDoc, DebugStartAction startAction) :
     this(serverIP, serverPort, startAction)
 {
     _remotePath = remotePath;
     _scripts    = scripts;
     _startupDoc = startupDoc;
 }
Exemple #6
0
        private bool FilterDocument(ILuaEditDocument doc)
        {
            if (string.IsNullOrEmpty(txtFilter.Text))
            {
                return(false);
            }

            return(doc.FileName.IndexOf(txtFilter.Text, StringComparison.OrdinalIgnoreCase) < 0);
        }
Exemple #7
0
        internal void FromXml(XmlLuaGroupDocumentBase objectToDeserialize)
        {
            // Deserialize sub-documents
            if (objectToDeserialize.Documents != null)
            {
                foreach (DocumentRef refDoc in objectToDeserialize.Documents)
                {
                    refDoc.FileName = Win32Utils.GetAbsolutePath(refDoc.FileName, _fileName);
                    ILuaEditDocument doc = DocumentsManager.Instance.BaseOpenDocument(refDoc);

                    if (doc != null)
                    {
                        this.AddDocument(doc);
                    }
                }
            }

            // Deserialize sub-folders
            if (objectToDeserialize.DocumentFolders != null)
            {
                foreach (XmlDocumentFolder xmlFolder in objectToDeserialize.DocumentFolders)
                {
                    DocumentFolder folderDoc = new DocumentFolder();
                    folderDoc.ParentDocument = this;
                    folderDoc.FromXml(xmlFolder);

                    if (folderDoc != null)
                    {
                        this.AddDocument(folderDoc as ILuaEditDocumentFolder);
                    }
                }
            }

            // Deserialize sub-group documents
            if (objectToDeserialize.DocumentGroups != null)
            {
                foreach (DocumentRef refDoc in objectToDeserialize.DocumentGroups)
                {
                    refDoc.FileName = Win32Utils.GetAbsolutePath(refDoc.FileName, _fileName);
                    ILuaEditDocumentGroup docGrp = DocumentsManager.Instance.BaseOpenDocument(refDoc) as ILuaEditDocumentGroup;

                    if (docGrp != null)
                    {
                        this.AddDocument(docGrp);
                    }
                }
            }
        }
Exemple #8
0
        public virtual void RemoveDocument(ILuaEditDocument doc)
        {
            doc.ParentDocument  = null;
            doc.ReferenceCount -= this;
            _documents.Remove(doc);

            if (!_terminating)
            {
                IsModified = true;

                if (DocumentRemoved != null)
                {
                    DocumentRemoved(this, new DocGroupDocActionEventArgs(doc));
                }
            }
        }
        public Breakpoint GetBreakpointAtLine(string fileName, int line)
        {
            if (_breakpoints.ContainsKey(fileName))
            {
                ILuaEditDocument         doc         = DocumentsManager.Instance.OpenDocument(fileName, false);
                ILuaEditDocumentEditable editableDoc = doc as ILuaEditDocumentEditable;
                Row row = editableDoc.Document.LineToRow(line);

                if (editableDoc != null && row != null && _breakpoints[fileName].ContainsKey(row))
                {
                    return(_breakpoints[fileName][row]);
                }
            }

            return(null);
        }
Exemple #10
0
        private TreeListViewItem FunctionCallToTreeListViewItem(LuaCall call)
        {
            // Create main item with name
            TreeListViewItem tlvi = new TreeListViewItem(string.Empty);

            tlvi.Tag       = call;
            tlvi.ForeColor = call.FunctionSource != "Lua" ? Color.LightGray : Color.Black;

            // Create subitem with name
            TreeListViewSubItem tlvsi = new TreeListViewSubItem(0);

            if (call.IsLineCall)
            {
                ILuaEditDocument doc = DocumentsManager.Instance.OpenDocument(call.FileName, false);

                if (doc is LuaScriptDocument)
                {
                    LuaScriptDocument luaDoc = doc as LuaScriptDocument;

                    if (call.FunctionLineCall < luaDoc.Document.Lines.Length)
                    {
                        tlvsi.Object = string.Format("{0}  Line {1}", luaDoc.Document.Lines[call.FunctionLineCall - 1].TrimStart(new char[] { ' ', '\t' }), call.FunctionLineCall);
                    }
                }
            }
            else
            {
                if (call.FunctionName == "[EntryPoint]")
                {
                    tlvsi.Object = call.FunctionName;
                }
                else
                {
                    tlvsi.Object = string.Format("{0}({1})  Line {2}", call.FunctionName, call.ParamString, call.FunctionLineCall);
                }
            }

            tlvi.SubItems.Add(tlvsi);

            // Create subitem with language
            tlvi.SubItems.Add(new TreeListViewSubItem(1, call.FunctionSource));

            // Create subitem with filename
            tlvi.SubItems.Add(new TreeListViewSubItem(2, call.FileName));

            return(tlvi);
        }
Exemple #11
0
        public virtual void AddDocument(ILuaEditDocument doc)
        {
            if (_opening || FindDocument(doc.FileName) == null)
            {
                doc.ParentDocument  = this;
                doc.ReferenceCount += this;
                _documents.Add(doc);

                if (!_opening)
                {
                    IsModified = true;

                    if (DocumentAdded != null)
                    {
                        DocumentAdded(this, new DocGroupDocActionEventArgs(doc));
                    }
                }
            }
        }
        /// <summary>
        /// Find the node associated with the specified document
        /// </summary>
        /// <param name="root">The node from which to start searching</param>
        /// <param name="doc">The document to search for</param>
        /// <param name="result">A null initialized node that will get filled by the search</param>
        private void FindTreeListViewItemByDocument(TreeListViewItem root, ILuaEditDocument doc, ref TreeListViewItem result)
        {
            if (root.Tag == doc)
            {
                result = root;
            }

            if (result == null)
            {
                foreach (TreeListViewItem childItem in root.Items)
                {
                    FindTreeListViewItemByDocument(childItem, doc, ref result);

                    if (result != null)
                    {
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Occurs when a double click is performed in the tree
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void solutionExplorerTreeView_DoubleClick(object sender, EventArgs e)
        {
            if (solutionExplorerTreeView.SelectedItems.Count > 0)
            {
                ILuaEditDocument luaDoc = solutionExplorerTreeView.SelectedItems[0].Tag as ILuaEditDocument;

                if (luaDoc != null && !solutionExplorerTreeView.SelectedItems[0].HasChildren)
                {
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        DocumentsManager.Instance.OpenDocument((luaDoc).DocumentRef, false);
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                    }
                }
            }
        }
        /// <summary>
        /// Occurs when a document gets added to a group document
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDocumentAdded(object sender, DocGroupDocActionEventArgs e)
        {
            TreeListViewItem result = null;
            ILuaEditDocument doc    = sender as ILuaEditDocument;

            FindTreeListViewItemByDocument(solutionExplorerTreeView.Items[0], doc, ref result);

            if (result != null)
            {
                e.Document.ToTreeListViewItem(result);
                result.Expand();

                if (e.Document is ILuaEditDocumentGroup)
                {
                    ILuaEditDocumentGroup grpDoc = e.Document as ILuaEditDocumentGroup;
                    grpDoc.DocumentRemoved += OnDocumentRemoved;
                    grpDoc.DocumentAdded   += OnDocumentAdded;
                }
            }

            solutionExplorerTreeView.ShowRootTreeLines = (solutionExplorerTreeView.Items.Count > 0 && solutionExplorerTreeView.Items[0].Items.Count > 0);
            solutionExplorerTreeView.AutoSizeColumnWidths(true);
        }
        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);
                }
            }
        }
 public DebugInfo(int processID, IPAddress serverIP, int serverPort, string remotePath,
                  List <ILuaEditDocument> scripts, ILuaEditDocument startupDoc, DebugStartAction startAction)
     : this(serverIP, serverPort, remotePath, scripts, startupDoc, startAction)
 {
     _processID = processID;
 }
Exemple #17
0
 public CloseDialogItem(ILuaEditDocument data, int level)
 {
     _data  = data;
     _level = level;
 }
Exemple #18
0
        private void UpdateThreads()
        {
            tlvwThreads.BeginUpdate();

            try
            {
                ClearThreads();

                if (ClientDebugManager.Instance.LuaThreads != null)
                {
                    foreach (LuaThread luaThread in ClientDebugManager.Instance.LuaThreads)
                    {
                        LuaCall          call = luaThread.CallStackTopCall;
                        TreeListViewItem tlvi = new TreeListViewItem();
                        tlvi.Tag = luaThread;
                        tlvi.SubItems.Add(new TreeListViewSubItem(0));

                        TreeListViewSubItem tlvsiID = new TreeListViewSubItem(1, luaThread.ThreadID);
                        tlvi.SubItems.Add(tlvsiID);

                        if (call != null)
                        {
                            if (call.IsLineCall)
                            {
                                ILuaEditDocument  doc    = DocumentsManager.Instance.OpenDocument(call.FileName, false);
                                LuaScriptDocument luaDoc = doc as LuaScriptDocument;

                                if (luaDoc != null)
                                {
                                    string location = string.Format("{0}   (Lua)   Line {1}", luaDoc.Document.Lines[call.FunctionLineCall - 1].TrimStart(new char[] { ' ', '\t' }), call.FunctionLineCall);
                                    TreeListViewSubItem tlvsiLocation = new TreeListViewSubItem(2, location);
                                    tlvi.SubItems.Add(tlvsiLocation);
                                }
                            }
                            else
                            {
                                string location = string.Format("{0}   ({1})   Line {2}", call.FunctionName, call.FunctionSource, call.LineCalled);
                                TreeListViewSubItem tlvsiLocation = new TreeListViewSubItem(2, location);
                                tlvi.SubItems.Add(tlvsiLocation);
                            }
                        }

                        if (luaThread.ThreadID == ClientDebugManager.Instance.CurrentThreadID)
                        {
                            tlvi.ImageIndex         = 0;
                            tlvi.SelectedImageIndex = 0;
                        }
                        else
                        {
                            tlvi.ImageIndex         = -1;
                            tlvi.SelectedImageIndex = -1;
                        }

                        tlvwThreads.Items.Add(tlvi);
                    }
                }
            }
            finally
            {
                tlvwThreads.EndUpdate();
            }
        }
 public DocGroupDocActionEventArgs(ILuaEditDocument doc)
 {
     _doc = doc;
 }
        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);
                        }
                    }
                }
            }
        }