Fix a few CRLF issues
[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 #if NET_2_0
28
29 using NUnit.Framework;
30 using System;
31 using System.Drawing;
32 using System.Windows.Forms;
33 using System.ComponentModel;
34 using System.Collections;
35 using System.Collections.Generic;
36
37 namespace MonoTests.System.Windows.Forms
38 {
39         public static class DataGridViewCommon
40         {
41                 /// <summary>
42                 /// Creates a 2x2 grid.
43                 /// <para>     A   B </para>
44                 /// <para>1   A1  B1</para>
45                 /// <para>2   A2  B2</para>
46                 /// </summary>
47                 /// <returns></returns>
48                 public static DataGridView CreateAndFill ()
49                 {
50                         DataGridView dgv = new DataGridView ();
51                         dgv.Columns.Add ("A", "A");
52                         dgv.Columns.Add ("B", "B");
53                         dgv.Rows.Add ("Cell A1", "Cell B1");
54                         dgv.Rows.Add ("Cell A2", "Cell B2");
55                         return dgv;
56                 }
57
58                 /// <summary>
59                 /// Creates a 2x2 grid, all cells have a GetClipboardContentsPublic method.
60                 /// <para>     A   B </para>
61                 /// <para>1   A1  B1</para>
62                 /// <para>2   A2  B2</para>
63                 /// </summary>
64                 /// <returns></returns>
65                 public static DataGridView CreateAndFillForClipboard ()
66                 {
67                         DataGridView dgv = new DataGridView ();
68                         DataGridViewColumn col;
69                         DataGridViewRow row;
70                         DataGridViewCell cell;
71                         
72                         foreach (string name in new string [] {"A", "B", "C", "D"}) {
73                                 col = new DataGridViewColumn ();
74                                 col.CellTemplate = new DataGridViewTextBoxCell ();
75                                 col.HeaderCell = new DataGridViewColumnHeaderTest.DataGridViewColumnHeaderClipboardCell ();
76                                 col.Name = name;
77                                 //if (dgv.Columns.Count == 1) {
78                                 //        col.HeaderText = null;
79                                 //} else if (dgv.Columns.Count == 2) {
80                                 //        col.HeaderText = string.Empty;
81                                 //} else {
82                                         col.HeaderText = name;
83                                 //}
84                                 
85                                 dgv.Columns.Add (col);
86                         }
87                         
88                         for (int i = 1; i <= 4; i++) {
89                                 row = new DataGridViewRow ();
90                                 row.HeaderCell = new DataGridViewRowHeaderTest.DataGridViewRowHeaderClipboardCell ();
91                                 //if (i == 3) { // Leave one at default value of null
92                                 //        row.HeaderCell.Value = null;
93                                 //} else if (i == 2) {
94                                 //        row.HeaderCell.Value = string.Empty;
95                                 //} else {
96                                         row.HeaderCell.Value = "Row#" + i.ToString ();
97                                 //}
98                                         
99                                 foreach (DataGridViewColumn c in dgv.Columns) {
100                                         cell = new DataGridViewCellTest.DataGridViewClipboardCell ();
101                                         cell.Value = "Cell " + c.Name + i.ToString ();
102                                         row.Cells.Add (cell);
103                                 }
104                                 dgv.Rows.Add (row);
105                         }
106                         
107                         return dgv;
108                 }
109
110                 /// <summary>
111                 /// Creates a 10x10 grid.
112                 /// <para>     A   B </para>
113                 /// <para>1   A1  B1</para>
114                 /// <para>2   A2  B2</para>
115                 /// </summary>
116                 /// <returns></returns>
117                 public static DataGridView CreateAndFillBig ()
118                 {
119                         DataGridView dgv = new DataGridView ();
120                         for (int c = 0; c < 10; c++) {
121                                 string A = (((char) ((int) 'A') + c)).ToString ();
122                                 dgv.Columns.Add (A, A);
123                         }
124                         for (int r = 0; r < 10; r++) {
125                                 List<object> cells = new List<object> ();
126                                 for (int c = 0; c < 10; c++) {
127                                         cells.Add (string.Format ("Cell {0}{1}", dgv.Columns [c].Name, r));
128                                 }
129                                 dgv.Rows.Add (cells);
130                         }
131                         return dgv;
132                 }
133         }
134 }
135 #endif