[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / DataGridViewCommon.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
21 //
22 // Author:
23 //      Rolf Bjarne Kvinge  (RKvinge@novell.com)
24 //
25
26
27
28 using NUnit.Framework;
29 using System;
30 using System.Drawing;
31 using System.Windows.Forms;
32 using System.ComponentModel;
33 using System.Collections;
34 using System.Collections.Generic;
35
36 namespace MonoTests.System.Windows.Forms
37 {
38         public static class DataGridViewCommon
39         {
40                 /// <summary>
41                 /// Creates a 2x2 grid.
42                 /// <para>     A   B </para>
43                 /// <para>1   A1  B1</para>
44                 /// <para>2   A2  B2</para>
45                 /// </summary>
46                 /// <returns></returns>
47                 public static DataGridView CreateAndFill ()
48                 {
49                         DataGridView dgv = new DataGridView ();
50                         dgv.Columns.Add ("A", "A");
51                         dgv.Columns.Add ("B", "B");
52                         dgv.Rows.Add ("Cell A1", "Cell B1");
53                         dgv.Rows.Add ("Cell A2", "Cell B2");
54                         return dgv;
55                 }
56
57                 /// <summary>
58                 /// Creates a 2x2 grid, all cells have a GetClipboardContentsPublic method.
59                 /// <para>     A   B </para>
60                 /// <para>1   A1  B1</para>
61                 /// <para>2   A2  B2</para>
62                 /// </summary>
63                 /// <returns></returns>
64                 public static DataGridView CreateAndFillForClipboard ()
65                 {
66                         DataGridView dgv = new DataGridView ();
67                         DataGridViewColumn col;
68                         DataGridViewRow row;
69                         DataGridViewCell cell;
70                         
71                         foreach (string name in new string [] {"A", "B", "C", "D"}) {
72                                 col = new DataGridViewColumn ();
73                                 col.CellTemplate = new DataGridViewTextBoxCell ();
74                                 col.HeaderCell = new DataGridViewColumnHeaderTest.DataGridViewColumnHeaderClipboardCell ();
75                                 col.Name = name;
76                                 //if (dgv.Columns.Count == 1) {
77                                 //        col.HeaderText = null;
78                                 //} else if (dgv.Columns.Count == 2) {
79                                 //        col.HeaderText = string.Empty;
80                                 //} else {
81                                         col.HeaderText = name;
82                                 //}
83                                 
84                                 dgv.Columns.Add (col);
85                         }
86                         
87                         for (int i = 1; i <= 4; i++) {
88                                 row = new DataGridViewRow ();
89                                 row.HeaderCell = new DataGridViewRowHeaderTest.DataGridViewRowHeaderClipboardCell ();
90                                 //if (i == 3) { // Leave one at default value of null
91                                 //        row.HeaderCell.Value = null;
92                                 //} else if (i == 2) {
93                                 //        row.HeaderCell.Value = string.Empty;
94                                 //} else {
95                                         row.HeaderCell.Value = "Row#" + i.ToString ();
96                                 //}
97                                         
98                                 foreach (DataGridViewColumn c in dgv.Columns) {
99                                         cell = new DataGridViewCellTest.DataGridViewClipboardCell ();
100                                         cell.Value = "Cell " + c.Name + i.ToString ();
101                                         row.Cells.Add (cell);
102                                 }
103                                 dgv.Rows.Add (row);
104                         }
105                         
106                         return dgv;
107                 }
108
109                 /// <summary>
110                 /// Creates a 10x10 grid.
111                 /// <para>     A   B </para>
112                 /// <para>1   A1  B1</para>
113                 /// <para>2   A2  B2</para>
114                 /// </summary>
115                 /// <returns></returns>
116                 public static DataGridView CreateAndFillBig ()
117                 {
118                         DataGridView dgv = new DataGridView ();
119                         for (int c = 0; c < 10; c++) {
120                                 string A = (((char) ((int) 'A') + c)).ToString ();
121                                 dgv.Columns.Add (A, A);
122                         }
123                         for (int r = 0; r < 10; r++) {
124                                 List<object> cells = new List<object> ();
125                                 for (int c = 0; c < 10; c++) {
126                                         cells.Add (string.Format ("Cell {0}{1}", dgv.Columns [c].Name, r));
127                                 }
128                                 dgv.Rows.Add (cells);
129                         }
130                         return dgv;
131                 }
132         }
133 }