-
Notifications
You must be signed in to change notification settings - Fork 2
/
Selection.xaml.cs
40 lines (35 loc) · 1.09 KB
/
Selection.xaml.cs
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
using System;
using System.Collections.Generic;
using System.Windows;
namespace EldenRingTool
{
/// <summary>
/// Interaction logic for Selection.xaml
/// </summary>
public partial class Selection : Window
{
Action<object> _callback;
public Selection(List<object> items, Action<object> callback, string name = null)
{
_callback = callback;
InitializeComponent();
if (!string.IsNullOrWhiteSpace(name)) { Title = name; }
listBox.ItemsSource = items;
SetMaxHeight();//try and prevent OK button clipping off screeen
DpiChanged += OnDpiChanged;
}
private void OnDpiChanged(object sender, DpiChangedEventArgs e)
{
SetMaxHeight();
}
private void SetMaxHeight()
{
MaxHeight = SystemParameters.PrimaryScreenHeight * 0.9;
}
private void okClick(object sender, RoutedEventArgs e)
{
_callback(listBox.SelectedItem);
Close();
}
}
}