예제 #1
0
        private void GetPurchasedList(uint start, uint end)
        {
            var purchaseRequest = new GetMotionDownloadByUserStoreRequest(start, end);

            purchaseRequest.ProcessSuccessfully += reply =>
                                                   Dispatcher.BeginInvoke((Action) delegate
            {
                foreach (var motionInfo in reply.user_motion.motion_short_info)
                {
                    numberMotions++;
                    var motion = new MotionItemVertical();
                    motion.SetInfo(motionInfo);
                    ViewModel.PurchasedMotionList.Add(motion);
                    motion.MotionClicked += PurchasedMotion_MotionClicked;
                    DownloadMotionImage(motionInfo.icon_url, motion);
                }
                StaticMainWindow.Window.ShowContentScreen();
            });
            purchaseRequest.ProcessError += (reply, msg) =>
            {
                if (reply == null)
                {
                    Debug.Fail("reply is null");
                }
                else
                {
                    Debug.Fail(reply.type.ToString(), msg);
                }
                Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
            };
            GlobalVariables.StoreWorker.ForceAddRequest(purchaseRequest);
        }
예제 #2
0
 private void DownloadMotionImage(string url, MotionItemVertical motion)
 {
     var download = new ImageDownload(url);
     var cacheImage = download.FindInCacheOrLocal();
     if (cacheImage != null)
     {
         Dispatcher.BeginInvoke((Action)(() => motion.SetImage(cacheImage)));
         return;
     }
     download.DownloadCompleted += (image) => Dispatcher.BeginInvoke((Action)(() => motion.SetImage(image)));
     download.DownloadFailed += (s, msg) => Debug.Fail(msg);
     GlobalVariables.ImageDownloadWorker.AddDownload(download);
 }
예제 #3
0
        private void UpdateSearchMotionCover(string url, MotionItemVertical item)
        {
            var         coverImage = new ImageDownload(url);
            BitmapImage cacheImage = coverImage.FindInCacheOrLocal();

            if (cacheImage != null)
            {
                Dispatcher.BeginInvoke((Action)(() => item.SetImage(cacheImage)));
                return;
            }
            coverImage.DownloadCompleted += (image) =>
                                            Dispatcher.BeginInvoke((Action)(() => item.SetImage(image)));
            GlobalVariables.ImageDownloadWorker.AddDownload(coverImage);
        }
예제 #4
0
        private void DownloadMotionImage(string url, MotionItemVertical motion)
        {
            var download   = new ImageDownload(url);
            var cacheImage = download.FindInCacheOrLocal();

            if (cacheImage != null)
            {
                Dispatcher.BeginInvoke((Action)(() => motion.SetImage(cacheImage)));
                return;
            }
            download.DownloadCompleted += (image) => Dispatcher.BeginInvoke((Action)(() => motion.SetImage(image)));
            download.DownloadFailed    += (s, msg) => Debug.Fail(msg);
            GlobalVariables.ImageDownloadWorker.AddDownload(download);
        }
예제 #5
0
        public void UpdateSearchList(uint start, uint end)
        {
            var searchRequest = new SearchMotionStoreRequest(Query, start, end);

            searchRequest.ProcessSuccessfully += (reply) =>
                                                 Dispatcher.BeginInvoke((Action) delegate
            {
                if (reply.search_motion.motion_short_info.Count == 0 && FirstLoad)
                {
                    ViewModel.NoResultVisibility = true;
                    //return;
                }
                foreach (var info in reply.search_motion.motion_short_info)
                {
                    var motionFull = new MotionItemVertical();
                    motionFull.SetInfo(info);
                    motionFull.MotionClicked += motionFull_MotionClicked;
                    UpdateSearchMotionCover(info.icon_url, motionFull);
                    ViewModel.SearchList.Add(motionFull);
                    numberSearchItem++;
                    //for (int i = 0; i < 10; i++)
                    //{
                    //    var motionFull = new MotionItemVertical();
                    //    motionFull.SetInfo(info);
                    //    motionFull.MotionClicked += motionFull_MotionClicked;
                    //    UpdateSearchMotionCover(info.icon_url, motionFull);
                    //    ViewModel.SearchList.Add(motionFull);

                    //}
                }
                if (FirstLoad)
                {
                    StaticMainWindow.Window.ShowContentScreen();
                    FirstLoad = false;
                }
            });
            searchRequest.ProcessError += (reply, msg) =>
            {
                Debug.Fail(msg, reply.type.ToString());
                if (FirstLoad)
                {
                    Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
                }
            };
            GlobalVariables.StoreWorker.ForceAddRequest(searchRequest);
        }
