|
@@ -14,6 +14,7 @@ using Microsoft.Office.Core;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using PDF_Master.Properties;
|
|
|
+using PDF_Master.CustomControl;
|
|
|
|
|
|
namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
|
|
|
{
|
|
@@ -86,7 +87,7 @@ namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
|
|
|
SetProperty(ref progressVisible, value);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
private double processvalue = 0;
|
|
|
|
|
@@ -166,12 +167,14 @@ namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
|
|
|
#region 委托声明
|
|
|
public DelegateCommand TranslateCommand { get; set; }
|
|
|
public DelegateCommand CopyCommand { get; set; }
|
|
|
+ public DelegateCommand<object> textBoxEnterCharactersTextChangedCommad { get; set; }
|
|
|
|
|
|
#endregion
|
|
|
public SelectedTranslationDialogViewModel()
|
|
|
{
|
|
|
TranslateCommand = new DelegateCommand(translate);
|
|
|
CopyCommand = new DelegateCommand(copy);
|
|
|
+ textBoxEnterCharactersTextChangedCommad = new DelegateCommand<object>(textBoxEnterCharactersTextChanged);
|
|
|
init();
|
|
|
}
|
|
|
#region 逻辑函数
|
|
@@ -185,6 +188,28 @@ namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
|
|
|
GetTolanguageOrigin();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 检查文字是否超出范围
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void textBoxEnterCharactersTextChanged(object e)
|
|
|
+ {
|
|
|
+ var ConverterPreview = e as TextBoxEx;
|
|
|
+ if (ConverterPreview != null)
|
|
|
+ {
|
|
|
+ if (ConverterPreview.Text.Length > 150)
|
|
|
+ {
|
|
|
+
|
|
|
+ ErrorTipText = "Limit 150 characters at a time";
|
|
|
+ ErrorVisible = Visibility.Visible;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ErrorVisible = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 文本翻译
|
|
|
/// </summary>
|
|
@@ -207,12 +232,13 @@ namespace PDF_Master.ViewModels.Dialog.ChatGPTAIDialogs
|
|
|
string translatetext = "";
|
|
|
string Code = "";
|
|
|
Value = 4;
|
|
|
- await Task.Run( delegate
|
|
|
+ await Task.Run(delegate
|
|
|
{
|
|
|
- Code=ChatGTPAIHelper.textTranslate(SelectedText, fromlanguage, tolanguage, ref translatetext);
|
|
|
+ Code = ChatGTPAIHelper.textTranslate(SelectedText, fromlanguage, tolanguage, ref translatetext);
|
|
|
});
|
|
|
Value = 7;
|
|
|
- if (Code != "200") {
|
|
|
+ if (Code != "200")
|
|
|
+ {
|
|
|
ErrorTipText = Code;
|
|
|
ErrorVisible = Visibility.Visible;
|
|
|
}
|