|
1 /* |
|
2 * Copyright (c) 2009 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 using System; |
|
18 using System.Text; |
|
19 using System.Collections.Generic; |
|
20 using CrashItemLib.Crash; |
|
21 using CrashItemLib.Crash.Base; |
|
22 using CrashItemLib.Crash.Base.DataBinding; |
|
23 using CrashItemLib.Crash.Utils; |
|
24 using CrashItemLib.Crash.Container; |
|
25 |
|
26 namespace CrashItemLib.Crash.Events |
|
27 { |
|
28 public class CIEvent : CIElement |
|
29 { |
|
30 #region Enumerations |
|
31 public enum TSpecificType |
|
32 { |
|
33 /// <summary> |
|
34 /// Specific type unknown - nothing can be inferred from the 'type' or 'value' fields |
|
35 /// included as properties of this object. |
|
36 /// </summary> |
|
37 ETypeUnknown = 0, |
|
38 |
|
39 /// <summary> |
|
40 /// The event relates to a key press and therefore the 'value' field includes a |
|
41 /// text-encoded represenation of the keyboard scan code. |
|
42 /// </summary> |
|
43 ETypeKey |
|
44 } |
|
45 #endregion |
|
46 |
|
47 #region Constructors |
|
48 public CIEvent( CIContainer aContainer ) |
|
49 : base( aContainer ) |
|
50 { |
|
51 } |
|
52 #endregion |
|
53 |
|
54 #region API |
|
55 #endregion |
|
56 |
|
57 #region Properties |
|
58 public string TypeName |
|
59 { |
|
60 get { return iTypeName; } |
|
61 set { iTypeName = value; } |
|
62 } |
|
63 |
|
64 public object Value |
|
65 { |
|
66 get { return iValue; } |
|
67 set { iValue = value; } |
|
68 } |
|
69 |
|
70 public TSpecificType Type |
|
71 { |
|
72 get { return iType; } |
|
73 set { iType = value; } |
|
74 } |
|
75 #endregion |
|
76 |
|
77 #region Operators |
|
78 public static implicit operator CIDBRow( CIEvent aEvent ) |
|
79 { |
|
80 CIDBRow row = new CIDBRow(); |
|
81 |
|
82 // To ensure that the register and cells are correctly associated |
|
83 row.Element = aEvent; |
|
84 row.Add( new CIDBCell( aEvent.TypeName ) ); |
|
85 |
|
86 string value = string.Empty; |
|
87 if ( aEvent.Value != null ) |
|
88 { |
|
89 value = aEvent.Value.ToString(); |
|
90 } |
|
91 row.Add( new CIDBCell( value ) ); |
|
92 // |
|
93 return row; |
|
94 } |
|
95 #endregion |
|
96 |
|
97 #region Internal methods |
|
98 #endregion |
|
99 |
|
100 #region From CIElement |
|
101 internal override void OnFinalize( CIElementFinalizationParameters aParams ) |
|
102 { |
|
103 try |
|
104 { |
|
105 if ( iType == TSpecificType.ETypeKey && ( iValue is int ) ) |
|
106 { |
|
107 // Replace generic scan/key code with key name |
|
108 int keyCode = (int) iValue; |
|
109 string keyName = keyCode.ToString(); |
|
110 // |
|
111 if ( aParams.DebugEngine.KeyBindings.IsKeyBindingTableAvailable ) |
|
112 { |
|
113 keyName = aParams.DebugEngine.KeyBindings[ keyCode ]; |
|
114 } |
|
115 // |
|
116 System.Diagnostics.Debug.Assert( keyName != null ); |
|
117 iValue = keyName; |
|
118 } |
|
119 else |
|
120 { |
|
121 // No operation required. |
|
122 } |
|
123 } |
|
124 finally |
|
125 { |
|
126 base.OnFinalize( aParams ); |
|
127 } |
|
128 } |
|
129 #endregion |
|
130 |
|
131 #region Data members |
|
132 private string iTypeName = string.Empty; |
|
133 private object iValue = string.Empty; |
|
134 private TSpecificType iType = TSpecificType.ETypeUnknown; |
|
135 #endregion |
|
136 } |
|
137 } |