コード例 #1
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            int    editalbumid = 0;
            string albumid     = EditAlbumID.Text;

            if (string.IsNullOrEmpty(albumid))
            {
                messageUserControl.ShowInfo("Attention, Actung! Arrividarchi!", "Lookup the album before editing, please.");
            }
            else if (!int.TryParse(albumid, out editalbumid))
            {
                throw new Exception("Current albumid is invalid. Perform lookup again, please.");
            }
            else
            {
                messageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int rowsaffected       = sysmgr.Album_Delete(editalbumid);
                    if (rowsaffected > 0)
                    {
                        AlbumList.DataBind(); //re-executes the ods for the album list
                        EditAlbumID.Text = "";
                    }
                    else
                    {
                        messageUserControl.ShowInfo("Hello, I am a title", "You monster!");
                    }
                }, "Successful", "Album removed, you monster!");
            }
        }
コード例 #2
0
        protected void Add_Click(object sender, EventArgs e)
        {
            //Check validation and additional validation within the code behind.
            //Load up the entity
            if (Page.IsValid)
            {
                string albumtitle  = EditTitle.Text;
                int    albumyear   = int.Parse(EditReleaseYear.Text);
                string albumlabel  = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;
                int    albumartist = int.Parse(EditAlbumArtistList.SelectedValue);

                Album theAlbum = new Album();
                //brings in values to the webpage
                theAlbum.Title        = albumtitle;
                theAlbum.ArtistId     = albumartist;
                theAlbum.ReleaseYear  = albumyear;
                theAlbum.ReleaseLabel = albumlabel;

                messageUserControl.TryRun(() => {
                    AlbumController sysmgr = new AlbumController();
                    int albumid            = sysmgr.Album_Add(theAlbum);
                    EditAlbumID.Text       = albumid.ToString();
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind(); //re-executes the ods for the album list
                    }
                }, "Successful", "Album added");
            }
        }
コード例 #3
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            int    editablumid = 0;
            string albumid     = EditAlbumID.Text;

            if (string.IsNullOrEmpty(albumid))
            {
                MessageUserControl.ShowInfo("Select the album before deleting");
            }
            else if (!int.TryParse(albumid, out editablumid))
            {
                MessageUserControl.ShowInfo("failed", "invalid album id");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int rowsAffected       = sysmgr.Album_Delete(editablumid);
                    EditAlbumID.Text       = rowsAffected.ToString();
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind();
                        ClearControls();
                    }
                    else
                    {
                        throw new Exception("Album was not found. Repeat lookup and update again.");
                    }
                }, "Successful", "Album Removed");
            }
        }
コード例 #4
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            string editID  = EditAlbumID.Text;
            int    albumID = 0;

            if (string.IsNullOrEmpty(editID))
            {
                MessageUserControl.ShowInfo("Error", "Must have album to edit.");
            }
            else if (!int.TryParse(editID, out albumID))
            {
                MessageUserControl.ShowInfo("Error", "Invalid album ID");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController controller = new AlbumController();
                    int rows = controller.Album_Delete(albumID);

                    if (rows > 0)
                    {
                        AlbumList.DataBind();
                        EditAlbumID.Text = "";
                    }
                    else
                    {
                        throw new Exception("No album found. Try again.");
                    }
                }, "Sucessful!", "Album deleted.");
            }
        }
コード例 #5
0
        // GET: Admin/Albums
        public async Task <IActionResult> Index(string orderby, string sort, string keyword)
        {
            var vm = new AlbumList
            {
                Keyword = keyword,
                OrderBy = orderby,
                Sort    = sort
            };

            var query = _context.Albums.AsNoTracking().AsQueryable();

            if (!string.IsNullOrEmpty(keyword))
            {
                query = query.Where(d => d.Title.Contains(keyword) || d.Description.Contains(keyword));
            }


            var gosort = $"{orderby}_{sort}";

            query = gosort switch
            {
                "title_asc" => query.OrderBy(s => s.Title),
                "title_desc" => query.OrderByDescending(s => s.Title),
                "date_asc" => query.OrderBy(s => s.CreatedDate),
                "date_desc" => query.OrderByDescending(s => s.CreatedDate),
                "importance_asc" => query.OrderBy(s => s.Importance),
                "importance_desc" => query.OrderByDescending(s => s.Importance),
                _ => query.OrderByDescending(s => s.Id),
            };

            vm.Albums = await query.ProjectTo <AlbumBVM>(_mapper.ConfigurationProvider).ToListAsync();

            return(View(vm));
        }
