~ubuntu-branches/ubuntu/karmic/moon/karmic

« back to all changes in this revision

Viewing changes to class/Microsoft.SilverlightControls/Controls/Data/src/DataGrid/DataGridDisplayData.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
ļ»æ// Copyright Ā© Microsoft Corporation. 
 
2
// This source is subject to the Microsoft Source License for Silverlight Controls (March 2008 Release).
 
3
// Please see http://go.microsoft.com/fwlink/?LinkID=111693 for details.
 
4
// All other rights reserved. 
 
5
 
 
6
namespace System.Windows.Controlsb1
 
7
 
8
    internal class DataGridDisplayData 
 
9
    {
 
10
        #region Data 
 
11
 
 
12
        private int _firstDisplayedFrozenCol;
 
13
        // 
 
14
        private int _firstDisplayedScrollingCol;
 
15
        private int _firstDisplayedScrollingRow;
 
16
        private int _lastDisplayedFrozenCol; 
 
17
        // 
 
18
        private int _lastDisplayedScrollingRow;
 
19
        private int _lastTotallyDisplayedScrollingCol; 
 
20
        private int _numDisplayedFrozenCols;
 
21
        //
 
22
        private int _numDisplayedScrollingCols; 
 
23
        private int _numDisplayedScrollingRows;
 
24
        //
 
25
        private int _numTotallyDisplayedScrollingRows; 
 
26
 
 
27
        #endregion
 
28
 
 
29
        public DataGridDisplayData()
 
30
        {
 
31
            // 
 
32
            _firstDisplayedFrozenCol = -1;
 
33
            _firstDisplayedScrollingRow = -1;
 
34
            _firstDisplayedScrollingCol = -1; 
 
35
            _lastTotallyDisplayedScrollingCol = -1; 
 
36
            _lastDisplayedScrollingRow = -1;
 
37
            _lastDisplayedFrozenCol = -1; 
 
38
            //
 
39
            OldFirstDisplayedScrollingRow = -1;
 
40
            OldFirstDisplayedScrollingCol = -1; 
 
41
        }
 
42
 
 
43
        #region Public Properties 
 
44
 
 
45
        public bool ColumnInsertionOccurred
 
46
        { 
 
47
            get;
 
48
            private set;
 
49
        } 
 
50
 
 
51
        public bool Dirty
 
52
        { 
 
53
            get; 
 
54
            set;
 
55
        } 
 
56
 
 
57
        public int FirstDisplayedFrozenCol
 
58
        { 
 
59
            get
 
60
            {
 
61
                return this._firstDisplayedFrozenCol; 
 
62
            } 
 
63
            set
 
64
            { 
 
65
                if (value != _firstDisplayedFrozenCol)
 
66
                {
 
67
                    EnsureDirtyState(); 
 
68
                    _firstDisplayedFrozenCol = value;
 
69
                }
 
70
            } 
 
71
        } 
 
72
 
 
73
        // 
 
74
 
 
75
 
 
76
 
 
77
 
 
78
 
 
79
 
 
80
 
 
81
 
 
82
 
 
83
 
 
84
 
 
85
        public int FirstDisplayedScrollingCol 
 
86
        {
 
87
            get
 
88
            { 
 
89
                return _firstDisplayedScrollingCol; 
 
90
            }
 
91
            set 
 
92
            {
 
93
                if (value != _firstDisplayedScrollingCol)
 
94
                { 
 
95
                    EnsureDirtyState();
 
96
                    _firstDisplayedScrollingCol = value;
 
97
                } 
 
98
            } 
 
99
        }
 
100
 
 
101
        public int FirstDisplayedScrollingRow
 
102
        {
 
103
            get 
 
104
            {
 
105
                return _firstDisplayedScrollingRow;
 
106
            } 
 
107
            set 
 
108
            {
 
109
                if (value != _firstDisplayedScrollingRow) 
 
110
                {
 
111
                    EnsureDirtyState();
 
112
                    _firstDisplayedScrollingRow = value; 
 
113
                }
 
114
            }
 
115
        } 
 
116
 
 
117
        public int LastDisplayedFrozenCol
 
118
        { 
 
119
            get
 
120
            {
 
121
                return _lastDisplayedFrozenCol; 
 
122
            }
 
123
            set
 
124
            { 
 
125
                if (value != _lastDisplayedFrozenCol) 
 
126
                {
 
127
                    EnsureDirtyState(); 
 
128
                    _lastDisplayedFrozenCol = value;
 
129
                }
 
130
            } 
 
131
        }
 
132
 
 
133
        // 
 
134
 
 
135
 
 
136
 
 
137
 
 
138
 
 
139
 
 
140
 
 
141
 
 
142
 
 
143
 
 
144
 
 
145
        public int LastDisplayedScrollingRow 
 
146
        {
 
147
            get
 
148
            { 
 
149
                return _lastDisplayedScrollingRow;
 
150
            }
 
151
            set 
 
152
            { 
 
153
                if (value != _lastDisplayedScrollingRow)
 
154
                { 
 
155
                    EnsureDirtyState();
 
156
                    _lastDisplayedScrollingRow = value;
 
157
                } 
 
158
            }
 
159
        }
 
160
 
 
161
        public int LastTotallyDisplayedScrollingCol 
 
162
        {
 
163
            get 
 
164
            {
 
165
                return _lastTotallyDisplayedScrollingCol;
 
166
            } 
 
167
            set
 
168
            {
 
169
                if (value != _lastTotallyDisplayedScrollingCol) 
 
170
                { 
 
171
                    EnsureDirtyState();
 
172
                    _lastTotallyDisplayedScrollingCol = value; 
 
173
                }
 
174
            }
 
175
        } 
 
176
 
 
177
        public int NumDisplayedFrozenCols
 
178
        { 
 
179
            get 
 
180
            {
 
181
                return _numDisplayedFrozenCols; 
 
182
            }
 
183
            set
 
184
            { 
 
185
                if (value != _numDisplayedFrozenCols)
 
186
                {
 
187
                    EnsureDirtyState(); 
 
188
                    _numDisplayedFrozenCols = value; 
 
189
                }
 
190
            } 
 
191
        }
 
192
 
 
193
        // 
 
194
 
 
195
 
 
196
 
 
197
 
 
198
 
 
199
 
 
200
 
 
201
 
 
202
 
 
203
 
 
204
 
 
205
 
 
206
 
 
207
 
 
208
 
 
209
        public int NumDisplayedScrollingCols
 
210
        {
 
211
            get 
 
212
            {
 
213
                return _numDisplayedScrollingCols;
 
214
            } 
 
215
            set 
 
216
            {
 
217
                if (value != _numDisplayedScrollingCols) 
 
218
                {
 
219
                    EnsureDirtyState();
 
220
                    _numDisplayedScrollingCols = value; 
 
221
                }
 
222
            }
 
223
        } 
 
224
 
 
225
        public int NumDisplayedScrollingRows
 
226
        { 
 
227
            get
 
228
            {
 
229
                return _numDisplayedScrollingRows; 
 
230
            }
 
231
            set
 
232
            { 
 
233
                if (value != _numDisplayedScrollingRows) 
 
234
                {
 
235
                    EnsureDirtyState(); 
 
236
                    _numDisplayedScrollingRows = value;
 
237
                }
 
238
            } 
 
239
        }
 
240
 
 
241
        // 
 
242
 
 
243
 
 
244
 
 
245
 
 
246
 
 
247
 
 
248
 
 
249
 
 
250
 
 
251
 
 
252
 
 
253
 
 
254
 
 
255
 
 
256
 
 
257
        public int NumTotallyDisplayedScrollingRows
 
258
        {
 
259
            get 
 
260
            { 
 
261
                return _numTotallyDisplayedScrollingRows;
 
262
            } 
 
263
            set
 
264
            {
 
265
                if (value != _numTotallyDisplayedScrollingRows) 
 
266
                {
 
267
                    EnsureDirtyState();
 
268
                    _numTotallyDisplayedScrollingRows = value; 
 
269
                } 
 
270
            }
 
271
        } 
 
272
 
 
273
        public int OldFirstDisplayedScrollingCol
 
274
        { 
 
275
            get;
 
276
            private set;
 
277
        } 
 
278
 
 
279
        public int OldFirstDisplayedScrollingRow
 
280
        { 
 
281
            get;
 
282
            private set;
 
283
        } 
 
284
 
 
285
        //
 
286
 
 
287
 
 
288
 
 
289
 
 
290
 
 
291
        public int OldNumDisplayedScrollingRows
 
292
        { 
 
293
            get;
 
294
            private set;
 
295
        } 
 
296
 
 
297
        public bool RowInsertionOccurred
 
298
        { 
 
299
            get;
 
300
            private set;
 
301
        } 
 
302
 
 
303
        #endregion
 
304
 
 
305
        #region Public Methods 
 
306
 
 
307
        public void CorrectColumnIndexAfterInsertion(int columnIndex, int insertionCount) 
 
308
        {
 
309
            EnsureDirtyState();
 
310
            if (OldFirstDisplayedScrollingCol != -1 && columnIndex <= OldFirstDisplayedScrollingCol) 
 
311
            {
 
312
                OldFirstDisplayedScrollingCol += insertionCount;
 
313
            } 
 
314
            ColumnInsertionOccurred = true; 
 
315
        }
 
316
 
 
317
        public void CorrectRowIndexAfterDeletion(int rowIndex)
 
318
        {
 
319
            EnsureDirtyState(); 
 
320
            if (OldFirstDisplayedScrollingRow != -1 && rowIndex <= OldFirstDisplayedScrollingRow)
 
321
            {
 
322
                OldFirstDisplayedScrollingRow--; 
 
323
            } 
 
324
        }
 
325
 
 
326
        public void CorrectRowIndexAfterInsertion(int rowIndex, int insertionCount)
 
327
        {
 
328
            EnsureDirtyState(); 
 
329
            if (OldFirstDisplayedScrollingRow != -1 && rowIndex <= OldFirstDisplayedScrollingRow)
 
330
            {
 
331
                OldFirstDisplayedScrollingRow += insertionCount; 
 
332
            } 
 
333
            RowInsertionOccurred = true;
 
334
            OldNumDisplayedScrollingRows += insertionCount; 
 
335
            //
 
336
        }
 
337
 
 
338
        public void EnsureDirtyState()
 
339
        {
 
340
            if (!Dirty) 
 
341
            { 
 
342
                Dirty = true;
 
343
                RowInsertionOccurred = false; 
 
344
                ColumnInsertionOccurred = false;
 
345
                SetOldValues();
 
346
            } 
 
347
        }
 
348
 
 
349
        #endregion 
 
350
 
 
351
        #region Private Methods
 
352
 
 
353
        private void SetOldValues()
 
354
        {
 
355
            OldFirstDisplayedScrollingRow = _firstDisplayedScrollingRow; 
 
356
            OldFirstDisplayedScrollingCol = _firstDisplayedScrollingCol;
 
357
            //
 
358
            OldNumDisplayedScrollingRows = _numDisplayedScrollingRows; 
 
359
        } 
 
360
 
 
361
        #endregion 
 
362
    }
 
363
}