|
| 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 llcom.Pages |
| 17 | +{ |
| 18 | + /// <summary> |
| 19 | + /// EncodingFixPage.xaml 的交互逻辑 |
| 20 | + /// </summary> |
| 21 | + public partial class EncodingFixPage : Page |
| 22 | + { |
| 23 | + public EncodingFixPage() |
| 24 | + { |
| 25 | + InitializeComponent(); |
| 26 | + } |
| 27 | + class fixedData |
| 28 | + { |
| 29 | + public string raw { get; set; } |
| 30 | + public string target { get; set; } |
| 31 | + public string result { get; set; } |
| 32 | + } |
| 33 | + |
| 34 | + string[] encodingList = new string[] |
| 35 | + { |
| 36 | + "UTF-8", |
| 37 | + "GBK", |
| 38 | + "windows-1252", |
| 39 | + "Big5", |
| 40 | + "Shift_Jis", |
| 41 | + "iso-8859-1", |
| 42 | + }; |
| 43 | + |
| 44 | + private void RawTextBox_TextChanged(object sender, TextChangedEventArgs e) |
| 45 | + { |
| 46 | + FixResultList.Items.Clear(); |
| 47 | + for(int i = 0; i < encodingList.Length; i++) |
| 48 | + { |
| 49 | + for(int j = 0; j < encodingList.Length; j++) |
| 50 | + { |
| 51 | + if (i == j) |
| 52 | + continue; |
| 53 | + FixResultList.Items.Add(new fixedData |
| 54 | + { |
| 55 | + raw = encodingList[i], |
| 56 | + target = encodingList[j], |
| 57 | + result = Encoding.GetEncoding(encodingList[i]).GetString(Encoding.GetEncoding(encodingList[j]).GetBytes(RawTextBox.Text)) |
| 58 | + }); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + private void FixResultList_MouseDown(object sender, MouseButtonEventArgs e) |
| 64 | + { |
| 65 | + if (e.RightButton == MouseButtonState.Pressed) |
| 66 | + { |
| 67 | + //获取单元格内容 |
| 68 | + string copiedData = (FixResultList.SelectedItem as fixedData).result; |
| 69 | + if (string.IsNullOrEmpty(copiedData)) return; |
| 70 | + //复制到剪贴板 |
| 71 | + Clipboard.Clear(); |
| 72 | + Clipboard.SetData(DataFormats.Text, copiedData); |
| 73 | + MessageBox.Show("copyed:\r\n" + copiedData); |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | +} |
0 commit comments