コード例 #6
0
 protected void Remove_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         int    editalbumid = 0;
         string albumid     = EditAlbumID.Text;
         if (string.IsNullOrEmpty(albumid))
         {
             MessageUserControl.ShowInfo("Attention", "Look up the album before editing");
         }
         else if (int.TryParse(albumid, out editalbumid))
         {
             MessageUserControl.ShowInfo("Attention", "Current Album ID is Invalid, Look Again!");
         }
         else
         {
             MessageUserControl.TryRun(() =>
             {
                 AlbumController sysmgr = new AlbumController();
                 int rowsaffected       = sysmgr.Album_Delete(editalbumid);
                 EditAlbumID.Text       = albumid.ToString();
                 if (rowsaffected > 0)
                 {
                     AlbumList.DataBind();
                     EditAlbumID.Text = "";
                 }
                 else
                 {
                     throw new Exception("Album was not found. Remove again again");
                 }
             }, "Successful", "Album Removed");
         }
     }
 }
コード例 #7
0
ファイル: ArtistViewModel.cs プロジェクト: thongbkvn/NCT
        public ArtistViewModel(Artist artist)
        {
            Name       = artist.Name;
            Cover      = artist.Cover;
            ArtistInfo = artist;
            if (artist.Cover != null)
            {
                BgImage           = new BitmapImage();
                BgImage.UriSource = new Uri(artist.Cover);
            }
            if (artist.TrackList != null)
            {
                foreach (var track in artist.TrackList)
                {
                    TrackList.Add(new TrackViewModel(track));
                }
            }

            if (artist.AlbumList != null)
            {
                foreach (var album in artist.AlbumList)
                {
                    AlbumList.Add(new AlbumViewModel(album));
                }
            }
        }
コード例 #8
0
 protected void Add_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         //the validation that exists within the event is probably validation that
         //   a) is not possible on the form
         //   b) required for specific events only
         //   c) for some reason, it was decided to the validation in code-behind
         if (int.Parse(EditReleaseYear.Text) >= 1950 &&
             int.Parse(EditReleaseYear.Text) <= DateTime.Today.Year)
         {
             MessageUserControl.TryRun(() =>
             {
                 Album item               = new Album();
                 item.Title               = EditTitle.Text;
                 item.ReleaseYear         = int.Parse(EditReleaseYear.Text);
                 item.ReleaseLabel        = string.IsNullOrEmpty(EditReleaseLabel.Text) ? null : EditReleaseLabel.Text;
                 item.ArtistId            = int.Parse(EditAlbumArtistList.SelectedValue);
                 AlbumController sysmgr   = new AlbumController();
                 int newalbumid           = sysmgr.Album_Add(item);
                 EditAlbumID.Text         = newalbumid.ToString();
                 ArtistList.SelectedValue = item.ArtistId.ToString();
                 AlbumList.DataBind();
             });
         }
         else
         {
             MessageUserControl.ShowInfo("Adding", "Release Year must be 1950 to today");
         }
     }
 }
コード例 #9
0
 protected void Remove_Click(object sender, EventArgs e)
 {
     //the validation that exists within the event is probably validation that
     //   a) is not possible on the form
     //   b) required for specific events only
     //   c) for some reason, it was decided to the validation in code-behind
     if (string.IsNullOrEmpty(EditAlbumID.Text))
     {
         MessageUserControl.ShowInfo("Removing", "Search for an exsiting album before removing");
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             int rowsaffected       = sysmgr.Album_Delete(int.Parse(EditAlbumID.Text));
             if (rowsaffected == 0)
             {
                 throw new Exception("Album no longer on file. Refresh your search.");
             }
             else
             {
                 EditAlbumID.Text = "";
                 AlbumList.DataBind();
             }
         }, "Remove", "Action successful");
     }
 }
