using System; using System.IO; using System.Windows; using System.Windows.Media.Imaging; namespace ENI2.EditControls { /// /// Interaction logic for CompareExcelDialog.xaml /// public partial class CompareExcelDialog : Controls.StatusWindowBase { private string _sourcePath = null; private string _targetPath = null; public CompareExcelDialog() { InitializeComponent(); } private void imageSource_Drop(object sender, DragEventArgs e) { string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) Console.WriteLine(file); if(files.Length > 0) { if(File.Exists(files[0])) { if(files[0].EndsWith("xls") || files[0].EndsWith("xlsx")) { _sourcePath = files[0]; textBoxSource.Text = _sourcePath; } else { textBoxSource.Text = null; _sourcePath = null; } } else { textBoxSource.Text = null; _sourcePath = null; } EnableCompareButton(); } } private void imageTarget_Drop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) Console.WriteLine(file); if (files.Length > 0) { if (File.Exists(files[0])) { if (files[0].EndsWith("xls") || files[0].EndsWith("xlsx")) { _targetPath = files[0]; textBoxTarget.Text = _targetPath; } else { _targetPath = null; textBoxTarget.Text = null; } } else { _targetPath = null; textBoxTarget.Text = null; } EnableCompareButton(); } } private void imageSource_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effects = DragDropEffects.Copy; } } private void EnableCompareButton() { this.buttonCompare.IsEnabled = (_targetPath != null) && (_sourcePath != null); } private void buttonCompare_Click(object sender, RoutedEventArgs e) { } } }