using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using VisionCommon; namespace MilUI { /// /// Interaction logic for VisionImageTestSettingView.xaml /// public partial class VisionImageTestSettingView : UserControl { private FovInfo _FovInfo; private eVisionTestType _VisionTestType; public VisionImageTestSettingView(FovInfo fovInfo, eVisionTestType visionTestType) { _FovInfo = fovInfo; _VisionTestType = visionTestType; InitializeComponent(); } private async void dataGridFilePaths_SelectionChanged(object sender, SelectionChangedEventArgs e) { if(e.AddedItems.Count > 0) { var dataGrid = sender as DataGrid; } } private void DataGridFilePaths_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effects = DragDropEffects.Copy; } else { e.Effects = DragDropEffects.None; } } private void DataGridFilePaths_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var viewModel = DataContext as VisionImageTestSettingViewModel; string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string path in paths) { if (File.Exists(path)) { if (viewModel.IsImageFile(path)) { viewModel.ImagePaths.Add(new SelectedImagePath(path)); } } else if (Directory.Exists(path)) { viewModel.GetImagePathInFolder(path); } } } } } }