コード例 #10
0
ファイル: Search.xaml.cs プロジェクト: aboe026/boxify
 /// <summary>
 /// Clears the search results objects to purge them from memory
 /// </summary>
 private void ClearResults()
 {
     while (Results.Items.Count > 0)
     {
         object listItem = Results.Items.ElementAt(0);
         if (listItem is PlaylistList)
         {
             PlaylistList playlistList = listItem as PlaylistList;
             playlistList.Unload();
             Results.Items.Remove(playlistList);
         }
         else if (listItem is TrackList)
         {
             TrackList trackList = listItem as TrackList;
             trackList.Unload();
             Results.Items.Remove(trackList);
         }
         else if (listItem is AlbumList)
         {
             AlbumList albumList = listItem as AlbumList;
             albumList.Unload();
             Results.Items.Remove(albumList);
         }
     }
 }
コード例 #11
0
        private void Flyout_Click(object sender, RoutedEventArgs e)
        {
            // Walk up the tree to find the ListViewItem.
            // There may not be one if the click wasn't on an item.
            var requestedElement = (FrameworkElement)e.OriginalSource;

            while ((requestedElement != AlbumList) && !(requestedElement is SelectorItem))
            {
                requestedElement = (FrameworkElement)VisualTreeHelper.GetParent(requestedElement);
            }
            var model = AlbumList.ItemFromContainer(requestedElement) as AlbumViewModel;

            if (requestedElement != AlbumList)
            {
                var albumMenu = MainPage.Current.SongFlyout.Items.First(x => x.Name == "AlbumMenu") as MenuFlyoutItem;
                albumMenu.Text       = model.Name;
                albumMenu.Visibility = Visibility.Collapsed;

                // remove performers in flyout
                var index = MainPage.Current.SongFlyout.Items.IndexOf(albumMenu);
                while (!(MainPage.Current.SongFlyout.Items[index + 1] is MenuFlyoutSeparator))
                {
                    MainPage.Current.SongFlyout.Items.RemoveAt(index + 1);
                }

                MainPage.Current.SongFlyout.ShowAt(requestedElement);
            }
        }
コード例 #12
0
        protected void Add_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string title  = EditTitle.Text;
                int    year   = int.Parse(EditReleaseYear.Text);
                string label  = EditReleaseLabel.Text == "" ? null : EditReleaseLabel.Text;
                int    artist = int.Parse(EditAlbumArtistList.SelectedValue);

                Album newAlbum = new Album();
                newAlbum.ArtistId     = artist;
                newAlbum.Title        = title;
                newAlbum.ReleaseYear  = year;
                newAlbum.ReleaseLabel = label;

                MessageUserControl.TryRun(() =>
                {
                    AlbumController controller = new AlbumController();
                    int albumID      = controller.Album_Add(newAlbum);
                    EditAlbumID.Text = albumID.ToString(); //redoes ODS controls
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind();
                    }
                }, "Sucessful!", "Album added to file.");
            }
        }
コード例 #13
0
        public async Task <IActionResult> GetAlbumsForUser([FromQuery] int page = 0, [FromQuery] int pageSize = 20)
        {
            try
            {
                DbUser usr = await this._userManager.GetUserAsync(this.User);

                if (usr != null)
                {
                    AlbumList result = await _repository.ListUserPurchasedAlbumsAsync(usr.Id, page, pageSize, PublishStatus.PUBLISHED);

                    return(Ok(result));
                }
                else
                {
                    return(Unauthorized());
                }
            }
            catch (EntityNotFoundRepositoryException e)
            {
                return(NotFound(new ApiErrorRep(e.Message)));
            }
            catch (Exception e)
            {
                _logger.LogError("ListAlbum", e, "Error listing albums");
                return(StatusCode(500, new ApiErrorRep("Unknown error")));
            }
        }
コード例 #14
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            string albumid     = EditAlbumID.Text;
            int    editalbumid = 0;

            if (string.IsNullOrEmpty(albumid))
            {
                MessageUserControl.ShowInfo("Attention", "Lookup the album before editing, idiot");
            }
            else if (!int.TryParse(albumid, out editalbumid))
            {
                MessageUserControl.ShowInfo("Attention", "Current AlbumID is invalid, idiot");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int rowsaffected       = sysmgr.Album_Delete(editalbumid);
                    if (rowsaffected > 0)
                    {
                        AlbumList.DataBind(); //Re-execute the ODS for the Album List
                        EditAlbumID.Text = "";
                    }
                    else
                    {
                        throw new Exception("Album was not found. Repeat lookup and delete again.");
                    }
                }, "Successful", "Album deleted");
            }
        }
