|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions are met: |
|
7 * |
|
8 * - Redistributions of source code must retain the above copyright notice, |
|
9 * this list of conditions and the following disclaimer. |
|
10 * - Redistributions in binary form must reproduce the above copyright notice, |
|
11 * this list of conditions and the following disclaimer in the documentation |
|
12 * and/or other materials provided with the distribution. |
|
13 * - Neither the name of Nokia Corporation nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 * POSSIBILITY OF SUCH DAMAGE. |
|
28 * |
|
29 * Initial Contributors: |
|
30 * Nokia Corporation - initial contribution. |
|
31 * |
|
32 * Contributors: |
|
33 * |
|
34 * Description: |
|
35 * |
|
36 */ |
|
37 |
|
38 using System; |
|
39 using System.Text; |
|
40 using System.Drawing; |
|
41 using System.Collections; |
|
42 using System.ComponentModel; |
|
43 using System.Windows.Forms; |
|
44 using System.Runtime.InteropServices; |
|
45 using HeapLib.Cells; |
|
46 using HeapLib.Array; |
|
47 using HeapLib.Relationships; |
|
48 using HeapLib.Statistics; |
|
49 using HeapLib.Statistics.Tracking.Base; |
|
50 using SymbianUtils.RawItems; |
|
51 |
|
52 namespace HeapCtrlLib.Popups.Forms |
|
53 { |
|
54 public class PopupCellRelationshipInfo : PopupBase |
|
55 { |
|
56 #region Windows Form Designer data members |
|
57 private System.ComponentModel.IContainer components = null; |
|
58 #endregion |
|
59 |
|
60 #region Constructors & destructor |
|
61 public PopupCellRelationshipInfo() |
|
62 { |
|
63 InitializeComponent(); |
|
64 // |
|
65 this.SetStyle( ControlStyles.UserPaint, true ); |
|
66 this.SetStyle( ControlStyles.DoubleBuffer, true ); |
|
67 this.SetStyle( ControlStyles.AllPaintingInWmPaint, true ); |
|
68 this.SetStyle( ControlStyles.ResizeRedraw, true ); |
|
69 this.SetStyle( ControlStyles.Selectable, false ); |
|
70 } |
|
71 |
|
72 protected override void Dispose( bool disposing ) |
|
73 { |
|
74 if( disposing ) |
|
75 { |
|
76 if (components != null) |
|
77 { |
|
78 components.Dispose(); |
|
79 } |
|
80 } |
|
81 base.Dispose( disposing ); |
|
82 } |
|
83 #endregion |
|
84 |
|
85 #region Windows Form Designer generated code |
|
86 private void InitializeComponent() |
|
87 { |
|
88 this.iLbl_Description = new System.Windows.Forms.Label(); |
|
89 this.SuspendLayout(); |
|
90 // |
|
91 // iLbl_Description |
|
92 // |
|
93 this.iLbl_Description.Anchor = ( (System.Windows.Forms.AnchorStyles) ( ( ( ( System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom ) |
|
94 | System.Windows.Forms.AnchorStyles.Left ) |
|
95 | System.Windows.Forms.AnchorStyles.Right ) ) ); |
|
96 this.iLbl_Description.BackColor = System.Drawing.Color.Transparent; |
|
97 this.iLbl_Description.Font = new System.Drawing.Font( "Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ( (byte) ( 0 ) ) ); |
|
98 this.iLbl_Description.Location = new System.Drawing.Point( 8, 32 ); |
|
99 this.iLbl_Description.Name = "iLbl_Description"; |
|
100 this.iLbl_Description.Size = new System.Drawing.Size( 344, 129 ); |
|
101 this.iLbl_Description.TabIndex = 4; |
|
102 // |
|
103 // PopupCellAllocatedSymbols |
|
104 // |
|
105 this.AutoScaleBaseSize = new System.Drawing.Size( 5, 13 ); |
|
106 this.BackColor = System.Drawing.SystemColors.Control; |
|
107 this.ClientSize = new System.Drawing.Size( 360, 193 ); |
|
108 this.Controls.Add( this.iLbl_Description ); |
|
109 this.Name = "PopupCellRelationshipInfo"; |
|
110 this.Title = "Allocated Cell (23 instances)"; |
|
111 this.Layout += new System.Windows.Forms.LayoutEventHandler( this.PopupCellAllocatedRaw_Layout ); |
|
112 this.Controls.SetChildIndex( this.iLbl_Description, 0 ); |
|
113 this.ResumeLayout( false ); |
|
114 |
|
115 } |
|
116 #endregion |
|
117 |
|
118 #region Internal constants |
|
119 private const string KLabelValuesPrefix = "iLbl_Values"; |
|
120 private const string KLabelCharsPrefix = "iLbl_Chars"; |
|
121 private System.Windows.Forms.Label iLbl_Description; |
|
122 private const int KNumberOfLabelRows = 4; |
|
123 #endregion |
|
124 |
|
125 #region From PopupBase |
|
126 public override void PrepareContent( HeapCellArrayWithStatistics aCells, HeapStatistics aStats, RawItem aRawItem ) |
|
127 { |
|
128 try |
|
129 { |
|
130 System.Diagnostics.Debug.Assert( aCells.Count == 1 ); |
|
131 System.Diagnostics.Debug.Assert( aRawItem.Tag != null && aRawItem.Tag is RelationshipInfo ); |
|
132 HeapCell cell = aCells[ 0 ]; |
|
133 RelationshipManager relMgr = cell.RelationshipManager; |
|
134 RelationshipInfo relInfo = (RelationshipInfo) aRawItem.Tag; |
|
135 // |
|
136 StringBuilder msg = new StringBuilder(); |
|
137 // |
|
138 msg.AppendFormat( "This is an embedded reference to the cell at address 0x{0}", relInfo.ToCell.Address.ToString("x8") ); |
|
139 if ( relInfo.ToCell.Symbol != null ) |
|
140 { |
|
141 msg.AppendFormat( ", which is an instance of a {0} object.", relInfo.ToCell.SymbolString ); |
|
142 } |
|
143 msg.Append( System.Environment.NewLine + System.Environment.NewLine ); |
|
144 // |
|
145 msg.AppendFormat( "In total, this cell references {0} other cell(s), and is referenced by {1} cell(s)", relMgr.EmbeddedReferencesTo.Count, relMgr.ReferencedBy.Count ); |
|
146 msg.Append( System.Environment.NewLine + System.Environment.NewLine ); |
|
147 // |
|
148 iLbl_Description.Text = msg.ToString(); |
|
149 } |
|
150 finally |
|
151 { |
|
152 base.PrepareContent( aCells, aStats, aRawItem ); |
|
153 } |
|
154 } |
|
155 #endregion |
|
156 |
|
157 #region Event handlers |
|
158 private void PopupCellAllocatedRaw_Layout( object sender, System.Windows.Forms.LayoutEventArgs e ) |
|
159 { |
|
160 iLbl_Description.Bounds = base.ClientRect; |
|
161 } |
|
162 #endregion |
|
163 |
|
164 #region Internal methods |
|
165 private Label LabelByName( string aName ) |
|
166 { |
|
167 Label ret = null; |
|
168 // |
|
169 foreach( Control ctrl in Controls ) |
|
170 { |
|
171 if ( ctrl is Label && ctrl.Name == aName ) |
|
172 { |
|
173 ret = (Label) ctrl; |
|
174 break; |
|
175 } |
|
176 } |
|
177 // |
|
178 return ret; |
|
179 } |
|
180 #endregion |
|
181 |
|
182 #region Data members |
|
183 #endregion |
|
184 } |
|
185 } |