17 { |
17 { |
18 VERTICAL, |
18 VERTICAL, |
19 HORIZONTAL |
19 HORIZONTAL |
20 } |
20 } |
21 |
21 |
22 public class BoxContainer : Container |
22 public class BoxContainer : Grid, Container |
23 { |
23 { |
24 public Grid Grid; |
|
25 public BoxOrientation Orientation; |
24 public BoxOrientation Orientation; |
26 |
25 |
27 private int x = 0; |
26 private int x = 0; |
28 private int y = 0; |
27 private int y = 0; |
29 |
28 |
30 private bool filled = false; |
29 private bool filled = false; |
31 |
30 |
32 public BoxContainer(Grid grid, BoxOrientation orientation) |
31 public BoxContainer(BoxOrientation orientation) : base() |
33 { |
32 { |
34 Grid = grid; |
|
35 Orientation = orientation; |
33 Orientation = orientation; |
36 if(Orientation == BoxOrientation.HORIZONTAL) |
34 if(Orientation == BoxOrientation.HORIZONTAL) |
37 { |
35 { |
38 RowDefinition row = new RowDefinition(); |
36 RowDefinition row = new RowDefinition(); |
39 row.Height = new GridLength(1, GridUnitType.Star); |
37 row.Height = new GridLength(1, GridUnitType.Star); |
40 Grid.RowDefinitions.Add(row); |
38 RowDefinitions.Add(row); |
41 } |
39 } |
42 else |
40 else |
43 { |
41 { |
44 ColumnDefinition col = new ColumnDefinition(); |
42 ColumnDefinition col = new ColumnDefinition(); |
45 col.Width = new GridLength(1, GridUnitType.Star); |
43 col.Width = new GridLength(1, GridUnitType.Star); |
46 Grid.ColumnDefinitions.Add(col); |
44 ColumnDefinitions.Add(col); |
47 } |
45 } |
|
46 } |
|
47 |
|
48 public BoxContainer(Container parent, BoxOrientation orientation) : this(orientation) |
|
49 { |
|
50 parent.Add(this, true); |
48 } |
51 } |
49 |
52 |
50 public void Add(UIElement control, bool fill) |
53 public void Add(UIElement control, bool fill) |
51 { |
54 { |
52 if(Orientation == BoxOrientation.HORIZONTAL) |
55 if(Orientation == BoxOrientation.HORIZONTAL) |
83 } |
86 } |
84 else |
87 else |
85 { |
88 { |
86 row.Height = GridLength.Auto; |
89 row.Height = GridLength.Auto; |
87 } |
90 } |
88 Grid.RowDefinitions.Add(row); |
91 RowDefinitions.Add(row); |
89 } |
92 } |
90 |
93 |
91 Grid.SetColumn(control, x); |
94 Grid.SetColumn(control, x); |
92 Grid.SetRow(control, y); |
95 Grid.SetRow(control, y); |
93 Grid.Children.Add(control); |
96 Children.Add(control); |
94 |
97 |
95 if(Orientation == BoxOrientation.HORIZONTAL) |
98 if(Orientation == BoxOrientation.HORIZONTAL) |
96 { |
99 { |
97 x++; |
100 x++; |
98 } |
101 } |
99 else |
102 else |
100 { |
103 { |
101 y++; |
104 y++; |
102 } |
105 } |
|
106 } |
|
107 |
|
108 public static BoxContainer CreateBoxContainer(Container parent, BoxOrientation orientation) |
|
109 { |
|
110 return Application.GetInstance().Exec<BoxContainer>(() => new BoxContainer(parent, orientation)); |
103 } |
111 } |
104 } |
112 } |
105 |
113 |
106 public class GridContainer : Container |
114 public class GridContainer : Container |
107 { |
115 { |