示例#1
0
 public ActionResult Save(Bam.Net.Analytics.Image[] values)
 {
     try
     {
         ImageCollection saver = new ImageCollection();
         saver.AddRange(values);
         saver.Save();
         return(Json(new { Success = true, Message = "", Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
 public void DropImages(DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         var pathes = e.Data.GetData(DataFormats.FileDrop, true) as string[];
         if (pathes == null)
         {
             return;
         }
         Task.Factory.StartNew(() =>
         {
             var viewModels = new List <ImageViewModel>();
             foreach (var path in pathes)
             {
                 var attributes = File.GetAttributes(path);
                 bool isFolder  = (attributes & FileAttributes.Directory) == FileAttributes.Directory;
                 if (isFolder)
                 {
                     var files           = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(ImageFormatHelper.IsImage);
                     var imageViewModels = files.Select(p => new ImageViewModel {
                         Path = p
                     });
                     viewModels.AddRange(imageViewModels);
                 }
                 else
                 {
                     if (ImageFormatHelper.IsImage(path))
                     {
                         viewModels.Add(new ImageViewModel {
                             Path = path
                         });
                     }
                 }
                 Application.Current.Dispatcher.Invoke((Action)(() => ImageCollection.AddRange(viewModels)));
             }
         });
     }
 }