コード例 #1
0
ファイル: ListPage.xaml.cs プロジェクト: xyzyx233/EHentai.uwp
 private void Image_OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     try
     {
         Image img = sender as Image;
         if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
         {
             var properties = e.GetCurrentPoint(img).Properties;
             if (properties.IsLeftButtonPressed)
             {
                 var bitmap    = img.Source as BitmapImage;
                 var urls      = bitmap.UriSource.Segments;
                 var viewModel = new ImageViewModel();
                 viewModel.ImgBase64 = ImageCache.GetImageBase64(urls[urls.Length - 1]);
                 viewModel.Width     = img.ActualWidth;
                 viewModel.Height    = img.ActualHeight;
                 ImageViewPage.Create(viewModel);
             }
             else if (properties.IsRightButtonPressed)
             {
                 var imgModel = img.Tag as ImageListModel;
                 if (imgModel.ImageLoadState == EnumLoadState.Loaded)
                 {
                     imgModel.ImageLoadState = EnumLoadState.NotLoaded;
                     imgModel.IsCance.Cancel();
                     imgModel.ReLoad();
                     GetImageAsync(imgModel);
                 }
             }
         }
     }
     catch (Exception ex)
     { }
 }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: xyzyx233/EHentai.uwp
        private async void MainPage_OnDrop(object sender, DragEventArgs e)
        {
            // 记得获取Deferral对象
            var             def  = e.GetDeferral();
            DataPackageView data = e.DataView;

            // 还是再验证一下吧,防止意外
            if (data.Contains(StandardDataFormats.StorageItems))
            {
                var storageItems = await data.GetStorageItemsAsync();

                if (storageItems.Count > 0)
                {
                    var         item = storageItems[0];
                    StorageFile file = item as StorageFile;
                    // 生成内存图像
                    if (file != null)
                    {
                        ImageViewPage.Create(file);
                    }
                }
            }
            VisualStateManager.GoToState(this, "Generic", false);
            // 报告操作系统,处理完成
            def.Complete();
        }
コード例 #3
0
ファイル: ImagePage.cs プロジェクト: xyzyx233/EHentai.uwp
        private void View_ScriptNotify(object sender, NotifyEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(e.Value))
                {
                    JObject jsonBody = JObject.Parse(e.Value);
                    string  method   = jsonBody["method"].ToString();
                    string  data     = jsonBody["data"].ToString();
                    switch (method)
                    {
                    case "Scroll":
                        if (!IsLoadNextPage)
                        {
                            IsLoadNextPage = true;
                            LoadDataByPage();
                        }
                        break;

                    case "CacheImage":
                        var model = data.ToEntity <ImageListModel>();
                        ImageCache.SaveImageByBase64(model.ImageUrl, model.CacheName);
                        break;

                    case "ToImageView":
                        var imgViewData = data.ToEntity <ImageViewModel>();
                        ImageViewPage.Create(imgViewData);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message);
            }
        }