blob: f0dcffa65bf027f4007e645b759d9f5f4617f0e7 (
plain)
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
|
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
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.Navigation;
using System.Windows.Shapes;
namespace Tango.FSE.UI.Dialogs
{
/// <summary>
/// Interaction logic for ApplicationUpdateView.xaml
/// </summary>
public partial class JobUploadView : UserControl
{
private List<NumericUpDown> nums;
public JobUploadView()
{
InitializeComponent();
nums = new List<NumericUpDown>();
}
private void Num_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control)
{
if (e.Key == Key.V)
{
try
{
DataObject o = (DataObject)Clipboard.GetDataObject();
if (o.GetDataPresent(DataFormats.Text))
{
string[] cells = Regex.Split(o.GetData(DataFormats.Text).ToString().TrimEnd("\r\n".ToCharArray()), "\t");
if (cells.Length > 1)
{
e.Handled = true;
int indexOfSender = nums.IndexOf(sender as NumericUpDown);
for (int i = indexOfSender; i < nums.Count; i++)
{
if (i - indexOfSender < cells.Length)
{
if (int.TryParse(cells[i - indexOfSender], out int value))
{
nums[i].Value = value;
}
}
}
}
}
}
catch { }
}
}
}
private void NumericUpDown_Loaded(object sender, RoutedEventArgs e)
{
NumericUpDown num = sender as NumericUpDown;
nums.Add(num);
}
}
}
|