|
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.Collections.Generic; |
|
40 using System.ComponentModel; |
|
41 using System.Drawing; |
|
42 using System.Data; |
|
43 using System.Text; |
|
44 using System.Windows.Forms; |
|
45 using HeapCtrlLib.Utilities; |
|
46 using HeapLib.Statistics.Tracking.Base; |
|
47 |
|
48 namespace HeapCtrlLib.Controls |
|
49 { |
|
50 internal partial class HeapFilteringControl : UserControl |
|
51 { |
|
52 #region Constructors & destructor |
|
53 public HeapFilteringControl() |
|
54 { |
|
55 InitializeComponent(); |
|
56 } |
|
57 #endregion |
|
58 |
|
59 #region Properties |
|
60 internal HeapCellFilterTripletDictionary Dictionary |
|
61 { |
|
62 get |
|
63 { |
|
64 HeapCellFilterTripletDictionary ret = new HeapCellFilterTripletDictionary(); |
|
65 // |
|
66 foreach ( XPTable.Models.Row row in iTableModel.Rows ) |
|
67 { |
|
68 TripletDictionaryEntry entry = (TripletDictionaryEntry) row.Tag; |
|
69 // |
|
70 //XPTable.Models.Cell cellEnabled = row.Cells[ 0 ]; |
|
71 XPTable.Models.Cell cellColor = row.Cells[ 1 ]; |
|
72 // |
|
73 ret.Add( entry.iKey, entry.iTriplet.Entity, (Color) cellColor.Data, entry.iTriplet.TrackingInfo ); |
|
74 } |
|
75 |
|
76 return ret; |
|
77 } |
|
78 set |
|
79 { |
|
80 iDictionary = value; |
|
81 UpdateFilters(); |
|
82 } |
|
83 } |
|
84 #endregion |
|
85 |
|
86 #region Event handlers |
|
87 private void iTable_CellCheckChanged( object sender, XPTable.Events.CellCheckBoxEventArgs e ) |
|
88 { |
|
89 XPTable.Models.Row row = iTableModel.Rows[ e.Row ]; |
|
90 XPTable.Models.Cell cellEnabled = e.Cell; |
|
91 XPTable.Models.Cell cellColor = row.Cells[ 1 ]; |
|
92 TripletDictionaryEntry entry = (TripletDictionaryEntry) row.Tag; |
|
93 // |
|
94 if ( e.Column == 0 ) // iCol_Enabled |
|
95 { |
|
96 entry.iTriplet.Enabled = ( cellEnabled.Checked ); |
|
97 // |
|
98 if ( cellEnabled.Checked ) |
|
99 { |
|
100 row.ForeColor = iTable.ForeColor; |
|
101 cellColor.Data = entry.iTriplet.Color; |
|
102 } |
|
103 else |
|
104 { |
|
105 row.ForeColor = Color.DarkGray; |
|
106 cellColor.Data = HeapCellFilterTriplet.KDisabledColour; |
|
107 } |
|
108 } |
|
109 else if ( e.Column == 1 ) // iCol_Colour |
|
110 { |
|
111 if ( cellEnabled.Checked ) |
|
112 { |
|
113 entry.iTriplet.Color = (Color) cellColor.Data; |
|
114 } |
|
115 } |
|
116 } |
|
117 #endregion |
|
118 |
|
119 #region Internal methods |
|
120 private void UpdateFilters() |
|
121 { |
|
122 iTable.BeginUpdate(); |
|
123 iTable.TableModel.Rows.Clear(); |
|
124 // |
|
125 foreach ( KeyValuePair<string, HeapCellFilterTriplet> entry in iDictionary ) |
|
126 { |
|
127 XPTable.Models.Row row = new XPTable.Models.Row(); |
|
128 row.Tag = new TripletDictionaryEntry( entry.Key, entry.Value ); |
|
129 // |
|
130 XPTable.Models.Cell cellEnabled = new XPTable.Models.Cell( string.Empty, entry.Value.Enabled ); |
|
131 XPTable.Models.Cell cellColour = new XPTable.Models.Cell( string.Empty, entry.Value.Color ); |
|
132 XPTable.Models.Cell cellText = new XPTable.Models.Cell( entry.Value.Entity ); |
|
133 // |
|
134 row.Cells.Add( cellEnabled ); |
|
135 row.Cells.Add( cellColour ); |
|
136 row.Cells.Add( cellText ); |
|
137 // |
|
138 if ( cellEnabled.Checked ) |
|
139 { |
|
140 row.ForeColor = iTable.ForeColor; |
|
141 cellColour.Data = entry.Value.Color; |
|
142 } |
|
143 else |
|
144 { |
|
145 row.ForeColor = Color.DarkGray; |
|
146 cellColour.Data = HeapCellFilterTriplet.KDisabledColour; |
|
147 } |
|
148 // |
|
149 if ( !entry.Value.TrackingInfo.IsUnknownSymbolMatchItem ) |
|
150 { |
|
151 iTableModel.Rows.Add( row ); |
|
152 } |
|
153 } |
|
154 // |
|
155 iTable.EndUpdate(); |
|
156 } |
|
157 #endregion |
|
158 |
|
159 #region Data members |
|
160 private HeapCellFilterTripletDictionary iDictionary = new HeapCellFilterTripletDictionary(); |
|
161 #endregion |
|
162 } |
|
163 |
|
164 #region Internal class |
|
165 internal class TripletDictionaryEntry |
|
166 { |
|
167 public TripletDictionaryEntry( string aKey, HeapCellFilterTriplet aTriplet ) |
|
168 { |
|
169 iKey = aKey; |
|
170 iTriplet = aTriplet; |
|
171 } |
|
172 |
|
173 public readonly string iKey; |
|
174 public readonly HeapCellFilterTriplet iTriplet; |
|
175 } |
|
176 #endregion |
|
177 } |