예제 #6
0
        private void GetMotionList(uint start, uint end)
        {
            var request = new ListCategoryMotionStoreRequest(ViewModel.CategoryType, start, end);

            request.ProcessSuccessfully += (reply) =>
            {
                Dispatcher.BeginInvoke((Action) delegate
                {
                    if (reply.list_motion.motion_short_info.Count == 0 && FirstLoad)
                    {
                        ViewModel.NoResultVisibility = true;
                    }
                    foreach (var info in reply.list_motion.motion_short_info)
                    {
                        var motion = new MotionItemVertical();
                        motion.SetInfo(info);
                        motion.MotionClicked += motion_MotionClicked;
                        UpdateMotionCover(info.icon_url, motion);
                        ViewModel.CategoryList.Add(motion);
                        TotalNumberMotion++;
                    }
                    if (FirstLoad)
                    {
                        StaticMainWindow.Window.ShowContentScreen();
                        FirstLoad = false;
                    }
                });
            };
            request.ProcessError += (reply, msg) =>
            {
                if (reply == null)
                {
                    Debug.Fail("reply is null");
                }
                else
                {
                    Debug.Fail(msg, reply.type.ToString());
                    if (FirstLoad)
                    {
                        Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
                    }
                }
            };
            GlobalVariables.StoreWorker.ForceAddRequest(request);
        }
예제 #7
0
        public void UpdateSearchList(uint start, uint end)
        {
            var searchRequest = new SearchMotionStoreRequest(Query, start, end);
            searchRequest.ProcessSuccessfully += (reply) =>
              Dispatcher.BeginInvoke((Action)delegate
                {
                    if (reply.search_motion.motion_short_info.Count == 0 && FirstLoad)
                    {
                        ViewModel.NoResultVisibility = true;
                        //return;
                    }
                    foreach (var info in reply.search_motion.motion_short_info)
                    {
                        var motionFull = new MotionItemVertical();
                        motionFull.SetInfo(info);
                        motionFull.MotionClicked += motionFull_MotionClicked;
                        UpdateSearchMotionCover(info.icon_url, motionFull);
                        ViewModel.SearchList.Add(motionFull);
                        numberSearchItem++;
                        //for (int i = 0; i < 10; i++)
                        //{
                        //    var motionFull = new MotionItemVertical();
                        //    motionFull.SetInfo(info);
                        //    motionFull.MotionClicked += motionFull_MotionClicked;
                        //    UpdateSearchMotionCover(info.icon_url, motionFull);
                        //    ViewModel.SearchList.Add(motionFull);

                        //}

                    }
                    if (FirstLoad)
                    {
                        StaticMainWindow.Window.ShowContentScreen();
                        FirstLoad = false;
                    }
                });
            searchRequest.ProcessError += (reply, msg) =>
            {
                Debug.Fail(msg, reply.type.ToString());
                if (FirstLoad) Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
            };
            GlobalVariables.StoreWorker.ForceAddRequest(searchRequest);
        }
