예제 #1
0
 public void ItemSelected(QuickAccessItem item)
 {
     InvertApplication.Execute(new LambdaCommand("Select Item", () =>
     {
         QuickLaunchItems[SelectedIndex].Action(QuickLaunchItems[SelectedIndex].Item);
     }));
     InvertApplication.SignalEvent <IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this));
 }
 public void ItemSelected(QuickAccessItem item)
 {
     InvertApplication.Execute(new LambdaCommand("Select Item", () =>
     {
         QuickLaunchItems[SelectedIndex].Action(QuickLaunchItems[SelectedIndex].Item);
     }));
     InvertApplication.SignalEvent<IWindowsEvents>(i=>i.WindowRequestCloseWithViewModel(this));
 }
예제 #3
0
        public async Task <List <Playlist> > ConvertPlaylists(IEnumerable <FullPlaylist> playlists)
        {
            try
            {
                List <Playlist> results    = new List <Playlist>();
                BitmapImage     image      = null;
                User            owner      = null;
                int             itemsCount = 0;

                foreach (var item in playlists)
                {
                    if (item.Owner != null)
                    {
                        BitmapImage ownerImg = null;
                        if (item.Owner.Images != null && item.Owner.Images.Count > 0)
                        {
                            ownerImg = new BitmapImage(new Uri(item.Owner.Images.FirstOrDefault().Url));
                        }
                        owner = new User(item.Owner.Id, item.Owner.DisplayName, ownerImg, item.Owner.Uri, item.Owner.ExternalUrls);
                    }

                    if (item.Images != null && item.Images.Count > 0)
                    {
                        image = new BitmapImage(new Uri(item.Images.FirstOrDefault().Url));
                    }

                    if (item.Tracks != null)
                    {
                        itemsCount = item.Tracks.Total;
                    }

                    results.Add(new Playlist(item.Id,
                                             item.Name,
                                             image,
                                             item.Uri,
                                             item.ExternalUrls,
                                             owner,
                                             "",
                                             "",
                                             PlaylistCategoryType.MyPlaylist,
                                             itemsCount,
                                             await QuickAccessItem.IsQuickAccessItem(item.Id)));

                    owner      = null;
                    image      = null;
                    itemsCount = 0;
                }
                return(results);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #4
0
    public void Execute(QuickAccessItem item)
    {
        var x = item.Item;
        var z = item;

        InvertApplication.Execute(new LambdaCommand("Select Item", () =>
        {
            z.Action(x);
        }));

        InvertApplication.SignalEvent <IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this));
    }
예제 #5
0
 public QuickAccessItemViewModel(QuickAccessItem item)
 {
     this.item = item;
 }
예제 #6
0
        /// <summary>
        /// Gets a list of the current users playlists, including following and own playlists.
        /// </summary>
        /// <returns>
        /// The list of playlists.
        /// </returns>
        public async Task <List <Playlist> > GetPlaylists()
        {
            var results = new List <Playlist>();

            PlaylistCurrentUsersRequest request = new PlaylistCurrentUsersRequest
            {
                Limit  = limit,
                Offset = startIndex
            };
            var spotify = await Authentication.GetSpotifyClientAsync();

            if (spotify != null)
            {
                var result = await spotify.Playlists.CurrentUsers(request);

                if (startIndex == 0)
                {
                    page = result;
                }

                if (result != null && result.Items != null)
                {
                    BitmapImage          image        = null;
                    User                 owner        = null;
                    int                  itemsCount   = 0;
                    PlaylistCategoryType categoryType = PlaylistCategoryType.All;
                    foreach (var item in result.Items)
                    {
                        //if (_playlist.Find(c => c.Id == item.Id) == null)
                        //    _playlist.Add(item);

                        if (Profile != null && item.Owner != null)
                        {
                            if (item.Owner.Id == Profile.Id)
                            {
                                categoryType = PlaylistCategoryType.MyPlaylist;
                            }
                            else
                            {
                                if (Models.Category._personalizedPlaylistNames.Find(c => c.ToLower().Equals(item.Name.ToLower())) != null)
                                {
                                    categoryType = PlaylistCategoryType.MadeForYou;
                                }
                                else
                                {
                                    categoryType = PlaylistCategoryType.Following;
                                }
                            }
                        }

                        if (item.Images != null && item.Images.Count > 0)
                        {
                            image = new BitmapImage(new Uri(item.Images.FirstOrDefault().Url));
                        }

                        if (item.Tracks != null)
                        {
                            itemsCount = item.Tracks.Total;
                        }

                        if (item.Owner != null)
                        {
                            BitmapImage ownerImg = null;
                            if (item.Owner.Images != null && item.Owner.Images.Count > 0)
                            {
                                ownerImg = new BitmapImage(new Uri(item.Owner.Images.FirstOrDefault().Url));
                            }
                            owner = new User(item.Owner.Id, item.Owner.DisplayName, ownerImg, item.Owner.Uri, item.Owner.ExternalUrls);
                        }

                        results.Add(new Playlist(item.Id,
                                                 item.Name,
                                                 image,
                                                 item.Uri,
                                                 item.ExternalUrls,
                                                 owner,
                                                 null,
                                                 item.Description,
                                                 categoryType,
                                                 itemsCount,
                                                 await QuickAccessItem.IsQuickAccessItem(item.Id)));

                        //reset
                        image        = null;
                        itemsCount   = 0;
                        owner        = null;
                        categoryType = PlaylistCategoryType.All;
                    }
                }

                startIndex += results.Count;
                return(results);
            }
            else
            {
                ViewModels.Helpers.DisplayDialog("Unable to load playlists", "An error occured, could not load items. Please give it another shot and make sure your internet connection is working");;
                return(null);
            }
        }
    public void Execute(QuickAccessItem item)
    {
        var x = item.Item;
        var z = item;
        InvertApplication.Execute(new LambdaCommand("Select Item", () =>
        {
            z.Action(x);
        }));

        InvertApplication.SignalEvent<IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this));
    }