Ejemplo n.º 1
0
        /// <summary>
        /// Create an AudioSourceSearchResultItem from the given AudioSource SearchResult
        /// </summary>
        /// <param name="result"></param>
        public SearchResultListItem(ISearchResult result) : base()
        {
            this.Text = result.Title;
            this.SubItems.Add(result.Author);
            this.SubItems.Add(
                (DateTime.Today + result.Duration).ToString("HH::mm::ss.fff")
                );
            this.m_ItemAudioType = result.ResultType;
            this.m_SearchResult  = result;

            switch (result.ResultType)
            {
            case AudioSearchResultType.ModeElement:
                this.ImageIndex = AudioSourceSearchWindow.IMAGE_INDEX_MODE_ELEMENT;
                break;

            case AudioSearchResultType.MusicFile:
                this.ImageIndex = AudioSourceSearchWindow.IMAGE_INDEX_MUSIC;
                break;

            case AudioSearchResultType.SoundFile:
                this.ImageIndex = AudioSourceSearchWindow.IMAGE_INDEX_SOUND;
                break;
            }
        }
Ejemplo n.º 2
0
 public FileSearchResult(TestAudioSource audioSource, AudioSearchResultType type, string resourceName)
     : base(audioSource, type)
 {
     this.m_ResourceName = resourceName;
     this.m_Type         = type;
     this.FileType       = type == AudioSearchResultType.MusicFile ? SoundFileType.Music : SoundFileType.SoundEffect;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Determine the AudioSearchResultType of the given selected items.
        /// The first item's AudioSearchResultType is assumed to apply to all items, but
        /// this is verified and an InvalidOperationException is thrown if any item in the
        /// list has a different AudioSearchResultType than the first one.
        /// </summary>
        /// <param name="selectedItems"></param>
        /// <returns></returns>
        private static AudioSearchResultType FindAndVerifySelectedAudioType(IEnumerable <SearchResultListItem> selectedItems)
        {
            // Determine the overall AudioType from the first selected item
            SearchResultListItem  firstItem            = selectedItems.First();
            AudioSearchResultType overallItemAudioType = firstItem.ItemAudioType;

            // Make sure all other items' AudioTypes are compatible (the same)
            foreach (SearchResultListItem item in selectedItems)
            {
                if (item.ItemAudioType != overallItemAudioType)
                {
                    // Show a message to the user that he should only select items of the same type?
                    throw new InvalidOperationException(StringResources.PleaseSelectOnlyEntriesOfTheSameType);
                }
            }

            return(overallItemAudioType);
        }
Ejemplo n.º 4
0
 protected BaseSearchResult(IAudioSource audioSource, AudioSearchResultType resultType)
 {
     this.ResultType          = resultType;
     this.AudioSource         = audioSource;
     this.FilesToBeDownloaded = new List <IDeployableAudioFile>();
 }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
0
 public bool IsAudioTypeSupported(AudioSearchResultType type)
 {
     return(true);
 }