예제 #8
0
        private void GetMotionOfArtist()
        {
            var countRequest = new GetNumberMotionOfArtistStoreRequest(ArtistID);

            countRequest.ProcessSuccessfully += (countReply) =>
            {
                Dispatcher.BeginInvoke((Action) delegate { ViewModel.NumberMotion = countReply.number_motion_artist.number_motion; });
                var motionRequest = new GetMotionOfArtistStoreRequest(ArtistID, 0, countReply.number_motion_artist.number_motion);
                motionRequest.ProcessSuccessfully += (motionReply) =>
                                                     Dispatcher.BeginInvoke((Action) delegate
                {
                    foreach (var motionInfo in motionReply.artist_motion.motion_short_info)
                    {
                        var motionItemVertical = new MotionItemVertical();
                        motionItemVertical.SetInfo(motionInfo);
                        ViewModel.ArtistMotionsList.Add(motionItemVertical);
                        motionItemVertical.MotionClicked += motionItemVertical_MotionClicked;
                        DownloadMotionImage(motionInfo.icon_url, motionItemVertical);
                        //for (int i = 0; i < 20; i++)
                        //{
                        //    var motionItemVertical = new MotionItemVertical();
                        //    motionItemVertical.SetInfo(motionInfo);
                        //    ViewModel.ArtistMotionsList.Add(motionItemVertical);
                        //}
                    }
                    StaticMainWindow.Window.ShowContentScreen();
                });
                motionRequest.ProcessError += (motionReply, msg) =>
                {
                    Debug.Assert(false, motionReply.type.ToString() + msg);
                    Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
                };
                GlobalVariables.StoreWorker.ForceAddRequest(motionRequest);
            };
            countRequest.ProcessError += (countReply, msg) =>
            {
                Debug.Assert(false, msg + countReply.type.ToString());
                Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
            };
            GlobalVariables.StoreWorker.ForceAddRequest(countRequest);
        }
예제 #9
0
        private void GetMotionList(uint start, uint end)
        {
            var request = new ListCategoryMotionStoreRequest(ViewModel.CategoryType, start, end);
            request.ProcessSuccessfully += (reply) =>
            {
                Dispatcher.BeginInvoke((Action)delegate
                {
                    if (reply.list_motion.motion_short_info.Count == 0 && FirstLoad)
                    {
                        ViewModel.NoResultVisibility = true;
                    }
                    foreach (var info in reply.list_motion.motion_short_info)
                    {
                        var motion = new MotionItemVertical();
                        motion.SetInfo(info);
                        motion.MotionClicked += motion_MotionClicked;
                        UpdateMotionCover(info.icon_url, motion);
                        ViewModel.CategoryList.Add(motion);
                        TotalNumberMotion++;
                    }
                    if (FirstLoad)
                    {
                        StaticMainWindow.Window.ShowContentScreen();
                        FirstLoad = false;
                    }
                });

            };
            request.ProcessError += (reply, msg) =>
            {
                if (reply == null) Debug.Fail("reply is null");
                else
                {
                    Debug.Fail(msg, reply.type.ToString());
                    if (FirstLoad) Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
                }
            };
            GlobalVariables.StoreWorker.ForceAddRequest(request);
        }
예제 #10
0
        private void UpdateRelatedMotions(uint start, uint end)
        {
            var relatedRequest = new GetMotionOfArtistStoreRequest(Info.artist_id, start, end);

            relatedRequest.ProcessSuccessfully += (reply) =>
                                                  Dispatcher.BeginInvoke((Action) delegate
            {
                foreach (var motionInfo in reply.artist_motion.motion_short_info)
                {
                    if (MotionID == motionInfo.motion_id)
                    {
                        continue;
                    }
                    var verticalMotionItem = new MotionItemVertical();
                    verticalMotionItem.SetInfo(motionInfo);
                    verticalMotionItem.MotionClicked += RelatedMotions_MotionClicked;
                    ViewModel.RelatedMotionsList.Add(verticalMotionItem);
                    UpdateRelatedMotionCover(motionInfo.icon_url, verticalMotionItem);
                }
            });
            relatedRequest.ProcessError += (reply, msg) => Debug.Assert(false, msg);
            GlobalVariables.StoreWorker.ForceAddRequest(relatedRequest);
        }
예제 #11
0
 private void UpdateMotionCover(string url, MotionItemVertical item)
 {
     var coverImage = new ImageDownload(url);
     BitmapImage cacheImage = coverImage.FindInCacheOrLocal();
     if (cacheImage!=null)
     {
         Dispatcher.BeginInvoke((Action)(() => item.SetImage(cacheImage)));
         return;
     }
     coverImage.DownloadCompleted += (image) =>
         Dispatcher.BeginInvoke((Action)(() => item.SetImage(image)));
     GlobalVariables.ImageDownloadWorker.AddDownload(coverImage);
 }
