123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using PDF_Master.Helper;
- using Prism.Commands;
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Forms;
- using System.Windows.Threading;
- namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
- {
- public class ChatGPTAIRewritingContentViewModel : BindableBase
- {
- private string inputText;
- public string InputText
- {
- get { return inputText; }
- set
- {
- SetProperty(ref inputText, value);
- }
- }
- private string rewriteText;
- public string RewriteText
- {
- get { return rewriteText; }
- set
- {
- SetProperty(ref rewriteText, value);
- }
- }
- private Visibility showTip = Visibility.Collapsed;
- public Visibility ShowTip
- {
- get
- {
- return showTip;
- }
- set
- {
- SetProperty(ref showTip, value);
- }
- }
- private string errorTipText;
- public string ErrorTipText
- {
- get { return errorTipText; }
- set
- {
- SetProperty(ref errorTipText, value);
- }
- }
- private Visibility errorVisible = Visibility.Collapsed;
- public Visibility ErrorVisible
- {
- get
- {
- return errorVisible;
- }
- set
- {
- SetProperty(ref errorVisible, value);
- }
- }
- public DelegateCommand CopyCommand { get; set; }
- public DelegateCommand RewriteCommand { get; set; }
- public ChatGPTAIRewritingContentViewModel()
- {
- CopyCommand = new DelegateCommand(copy);
- RewriteCommand = new DelegateCommand(rewrite);
- }
- public void copy()
- {
- try
- {
- System.Windows.Forms.Clipboard.SetText(RewriteText);
- ShowTip=Visibility.Visible;
- }
- catch { }
- }
- public async void rewrite() {
- await Task.Run(async delegate
- {
- RewriteText = await ChatGTPAIHelper.Rewrite(InputText);
- });
- if (ChatGTPAIHelper.Code != "200")
- {
- ErrorVisible = Visibility.Visible;
- }
- }
- }
- }
|