Download csharp/mdict/Views/LibraryView.xaml.cs from dlxjj/WpfMdict: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/datasets/dlxjj/WpfMdict/resolve/main/csharp/mdict/Views/LibraryView.xaml.cs
- Command line
-
hf download hf://datasets/dlxjj/WpfMdict/csharp/mdict/Views/LibraryView.xaml.cs
-
curl -L -o LibraryView.xaml.cs https://huggingface.co/datasets/dlxjj/WpfMdict/resolve/main/csharp/mdict/Views/LibraryView.xaml.cs
1.47 kB
| using System.Windows; | |
| using System.Windows.Controls; | |
| using Microsoft.Win32; | |
| using mdict.Services; | |
| namespace mdict.Views | |
| { | |
| public partial class LibraryView : UserControl | |
| { | |
| public LibraryView() | |
| { | |
| InitializeComponent(); | |
| DictionariesList.ItemsSource = LibraryManager.Instance.LoadedDictionaries; | |
| } | |
| private void AddDictionary_Click(object sender, RoutedEventArgs e) | |
| { | |
| var openFileDialog = new OpenFileDialog | |
| { | |
| Filter = "MDict Files (*.mdx)|*.mdx|All Files (*.*)|*.*", | |
| Multiselect = true | |
| }; | |
| if (openFileDialog.ShowDialog() == true) | |
| { | |
| foreach (var filename in openFileDialog.FileNames) | |
| { | |
| try | |
| { | |
| LibraryManager.Instance.AddDictionary(filename); | |
| } | |
| catch (System.Exception ex) | |
| { | |
| MessageBox.Show($"Failed to load {filename}:\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); | |
| } | |
| } | |
| } | |
| } | |
| private void RemoveDictionary_Click(object sender, RoutedEventArgs e) | |
| { | |
| if (sender is Button button && button.Tag is DictionaryItem item) | |
| { | |
| LibraryManager.Instance.RemoveDictionary(item); | |
| } | |
| } | |
| } | |
| } | |