~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/MemoryPadCommands.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 GNU LGPL (for details please see \doc\license.txt)
 
3
using System;
 
4
using System.Windows.Controls;
 
5
using System.Windows.Input;
 
6
 
 
7
using ICSharpCode.Core;
 
8
 
 
9
namespace ICSharpCode.SharpDevelop.Gui.Pads
 
10
{
 
11
        public sealed class JumpToAddressCommand : AbstractComboBoxCommand
 
12
        {
 
13
                MemoryPad pad;
 
14
                ComboBox comboBox;              
 
15
                
 
16
                protected override void OnOwnerChanged(EventArgs e)
 
17
                {
 
18
                        this.pad = this.Owner as MemoryPad;
 
19
                        if (this.pad == null)
 
20
                                return;
 
21
                        
 
22
                        comboBox = this.ComboBox as ComboBox;
 
23
                        
 
24
                        if (this.comboBox == null)
 
25
                                return;
 
26
                        
 
27
                        comboBox.KeyUp += (s, ea) => { if (ea.Key == Key.Enter) Run(); };
 
28
                        comboBox.IsEditable = true;
 
29
                        comboBox.Width = 130;
 
30
                        
 
31
                        base.OnOwnerChanged(e);
 
32
                }
 
33
                
 
34
                public override void Run()
 
35
                {
 
36
                        if (this.pad != null && this.comboBox != null) {
 
37
                                pad.JumpToAddress(comboBox.Text);
 
38
                        }
 
39
                        base.Run();
 
40
                }
 
41
        }
 
42
        
 
43
        public abstract class ItemMemoryCommand : AbstractCommand
 
44
        {
 
45
                protected MemoryPad pad;
 
46
                
 
47
                protected override void OnOwnerChanged(EventArgs e)
 
48
                {
 
49
                        this.pad = this.Owner as MemoryPad;
 
50
                        if (this.pad == null)
 
51
                                return;
 
52
                        
 
53
                        base.OnOwnerChanged(e);
 
54
                }
 
55
        }
 
56
        
 
57
        public sealed class RefreshAddressCommand : ItemMemoryCommand
 
58
        {
 
59
                public override void Run()
 
60
                {
 
61
                        if (this.pad == null)
 
62
                                return;
 
63
                        
 
64
                        this.pad.Refresh();
 
65
                }
 
66
        }
 
67
        
 
68
        public sealed class NextAddressCommand : ItemMemoryCommand
 
69
        {
 
70
                public override void Run()
 
71
                {
 
72
                        if (this.pad == null)
 
73
                                return;
 
74
                        
 
75
                        this.pad.MoveToNextAddress();
 
76
                }
 
77
        }
 
78
        
 
79
        public sealed class PreviousAddressCommand : ItemMemoryCommand
 
80
        {
 
81
                public override void Run()
 
82
                {
 
83
                        if (this.pad == null)
 
84
                                return;
 
85
                        
 
86
                        this.pad.MoveToPreviousAddress();
 
87
                }
 
88
        }
 
89
        
 
90
        public sealed class DisplayByteSizeCommand : AbstractComboBoxCommand
 
91
        {
 
92
                MemoryPad pad;
 
93
                ComboBox comboBox;              
 
94
                
 
95
                protected override void OnOwnerChanged(EventArgs e)
 
96
                {
 
97
                        this.pad = this.Owner as MemoryPad;
 
98
                        if (this.pad == null)
 
99
                                return;
 
100
                        
 
101
                        comboBox = this.ComboBox as ComboBox;
 
102
                        
 
103
                        if (this.comboBox == null)
 
104
                                return;
 
105
                        
 
106
                        comboBox.SelectionChanged += (s, ea) => { Run(); };
 
107
                        
 
108
                        comboBox.Items.Add(1);
 
109
                        comboBox.Items.Add(2);
 
110
                        comboBox.Items.Add(4);
 
111
                        comboBox.Text = "1";
 
112
                        comboBox.Width = 30;
 
113
                        comboBox.IsEditable = false;
 
114
                        
 
115
                        base.OnOwnerChanged(e);
 
116
                }
 
117
                
 
118
                public override void Run()
 
119
                {
 
120
                        if (this.pad != null && this.comboBox != null) {
 
121
                                pad.DisplayByteSize = Convert.ToByte(this.comboBox.SelectedValue);
 
122
                                pad.DisplayMemory();
 
123
                        }
 
124
                        base.Run();
 
125
                }
 
126
        }
 
127
}