~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
 
3
 
 
4
using ICSharpCode.Core;
 
5
using System;
 
6
using System.Collections.Generic;
 
7
using System.Linq;
 
8
using System.Windows;
 
9
using Debugger;
 
10
using Debugger.AddIn.Visualizers.Graph;
 
11
 
 
12
namespace ICSharpCode.SharpDevelop.Gui.Pads
 
13
{
 
14
        /// <summary>
 
15
        /// Description of ObjectGraphPad.
 
16
        /// </summary>
 
17
        public class ObjectGraphPad : DebuggerPad
 
18
        {
 
19
                Process debuggedProcess;
 
20
                ObjectGraphControl objectGraphControl;
 
21
                static ObjectGraphPad instance;
 
22
                
 
23
                public ObjectGraphPad()
 
24
                {
 
25
                        instance = this;
 
26
                }
 
27
                
 
28
                /// <remarks>Always check if Instance is null, might be null if pad is not opened!</remarks>
 
29
                public static ObjectGraphPad Instance {
 
30
                        get { return instance; }
 
31
                }
 
32
                
 
33
                protected override void InitializeComponents()
 
34
                {
 
35
                        objectGraphControl = new ObjectGraphControl();
 
36
                        panel.Children.Add(objectGraphControl);
 
37
                }
 
38
                
 
39
                
 
40
                public override void RefreshPad()
 
41
                {
 
42
                        // BUG: if pad window is undocked and floats standalone, IsVisible == false (so pad won't refresh)
 
43
                        // REQUEST: need to refresh when pad becomes visible -> VisibleChanged event?
 
44
                        if (!objectGraphControl.IsVisible)
 
45
                        {
 
46
                                return;
 
47
                        }
 
48
                        if (debuggedProcess == null || debuggedProcess.IsRunning || debuggedProcess.SelectedStackFrame == null) {
 
49
                                this.objectGraphControl.Clear();
 
50
                                return;
 
51
                        }
 
52
                        this.objectGraphControl.Refresh();
 
53
                }
 
54
                
 
55
                protected override void SelectProcess(Process process)
 
56
                {
 
57
                        if (debuggedProcess != null) {
 
58
                                debuggedProcess.Paused -= debuggedProcess_Paused;
 
59
                        }
 
60
                        debuggedProcess = process;
 
61
                        if (debuggedProcess != null) {
 
62
                                debuggedProcess.Paused += debuggedProcess_Paused;
 
63
                        }
 
64
                        RefreshPad();
 
65
                }
 
66
                
 
67
                void debuggedProcess_Paused(object sender, ProcessEventArgs e)
 
68
                {
 
69
                        RefreshPad();
 
70
                }
 
71
        }
 
72
}