Ejemplo n.º 1
0
        private void GetMotionInfo()
        {
            var infoRequest = new GetMotionFullInfoStoreRequest(MotionID);

            infoRequest.ProcessSuccessfully += delegate(Reply reply)
            {
                Info = reply.motion_info.info;
                UpdateContent(reply.motion_info.info);
            };
            infoRequest.ProcessError += (reply, msg) =>
            {
                Debug.Assert(false, msg);
                Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
            };
            GlobalVariables.StoreWorker.AddRequest(infoRequest);
        }
Ejemplo n.º 2
0
        private void DownloadImage(ulong id, MotionFullInfoItemViewModel model)
        {
            var localIcon = FindLocalIcon(id);

            if (localIcon != null)
            {
                model.CoverImage = localIcon;
                return;
            }
            var motionInfoRequest = new GetMotionFullInfoStoreRequest(id);

            motionInfoRequest.ProcessSuccessfully += (data) =>
            {
                var         imageDownload = new ImageDownload(data.motion_info.info.icon_url);
                BitmapImage cacheImage    = imageDownload.FindInCacheOrLocal();
                if (cacheImage != null)
                {
                    Dispatcher.BeginInvoke((Action) delegate
                    {
                        model.CoverImage = cacheImage;
                        GlobalFunction.SaveIconImage(cacheImage, id);
                    });
                    return;
                }
                imageDownload.DownloadCompleted += (img) => Dispatcher.BeginInvoke((Action) delegate
                {
                    model.CoverImage = img;
                    GlobalFunction.SaveIconImage(img, id);
                });
                GlobalVariables.ImageDownloadWorker.AddDownload(imageDownload);
            };
            motionInfoRequest.ProcessError += (data, msg) =>
            {
                if (data == null)
                {
                    Debug.Fail(msg);
                }
                else
                {
                    Debug.Fail(data.type.ToString(), msg);
                }
            };
            GlobalVariables.StoreWorker.ForceAddRequest(motionInfoRequest);
        }