|
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 System.Drawing; |
|
21 |
|
22 namespace CrashItemLib.Crash.Base.DataBinding |
|
23 { |
|
24 public class CIDBRow : IEnumerable<CIDBCell> |
|
25 { |
|
26 #region Constructors |
|
27 public CIDBRow() |
|
28 { |
|
29 } |
|
30 |
|
31 public CIDBRow( params CIDBCell[] aCells ) |
|
32 { |
|
33 iCells.AddRange( aCells ); |
|
34 } |
|
35 |
|
36 public CIDBRow( Color aForeColor ) |
|
37 : this( aForeColor, Color.Transparent ) |
|
38 { |
|
39 } |
|
40 |
|
41 public CIDBRow( Color aForeColor, Color aBackColor ) |
|
42 { |
|
43 iForeColor = aForeColor; |
|
44 iBackColor = aBackColor; |
|
45 } |
|
46 #endregion |
|
47 |
|
48 #region API |
|
49 public void Add( CIDBCell aCell ) |
|
50 { |
|
51 aCell.Row = this; |
|
52 iCells.Add( aCell ); |
|
53 } |
|
54 #endregion |
|
55 |
|
56 #region Properties |
|
57 public int Count |
|
58 { |
|
59 get { return iCells.Count; } |
|
60 } |
|
61 |
|
62 public CIDBCell this[ int aIndex ] |
|
63 { |
|
64 get { return iCells[ aIndex ]; } |
|
65 } |
|
66 |
|
67 public Color ForeColor |
|
68 { |
|
69 get { return iForeColor; } |
|
70 set { iForeColor = value; } |
|
71 } |
|
72 |
|
73 public Color BackColor |
|
74 { |
|
75 get { return iBackColor; } |
|
76 set { iBackColor = value; } |
|
77 } |
|
78 |
|
79 public CIElement Element |
|
80 { |
|
81 get |
|
82 { |
|
83 CIElement element = iElement; |
|
84 // |
|
85 if ( element == null && Model != null ) |
|
86 { |
|
87 element = Model.Element; |
|
88 } |
|
89 // |
|
90 return element; |
|
91 } |
|
92 set { iElement = value; } |
|
93 } |
|
94 |
|
95 internal CIDBModel Model |
|
96 { |
|
97 get { return iModel; } |
|
98 set |
|
99 { |
|
100 iModel = value; |
|
101 |
|
102 // Try to ensure the element points to something |
|
103 if ( iElement == null ) |
|
104 { |
|
105 iElement = Model.Element; |
|
106 } |
|
107 } |
|
108 } |
|
109 #endregion |
|
110 |
|
111 #region From IEnumerable<CICell> |
|
112 public IEnumerator<CIDBCell> GetEnumerator() |
|
113 { |
|
114 foreach ( CIDBCell c in iCells ) |
|
115 { |
|
116 yield return c; |
|
117 } |
|
118 } |
|
119 |
|
120 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
121 { |
|
122 foreach ( CIDBCell c in iCells ) |
|
123 { |
|
124 yield return c; |
|
125 } |
|
126 } |
|
127 #endregion |
|
128 |
|
129 #region Data members |
|
130 private Color iForeColor = Color.Black; |
|
131 private Color iBackColor = Color.Transparent; |
|
132 private List<CIDBCell> iCells = new List<CIDBCell>(); |
|
133 private CIDBModel iModel = null; |
|
134 private CIElement iElement = null; |
|
135 #endregion |
|
136 } |
|
137 } |