Esempio n. 1
0
        /// <summary>
        /// Start a drag&drop operation with the given IModelElementSearchResults
        /// </summary>
        /// <param name="selectedItems"></param>
        /// <returns></returns>
        private DragDropEffects StartDragModeElementSearchResults(IEnumerable <IModeElementSearchResult> searchResults, AresTargetDirectoryProvider targetDirectoryProvider)
        {
            List <IXmlWritable> draggedItems = new List <IXmlWritable>();

            foreach (IModeElementSearchResult modeElementSearchResult in searchResults)
            {
                // Get the ModeElement definition
                draggedItems.Add(modeElementSearchResult.GetModeElementDefinition(targetDirectoryProvider));
            }

            // Start a drag & drop operation for those project elements
            StringBuilder serializedForm = new StringBuilder();

            Data.DataModule.ProjectManager.ExportElements(draggedItems, serializedForm);
            ProjectExplorer.ClipboardElements cpElements = new ProjectExplorer.ClipboardElements()
            {
                SerializedForm = serializedForm.ToString()
            };
            return(DoDragDrop(cpElements, DragDropEffects.Move));
        }
Esempio n. 2
0
        /// <summary>
        /// Start a drag&drop operation with the given IFileSearchResults
        /// </summary>
        /// <param name="searchResults"></param>
        /// <param name="overallItemAudioType"></param>
        /// <returns></returns>
        private DragDropEffects StartDragFileSearchResults(IEnumerable <IFileSearchResult> searchResults, AudioSearchResultType overallItemAudioType, AresTargetDirectoryProvider targetDirectoryProvider)
        {
            List <DraggedItem> draggedFiles = new List <DraggedItem>();

            foreach (IFileSearchResult fileSearchResult in searchResults)
            {
                // Create a new DraggedItem (dragged file/folder)
                DraggedItem draggedFile = new DraggedItem();

                // Set item & node type for the file
                draggedFile.ItemType = overallItemAudioType == AudioSearchResultType.MusicFile ? FileType.Music : FileType.Sound;
                draggedFile.NodeType = DraggedItemType.File;

                // Determine the relative path where the downloaded file will be placed
                string relativeDownloadPath = targetDirectoryProvider.GetFolderWithinLibrary(fileSearchResult);
                draggedFile.RelativePath = System.IO.Path.Combine(relativeDownloadPath, fileSearchResult.Filename);
                draggedFile.Title        = fileSearchResult.Title;
                draggedFiles.Add(draggedFile);
            }

            // Start a file/folder drag & drop operation for those files
            FileDragInfo info = new FileDragInfo();

            info.Source       = FileSource.Online;
            info.DraggedItems = draggedFiles;
            info.TagsFilter   = new TagsFilter();
            return(DoDragDrop(info, DragDropEffects.Copy));
        }
Esempio n. 3
0
        /// <summary>
        /// Start a drag&drop operation for the items currently selected in the results list
        /// </summary>
        private void StartDragSelectedResults()
        {
            // Make sure there actually is a selection
            if (resultsListView.SelectedIndices.Count < 1)
            {
                // No item selecte, don't drag
                return;
            }

            IEnumerable <SearchResultListItem> selectedItems = GetSelectedItems();

            AresTargetDirectoryProvider targetDirectoryProvider = new AresTargetDirectoryProvider(m_selectedAudioSource, String.Empty);

            TargetDirectoryProvider.Current = targetDirectoryProvider;
            AudioSearchResultType overallItemAudioType = FindAndVerifySelectedAudioType(selectedItems);

            // Decide depending on the overall AudioType of the selected items
            DragDropEffects dragDropResult = DragDropEffects.None;
            List <string>   stubFiles      = null;

            switch (overallItemAudioType)
            {
            // If the dragged items are Music or Sound files
            case AudioSearchResultType.MusicFile:
            case AudioSearchResultType.SoundFile:
                IEnumerable <IFileSearchResult> selectedFileResults =
                    selectedItems
                    // Extract the IFileSearchResult from the SearchResultListItem
                    .Select(item => item.SearchResult as IFileSearchResult)
                    // Filter out null/incompatible search results
                    .Where(result => result != null);

                BeforeStartDrag(selectedFileResults, targetDirectoryProvider, out stubFiles);
                dragDropResult = StartDragFileSearchResults(selectedFileResults, overallItemAudioType, targetDirectoryProvider);

                if (dragDropResult == DragDropEffects.Copy)
                {
                    AfterCompleteDrag(selectedFileResults, targetDirectoryProvider);
                }
                else
                {
                    AfterCancelDrag(selectedFileResults, targetDirectoryProvider, stubFiles);
                }
                TargetDirectoryProvider.Current = null;
                return;

            // If the dragged items are ModeElements
            case AudioSearchResultType.ModeElement:
                IEnumerable <IModeElementSearchResult> selectedModeElementResults =
                    selectedItems
                    // Extract the IModeElementSearchResult from the SearchResultListItem
                    .Select(item => item.SearchResult as IModeElementSearchResult)
                    // Filter out null/incompatible search results
                    .Where(result => result != null);

                BeforeStartDrag(selectedModeElementResults, targetDirectoryProvider, out stubFiles);
                dragDropResult = StartDragModeElementSearchResults(selectedModeElementResults, targetDirectoryProvider);

                if (dragDropResult == DragDropEffects.Move)
                {
                    AfterCompleteDrag(selectedModeElementResults, targetDirectoryProvider);
                }
                else
                {
                    AfterCancelDrag(selectedModeElementResults, targetDirectoryProvider, stubFiles);
                }
                TargetDirectoryProvider.Current = null;
                return;
            }
        }