コード例 #1
0
ファイル: MyMusicViewModel.cs プロジェクト: Haz3/Soonzik
        private void DownloadMusicExecute()
        {
            var request = new HttpRequestGet();
            var res = request.GetObject(new Music(), "musics", SelectedMusic.id.ToString());
            res.ContinueWith(delegate(Task<object> task)
            {
                var music = task.Result as Music;
                if (music != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                        () =>
                        {
                            SelectedMusic = music;
                            SelectedMusic.file = "http://soonzikapi.herokuapp.com/musics/get/" + SelectedMusic.id;

                            DownloadFile();
                        });
                }
            });
        }
コード例 #2
0
 private void ArtistStackPanel_OnTapped(object sender, TappedRoutedEventArgs e)
 {
     var get = new HttpRequestGet();
     var res = get.GetObject(new User(), "users", SelectedArtist.id.ToString());
     res.ContinueWith(delegate(Task<object>tmp)
     {
         var user = tmp.Result as User;
         if (user != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     user.profilImage =
                         new BitmapImage(new Uri(Constant.UrlImageUser + user.image, UriKind.RelativeOrAbsolute));
                     ProfilArtisteViewModel.TheUser = user;
                     SetChildren(new ProfilArtiste());
                 });
         }
     });
 }
コード例 #3
0
ファイル: MyNetworkViewModel.cs プロジェクト: Haz3/Soonzik
 private static async void CheckConversation()
 {
     var localFolder = ApplicationData.Current.LocalFolder;
     try
     {
         // Getting JSON from file if it exists, or file not found exception if it does not  
         var textFile = await localFolder.GetFileAsync("conversations");
         if (textFile == null)
         {
             var localFolder2 = ApplicationData.Current.LocalFolder;
             textFile = await localFolder2.CreateFileAsync("conversations",
                 CreationCollisionOption.ReplaceExisting);
         }
         using (IRandomAccessStream textStream = await textFile.OpenReadAsync())
         {
             // Read text stream     
             using (var textReader = new DataReader(textStream))
             {
                 //get size                       
                 var textLength = (uint) textStream.Size;
                 await textReader.LoadAsync(textLength);
                 // read it                    
                 var jsonContents = textReader.ReadString(textLength);
                 // deserialize back to our product!  
                 var getConv = JsonConvert.DeserializeObject<ObservableCollection<Message>>(jsonContents);
                 if (getConv.Count == _conversation.Count)
                 {
                     return;
                 }
                 AgileCallback();
                 var newList = new ObservableCollection<Message>();
                 for (var i = getConv.Count; i < _conversation.Count; i++)
                 {
                     if (_conversation[i].user_id != Singleton.Singleton.Instance().CurrentUser.id)
                         newList.Add(_conversation[i]);
                 }
                 var req = new HttpRequestGet();
                 foreach (var message in newList)
                 {
                     var user = req.GetObject(new User(), "users", message.user_id.ToString());
                     user.ContinueWith(delegate(Task<object> task)
                     {
                         var res = task.Result as User;
                         if (res != null)
                         {
                             var toastType = ToastTemplateType.ToastText02;
                             var toastXml = ToastNotificationManager.GetTemplateContent(toastType);
                             var toastTextElement = toastXml.GetElementsByTagName("text");
                             toastTextElement[0].AppendChild(
                                 toastXml.CreateTextNode("New Message from " + res.username));
                             var toastNode = toastXml.SelectSingleNode("/toast");
                             ((XmlElement) toastNode).SetAttribute("duration", "long");
                             var toast = new ToastNotification(toastXml);
                             ToastNotificationManager.CreateToastNotifier().Show(toast);
                         }
                     });
                 }
             }
         }
     }
     catch (Exception ex)
     {
         var Text = "Exception: " + ex.Message;
     }
 }
