|
1 /* |
|
2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 using System; |
|
19 using System.Collections.Generic; |
|
20 using System.ComponentModel; |
|
21 using System.Data; |
|
22 using System.Text; |
|
23 using System.Windows.Forms; |
|
24 using CAPRawStack.Plugin; |
|
25 using SymbianUtilsUi.Dialogs; |
|
26 using CAPluginRawStackUi.Dialogs; |
|
27 using SymbianStackLibUi.GUI; |
|
28 using SymbianUtils; |
|
29 |
|
30 namespace CAPluginRawStackUi.Wizards |
|
31 { |
|
32 internal partial class CAWizardRawStack : Form |
|
33 { |
|
34 #region Constructors |
|
35 public CAWizardRawStack( CAPluginRawStack aEngine ) |
|
36 { |
|
37 iEngine = aEngine; |
|
38 // |
|
39 InitializeComponent(); |
|
40 } |
|
41 #endregion |
|
42 |
|
43 #region Events |
|
44 private void CAWizardRawStack_Load( object sender, EventArgs e ) |
|
45 { |
|
46 } |
|
47 |
|
48 private void CAWizardRawStack_FormClosing( object sender, FormClosingEventArgs e ) |
|
49 { |
|
50 } |
|
51 |
|
52 private void iWizard_WizardClosedFromFinish( SymbianWizardLib.Engine.SymWizardClosureEvent aEventArgs ) |
|
53 { |
|
54 string errorText = string.Empty; |
|
55 bool isReady = iPG_DebugEngine_Control.IsReadyToPrime( out errorText ); |
|
56 if ( isReady ) |
|
57 { |
|
58 // Create new engine with (optionally) any new prefix values |
|
59 iEngine.StackEngine.Prefixes.SetCustomPointer( iTB_PrefixCurrentStackPointer.Text ); |
|
60 iEngine.StackEngine.Prefixes.SetCustomCodeSegment( iTB_PrefixCodeSegment.Text ); |
|
61 iEngine.StackEngine.AddressInfo.Pointer = 0; |
|
62 |
|
63 // Check current stack pointer address is valid... |
|
64 long currentStackAddress = 0; |
|
65 string currentStackAddressText = iTB_CurrentStackPointerAddress.Text.Trim(); |
|
66 NumberBaseUtils.TNumberBase numberBase; |
|
67 if ( NumberBaseUtils.TextToDecimalNumber( ref currentStackAddressText, out currentStackAddress, out numberBase ) ) |
|
68 { |
|
69 iEngine.StackEngine.AddressInfo.Pointer = System.Convert.ToUInt32( currentStackAddress ); |
|
70 } |
|
71 |
|
72 // Prime stack engine content |
|
73 iEngine.StackEngine.Primer.Prime( iTB_RawStackData.Lines ); |
|
74 |
|
75 // If we still haven't obtained the stack pointer, then use the base address |
|
76 if ( iEngine.StackEngine.AddressInfo.Pointer == 0 ) |
|
77 { |
|
78 iEngine.StackEngine.AddressInfo.Pointer = iEngine.StackEngine.AddressInfo.Top; |
|
79 } |
|
80 |
|
81 // Prime debug engine |
|
82 iPG_DebugEngine_Control.Prime(); |
|
83 |
|
84 // Store the settings at this point as we are largely past the |
|
85 // initial configuration |
|
86 iEngine.Settings.Store(); |
|
87 |
|
88 // Also save debug engine configuration |
|
89 iPG_DebugEngine_Control.XmlSettingsSave(); |
|
90 |
|
91 DialogResult = DialogResult.OK; |
|
92 } |
|
93 else |
|
94 { |
|
95 MessageBox.Show( errorText, "Error" ); |
|
96 aEventArgs.CancelClosure = true; |
|
97 } |
|
98 } |
|
99 #endregion |
|
100 |
|
101 #region Page - source data |
|
102 private void iPG_SourceData_Load( object aSender, EventArgs aArgs ) |
|
103 { |
|
104 iEngine.Settings.Load( this.Name, iTB_PrefixCodeSegment ); |
|
105 iEngine.Settings.Load( this.Name, iTB_PrefixCurrentStackPointer ); |
|
106 iEngine.Settings.Load( this.Name, iCB_MatchExactSymbols ); |
|
107 } |
|
108 |
|
109 private void iPG_SourceData_PageClosedFromButtonNext( SymbianWizardLib.Engine.SymWizardPageTransitionEvent aEventArgs ) |
|
110 { |
|
111 iEngine.Settings.Save( this.Name, iTB_PrefixCodeSegment ); |
|
112 iEngine.Settings.Save( this.Name, iTB_PrefixCurrentStackPointer ); |
|
113 iEngine.Settings.Save( this.Name, iCB_MatchExactSymbols ); |
|
114 } |
|
115 |
|
116 private void iBT_LoadTextDataFromFile_Click( object sender, EventArgs e ) |
|
117 { |
|
118 string fileName; |
|
119 string filter; |
|
120 // |
|
121 DialogResult result = RawStackImportDialog.ShowDialog( iEngine.Settings, out fileName, out filter ); |
|
122 // |
|
123 if ( result == DialogResult.OK ) |
|
124 { |
|
125 FileToTextBoxProgressDialog.Read( fileName, filter, iTB_RawStackData ); |
|
126 iTB_RawStackData.Select(); |
|
127 iTB_RawStackData.Focus(); |
|
128 } |
|
129 } |
|
130 |
|
131 private void iBT_LoadBinaryDataFromFile_Click( object sender, EventArgs e ) |
|
132 { |
|
133 OpenFileDialog dialog = new OpenFileDialog(); |
|
134 // |
|
135 dialog.Filter = "All Files|*.*"; |
|
136 dialog.Title = "Select a File"; |
|
137 // |
|
138 if ( dialog.ShowDialog() == DialogResult.OK ) |
|
139 { |
|
140 string fileName = dialog.FileName; |
|
141 // |
|
142 string data = StackFileToTextConverterDialog.Convert( fileName ); |
|
143 iTB_RawStackData.Text = data; |
|
144 iTB_RawStackData.Select(); |
|
145 iTB_RawStackData.Focus(); |
|
146 } |
|
147 } |
|
148 |
|
149 private void iTB_RawStackData_KeyDown( object sender, KeyEventArgs e ) |
|
150 { |
|
151 if ( e.KeyCode == Keys.A && e.Control ) |
|
152 { |
|
153 iTB_RawStackData.SelectAll(); |
|
154 e.Handled = true; |
|
155 } |
|
156 } |
|
157 #endregion |
|
158 |
|
159 #region Page - debug engine |
|
160 private void iPG_DebugEngine_Load( object aSender, EventArgs aArgs ) |
|
161 { |
|
162 iPG_DebugEngine_Control.Engine = iEngine.DebugEngine; |
|
163 } |
|
164 |
|
165 private void iPG_DebugEngine_PageClosedFromButtonNext( SymbianWizardLib.Engine.SymWizardPageTransitionEvent aEventArgs ) |
|
166 { |
|
167 string errorText = string.Empty; |
|
168 bool isReady = iPG_DebugEngine_Control.IsReadyToPrime( out errorText ); |
|
169 if ( isReady == false ) |
|
170 { |
|
171 MessageBox.Show( errorText, "Error" ); |
|
172 aEventArgs.SuggestedNewPage = aEventArgs.CurrentPage; |
|
173 } |
|
174 } |
|
175 #endregion |
|
176 |
|
177 #region Internal methods |
|
178 #endregion |
|
179 |
|
180 #region Data members |
|
181 private readonly CAPluginRawStack iEngine; |
|
182 #endregion |
|
183 |
|
184 } |
|
185 } |