ChatGPTAIRewritingContentViewModel.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using PDF_Master.Helper;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. namespace PDF_Master.ViewModels.HomePanel.ChatGPTAI
  10. {
  11. public class ChatGPTAIRewritingContentViewModel : BindableBase
  12. {
  13. private string inputText;
  14. public string InputText
  15. {
  16. get { return inputText; }
  17. set
  18. {
  19. SetProperty(ref inputText, value);
  20. }
  21. }
  22. private string rewriteText;
  23. public string RewriteText
  24. {
  25. get { return rewriteText; }
  26. set
  27. {
  28. SetProperty(ref rewriteText, value);
  29. }
  30. }
  31. public DelegateCommand CopyCommand { get; set; }
  32. public DelegateCommand RewriteCommand { get; set; }
  33. public ChatGPTAIRewritingContentViewModel()
  34. {
  35. CopyCommand = new DelegateCommand(copy);
  36. RewriteCommand = new DelegateCommand(rewrite);
  37. }
  38. public void copy()
  39. {
  40. try
  41. {
  42. Clipboard.SetText(RewriteText);
  43. }
  44. catch { }
  45. }
  46. public async void rewrite() {
  47. await Task.Run(async delegate
  48. {
  49. RewriteText = await ChatGTPAIHelper.Rewrite(InputText);
  50. });
  51. }
  52. }
  53. }