コード例 #4
0
ファイル: ExplorerViewModel.cs プロジェクト: Haz3/Soonzik
 private void PlayCommandExecute()
 {
     if (SelecMusic != null)
         SelectedMusic = SelecMusic;
     var request = new HttpRequestGet();
     var res = request.GetObject(new Music(), "musics", SelectedMusic.id.ToString());
     res.ContinueWith(delegate(Task<object> task)
     {
         var music = task.Result as Music;
         if (music != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     SelectedMusic = music;
                     SelectedMusic.file = "http://soonzikapi.herokuapp.com/musics/get/" + SelectedMusic.id;
                     Singleton.Singleton.Instance().SelectedMusicSingleton.Clear();
                     Singleton.Singleton.Instance().SelectedMusicSingleton.Add(SelectedMusic);
                     GlobalMenuControl.MyPlayerToggleButton.IsChecked = true;
                     GlobalMenuControl.SetPlayerAudio();
                 });
         }
     });
 }
コード例 #5
0
ファイル: ExplorerViewModel.cs プロジェクト: Haz3/Soonzik
 public void LoadContent()
 {
     ListArtiste = new ObservableCollection<User>();
     ListMusique = new ObservableCollection<Music>();
     ListInfluences = new ObservableCollection<Influence>();
     ListAmbiance = new ObservableCollection<Ambiance>();
     var request = new HttpRequestGet();
     try
     {
         var listIdentities = request.GetIdentities(new List<Identities>(), Singleton.Singleton.Instance().CurrentUser.id.ToString(), Singleton.Singleton.Instance().SecureKey);
         listIdentities.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Identities>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     if (item.provider == "soundcloud")
                     {
                         var post = new HttpRequestPost();
                         var result = post.GetMusicalPast(item.uid, Singleton.Singleton.Instance().SecureKey,
                             Singleton.Singleton.Instance().CurrentUser.id.ToString());
                         result.ContinueWith(delegate(Task<string> t) { var res = t.Result; });
                     }
                 }
             }
         });
         var listGenre = request.GetListObject(new List<Influence>(), "influences");
         listGenre.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Influence>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                         () => { ListInfluences.Add(item); });
                 }
             }
         });
         var listUser = request.GetListObject(new List<User>(), "users");
         listUser.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<User>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     var res = request.GetArtist(new Artist(), "users", item.id.ToString());
                     res.ContinueWith(delegate(Task<object> obj)
                     {
                         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                             () =>
                             {
                                 var art = obj.Result as Artist;
                                 item.profilImage =
                                     new BitmapImage(new Uri(Constant.UrlImageUser + item.image,
                                         UriKind.RelativeOrAbsolute));
                                 if (art != null && art.artist)
                                     ListArtiste.Add(item);
                             });
                     });
                 }
             }
         });
         ValidateKey.GetValideKey();
         var listZik = request.GetSuggest(new List<Music>(), "music");
         listZik.ContinueWith(delegate(Task<object> tmp)
         {
             var test = tmp.Result as List<Music>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                         CoreDispatcherPriority.Normal,
                         () =>
                         {
                             item.album.imageAlbum =
                                 new BitmapImage(new Uri(Constant.UrlImageAlbum + item.album.image,
                                     UriKind.RelativeOrAbsolute));
                             ListMusique.Add(item);
                         });
                 }
             }
         });
         var listAmb = request.GetListObject(new List<Ambiance>(), "ambiances");
         listAmb.ContinueWith(delegate(Task<object> task)
         {
             var test = listAmb.Result as List<Ambiance>;
             if (test != null)
             {
                 foreach (var item in test)
                 {
                     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                         CoreDispatcherPriority.Normal,
                         () =>
                         {
                             var ambiance = request.GetObject(new Ambiance(), "ambiances", item.id.ToString());
                             ambiance.ContinueWith(delegate(Task<object> task1)
                             {
                                 var am = task1.Result as Ambiance;
                                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                                     CoreDispatcherPriority.Normal,
                                     () =>
                                     {
                                         foreach (var music in am.musics)
                                         {
                                             music.album.imageAlbum =
                                                 new BitmapImage(
                                                     new Uri(Constant.UrlImageAlbum + music.album.image,
                                                         UriKind.RelativeOrAbsolute));
                                         }
                                         ListAmbiance.Add(am);
                                     });
                             });
                         });
                 }
             }
         });
     }
     catch (Exception e)
     {
         //new MessageDialog("probleme reseau : " + e.Message).ShowAsync();
     }
 }
