private MethodDesignerHolder GetViewer(int threadId, UInt32 groupId, SplitContainer s)
 {
     for (int i = 0; i < s.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = s.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             if (h.ThreadId == threadId && h.ActionGroup.GroupId == groupId)
             {
                 return(h);
             }
         }
     }
     for (int i = 0; i < s.Panel2.Controls.Count; i++)
     {
         SplitContainer s0 = s.Panel2.Controls[i] as SplitContainer;
         if (s0 != null)
         {
             MethodDesignerHolder h = GetViewer(threadId, groupId, s0);
             if (h != null)
             {
                 return(h);
             }
         }
     }
     return(null);
 }
        private void h_DesignerSelected(object sender, EventArgs e)
        {
            MethodDesignerHolder h = sender as MethodDesignerHolder;

            if (h != null)
            {
                _currentViewer   = h;
                _currentThreadId = h.ThreadId;
                if (treeView1.ThreadId == _currentThreadId)
                {
                    treeView1.BackColor = Color.LightYellow;
                }
                else
                {
                    treeView1.BackColor = Color.White;
                }
                h.SetViewerBackColor();
                showActiveControl(splitContainer1, h.Parent);
                FormDebugger f = this.FindForm() as FormDebugger;
                if (f != null)
                {
                    f.setButtonImages();
                }
            }
        }
        private void clearBreakPointInMethod(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
        {
            MethodDesignerHolder h = getViewer(threadId, method, group, branch);

            if (h != null)
            {
                h.ClearBreakpoint();
            }
        }
 private void adjustViewerSize(SplitContainer sp)
 {
     for (int i = 0; i < sp.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = sp.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             h.AdjustViewerSize();
         }
     }
 }
 private void showActiveControl(SplitContainer s, Control c)
 {
     if (s.Panel1 != c)
     {
         if (s.Panel1.Controls.Count > 0)
         {
             bool bFound = false;
             for (int i = 0; i < s.Panel1.Controls.Count; i++)
             {
                 SplitContainer v = s.Panel1.Controls[i] as SplitContainer;
                 if (v != null)
                 {
                     for (int k = 0; k < v.Panel1.Controls.Count; k++)
                     {
                         TreeView tv = v.Panel1.Controls[k] as TreeView;
                         if (tv != null)
                         {
                             //tv.BackColor = Color.White;
                             tv.Refresh();
                             break;
                         }
                     }
                     bFound = true;
                     break;
                 }
             }
             if (!bFound)
             {
                 for (int i = 0; i < s.Panel1.Controls.Count; i++)
                 {
                     MethodDesignerHolder h = s.Panel1.Controls[i] as MethodDesignerHolder;
                     if (h != null)
                     {
                         h.SetViewerBackColor();                                //Color.White);
                         break;
                     }
                 }
             }
         }
     }
     if (s.Panel2.Controls.Count > 0)
     {
         for (int i = 0; i < s.Panel2.Controls.Count; i++)
         {
             SplitContainer sp = s.Panel2.Controls[i] as SplitContainer;
             if (sp != null)
             {
                 showActiveControl(sp, c);
                 break;
             }
         }
     }
 }
        void treeView1_GotFocus(object sender, EventArgs e)
        {
            _currentViewer = null;
            FormDebugger f = this.FindForm() as FormDebugger;

            if (f != null)
            {
                _currentThreadId    = f.MainThreadId;
                treeView1.BackColor = Color.LightYellow;
                showActiveControl(splitContainer1, splitContainer1.Panel1);
                f.setButtonImages();
            }
        }
        private void showBreakPointInMethod(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
        {
            MethodDesignerHolder h = getViewer(threadId, method, group, branch);

            if (h == null)
            {
                IActionGroup g = (IActionGroup)(group.Clone());
                g = g.GetThreadGroup(branch.BranchId);
                //create a viewer
                SplitContainer c            = getLastContainer(splitContainer1);
                SplitContainer newContainer = new SplitContainer();
                newContainer.Dock = DockStyle.Fill;
                c.Panel2.Controls.Add(newContainer);
                c.Panel2Collapsed            = false;
                newContainer.Panel2Collapsed = true;
                h          = Activator.CreateInstance(g.ViewerHolderType, this, _designer) as MethodDesignerHolder;
                h.ThreadId = threadId;
                h.SetBackgroundText(group.GroupName);
                h.Dock = DockStyle.Fill;
                newContainer.Panel1.Controls.Add(h);
                h.LoadActions(g);
                _currentThreadId              = threadId;
                h.DesignerSelected           += new EventHandler(h_DesignerSelected);
                newContainer.Panel1.GotFocus += new EventHandler(Panel1_GotFocus);
                newContainer.SplitterMoved   += new SplitterEventHandler(newContainer_SplitterMoved);
                newContainer.Resize          += new EventHandler(newContainer_Resize);
            }
            else
            {
                if (h.ActionGroup.GroupFinished)
                {
                    h.ActionGroup.GroupFinished = false;
                    ThreadDebug td = ThreadData(threadId);
                    if (td.Status == EnumRunStatus.Finished)
                    {
                        FormDebugger f = this.FindForm() as FormDebugger;
                        if (f != null)
                        {
                            td.Status = f.DebugCommandStatus;
                        }
                        else
                        {
                            td.Status = EnumRunStatus.Run;
                        }
                    }
                    UpdateViewersBackColor();
                }
            }
            h.UpdateBreakpoint(branch);
        }
        private void Panel1_GotFocus(object sender, EventArgs e)
        {
            Control c = sender as Control;

            for (int i = 0; i < c.Controls.Count; i++)
            {
                MethodDesignerHolder h = c.Controls[i] as MethodDesignerHolder;
                if (h != null)
                {
                    _currentThreadId = h.ThreadId;
                    h.SetViewerBackColor();                    //Color.LightYellow);
                    showActiveControl(splitContainer1, c);
                    break;
                }
            }
        }
示例#9
0
        /// <summary>
        /// called from event action list, not from a custom method.
        /// called only between event actions
        /// </summary>
        /// <param name="objectKey"></param>
        /// <param name="eventName"></param>
        /// <param name="taskId"></param>
        /// <param name="executer"></param>
        public void BeforeExecuteEventAction(string objectKey, string eventName, int actionIndex, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            _ComponentDebugger.ClearBreakpointDisplay();
            EventAction ea = _ComponentDebugger.RootClass.GetEventHandler(eventName, objectKey);

            if (ea != null)
            {
                int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
                if (actionIndex > 0)
                {
                    //check the action just finished is an custom method or not
                    if (!ea.TaskIDList[actionIndex - 1].IsEmbedded)
                    {
                        IAction a = _ComponentDebugger.RootClass.GetActionInstance(ea.TaskIDList[actionIndex - 1].ActionId);
                        if (a != null)
                        {
                            CustomMethodPointer cmp = a.ActionMethod as CustomMethodPointer;
                            if (cmp != null)
                            {
                                MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, cmp.MethodDef.MethodID);
                                if (h != null)
                                {
                                    h.ActionGroup.GroupFinished = true;
                                    _ComponentDebugger.UpdateViewersBackColor();
                                }
                            }
                        }
                    }
                }
                EnumRunStatus status = _ComponentDebugger.GetRunStatus(threadId);
                if ((status != EnumRunStatus.Stop && status != EnumRunStatus.Run) || ea.TaskIDList[actionIndex].BreakAsEventAction)
                {
                    _ComponentDebugger.SetSelectedObject(executer);
                    _ComponentDebugger.SetAtBreak(threadId, true);
                    _debugUI.ShowBreakPoint(_ComponentDebugger);
                    _ComponentDebugger.ShowEventBreakPointInTreeView(objectKey, eventName, executer, actionIndex);
                    waitForBreakPoint(threadId);
                }
            }
        }
 private void setViewerBackColor(SplitContainer s)
 {
     for (int i = 0; i < s.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = s.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             h.SetViewerBackColor();
         }
     }
     for (int i = 0; i < s.Panel2.Controls.Count; i++)
     {
         SplitContainer s2 = s.Panel2.Controls[i] as SplitContainer;
         if (s2 != null)
         {
             setViewerBackColor(s2);
         }
     }
 }
 public MethodDesignerHolder GetViewer(int threadId, UInt32 groupId)
 {
     if (splitContainer1.Panel2.Controls.Count > 0)
     {
         for (int i = 0; i < splitContainer1.Panel2.Controls.Count; i++)
         {
             SplitContainer s = splitContainer1.Panel2.Controls[i] as SplitContainer;
             if (s != null)
             {
                 MethodDesignerHolder h = GetViewer(threadId, groupId, s);
                 if (h != null)
                 {
                     return(h);
                 }
             }
         }
     }
     return(null);
 }
 private void stopViewers(SplitContainer c)
 {
     for (int i = 0; i < c.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = c.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             h.Stopping = true;
             break;
         }
     }
     for (int i = 0; i < c.Panel2.Controls.Count; i++)
     {
         SplitContainer s = c.Panel2.Controls[i] as SplitContainer;
         if (s != null)
         {
             stopViewers(s);
             break;
         }
     }
 }
 private void setThreadGroupFinish(SplitContainer s, int threadId)
 {
     for (int i = 0; i < s.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = s.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             if (h.ThreadId == threadId)
             {
                 h.ActionGroup.GroupFinished = true;
             }
         }
     }
     for (int i = 0; i < s.Panel2.Controls.Count; i++)
     {
         SplitContainer s2 = s.Panel2.Controls[i] as SplitContainer;
         if (s2 != null)
         {
             setThreadGroupFinish(s2, threadId);
         }
     }
 }
 private MethodDesignerHolder getViewer(int threadId, SplitContainer c, MethodClass method, IActionGroup group, ActionBranch branch)
 {
     for (int i = 0; i < c.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = c.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             if (h.ThreadId == threadId)
             {
                 if (h.Method.WholeActionId == method.WholeActionId)
                 {
                     if (group.GroupId == h.ActionGroup.GroupId)
                     {
                         if (h.ActionList.ContainsAction(branch.BranchId))
                         {
                             return(h);
                         }
                     }
                 }
             }
         }
     }
     for (int i = 0; i < c.Panel2.Controls.Count; i++)
     {
         SplitContainer s = c.Panel2.Controls[i] as SplitContainer;
         if (s != null)
         {
             MethodDesignerHolder h = getViewer(threadId, s, method, group, branch);
             if (h != null)
             {
                 return(h);
             }
         }
     }
     return(null);
 }
