ConverterBarContentViewModel.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using ComPDFKitViewer.PdfViewer;
  2. using PDF_Office.Model;
  3. using Prism.Commands;
  4. using Prism.Mvvm;
  5. using Prism.Regions;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Windows.Controls;
  11. namespace PDF_Office.ViewModels.Tools
  12. {
  13. public class ConverterBarContentViewModel : BindableBase, INavigationAware
  14. {
  15. private bool isFirstLoad = true;
  16. private CPDFViewer PDFViewer;
  17. public IDialogService dialogs;
  18. private ViewContentViewModel viewContentViewModel;
  19. public DelegateCommand<object> ToConverterCommand { get; set; }
  20. public ConverterBarContentViewModel(IDialogService dialogService)
  21. {
  22. dialogs = dialogService;
  23. ToConverterCommand = new DelegateCommand<object>(toconverter);
  24. }
  25. private void toconverter(object sender)
  26. {
  27. var args = sender as Button;
  28. if (args != null)
  29. {
  30. DialogParameters value = new DialogParameters();
  31. value.Add(ParameterNames.PDFViewer, PDFViewer);
  32. switch (args.Name) {
  33. case "ConverterWordBtn":
  34. dialogs.ShowDialog(DialogNames.ConverterWordDialog, value, e => { });
  35. break;
  36. case "ConverterExcelBtn":
  37. dialogs.ShowDialog(DialogNames.ConverterExcelDialog, value, e => { });
  38. break;
  39. case "ConverterPPTBtn":
  40. dialogs.ShowDialog(DialogNames.ConverterPPTDialog, value, e => { });
  41. break;
  42. case "ConverterRTFBtn":
  43. dialogs.ShowDialog(DialogNames.ConverterRTFDialog, value, e => { });
  44. break;
  45. case "ConverterCSVBtn":
  46. dialogs.ShowDialog(DialogNames.ConverterCSVDialog, value, e => { });
  47. break;
  48. case "ConverterHTMLBtn":
  49. dialogs.ShowDialog(DialogNames.ConverterHTMLDialog, value, e => { });
  50. break;
  51. case "ConverterTextBtn":
  52. dialogs.ShowDialog(DialogNames.ConverterTextDialog, value, e => { });
  53. break;
  54. case "ConverterImgBtn":
  55. dialogs.ShowDialog(DialogNames.ConverterImgDialog, value, e => { });
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61. }
  62. public bool IsNavigationTarget(NavigationContext navigationContext)
  63. {
  64. return true;
  65. }
  66. public void OnNavigatedFrom(NavigationContext navigationContext)
  67. {
  68. }
  69. public void OnNavigatedTo(NavigationContext navigationContext)
  70. {
  71. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  72. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  73. if (PDFViewer != null)
  74. {
  75. isFirstLoad = false;
  76. }
  77. }
  78. }
  79. }