예제 #1
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);
        }
예제 #2
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();
            }
        }