159 private int X = 0; |
159 private int X = 0; |
160 private int Y = 0; |
160 private int Y = 0; |
161 private int CurrentWidth = 0; |
161 private int CurrentWidth = 0; |
162 private int CurrentHeight = 0; |
162 private int CurrentHeight = 0; |
163 |
163 |
|
164 private int ColSpacing; |
|
165 private int RowSpacing; |
|
166 |
164 public GridContainer(Container parent, int margin, int colspacing, int rowspacing) : base() |
167 public GridContainer(Container parent, int margin, int colspacing, int rowspacing) : base() |
165 { |
168 { |
166 Layout = new Layout(); |
169 Layout = new Layout(); |
|
170 |
|
171 Margin = new Thickness(margin); |
|
172 ColSpacing = colspacing; |
|
173 RowSpacing = rowspacing; |
167 |
174 |
168 parent.Add(this, true); |
175 parent.Add(this, true); |
169 } |
176 } |
170 |
177 |
171 public void Add(UIElement control, bool fill) |
178 public void Add(UIElement control, bool fill) |
176 Y++; |
183 Y++; |
177 } |
184 } |
178 |
185 |
179 ColumnDefinition col; |
186 ColumnDefinition col; |
180 RowDefinition row; |
187 RowDefinition row; |
|
188 bool getcol = false; |
181 if(X >= CurrentWidth) |
189 if(X >= CurrentWidth) |
182 { |
190 { |
|
191 if (ColSpacing > 0 && X != 0) |
|
192 { |
|
193 ColumnDefinition spaceCol = new ColumnDefinition(); |
|
194 spaceCol.Width = new GridLength(ColSpacing, GridUnitType.Pixel); |
|
195 ColumnDefinitions.Add(spaceCol); |
|
196 X++; |
|
197 } |
|
198 |
183 col = new ColumnDefinition(); |
199 col = new ColumnDefinition(); |
184 col.Width = GridLength.Auto; |
200 col.Width = GridLength.Auto; |
185 ColumnDefinitions.Add(col); |
201 ColumnDefinitions.Add(col); |
|
202 |
186 CurrentWidth = X + 1; |
203 CurrentWidth = X + 1; |
187 } |
204 } |
188 else |
205 else |
189 { |
206 { |
|
207 if (ColSpacing > 0 && X % 2 > 0) |
|
208 { |
|
209 X++; |
|
210 } |
190 col = ColumnDefinitions.ElementAt(X); |
211 col = ColumnDefinitions.ElementAt(X); |
191 } |
212 } |
192 |
213 |
|
214 if(getcol) |
|
215 { |
|
216 col = ColumnDefinitions.ElementAt(X); |
|
217 } |
|
218 |
193 if (Y >= CurrentHeight) |
219 if (Y >= CurrentHeight) |
194 { |
220 { |
|
221 if (RowSpacing > 0 && Y != 0) |
|
222 { |
|
223 RowDefinition spaceRow = new RowDefinition(); |
|
224 spaceRow.Height = new GridLength(RowSpacing, GridUnitType.Pixel); |
|
225 RowDefinitions.Add(spaceRow); |
|
226 Y++; |
|
227 } |
|
228 |
195 row = new RowDefinition(); |
229 row = new RowDefinition(); |
196 row.Height = GridLength.Auto; |
230 row.Height = GridLength.Auto; |
197 RowDefinitions.Add(row); |
231 RowDefinitions.Add(row); |
198 CurrentHeight = Y + 1; |
232 CurrentHeight = Y + 1; |
199 } |
233 } |