-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathFastbootActionWindow.xaml.cs
80 lines (69 loc) · 2.32 KB
/
FastbootActionWindow.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
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
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Windows;
namespace FastbootEnhance
{
/// <summary>
/// Fastboot_create_resize.xaml 的交互逻辑
/// </summary>
public partial class FastbootActionWindow : Window
{
public enum StartType
{
CREATE,
RESIZE
}
public delegate void FastbootLogicalCallback(string name, ulong size);
public FastbootActionWindow(StartType type,
string partition_name, long size, FastbootLogicalCallback callback)
{
InitializeComponent();
this.name.Text = partition_name;
this.size.Text = size.ToString();
this.ok.Click += delegate
{
if (this.name.Text == "")
{
MessageBox.Show(Properties.Resources.fastboot_partition_name_empty);
return;
}
if (this.size.Text == "")
{
MessageBox.Show(Properties.Resources.fastboot_partition_size_empty);
return;
}
ulong new_size = 0;
try
{
new_size = Convert.ToUInt64(this.size.Text);
}
catch (Exception)
{
MessageBox.Show(Properties.Resources.fastboot_partition_size_invalid);
return;
}
if (type == StartType.RESIZE && new_size == (ulong)size)
{
Close();
return;
}
if (type == StartType.RESIZE && new_size < (ulong)size)
{
MessageBox.Show(Properties.Resources.fastboot_partition_size_unable_shrink);
return;
}
callback(this.name.Text, new_size);
Close();
};
switch (type)
{
case StartType.CREATE:
this.Title = Properties.Resources.fastboot_create_dynamic_partition;
break;
case StartType.RESIZE:
this.Title = Properties.Resources.fastboot_expand_dynamic_partition;
this.name.IsReadOnly = true;
break;
}
}
}
}