-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringDialog.xaml.cs
More file actions
58 lines (53 loc) · 1.93 KB
/
StringDialog.xaml.cs
File metadata and controls
58 lines (53 loc) · 1.93 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Matrix_Elementary
{
/// <summary>
/// Interaction logic for StringDialog.xaml
/// </summary>
public partial class StringDialog : Window
{
public StringDialog(bool dark, string caption = "Input name", string start = "")
{
InitializeComponent();
if (dark)
{
stringDialogWindow.Background = new SolidColorBrush(Color.FromArgb(255, 34, 34, 34));
label1.Foreground = stringDialogWindow.Foreground = new SolidColorBrush(Colors.White);
stringDialogWindow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 80, 80, 80));
stringDialogWindow.Resources.Clear();
stringDialogWindow.Icon = new BitmapImage(new Uri(@"pack://application:,,,/images/ico_black.ico"));
}
stringDialogWindow.Title = caption;
textBox1.Text = start;
label1.Content = caption + ":";
textBox1.SelectAll();
textBox1.Focus();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (textBox1.Text.Length > 0) DialogResult = true;
}
public string Output => textBox1.Text;
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (DialogResult != true)
DialogResult = false;
}
private void Window_PreviewKeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape) Close();
}
}
}