示例#15
0
        /// <summary>
        /// finish execute an action
        /// </summary>
        /// <param name="objectKey"></param>
        /// <param name="methodWholeId"></param>
        /// <param name="branchId"></param>
        /// <param name="executer"></param>
        public void AfterExecuteAction(string objectKey, UInt64 methodWholeId, UInt32 branchId, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;

            _ComponentDebugger.DecrementStackLevel(threadId);
            //check if it is at a break point
            MethodClass mc = _ComponentDebugger.GetMethod(methodWholeId);

            if (mc != null)
            {
                IActionGroup g      = mc;
                ActionBranch branch = mc.GetBranchByIdInGroup(branchId, ref g);
                if (branch != null)
                {
                    IActionGroup g0 = branch as IActionGroup;
                    if (g0 != null)
                    {
                        //finished calling a group of actions
                        MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, g0.GroupId);
                        if (h != null)
                        {
                            h.ActionGroup.GroupFinished = true;
                            _ComponentDebugger.UpdateViewersBackColor();
                        }
                    }
                    else
                    {
                        ISingleAction sa = branch as ISingleAction;
                        if (sa != null)
                        {
                            CustomMethodPointer ac = sa.ActionData.ActionMethod as CustomMethodPointer;
                            if (ac != null)
                            {
                                //finished calling a custom action
                                MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, ac.MethodDef.MethodID);
                                if (h != null)
                                {
                                    h.ActionGroup.GroupFinished = true;
                                    _ComponentDebugger.UpdateViewersBackColor();
                                }
                            }
                        }
                    }
                    EnumRunStatus status = _ComponentDebugger.GetRunStatus(threadId);
                    bool          b      = (status == EnumRunStatus.Pause || status == EnumRunStatus.StepInto);
                    if (!b)
                    {
                        if (status == EnumRunStatus.StepOver && _ComponentDebugger.ReachStepOver(threadId))
                        {
                            b = true;
                        }
                        if (!b)
                        {
                            if (status == EnumRunStatus.StepOut && _ComponentDebugger.ReachStepOut(threadId))
                            {
                                b = true;
                            }
                        }
                    }

                    if (b || branch.BreakAfterExecute)
                    {
                        _ComponentDebugger.SetSelectedObject(executer);
                        _ComponentDebugger.SetAtBreak(threadId, true);
                        _debugUI.ShowBreakPoint(_ComponentDebugger);
                        branch.AtBreak = EnumActionBreakStatus.After;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                        waitForBreakPoint(threadId);
                        branch.AtBreak = EnumActionBreakStatus.None;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                    }
                    else
                    {
                        branch.AtBreak = EnumActionBreakStatus.None;
                        _ComponentDebugger.ClearBreakPointInMethod(threadId, mc, g, branch);
                    }
                }
            }
        }