コード例 #15
0
        protected void Add_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string albumtitle = EditTitle.Text;
                int    albumyear  = int.Parse(EditReleaseYear.Text);
                string albumlabel = EditReleaseLabel.Text == "" ?
                                    null : EditReleaseLabel.Text;
                int albumartist = int.Parse(EditAlbumArtistList.SelectedValue);

                Album theAlbum = new Album();
                theAlbum.Title        = albumtitle;
                theAlbum.ArtistId     = albumartist;
                theAlbum.ReleaseYear  = albumyear;
                theAlbum.ReleaseLabel = albumlabel;

                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();
                    int albumid            = sysmgr.Album_Add(theAlbum);
                    EditAlbumID.Text       = albumid.ToString();
                    if (AlbumList.Rows.Count > 0)
                    {
                        AlbumList.DataBind(); //Re-execute the ODS for the Album List
                    }
                }, "Successful", "Album added");
            }
        }
コード例 #16
0
ファイル: JRMC.cs プロジェクト: brianavid/Avid4G.Net
    /// <summary>
    /// Get the collection of tracks which comprise an album
    /// </summary>
    /// <param name="albumId"></param>
    /// <returns></returns>
    public static TrackData[] GetTracksByAlbumId(
        string albumId)
    {
        AlbumData album = AlbumList.GetById(albumId);

        return(album == null ? null : album.Tracks);
    }
コード例 #17
0
ファイル: JRMC.cs プロジェクト: brianavid/Avid4G.Net
    /// <summary>
    /// For all tracks in all Classical albums, build the albumsByComposerId and composerIdByName indexes
    /// </summary>
    private static void BuildIndexByComposer()
    {
        albumsByComposerId = new SortedDictionary <string, AlbumCollection>();
        composerIdByName   = new SortedDictionary <string, string>();

        foreach (var albumId in AlbumList.Keys)
        {
            var album = AlbumList.GetById(albumId);
            if (IsClassicalAlbum(album))
            {
                foreach (var track in album.Tracks)
                {
                    var trackInfo = track.Info;
                    if (trackInfo.ContainsKey("Composer"))
                    {
                        var    composer = trackInfo["Composer"];
                        string composerId;
                        if (!composerIdByName.ContainsKey(composer))
                        {
                            composerId = trackInfo["Key"];
                            albumsByComposerId[composerId] = new AlbumCollection();
                            composerIdByName[composer]     = composerId;
                        }
                        else
                        {
                            composerId = composerIdByName[composer];
                        }

                        albumsByComposerId[composerId].Add(albumId, album);
                    }
                }
            }
        }
    }
コード例 #18
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(EditAlbumID.Text))
     {
         MessageUserControl.ShowInfo("Updating", "Search for an exsiting album before updating");
     }
     else if (int.Parse(EditReleaseYear.Text) >= 1950 &&
              int.Parse(EditReleaseYear.Text) <= DateTime.Today.Year)
     {
         MessageUserControl.TryRun(() =>
         {
             Album item             = new Album();
             item.AlbumId           = int.Parse(EditAlbumID.Text);
             item.Title             = EditTitle.Text;
             item.ReleaseYear       = int.Parse(EditReleaseYear.Text);
             item.ReleaseLabel      = string.IsNullOrEmpty(EditReleaseLabel.Text) ? null : EditReleaseLabel.Text;
             item.ArtistId          = int.Parse(EditAlbumArtistList.SelectedValue);
             AlbumController sysmgr = new AlbumController();
             int rowsaffected       = sysmgr.Album_Update(item);
             if (rowsaffected == 0)
             {
                 throw new Exception("Album no longer on file. Refresh your search.");
             }
             else
             {
                 ArtistList.SelectedValue = item.ArtistId.ToString();
                 AlbumList.DataBind();
             }
         }, "Update", "Action successful");
     }
     else
     {
         MessageUserControl.ShowInfo("Adding", "Release Year must be 1950 to today");
     }
 }
コード例 #19
0
 protected void Search_Click(object sender, EventArgs e)
 {
     AlbumID.Text             = "";
     AlbumTitle.Text          = "";
     AlbumReleaseYear.Text    = "";
     AlbumReleaseLabel.Text   = "";
     ArtistList.SelectedIndex = 0;
     if (string.IsNullOrEmpty(SearchArg.Text))
     {
         MessageUserControl1.ShowInfo("Enter an album title or part of the title.");
     }
     else
     {
         MessageUserControl1.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
             if (albumlist.Count == 0)
             {
                 MessageUserControl1.ShowInfo("Search Result", "No data for album title or partial title " + SearchArg.Text);
                 AlbumList.DataSource = null;
                 AlbumList.DataBind();
             }
             else
             {
                 MessageUserControl1.ShowInfo("Search Result", "Select the desired album for maintanence");
                 AlbumList.DataSource = albumlist;
                 AlbumList.DataBind();
             }
         });
     }
 }