예제 #12
0
 private void GetMotionOfArtist()
 {
     var countRequest = new GetNumberMotionOfArtistStoreRequest(ArtistID);
     countRequest.ProcessSuccessfully += (countReply) =>
     {
         Dispatcher.BeginInvoke((Action)delegate { ViewModel.NumberMotion = countReply.number_motion_artist.number_motion; });
         var motionRequest = new GetMotionOfArtistStoreRequest(ArtistID, 0, countReply.number_motion_artist.number_motion);
         motionRequest.ProcessSuccessfully += (motionReply) =>
             Dispatcher.BeginInvoke((Action)delegate
             {
                 foreach (var motionInfo in motionReply.artist_motion.motion_short_info)
                 {
                     var motionItemVertical = new MotionItemVertical();
                     motionItemVertical.SetInfo(motionInfo);
                     ViewModel.ArtistMotionsList.Add(motionItemVertical);
                     motionItemVertical.MotionClicked += motionItemVertical_MotionClicked;
                     DownloadMotionImage(motionInfo.icon_url, motionItemVertical);
                     //for (int i = 0; i < 20; i++)
                     //{
                     //    var motionItemVertical = new MotionItemVertical();
                     //    motionItemVertical.SetInfo(motionInfo);
                     //    ViewModel.ArtistMotionsList.Add(motionItemVertical);
                     //}
                 }
                 StaticMainWindow.Window.ShowContentScreen();
             });
         motionRequest.ProcessError += (motionReply, msg) =>
         {
             Debug.Assert(false, motionReply.type.ToString() + msg);
             Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
         };
         GlobalVariables.StoreWorker.ForceAddRequest(motionRequest);
     };
     countRequest.ProcessError += (countReply, msg) =>
     {
         Debug.Assert(false, msg + countReply.type.ToString());
         Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
     };
     GlobalVariables.StoreWorker.ForceAddRequest(countRequest);
 }
예제 #13
0
 private void UpdateRelatedMotions(uint start, uint end)
 {
     var relatedRequest = new GetMotionOfArtistStoreRequest(Info.artist_id, start, end);
     relatedRequest.ProcessSuccessfully += (reply) =>
         Dispatcher.BeginInvoke((Action)delegate
         {
             foreach (var motionInfo in reply.artist_motion.motion_short_info)
             {
                 if (MotionID == motionInfo.motion_id) continue;
                 var verticalMotionItem = new MotionItemVertical();
                 verticalMotionItem.SetInfo(motionInfo);
                 verticalMotionItem.MotionClicked += RelatedMotions_MotionClicked;
                 ViewModel.RelatedMotionsList.Add(verticalMotionItem);
                 UpdateRelatedMotionCover(motionInfo.icon_url, verticalMotionItem);
             }
         });
     relatedRequest.ProcessError += (reply, msg) => Debug.Assert(false, msg);
     GlobalVariables.StoreWorker.ForceAddRequest(relatedRequest);
 }
예제 #14
0
 private void GetPurchasedList(uint start, uint end)
 {
     var purchaseRequest = new GetMotionDownloadByUserStoreRequest(start, end);
     purchaseRequest.ProcessSuccessfully += reply =>
         Dispatcher.BeginInvoke((Action)delegate
         {
             foreach (var motionInfo in reply.user_motion.motion_short_info)
             {
                 numberMotions++;
                 var motion = new MotionItemVertical();
                 motion.SetInfo(motionInfo);
                 ViewModel.PurchasedMotionList.Add(motion);
                 motion.MotionClicked += PurchasedMotion_MotionClicked;
                 DownloadMotionImage(motionInfo.icon_url, motion);
             }
             StaticMainWindow.Window.ShowContentScreen();
         });
     purchaseRequest.ProcessError += (reply, msg) =>
     {
         if(reply==null) Debug.Fail("reply is null");
         else Debug.Fail(reply.type.ToString(), msg);
         Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
     };
     GlobalVariables.StoreWorker.ForceAddRequest(purchaseRequest);
 }