コード例 #6
0
ファイル: PlaylistViewModel.cs プロジェクト: Haz3/Soonzik
        private void UpdatePlaylistExecute()
        {
            var request = new HttpRequestGet();

            var res = request.GetObject(new Playlist(), "playlists", ThePlaylist.id.ToString());
            res.ContinueWith(delegate(Task<object> tmp)
            {
                var pl = tmp.Result as Playlist;
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                    () =>
                    {
                        if (pl != null)
                            ThePlaylist = pl;
                    });
            });
        }
コード例 #7
0
 private void GetUser()
 {
     var request = new HttpRequestGet();
     var res = request.GetObject(new User(), "users", Friend.ToString());
     res.ContinueWith(delegate(Task<object> tmp)
     {
         var user = tmp.Result as User;
         if (user != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                 () =>
                 {
                     TheUser = user;
                     if (user.groups.Count > 0)
                     {
                         if (user.groups[0].name == "User")
                             ProfilFriendViewModel.UserFromButton = user;
                         else if (user.groups[0].name == "Artist")
                             ProfilArtisteViewModel.TheUser = user;
                     }
                     else
                     {
                         ProfilFriendViewModel.UserFromButton = user;
                     }
                 });
         }
     });
 }
コード例 #8
0
ファイル: Singleton.cs プロジェクト: Haz3/Soonzik
        public void Charge()
        {
            var request = new HttpRequestGet();

            var test = request.GetObject(new User(), "users", Instance().NewProfilUser.ToString());
            test.ContinueWith(delegate(Task<object> tmp)
            {
                var res = tmp.Result as User;
                if (res != null)
                {
                    CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                        () => { SelectedUser = res; });
                }
            });
        }
コード例 #9
0
ファイル: BattleDetailViewModel.cs プロジェクト: Haz3/Soonzik
 private void Vote(HttpRequestPost post, string cryptographic, HttpRequestGet get, string artistId)
 {
     var resPost = post.Vote(cryptographic, CurrentBattle.id.ToString(), artistId,
         Singleton.Singleton.Instance().CurrentUser.id.ToString());
     resPost.ContinueWith(delegate(Task<string> tmp)
     {
         var test = tmp.Result;
         if (test != null)
         {
             CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 var resGet = get.GetObject(new Battle(), "battles", CurrentBattle.id.ToString());
                 resGet.ContinueWith(
                     delegate(Task<object> newBattle) { CurrentBattle = newBattle.Result as Battle; });
                 InitializeData();
             });
         }
     });
 }
コード例 #10
0
ファイル: GenreViewModel.cs プロジェクト: Haz3/Soonzik
 private void SelectionCommandExecute()
 {
     ListGenreSelected = new ObservableCollection<Genre>();
     var get = new HttpRequestGet();
     foreach (var genre in TheListGenres)
     {
         var res = get.GetObject(new Genre(), "genres", genre.id.ToString());
         res.ContinueWith(delegate(Task<object> task)
         {
             var r = task.Result as Genre;
             if (r != null)
             {
                 CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                 {
                     foreach (var mus in r.musics)
                     {
                         mus.album.imageAlbum =
                             new BitmapImage(new Uri(Constant.UrlImageAlbum + mus.album.image,
                                 UriKind.RelativeOrAbsolute));
                     }
                     ListGenreSelected.Add(r);
                 });
             }
         });
     }
 }