コード例 #20
0
 protected void Remove_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(EditAlbumID.Text))
     {
         MessageUserControl.ShowInfo("Removing", "Search for an exsiting album before removing");
     }
     else
     {
         MessageUserControl.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             int rowsaffected       = sysmgr.Album_Delete(int.Parse(EditAlbumID.Text));
             if (rowsaffected == 0)
             {
                 throw new Exception("Album no longer on file. Refresh your search.");
             }
             else
             {
                 EditAlbumID.Text = "";
                 AlbumList.DataBind();
                 ClearControls();
             }
         }, "Remove", "Action successful");
     }
 }
コード例 #21
0
        protected void Remove_Click(object sender, EventArgs e)
        {
            // physical delete
            int    editalbumid = 0;
            string albumid     = EditAlbumID.Text;

            if (string.IsNullOrEmpty(albumid))                                                 // if there is no album selected to edit
            {
                MessageUserControl.ShowInfo("Attention", "Look up the album before deleting"); // "Title", "Message"
            }
            else if (!int.TryParse(albumid, out editalbumid))                                  // if albumid is not a number
            {
                MessageUserControl.ShowInfo("Attention", "Current albumid is invalid");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    AlbumController sysmgr = new AlbumController();

                    int rowsaffected = sysmgr.Album_Delete(editalbumid);

                    if (rowsaffected > 0)
                    {
                        AlbumList.DataBind();
                    }
                    else
                    {
                        throw new Exception("Album was not found. Repeat lookup and remove again.");
                    }
                }, "Successful", "Album Physically Deleted");
            }
        }
コード例 #22
0
        /// <summary>
        ///     Return All Albums for an Artist using known MusicBrainz_Release-Group_ID
        /// </summary>
        /// <param name="mbid">MusicBrainz_Release-Group_ID</param>
        /// <param name="apiKey">ApiKey</param>
        /// <returns></returns>
        public static AlbumList Album(Guid mbid, string apiKey = "")
        {
            var ret = new AlbumList();

            if (apiKey == "")
            {
                apiKey = Settings.TheAudioDb.ApiKey;
            }

            var le = new LogEntry("Sites.TheAudioDB", "Search", "Album");

            le.Parameters.Add(new Para("mbid", mbid.ToString()));
            le.Parameters.Add(new Para("apiKey", apiKey));
            Logging.NewLogEntry(le);

            try
            {
                ret.Data = Json.Deserialize <AlbumListResult>(Http.Request("http://www.theaudiodb.com/api/v1/json/" + apiKey + "/album-mb.php?i=" + mbid)) ?? new AlbumListResult();
            }
            catch (Exception ex)
            {
                Exceptions.NewException(ex);
            }

            return(new AlbumList(ret.Data));
        }
コード例 #23
0
        internal async void ChangeSort(int selectedIndex)
        {
            var albums = await FileReader.GetAllAlbumsAsync();

            IEnumerable <GroupedItem <AlbumViewModel> > grouped;

            switch (selectedIndex)
            {
            case 0:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                break;

            case 1:
                grouped = GroupedItem <AlbumViewModel> .CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

                break;

            case 2:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());

                break;

            default:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                break;
            }
            AlbumList.Clear();
            foreach (var item in grouped)
            {
                AlbumList.Add(item);
            }
        }
コード例 #24
0
ファイル: Album.aspx.cs プロジェクト: NiuGenen/Web_Log
        protected void Page_Load(object sender, EventArgs e)
        {
            DB.setDBPath(Page.Server.MapPath("/App_Data/UserCenter.accdb"));//设置数据库路径

            if (!IsPostBack)
            {
                if (Session["UserName"] != null)
                {
                    OleDbConnection myconn = DB.createConnection();
                    myconn.Open();
                    string           selectStr = "select * from Album";
                    OleDbDataAdapter oda       = new OleDbDataAdapter(selectStr, myconn);
                    DataSet          ds        = new DataSet();
                    oda.Fill(ds);
                    AlbumList.DataSource = ds;
                    AlbumList.DataBind();

                    myconn.Close();
                }
                else
                {
                    AlbumLabel.Text    = "请先登录";
                    AlbumLabel.Visible = true;
                }
            }
        }
