Пример #1
0
        private async void   _Click(object sender, RoutedEventArgs e)
        {
            SelectIMGCount.ClearValue(TextBlock.TextProperty);
            try
            {
                var    getCount = string.Format(@"document.querySelectorAll('.filedata').length.toString();");
                string reNum    = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCount });

                int count = Convert.ToInt32(reNum) - 1;

                var sendComm = string.Format(@"document.querySelectorAll('.filedata')[{0}].click();", count);
                await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { sendComm });

                await Task.Delay(1000);

                var    checkVaild = string.Format(@"document.querySelectorAll('.alert_error').length.toString();");
                string result     = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { checkVaild });

                if (result == "1")
                {
                    SelectIMGCount.Text = "请选择图片文件!(jpg, gif, png)";
                    return;
                }

                SelectIMGCount.Text = "您已选择了" + count + "张图片,点击上传按钮上传您的图片";
            }
            catch (Exception)
            {
                SelectIMGCount.Text = "操作已取消";
            }
        }
Пример #2
0
        private async void 开始_Click(object sender, RoutedEventArgs e)
        {
            SelectIMGCount.ClearValue(TextBlock.TextProperty);
            UploadIMGCount.ClearValue(TextBlock.TextProperty);
            try
            {
                var    getCount = string.Format(@"document.querySelectorAll('.filedata').length.toString();");
                string reNum    = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCount });

                if (reNum == "2")
                {
                    SelectIMGCount.Text = "您还没有选择图片";
                    return;
                }

                var get = string.Format(@"document.getElementsByClassName('pn pnc vm')[0].click();");
                await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { get });

                a1();
            }
            catch (Exception)
            {
            }
        }