ui/wpf/UIcore/Container.cs

Sun, 27 Oct 2024 10:33:24 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 27 Oct 2024 10:33:24 +0100
branch
newapi
changeset 358
98b26a19cbeb
parent 138
d781436e2490
permissions
-rw-r--r--

add more label styles (GTK)

83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 using System;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 using System.Collections.Generic;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 using System.Linq;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 using System.Text;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 using System.Threading.Tasks;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 using System.Windows;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 using System.Windows.Controls;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 namespace UI
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 public interface Container
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 {
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
13 Layout Layout { get; set; }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
14
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 void Add(UIElement control, bool fill);
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
18 public class Layout
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
19 {
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
20 public bool? Fill { get; set; }
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
21 public bool Hexpand { get; set; }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
22 public bool Vexpand { get; set; }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
23 public bool NewLine { get; set; }
136
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
24 public int GridWidth { get; set; }
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
25 public String Label { get; set; }
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
26
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
27 public Layout()
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
28 {
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
29 Reset();
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
30 }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
31
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
32 public bool IsFill(bool fill)
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
33 {
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
34 if (Fill != null)
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
35 {
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
36
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
37 return (bool)Fill;
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
38 }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
39 return fill;
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
40 }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
41
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
42 public void Reset()
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
43 {
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
44 Fill = null;
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
45 Hexpand = false;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
46 Vexpand = false;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
47 NewLine = false;
136
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
48 GridWidth = 1;
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
49 Label = null;
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
50 }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
51 }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
52
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 public enum BoxOrientation
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 VERTICAL,
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 HORIZONTAL
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
59 public class BoxContainer : Grid, Container
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 {
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
61 public Layout Layout { get; set; }
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
62
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
63 private BoxOrientation Orientation;
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
64 private int Spacing;
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 private int x = 0;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 private int y = 0;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 private bool filled = false;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
71 public BoxContainer(BoxOrientation orientation, int margin, int spacing) : base()
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 {
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
73 Layout = new Layout();
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
74 Margin = new Thickness(margin);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
75 Spacing = spacing;
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
76
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 Orientation = orientation;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 if(Orientation == BoxOrientation.HORIZONTAL)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 RowDefinition row = new RowDefinition();
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 row.Height = new GridLength(1, GridUnitType.Star);
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
82 RowDefinitions.Add(row);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 else
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 ColumnDefinition col = new ColumnDefinition();
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 col.Width = new GridLength(1, GridUnitType.Star);
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
88 ColumnDefinitions.Add(col);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 }
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
91
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
92 public BoxContainer(Container parent, BoxOrientation orientation, int margin, int spacing) : this(orientation, margin, spacing)
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
93 {
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
94 parent.Add(this, true);
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
95 }
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 public void Add(UIElement control, bool fill)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 {
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
99 fill = Layout.IsFill(fill);
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
100
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 if(Orientation == BoxOrientation.HORIZONTAL)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 {
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
103 if(Spacing > 0)
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
104 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
105 ColumnDefinition spaceCol = new ColumnDefinition();
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
106 spaceCol.Width = new GridLength(Spacing, GridUnitType.Pixel);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
107 ColumnDefinitions.Add(spaceCol);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
108 x++;
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
109 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
110
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 ColumnDefinition col = new ColumnDefinition();
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 if(filled && fill)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 fill = false;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 Console.WriteLine("BoxContainer can only contain one filled control");
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 if(fill)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 col.Width = new GridLength(1, GridUnitType.Star);
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 filled = true;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 else
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 col.Width = GridLength.Auto;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 }
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
126 ColumnDefinitions.Add(col);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 else
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 {
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
130 if (Spacing > 0)
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
131 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
132 RowDefinition spaceRow = new RowDefinition();
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
133 spaceRow.Height = new GridLength(Spacing, GridUnitType.Pixel);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
134 RowDefinitions.Add(spaceRow);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
135 y++;
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
136 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
137
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 RowDefinition row = new RowDefinition();
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 if (filled && fill)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 fill = false;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 Console.WriteLine("BoxContainer can only contain one filled control");
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 if(fill)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 row.Height = new GridLength(1, GridUnitType.Star);
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 filled = true;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 else
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 row.Height = GridLength.Auto;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 }
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
153 RowDefinitions.Add(row);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 Grid.SetColumn(control, x);
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 Grid.SetRow(control, y);
84
a56c2baa9429 added vbox,hbox function (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
158 Children.Add(control);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 if(Orientation == BoxOrientation.HORIZONTAL)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 x++;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 else
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 y++;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 }
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
168
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
169 Layout.Reset();
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
173 public class GridContainer : Grid, Container
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 {
85
91f45354d1e2 added ui_layout_fill (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 84
diff changeset
175 public Layout Layout { get; set; }
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
176
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
177 private int X = 0;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
178 private int Y = 0;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
179 private int CurrentWidth = 0;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
180 private int CurrentHeight = 0;
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
182 private int ColSpacing;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
183 private int RowSpacing;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
184
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
185 public GridContainer(Container parent, int margin, int colspacing, int rowspacing) : base()
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 {
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
187 Layout = new Layout();
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
188
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
189 Margin = new Thickness(margin);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
190 ColSpacing = colspacing;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
191 RowSpacing = rowspacing;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
192
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
193 parent.Add(this, true);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 public void Add(UIElement control, bool fill)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 {
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
198 if(Layout.NewLine)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
199 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
200 X = 0;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
201 Y++;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
202 }
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
204 ColumnDefinition col;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
205 RowDefinition row;
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
206 bool getcol = false;
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
207 if(X >= CurrentWidth)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
208 {
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
209 if (ColSpacing > 0 && X != 0)
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
210 {
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
211 ColumnDefinition spaceCol = new ColumnDefinition();
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
212 spaceCol.Width = new GridLength(ColSpacing, GridUnitType.Pixel);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
213 ColumnDefinitions.Add(spaceCol);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
214 X++;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
215 }
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
216
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
217 col = new ColumnDefinition();
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
218 col.Width = GridLength.Auto;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
219 ColumnDefinitions.Add(col);
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
220
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
221 CurrentWidth = X + 1;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
222 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
223 else
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
224 {
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
225 if (ColSpacing > 0 && X % 2 > 0)
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
226 {
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
227 X++;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
228 }
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
229 col = ColumnDefinitions.ElementAt(X);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
230 }
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
231
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
232 if(getcol)
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
233 {
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
234 col = ColumnDefinitions.ElementAt(X);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
235 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
236
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
237 if (Y >= CurrentHeight)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
238 {
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
239 if (RowSpacing > 0 && Y != 0)
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
240 {
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
241 RowDefinition spaceRow = new RowDefinition();
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
242 spaceRow.Height = new GridLength(RowSpacing, GridUnitType.Pixel);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
243 RowDefinitions.Add(spaceRow);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
244 Y++;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
245 }
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
246
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
247 row = new RowDefinition();
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
248 row.Height = GridLength.Auto;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
249 RowDefinitions.Add(row);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
250 CurrentHeight = Y + 1;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
251 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
252 else
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
253 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
254 row = RowDefinitions.ElementAt(Y);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
255 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
256
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
257 if(Layout.Hexpand)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
258 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
259 col.Width = new GridLength(1, GridUnitType.Star);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
260 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
261 if(Layout.Vexpand)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
262 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
263 row.Height = new GridLength(1, GridUnitType.Star);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
264 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
265
136
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
266 int gridwidth = Layout.GridWidth;
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
267 if(gridwidth > 1)
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
268 {
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
269 gridwidth++;
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
270 }
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
271
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
272 Grid.SetColumn(control, X);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
273 Grid.SetRow(control, Y);
136
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
274 Grid.SetColumnSpan(control, gridwidth);
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
275 Children.Add(control);
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
276
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
277 Layout.Reset();
136
1df2fb3d079c adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 135
diff changeset
278 X += gridwidth;
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 85
diff changeset
279 }
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 }
138
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
281
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
282 public class ScrollViewerContainer : ScrollViewer, Container
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
283 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
284 public Layout Layout { get; set; }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
285
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
286 public ScrollViewerContainer(Container parent) : base()
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
287 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
288 Layout = new Layout();
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
289
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
290 HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
291 VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
292
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
293 parent.Add(this, true);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
294 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
295
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
296 public void Add(UIElement control, bool fill)
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
297 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
298 Content = control;
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
299 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
300 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
301
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
302 public class TabViewContainer : TabControl, Container
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
303 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
304 public Layout Layout { get; set; }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
305
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
306 public TabViewContainer(Container parent) : base()
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
307 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
308 Layout = new Layout();
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
309 parent.Add(this, true);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
310 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
311
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
312 public void Add(UIElement control, bool fill)
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
313 {
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
314 TabItem tab = new TabItem();
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
315 tab.Header = Layout.Label != null ? Layout.Label : "New Tab";
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
316 Items.Add(tab);
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
317 tab.Content = control;
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
318 Layout.Reset();
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
319 }
d781436e2490 adds scrolledwindow and tabview container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
320 }
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 }

mercurial