Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using System.Threading.Tasks; |
---|
6 | using System.Windows; |
---|
7 | using System.Windows.Controls; |
---|
8 | using System.Windows.Data; |
---|
9 | using System.Windows.Documents; |
---|
10 | using System.Windows.Input; |
---|
11 | using System.Windows.Media; |
---|
12 | using System.Windows.Media.Imaging; |
---|
13 | using System.Windows.Navigation; |
---|
14 | using System.Windows.Shapes; |
---|
15 | |
---|
16 | namespace Leikepoyta |
---|
17 | { |
---|
18 | /// <summary> |
---|
19 | /// Interaction logic for MainWindow.xaml |
---|
20 | /// </summary> |
---|
21 | public partial class MainWindow : Window |
---|
22 | { |
---|
23 | public MainWindow() |
---|
24 | { |
---|
25 | InitializeComponent(); |
---|
26 | ClipboardListener.ClipboardUpdate += LisaaElementti; |
---|
27 | } |
---|
28 | |
---|
29 | public void LisaaElementti(string content) |
---|
30 | { |
---|
31 | listBox.Items.Add(content); |
---|
32 | } |
---|
33 | |
---|
34 | private async void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) |
---|
35 | { |
---|
36 | if (listBox.SelectedIndex >= 0) |
---|
37 | { |
---|
38 | ClipboardListener.ClipboardUpdate -= LisaaElementti; |
---|
39 | Clipboard.SetText(listBox.SelectedItem.ToString()); |
---|
40 | await Task.Delay(10); |
---|
41 | ClipboardListener.ClipboardUpdate += LisaaElementti; |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | private void listBox_KeyUp(object sender, KeyEventArgs e) |
---|
46 | { |
---|
47 | if (listBox.SelectedIndex >= 0 && e.Key.Equals(Key.Delete)) |
---|
48 | { |
---|
49 | listBox.SelectedIndex--; |
---|
50 | listBox.Items.RemoveAt(listBox.SelectedIndex + 1); |
---|
51 | } |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.