コード例 #25
0
        private void AlbumList_ItemClick(object sender, ItemClickEventArgs e)
        {
            var container = (AlbumList.ContainerFromItem(e.ClickedItem) as SelectorItem).ContentTemplateRoot as AlbumItem;

            container.PrePareConnectedAnimation();
            LibraryPage.Current.Navigate(typeof(AlbumDetailPage), e.ClickedItem);
            _clickedAlbum = e.ClickedItem as AlbumViewModel;
        }
コード例 #26
0
        public IActionResult Index2()
        {
            AlbumService service = new AlbumService();
            AlbumList    list    = new AlbumList();

            list.Albums = service.GetAlbums();
            return(View("Index2", list));
        }
コード例 #27
0
        public static AlbumList QueryFiles(string query = "")
        {
            try
            {
                string[] allFiles = { };
                MbApi.Library_QueryFilesEx(query, ref allFiles);
                MetaDataType[] fields =
                {
                    MetaDataType.Album,
                    MetaDataType.AlbumArtist,
                    MetaDataType.Artist,
                    MetaDataType.TrackNo,
                    MetaDataType.Rating,
                    MetaDataType.TrackTitle,
                    MetaDataType.RatingLove,
                };

                List <TrackData> allTrackData = new List <TrackData>();

                for (int i = 0; i < allFiles.Length; i++)
                {
                    string[] fileTags = { };
                    MbApi.Library_GetFileTags(allFiles[i], fields, ref fileTags);

                    allTrackData.Add(new TrackData()
                    {
                        FilePath    = allFiles[i],
                        Album       = fileTags[0],
                        AlbumArtist = fileTags[1],
                        Artist      = fileTags[2],
                        TrackNo     = fileTags[3],
                        Rating      = fileTags[4],
                        TrackTitle  = fileTags[5],
                        Loved       = fileTags[6],
                    });
                }

                var GroupedTrackList = allTrackData.GroupBy(t => new { t.Album, t.AlbumArtist }).Select(
                    albm => new AlbumData()
                {
                    Album       = albm.Key.Album,
                    AlbumArtist = albm.Key.AlbumArtist,
                    TrackList   = albm.ToList(),
                }).OrderBy(x => x.Album).ToList();

                AlbumList trackLists = new AlbumList()
                {
                    callback_function = "fileQueryComplete", AlbumLists = GroupedTrackList
                };


                return(trackLists);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #28
0
        public async Task GetAlbums()
        {
            var albums = await FileReader.GetAllAlbumsAsync();

            //var grouped = GroupedItem<AlbumViewModel>.CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

            //var grouped = GroupedItem<AlbumViewModel>.CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());
            IEnumerable <GroupedItem <AlbumViewModel> > grouped;

            switch (Settings.Current.AlbumsSort)
            {
            case SortMode.Alphabet:
                grouped = GroupedItem <AlbumViewModel> .CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

                SortIndex = 1;
                break;

            case SortMode.Year:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                SortIndex = 0;
                break;

            case SortMode.Artist:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());

                SortIndex = 2;
                break;

            default:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                SortIndex = 0;
                break;
            }

            var aCount = await FileReader.GetArtistsCountAsync();

            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                AlbumList.Clear();
                foreach (var item in grouped)
                {
                    AlbumList.Add(item);
                }
                SongsCount   = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartAlbums"), albums.Count);
                ArtistsCount = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartArtists"), aCount);


                var tileId = "albums";
                IsPinned   = SecondaryTile.Exists(tileId);

                if (IsPinned)
                {
                    Core.Tools.Tile.UpdateImage(tileId, AlbumList.SelectMany(a => a.Where(c => c.ArtworkUri != null).Select(b => b.ArtworkUri.OriginalString)).Distinct().OrderBy(x => Guid.NewGuid()).Take(10).ToList(), Consts.Localizer.GetString("AlbumsText"), Consts.Localizer.GetString("AlbumsTile"));
                }
            });
        }
