Example #1
0
        private void FileDropBorder_Drop(object sender, DragEventArgs e)
        {
            _picIOService = new FileIOService(PATHPICK);
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var currentRowIndex = dgTraderTable.Items.IndexOf(dgTraderTable.CurrentItem);
                if (currentRowIndex > -1)
                {
                    if (e.Data.GetDataPresent(DataFormats.FileDrop))
                    {
                        var      border       = (Border)sender;
                        var      imgThumbnail = (Image)border.Child;
                        string[] files        = (string[])e.Data.GetData(DataFormats.FileDrop);
                        string   filename     = Path.GetFileName(files[0]);
                        Uri      filepath     = new Uri(files[0]);

                        BitmapImage image = new BitmapImage();
                        image.BeginInit();
                        image.CacheOption = BitmapCacheOption.OnLoad;
                        image.UriSource   = filepath;
                        image.EndInit();
                        imgThumbnail.Source = image;

                        var imageName = PATHPICK + currentRowIndex + imgThumbnail.Name + ".bmp";
                        _fileIOService.SavePic((BitmapImage)imgThumbnail.Source, imageName);
                    }
                }
            }
        }