HomePageSetPasswordDialog.xaml.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using PDF_Master.Helper;
  2. using PDF_Master.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
  3. using PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs;
  4. using PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
  5. using System;
  6. using System.Collections;
  7. using System.Data;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Interop;
  11. namespace PDF_Master.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
  12. {
  13. /// <summary>
  14. /// Interaction logic for HomePageSetPasswordDialog
  15. /// </summary>
  16. public partial class HomePageSetPasswordDialog : UserControl
  17. {
  18. private HomePageSetPasswordDialogViewModel viewModel;
  19. private IDropTargetHelper dropHelper;
  20. public HomePageSetPasswordDialog()
  21. {
  22. InitializeComponent();
  23. viewModel= this.DataContext as HomePageSetPasswordDialogViewModel;
  24. }
  25. private void Menu_Click(object sender, System.Windows.RoutedEventArgs e)
  26. {
  27. menuPop1.IsOpen = true;
  28. }
  29. private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
  30. {
  31. IList list = listView.SelectedItems;
  32. var lists = listView.Items;
  33. System.Data.DataRowView a;
  34. viewModel.fileNamesView.Clear();
  35. foreach (var item in list)
  36. {
  37. a = (System.Data.DataRowView)item;
  38. viewModel.fileNamesView.Add(lists.IndexOf(a));
  39. }
  40. if (viewModel.fileNamesView.Count > 0)
  41. {
  42. viewModel.RemoveIsEnable = "True";
  43. }
  44. else
  45. {
  46. viewModel.RemoveIsEnable = "False";
  47. }
  48. }
  49. private void RemoveFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
  50. {
  51. viewModel.removepdffile();
  52. }
  53. private void OpenFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
  54. {
  55. viewModel.openfiledialog();
  56. }
  57. private void Grid_Drop(object sender, DragEventArgs e)
  58. {
  59. try
  60. {
  61. Point iconPoint = e.GetPosition(this);
  62. dropHelper?.Drop((System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
  63. }
  64. catch
  65. {
  66. }
  67. string dropFile = "Drop";
  68. if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
  69. {
  70. BtnBlank.IsEnabled = true;
  71. int count = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).Length;
  72. for (int i = 0; i < count; i++)
  73. {
  74. dropFile = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(i).ToString(); ;
  75. //MessageBox.Show(dropFile);
  76. if (dropFile.ToLower().EndsWith("pdf"))
  77. { viewModel.addPDFFiles(dropFile); }
  78. }
  79. }
  80. }
  81. private void MainPage_DragEnter(object sender, DragEventArgs e)
  82. {
  83. BtnBlank.IsEnabled = false;
  84. //页面编辑和缩略图
  85. if ((e.OriginalSource as Image) != null)
  86. return;
  87. try
  88. {
  89. if (dropHelper == null)
  90. {
  91. dropHelper = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("4657278A-411B-11D2-839A-00C04FD918D0"))) as IDropTargetHelper;
  92. }
  93. Point iconPoint = e.GetPosition(this);
  94. dropHelper?.DragEnter(new WindowInteropHelper(Window.GetWindow(this)).Handle, (System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
  95. }
  96. catch
  97. {
  98. }
  99. }
  100. private void MainPage_DragOver(object sender, DragEventArgs e)
  101. {
  102. if ((e.OriginalSource as Image) != null)
  103. return;
  104. try
  105. {
  106. Point iconPoint = e.GetPosition(this);
  107. dropHelper?.DragOver(ref iconPoint, e.Effects);
  108. }
  109. catch { }
  110. }
  111. private void MainPage_DragLeave(object sender, DragEventArgs e)
  112. {
  113. BtnBlank.IsEnabled = true;
  114. if ((e.OriginalSource as Image) != null)
  115. return;
  116. try
  117. {
  118. dropHelper?.DragLeave();
  119. }
  120. catch
  121. {
  122. }
  123. }
  124. private void DeleteTemplateBtn_Click(object sender, RoutedEventArgs e)
  125. {
  126. Button deletetemplatebtn = sender as Button;
  127. var ls = deletetemplatebtn.DataContext as DataRowView;
  128. if (ls != null)
  129. {
  130. viewModel.removepdffile(viewModel.PDFDataTable.Rows.IndexOf(ls.Row));
  131. }
  132. }
  133. }
  134. }