HomePageSetPasswordDialog.xaml.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. private Boolean canOpenPasswordBoxHasFocus = false;
  21. private Boolean canOpenTextBoxHasFocus = false;
  22. private Boolean canEditPasswordBoxHasFocus = false;
  23. private Boolean canEditTextBoxHasFocus = false;
  24. private string canOpenPasswordBoxName = "CanOpenPasswordBox";
  25. private string canEditPasswordBoxName = "CanEditPasswordBox";
  26. private string canOpenTextBoxName = "CanOpenTextBox";
  27. private string canEditTextBoxName = "CanEditTextBox";
  28. private string showOpenPasswordBoxEyeLabelName = "ShowOpenPasswordBoxEyeLabel";
  29. private string showEditPasswordBoxEyeLabelName = "ShowEditPasswordBoxEyeLabel";
  30. private string showOpenTextBoxEyeLabelName = "ShowOpenTextBoxEyeLabel";
  31. private string showEditTextBoxEyeLabelName = "ShowEditTextBoxEyeLabel";
  32. public HomePageSetPasswordDialog()
  33. {
  34. InitializeComponent();
  35. viewModel= this.DataContext as HomePageSetPasswordDialogViewModel;
  36. }
  37. private void Menu_Click(object sender, System.Windows.RoutedEventArgs e)
  38. {
  39. menuPop1.IsOpen = true;
  40. }
  41. private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
  42. {
  43. IList list = listView.SelectedItems;
  44. var lists = listView.Items;
  45. System.Data.DataRowView a;
  46. viewModel.fileNamesView.Clear();
  47. foreach (var item in list)
  48. {
  49. a = (System.Data.DataRowView)item;
  50. viewModel.fileNamesView.Add(lists.IndexOf(a));
  51. }
  52. if (viewModel.fileNamesView.Count > 0)
  53. {
  54. viewModel.RemoveIsEnable = "True";
  55. }
  56. else
  57. {
  58. viewModel.RemoveIsEnable = "False";
  59. }
  60. }
  61. private void RemoveFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
  62. {
  63. viewModel.removepdffile();
  64. }
  65. private void OpenFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
  66. {
  67. viewModel.openfiledialog();
  68. }
  69. private void Grid_Drop(object sender, DragEventArgs e)
  70. {
  71. try
  72. {
  73. Point iconPoint = e.GetPosition(this);
  74. dropHelper?.Drop((System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
  75. }
  76. catch (Exception ex)
  77. {
  78. }
  79. string dropFile = "Drop";
  80. if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
  81. {
  82. BtnBlank.IsEnabled = true;
  83. int count = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).Length;
  84. for (int i = 0; i < count; i++)
  85. {
  86. dropFile = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(i).ToString(); ;
  87. //MessageBox.Show(dropFile);
  88. if (dropFile.ToLower().EndsWith("pdf"))
  89. { viewModel.addPDFFiles(dropFile); }
  90. }
  91. }
  92. }
  93. private void MainPage_DragEnter(object sender, DragEventArgs e)
  94. {
  95. BtnBlank.IsEnabled = false;
  96. //页面编辑和缩略图
  97. if ((e.OriginalSource as Image) != null)
  98. return;
  99. try
  100. {
  101. if (dropHelper == null)
  102. {
  103. dropHelper = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("4657278A-411B-11D2-839A-00C04FD918D0"))) as IDropTargetHelper;
  104. }
  105. Point iconPoint = e.GetPosition(this);
  106. dropHelper?.DragEnter(new WindowInteropHelper(Window.GetWindow(this)).Handle, (System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
  107. }
  108. catch (Exception ex)
  109. {
  110. }
  111. }
  112. private void MainPage_DragOver(object sender, DragEventArgs e)
  113. {
  114. if ((e.OriginalSource as Image) != null)
  115. return;
  116. try
  117. {
  118. Point iconPoint = e.GetPosition(this);
  119. dropHelper?.DragOver(ref iconPoint, e.Effects);
  120. }
  121. catch (Exception ex)
  122. {
  123. }
  124. }
  125. private void MainPage_DragLeave(object sender, DragEventArgs e)
  126. {
  127. BtnBlank.IsEnabled = true;
  128. if ((e.OriginalSource as Image) != null)
  129. return;
  130. try
  131. {
  132. dropHelper?.DragLeave();
  133. }
  134. catch (Exception ex)
  135. {
  136. }
  137. }
  138. private void DeleteTemplateBtn_Click(object sender, RoutedEventArgs e)
  139. {
  140. Button deletetemplatebtn = sender as Button;
  141. var ls = deletetemplatebtn.DataContext as DataRowView;
  142. if (ls != null)
  143. {
  144. viewModel.removepdffile(viewModel.PDFDataTable.Rows.IndexOf(ls.Row));
  145. }
  146. }
  147. }
  148. }