ui/wpf/UIcore/Controls.cs

changeset 101
1c943d43fa81
parent 83
a38aec91bd66
child 104
3efe0210e27e
equal deleted inserted replaced
100:d276306d801f 101:1c943d43fa81
14 public static Button Button(Container container, String label, RoutedEventHandler e) 14 public static Button Button(Container container, String label, RoutedEventHandler e)
15 { 15 {
16 return Application.GetInstance().Exec<Button>(() => Controls.CreateButton(container, label, e)); 16 return Application.GetInstance().Exec<Button>(() => Controls.CreateButton(container, label, e));
17 } 17 }
18 18
19 public static Label Label(Container container, String label, int alignment)
20 {
21 HorizontalAlignment a;
22 switch(alignment)
23 {
24 case 0: a = HorizontalAlignment.Left; break;
25 case 1: a = HorizontalAlignment.Right; break;
26 case 2: a = HorizontalAlignment.Center; break;
27 default: a = HorizontalAlignment.Left; break;
28 }
29 return Application.GetInstance().Exec<Label>(() => Controls.CreateLabel(container, label, a));
30 }
31
32 public static Label Space(Container container)
33 {
34 return Application.GetInstance().Exec<Label>(() => Controls.CreateLabel(container, null, HorizontalAlignment.Center));
35 }
36
19 public static Button CreateButton(Container container, String label, RoutedEventHandler e) 37 public static Button CreateButton(Container container, String label, RoutedEventHandler e)
20 { 38 {
21 Button button = new Button(); 39 Button button = new Button();
22 button.Content = label; 40 button.Content = label;
23 container.Add(button, false); 41 container.Add(button, false);
25 button.Click += e; 43 button.Click += e;
26 44
27 return button; 45 return button;
28 } 46 }
29 47
48 public static Label CreateLabel(Container container, String str, HorizontalAlignment alignment)
49 {
50 Label label = new Label();
51 label.HorizontalAlignment = alignment;
52 label.Content = str;
53 container.Add(label, false);
30 54
55 return label;
56 }
31 } 57 }
32 } 58 }

mercurial