Exemplo n.º 1
0
        public void Drop(IDropInfo dropInfo)
        {
            NoteViewModel sourceItem = dropInfo.Data as NoteViewModel;

            if (sourceItem == null)
            {
                return;
            }

            NotebookViewModel targetItem    = dropInfo.TargetItem as NotebookViewModel;
            ListViewItem      targetElement = dropInfo.VisualTarget as ListViewItem;

            bool removeFromSourceCollection = false;

            if (targetItem != null)
            {
                if (sourceItem.Note.Notebook != targetItem.Notebook.ID)
                {
                    if (sourceItem.Note.InTrashCan)
                    {
                        sourceItem.Note.InTrashCan = false;
                        //sourceItem.Note.Save();
                    }

                    Hub.Instance.Storage.DataStore.MoveNote(sourceItem.Note, targetItem.Notebook);

                    if (SelectedNotebook != null)
                    {
                        removeFromSourceCollection = true;
                    }
                }
                else if (sourceItem.Note.InTrashCan)
                {
                    sourceItem.Note.InTrashCan = false;
                    //sourceItem.Note.Save();

                    removeFromSourceCollection = true;
                }
            }
            else if (targetElement != null)
            {
                if (targetElement.Name == "Favorites")
                {
                    sourceItem.Note.Favourite = true;
                }
                else if (targetElement.Name == "Trash" && !sourceItem.Note.Protected)
                {
                    sourceItem.Note.InTrashCan = true;
                    removeFromSourceCollection = true;
                }

                sourceItem.SaveNote();
            }

            if (removeFromSourceCollection)
            {
                ObservableCollection <NoteViewModel> sourceList = dropInfo.DragInfo.SourceCollection as ObservableCollection <NoteViewModel>;
                sourceList?.Remove(sourceItem);
            }
        }
Exemplo n.º 2
0
        public void Dropped(IDropInfo dropInfo)
        {
            ObservableCollection <NoteViewModel> targetList = dropInfo.TargetCollection as ObservableCollection <NoteViewModel>;

            if (targetList != null)
            {
                for (int i = 0; i < targetList.Count; i++)
                {
                    NoteViewModel nvm = targetList[i];
                    nvm.Note.SortIndex = i;
                    nvm.SaveNote();
                }
            }
        }