Esempio n. 1
0
 private async void DetailWebView_ScriptNotify(object sender, NotifyEventArgs e)
 {
     try
     {
         var data = JsonConvert.DeserializeObject <WebNotify>(e.Value);
         // 图片点击事件,弹出图片对话框
         if (data.Key == "ImageClick" && !string.IsNullOrEmpty(data.Value))
         {
             var imageDialog = new ImageDialog(data.Value);
             await imageDialog.ShowAsync();
         }
         // 文本选中事件,弹出对应菜单
         else if (data.Key == "SelectText" && !string.IsNullOrEmpty(data.Value))
         {
             var pos = new Point();
             if (_latestPoint == null)
             {
                 pos = Window.Current.CoreWindow.PointerPosition;
             }
             else
             {
                 pos = _latestPoint.Position;
             }
             double x = pos.X - Window.Current.Bounds.X;
             double y = pos.Y - Window.Current.Bounds.Y;
             _selectText = data.Value;
             SelectTextFlyout.ShowAt(MainPage.Current.RootGrid, new Point(x, y));
         }
         else if (data.Key == "LinkClick" && !string.IsNullOrEmpty(data.Value))
         {
             try
             {
                 await Launcher.LaunchUriAsync(new Uri(data.Value));
             }
             catch (Exception)
             {
                 new PopupToast(AppTools.GetReswLanguage("Tip_LaunchUriError")).ShowPopup();
             }
         }
         else if (data.Key == "Back")
         {
             CheckBack();
         }
     }
     catch (Exception)
     {
         return;
     }
 }
Esempio n. 2
0
        private async void AbbImage_OnClick(object sender, RoutedEventArgs e)
        {
            var result = await _imageDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                _image = _imageDialog.Image;
                var image = new BitmapImage(new Uri(_image, UriKind.Absolute));
                image.ImageOpened += (o, args) =>
                {
                    GrdImage.Width  = image.PixelWidth;
                    GrdImage.Height = image.PixelHeight;
                };
                ImgFace.Source = image;

                _imageDialog.Clear();
                CleanCanvas();
                AbbDetect.IsEnabled   = true;
                AbbIdentify.IsEnabled = false;
            }
        }