public void Drop(IDropInfo dropInfo)
        {
            var dataObject = dropInfo.Data as DataObject;

            if (dataObject != null)
            {
                if (dataObject.ContainsFileDropList())
                {
                    Mementor.BeginBatch();
                    var filedrop = dataObject.GetFileDropList();
                    foreach (string str in filedrop)
                    {
                        foreach (string fm in FileMask)
                        {
                            if (System.IO.Path.GetExtension(str).ToUpperInvariant() == fm)
                            {
                                FileNameItem lbfn = new FileNameItem(Mementor)
                                {
                                    FileName = str, FileIsSelected = false
                                };
                                FilePaths.Add(lbfn);
                                Mementor.ElementAdd(FilePaths, lbfn);
                            }
                        }
                    }
                    Mementor.EndBatch();
                }
            }


            if (dropInfo.DragInfo != null)
            {
                if (dropInfo.DragInfo.VisualSource != dropInfo.VisualTarget && dropInfo.Data.GetType() == typeof(FileNameItem))
                {
                    FileNameItem filenameitem    = dropInfo.Data as FileNameItem;
                    FileNameItem newfilenameitem = filenameitem.Clone() as FileNameItem;
                    FilePaths.Insert(dropInfo.InsertIndex, newfilenameitem);
                    Mementor.ElementAdd(FilePaths, newfilenameitem);
                }
            }
        }
Esempio n. 2
0
        private static void ClassChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Move:
                M.ElementIndexChange((Class)sender, (Student)args.OldItems[0], args.OldStartingIndex);
                Cache = new ObservableCollection <Student>((Class)sender);
                break;

            case NotifyCollectionChangedAction.Add:
            case NotifyCollectionChangedAction.Replace:
            case NotifyCollectionChangedAction.Remove:
                if (args.OldItems != null)
                {
                    foreach (var student in args.OldItems.Cast <Student>())
                    {
                        M.ElementRemove((Class)sender, student, Cache.IndexOf(student));
                        student.PropertyChanging -= StudentChanging;
                    }
                }

                if (args.NewItems != null)
                {
                    foreach (var student in args.NewItems.Cast <Student>())
                    {
                        M.ElementAdd((Class)sender, student);
                        student.PropertyChanging += StudentChanging;
                    }
                }

                Cache = new ObservableCollection <Student>((Class)sender);
                break;

            default:
                throw new NotSupportedException();
            }
        }