Exemplo n.º 1
0
        /// <summary>
        /// Deletes a song from the FileCollection. <seealso cref="DeleteCommand"/>
        /// </summary>
        /// <param name="path"><see cref="BreadPlayer.Models.Mediafile"/> to delete.</param>
        public async void Delete(object path)
        {
            try
            {
                int index = 0;
                if (SelectedItems.Count > 0)
                {
                    foreach (var item in SelectedItems)
                    {
                        index = TracksCollection.Elements.IndexOf(item);
                        TracksCollection.RemoveItem(item);
                        LibraryService.RemoveMediafile(item);
                        // SongCount--;
                    }
                }

                if (TracksCollection.Elements.Count > 0)
                {
                    await Task.Delay(100);

                    SelectedItem = index < TracksCollection.Elements.Count ? TracksCollection.Elements.ElementAt(index) : TracksCollection.Elements.ElementAt(index - 1);
                }
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes a song from the FileCollection. <seealso cref="DeleteCommand"/>
        /// </summary>
        /// <param name="path"><see cref="BreadPlayer.Models.Mediafile"/> to delete.</param>
        public async void Delete(object path)
        {
            try
            {
                int index = 0;
                if (SelectedItems.Count > 0)
                {
                    foreach (var item in SelectedItems)
                    {
                        index = TracksCollection.Elements.IndexOf(item);
                        TracksCollection.RemoveItem(item);
                        LibraryService.RemoveMediafile(item);
                    }
                }

                if (TracksCollection.Elements.Count > 0)
                {
                    await Task.Delay(100);

                    SelectedItem = index < TracksCollection.Elements.Count ? TracksCollection.Elements.ElementAt(index) : TracksCollection.Elements.ElementAt(index - 1);
                }
            }
            catch (Exception ex)
            {
                BLogger.Logger.Error("Error occured while deleting a song from collection and list.", ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes a song from the FileCollection. <seealso cref="DeleteCommand"/>
        /// </summary>
        /// <param name="path"><see cref="BreadPlayer.Models.Mediafile"/> to delete.</param>
        public async void Delete(object path)
        {
            int index = 0;

            foreach (var item in SelectedItems)
            {
                index = TracksCollection.Elements.IndexOf(item);
                TracksCollection.RemoveItem(item);
                Database.Remove(item);
                SongCount--;
            }
            await Task.Delay(100);

            SelectedItem = index < TracksCollection.Elements.Count ? TracksCollection.Elements.ElementAt(index) : TracksCollection.Elements.ElementAt(index - 1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deletes a song from the FileCollection. <seealso cref="DeleteCommand"/>
        /// </summary>
        /// <param name="path"><see cref="Macalifa.Models.Mediafile"/> to delete.</param>
        public void Delete(object path)
        {
            if (path is ListBox)
            {
                if (FileListBox == null)
                {
                    FileListBox = path as ListBox;
                }
            }
            else
            {
                var menu = path as MenuFlyoutItem;
                if (FileListBox == null)
                {
                    FileListBox = (menu.Tag as ListBoxItem).GetAncestorsOfType <ListBox>().ToList()[0];
                }
            }
            var       index   = FileListBox.SelectedIndex;
            Mediafile mp3File = FileListBox.SelectedItem as Mediafile;

            TracksCollection.RemoveItem(mp3File);
            FileListBox.SelectedIndex = index - 1;
            FileListBox.Focus(FocusState.Programmatic);
        }