コード例 #29
0
        private void SemanticZoom_ViewChangeCompleted(object sender, SemanticZoomViewChangedEventArgs e)
        {
            var zoom = sender as SemanticZoom;

            if (zoom.IsZoomedInViewActive)
            {
                var scroller = AlbumList.GetScrollViewer();
                scroller.ChangeView(null, scroller.VerticalOffset - 120, null);
            }
        }
コード例 #30
0
        public async Task GetAlbums()
        {
            var albumList = await _albumService.Get <IEnumerable <Album> >(SelectedPerformer.Id, "GetAlbumsByPerformerId");

            AlbumList.Clear();
            foreach (var item in albumList)
            {
                AlbumList.Add(item);
            }
        }
コード例 #31
0
        private void ListAlbumCallback()
        {
            var web = (HttpWebRequest)WebRequest.Create(string.Format("https://api.vkontakte.ru/method/photos.getAlbums?uid={0}&access_token={1}", _uid, Client.Instance.Access_token.token));
            web.Method = "POST";
            web.ContentType = "application/x-www-form-urlencoded";
            web.BeginGetResponse(delegate(IAsyncResult e)
                                     {
                                         var request = (HttpWebRequest)e.AsyncState;
                                         var response = (HttpWebResponse)request.EndGetResponse(e);

                                         var responseReader = new StreamReader(response.GetResponseStream());
                                         _al = new AlbumList();
                                         try
                                         {
                                             var responseString = responseReader.ReadToEnd();
                                             var o = JObject.Parse(responseString);
                                             try
                                             {
                                                 var responseArray = (JArray)o["response"];
                                                 foreach (var albumItem in responseArray.Select(album => new AlbumItem
                                                                                                             {
                                                                                                                 Aid = (string) album["aid"],
                                                                                                                 ThumbId = (string) album["thumb_id"],
                                                                                                                 OwnerId = (string) album["owner_id"],
                                                                                                                 Title = (string) album["title"],
                                                                                                                 Description = (string) album["description"],
                                                                                                                 Created = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Convert.ToDouble(Convert.ToInt32((string) album["created"]))),
                                                                                                                 Updated = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Convert.ToDouble(Convert.ToInt32((string) album["updated"]))),
                                                                                                                 Size = (string) album["size"] + " фот."
                                                                                                             }))
                                                 {
                                                     _thumbIdList.Add(albumItem.OwnerId + "_" + albumItem.ThumbId);
                                                     _al.Add(albumItem);
                                                 }
                                                 Dispatcher.BeginInvoke(ListAlbumThumbCallback);
                                             }
                                             catch
                                             {
                                                 Dispatcher.BeginInvoke(() =>
                                                 {
                                                     NoAlbums.Text = "альбомов нет";
                                                     progressBar1.IsIndeterminate = false;
                                                 });
                                                 return;
                                             }
                                         }
                                         catch (Exception ex)
                                         {
                                             Dispatcher.BeginInvoke(() => { MessageBox.Show(ex.Message); progressBar1.IsIndeterminate = false; });
                                         }
                                     }, web);
            progressBar1.IsIndeterminate = true;
        }
コード例 #32
0
ファイル: mainWindow.cs プロジェクト: nithyankug/PhotoViewer
        private void load()
        {
            string path = "Albums.xml";
            FileStream fs;

            if (!File.Exists(path))
            {
                fs = File.Create(path);
                fs.Close();
            }

            using (StreamReader rd = new StreamReader("Albums.xml"))
            {
                try
                {
                    albums = _xs.Deserialize(rd) as AlbumList;
                    if (albums.Count >= 1)
                    {
                        albums.SetActive(0);
                    }
                }
                catch (Exception excp)
                {
                    Console.WriteLine("********");
                    Console.WriteLine("********");
                    Console.WriteLine("******** " + excp.Message);
                    Console.WriteLine("******** " + excp.InnerException.Message);
                    Console.WriteLine("********");
                    Console.WriteLine("********");
                }
                finally
                {
                    rd.Close();
                }

                if (albums == null)
                {
                    load_default();
                    save();
                }
            }
        }
コード例 #33
0
ファイル: mainWindow.cs プロジェクト: nithyankug/PhotoViewer
        private void load_default()
        {
            PictureList pl;

            pl = Picture.ExtractListFromPath(Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures));
            Album a = new Album(pl, "Shared Pictures");
            albums = new AlbumList();
            albums.Add(a);
            albums.SetActive(a);
        }