forked from rstarkov/TankIconMaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddWindow.xaml.cs
More file actions
69 lines (61 loc) · 2.52 KB
/
Copy pathAddWindow.xaml.cs
File metadata and controls
69 lines (61 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System.Windows;
using System.Windows.Controls;
using RT.Util.Forms;
namespace TankIconMaker
{
partial class AddWindow : ManagedWindow
{
public AddWindow()
: base(App.Settings.AddWindow)
{
InitializeComponent();
MainWindow.ApplyUiZoom(this);
ContentRendered += delegate
{
((ListBoxItem) ctList.ItemContainerGenerator.ContainerFromIndex(0)).Focus();
};
}
private void add(object sender, RoutedEventArgs e)
{
DialogResult = true;
}
public static LayerBase ShowAddLayer(Window owner)
{
var wnd = new AddWindow { Owner = owner };
wnd.Title = App.Translation.AddWindow.AddLayerTitle;
wnd.lblName.Content = new AccessText { Text = App.Translation.AddWindow.LayerName };
wnd.lblList.Content = new AccessText { Text = App.Translation.AddWindow.LayerType };
wnd.ctAddLabel.Text = App.Translation.AddWindow.BtnAdd;
wnd.ctCancelLabel.Text = App.Translation.AddWindow.BtnCancel;
wnd.ctList.ItemsSource = App.LayerTypes;
wnd.ctList.SelectedIndex = 0;
if (wnd.ShowDialog() != true)
return null;
var item = wnd.ctList.SelectedItem as TypeInfo<LayerBase>;
if (item == null)
return null;
var result = item.Constructor();
result.Name = wnd.ctName.Text;
return result;
}
public static EffectBase ShowAddEffect(Window owner)
{
var wnd = new AddWindow { Owner = owner };
wnd.Title = App.Translation.AddWindow.AddEffectTitle;
wnd.lblName.Content = new AccessText { Text = App.Translation.AddWindow.EffectName };
wnd.lblList.Content = new AccessText { Text = App.Translation.AddWindow.EffectType };
wnd.ctAddLabel.Text = App.Translation.AddWindow.BtnAdd;
wnd.ctCancelLabel.Text = App.Translation.AddWindow.BtnCancel;
wnd.ctList.ItemsSource = App.EffectTypes;
wnd.ctList.SelectedIndex = 0;
if (wnd.ShowDialog() != true)
return null;
var item = wnd.ctList.SelectedItem as TypeInfo<EffectBase>;
if (item == null)
return null;
var result = item.Constructor();
result.Name = wnd.ctName.Text;
return result;
}
}
}