ui/wpf/UIcore/Controls.cs

Sun, 15 Jan 2017 15:08:07 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 15 Jan 2017 15:08:07 +0100
changeset 132
a24465cc7262
parent 104
3efe0210e27e
child 135
b9dc9cdfa23a
permissions
-rw-r--r--

fixes VS settings

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 class Controls
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 public static Button Button(Container container, String label, RoutedEventHandler e)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 return Application.GetInstance().Exec<Button>(() => Controls.CreateButton(container, label, e));
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
19 public static Label Label(Container container, String label, int alignment)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
20 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
21 HorizontalAlignment a;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
22 switch(alignment)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
23 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
24 case 0: a = HorizontalAlignment.Left; break;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
25 case 1: a = HorizontalAlignment.Right; break;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
26 case 2: a = HorizontalAlignment.Center; break;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
27 default: a = HorizontalAlignment.Left; break;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
28 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
29 return Application.GetInstance().Exec<Label>(() => Controls.CreateLabel(container, label, a));
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
30 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
31
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
32 public static Label Space(Container container)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
33 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
34 return Application.GetInstance().Exec<Label>(() => Controls.CreateLabel(container, null, HorizontalAlignment.Center));
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
35 }
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
36
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
37 public static Separator Separator(Container container)
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
38 {
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
39 return Application.GetInstance().Exec<Separator>(() => Controls.CreateSeparator(container));
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
40 }
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
41
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 public static Button CreateButton(Container container, String label, RoutedEventHandler e)
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 Button button = new Button();
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 button.Content = label;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 container.Add(button, false);
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 button.Click += e;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 return button;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
53 public static Label CreateLabel(Container container, String str, HorizontalAlignment alignment)
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
54 {
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
55 Label label = new Label();
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
56 label.HorizontalAlignment = alignment;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
57 label.Content = str;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
58 container.Add(label, false);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
60 return label;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
61 }
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
62
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
63 public static Separator CreateSeparator(Container container)
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
64 {
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
65 Separator separator = new Separator();
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
66 container.Add(separator, false);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
67 return separator;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
68 }
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 }

mercurial