-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDragDropViewModel.cs
38 lines (37 loc) · 1.15 KB
/
DragDropViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Mvvm.POCO;
using System.Data;
using System.Windows.Forms;
using System.ComponentModel;
using DragDropTwoGrids.Model;
namespace DragDropTwoGrids.ViewModels {
public class DragDropViewModel {
public virtual BindingList<File> Files { get; set; }
public DragDropViewModel() {
InitData();
}
private void InitData() {
Files = Repository.CreateFiles();
}
public void Drop(MyDragAndDropEventArgs dataObject) {
File file = dataObject.Record as File;
if(file != null) {
if(Files.Where(f => f.FileName == file.FileName && f.FileSize == file.FileSize).FirstOrDefault() != null) {
dataObject.Cancel = true;
}
else {
dataObject.Cancel = false;
Files.Add(file);
}
}
}
public void RemoveRecord(object record) {
File file = record as File;
if(file != null)
Files.Remove(file);
}
}
}