ui/wpf/UIcore/Controls.cs

Thu, 15 Feb 2024 21:33:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 Feb 2024 21:33:08 +0100
branch
newapi
changeset 262
81778b9589d0
parent 135
b9dc9cdfa23a
permissions
-rw-r--r--

port progressbar to new API (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 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 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
14 {
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 Button button = new Button();
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 button.Content = label;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 container.Add(button, false);
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 button.Click += e;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 return button;
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 }
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23
135
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
24 public static Label Label(Container container, String str, int alignment)
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
25 {
135
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
26 HorizontalAlignment a;
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
27 switch (alignment)
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
28 {
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
29 case 0: a = HorizontalAlignment.Left; break;
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
30 case 1: a = HorizontalAlignment.Right; break;
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
31 case 2: a = HorizontalAlignment.Center; break;
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
32 default: a = HorizontalAlignment.Left; break;
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
33 }
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
34
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
35 Label label = new Label();
135
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
36 label.HorizontalAlignment = a;
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
37 label.Content = str;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
38 container.Add(label, false);
83
a38aec91bd66 added box layout and button (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
101
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
40 return label;
1c943d43fa81 implemented grid container (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
41 }
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
42
135
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
43 public static Label Space(Container container)
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
44 {
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
45 return Label(container, null, 2);
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
46 }
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
47
b9dc9cdfa23a refactors architecture (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 104
diff changeset
48 public static Separator Separator(Container container)
104
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
49 {
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
50 Separator separator = new Separator();
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
51 container.Add(separator, false);
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
52 return separator;
3efe0210e27e added grid spacing (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 101
diff changeset
53 }
83
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 }

mercurial