예제 #1
0
        private void UpdateAlbum(AlbumCollectionEventArgs.ChangeType type, Album changedAlbum)
        {
            SuspendLayout();
            System.Windows.Forms.Control[] ctrls;
            switch (type)
            {
            case AlbumCollectionEventArgs.ChangeType.Add:
                AddAlbumControl(changedAlbum);
                break;

            case AlbumCollectionEventArgs.ChangeType.Clear:
                foreach (System.Windows.Forms.Control ctrl in panel.Controls)
                {
                    CleanAlbumControls(ctrl);
                }
                panel.Controls.Clear();
                LoadAlbums();
                break;

            case AlbumCollectionEventArgs.ChangeType.Remove:
                ctrls = new System.Windows.Forms.Control[panel.Controls.Count];
                panel.Controls.CopyTo(ctrls, 0);
                List <System.Windows.Forms.Control> controllist = new List <System.Windows.Forms.Control>(ctrls);
                CleanAlbumControls(controllist.Find((System.Windows.Forms.Control control) =>
                {
                    AlbumControl albumControl = control as AlbumControl;
                    return(albumControl.Album == changedAlbum);
                }));
                break;
            }
            ResumeLayout();
        }
예제 #2
0
        private void AddAlbumControl(Album album)
        {
            var ac = new AlbumControl();

            ac.LoadAlbum(album);
            panel.Controls.Add(ac);

            ac.DoubleClick += Ac_DoubleClick;
        }
예제 #3
0
        private void Ac_DoubleClick(object sender, EventArgs e)
        {
            AlbumControl ac = (AlbumControl)sender;

            AlbumControlClicked?.Invoke(this, new AlbumControlEventArgs()
            {
                Album = ac.Album
            });
        }
예제 #4
0
        private void LoadAlbums()
        {
            IEnumerable <Album> albumList = source;

            if (!string.IsNullOrEmpty(query))
            {
                albumList = source.SearchByTitle(query);
            }

            SuspendLayout();
            panel.Controls.Clear();

            foreach (Album a in albumList)
            {
                var ac = new AlbumControl();
                ac.LoadAlbum(a);
                panel.Controls.Add(ac);

                ac.DoubleClick += Ac_DoubleClick;
            }

            ResumeLayout();
        }