private void fixWebButton_Click(object sender, RoutedEventArgs e) { string boxStr = this.TextDemo.Text; boxStr = tencentServer.fixFomulashtml(boxStr); WebDemo.NavigateToString(boxStr); }
private void fixWebButton_Click(object sender, RoutedEventArgs e) { progresring.Visibility = Visibility.Visible; string boxStr = this.TextDemo.Text; boxStr = tencentServer.fixFomulashtml(boxStr); WebDemo.NavigateToString(boxStr); progresring.Visibility = Visibility.Collapsed; }
private async System.Threading.Tasks.Task chooseImageAndDeSerAsync() { FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); var file = await picker.PickSingleFileAsync(); if (file != null) { file = await file.CopyAsync(ApplicationData.Current.LocalFolder, file.GetHashCode() + file.Name); try { BitmapImage bmp = new BitmapImage(); await bmp.SetSourceAsync(await file.OpenAsync(FileAccessMode.Read)); ImageControl.Source = bmp; List <String> data; if (this.recognizeWordsCheck.IsChecked == true) { data = await TencentPaperData.getPaperStringArrayAsync(file); } else { data = await TencentData.getLatexStringArrayAsync(file); } if (data == null) { throw new Exception("Json didn't deserialize anything"); } HtmlResult htmlResult; try { tencentServer.init(); htmlResult = tencentServer.getServerHtmls(data); } catch (Exception e) { htmlResult = tencentServer.WebServerErrorHandles(e); } if (recognizeWordsCheck.IsChecked == true) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_w); } else if (recognizeWordsCheck.IsChecked == false) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_f); } else { WebDemo.NavigateToString(tencentServer.WebServerErrorHandle(new Exception("wrong option"))); } HistoryData.addHistory(new recognizedData(bmp, TextDemo.Text, htmlResult, file)); await HistoryData.storeAsync(); } catch (WebException ex) { try { var res = (HttpWebResponse)ex.Response; StreamReader streamReader = new StreamReader(res.GetResponseStream()); MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message + streamReader.ReadToEnd()); initalizeProgressringAndImage(); } catch (Exception e) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(e.Message + "(Probably network problem)"); initalizeProgressringAndImage(); } } catch (Exception ex) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message); initalizeProgressringAndImage(); } } else { DisplayNoFileDialog(); initalizeProgressringAndImage(); } saveStringTorefresh = TextDemo.Text; }
private async System.Threading.Tasks.Task <HtmlResult> pasteImageAndDeSerAsync(RandomAccessStreamReference imageStream) { if (imageStream != null) { try { BitmapImage bmp = new BitmapImage(); await bmp.SetSourceAsync(await imageStream.OpenReadAsync()); ImageControl.Source = bmp; List <string> data; if (this.recognizeWordsCheck.IsChecked == true) { data = await TencentPaperData.getPaperStringArrayAsync(imageStream); } else { data = await TencentData.getLatexStringArrayAsync(imageStream); } if (data == null) { throw new Exception("Json didn't deserialize anything"); } HtmlResult htmlResult; try { tencentServer.init(); htmlResult = tencentServer.getServerHtmls(data); } catch (Exception e) { htmlResult = tencentServer.WebServerErrorHandles(e); } if (recognizeWordsCheck.IsChecked == true) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_w); } else if (recognizeWordsCheck.IsChecked == false) { foreach (var i in data) { TextDemo.Text += i + "\n"; } WebDemo.NavigateToString(htmlResult.result_f); } else { WebDemo.NavigateToString(tencentServer.WebServerErrorHandle(new Exception("wrong option"))); } return(htmlResult); } catch (WebException ex) { try { var res = (HttpWebResponse)ex.Response; StreamReader streamReader = new StreamReader(res.GetResponseStream()); MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message + streamReader.ReadToEnd()); } catch (Exception e) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(e.Message + "(Probably network problem)"); initalizeProgressringAndImage(); } } catch (Exception ex) { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError(ex.Message); initalizeProgressringAndImage(); } } else { MainPage.Current.toNavigate(typeof(ErrorPage)); ErrorPage.errorPage.showError("读取剪切板图片失败!检查剪切板内容"); initalizeProgressringAndImage(); } saveStringTorefresh = TextDemo.Text; return(new HtmlResult("", "")); }