123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using PDF_Office.Helper;
- using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
- using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
- using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
- using System;
- using System.Collections;
- using System.Data;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Interop;
- namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
- {
- /// <summary>
- /// Interaction logic for HomePageSetPasswordDialog
- /// </summary>
- public partial class HomePageSetPasswordDialog : UserControl
- {
- private HomePageSetPasswordDialogViewModel viewModel;
- private IDropTargetHelper dropHelper;
- private Boolean canOpenPasswordBoxHasFocus = false;
- private Boolean canOpenTextBoxHasFocus = false;
- private Boolean canEditPasswordBoxHasFocus = false;
- private Boolean canEditTextBoxHasFocus = false;
- private string canOpenPasswordBoxName = "CanOpenPasswordBox";
- private string canEditPasswordBoxName = "CanEditPasswordBox";
- private string canOpenTextBoxName = "CanOpenTextBox";
- private string canEditTextBoxName = "CanEditTextBox";
- private string showOpenPasswordBoxEyeLabelName = "ShowOpenPasswordBoxEyeLabel";
- private string showEditPasswordBoxEyeLabelName = "ShowEditPasswordBoxEyeLabel";
- private string showOpenTextBoxEyeLabelName = "ShowOpenTextBoxEyeLabel";
- private string showEditTextBoxEyeLabelName = "ShowEditTextBoxEyeLabel";
- public HomePageSetPasswordDialog()
- {
- InitializeComponent();
- viewModel= this.DataContext as HomePageSetPasswordDialogViewModel;
- }
- private void Menu_Click(object sender, System.Windows.RoutedEventArgs e)
- {
- menuPop1.IsOpen = true;
- }
- private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- IList list = listView.SelectedItems;
- var lists = listView.Items;
- System.Data.DataRowView a;
- viewModel.fileNamesView.Clear();
- foreach (var item in list)
- {
- a = (System.Data.DataRowView)item;
- viewModel.fileNamesView.Add(lists.IndexOf(a));
- }
- if (viewModel.fileNamesView.Count > 0)
- {
- viewModel.RemoveIsEnable = "True";
- }
- else
- {
- viewModel.RemoveIsEnable = "False";
- }
- }
- private void RemoveFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
- {
- viewModel.removepdffile();
- }
- private void OpenFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
- {
- viewModel.openfiledialog();
- }
- private void Grid_Drop(object sender, DragEventArgs e)
- {
- try
- {
- Point iconPoint = e.GetPosition(this);
- dropHelper?.Drop((System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
- }
- catch (Exception ex)
- {
- }
- string dropFile = "Drop";
- if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
- {
- BtnBlank.IsEnabled = true;
- int count = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).Length;
- for (int i = 0; i < count; i++)
- {
- dropFile = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(i).ToString(); ;
- //MessageBox.Show(dropFile);
- if (dropFile.ToLower().EndsWith("pdf"))
- { viewModel.addPDFFiles(dropFile); }
- }
- }
- }
- private void MainPage_DragEnter(object sender, DragEventArgs e)
- {
- BtnBlank.IsEnabled = false;
- //页面编辑和缩略图
- if ((e.OriginalSource as Image) != null)
- return;
- try
- {
- if (dropHelper == null)
- {
- dropHelper = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("4657278A-411B-11D2-839A-00C04FD918D0"))) as IDropTargetHelper;
- }
- Point iconPoint = e.GetPosition(this);
- dropHelper?.DragEnter(new WindowInteropHelper(Window.GetWindow(this)).Handle, (System.Runtime.InteropServices.ComTypes.IDataObject)e.Data, ref iconPoint, e.Effects);
- }
- catch (Exception ex)
- {
- }
- }
- private void MainPage_DragOver(object sender, DragEventArgs e)
- {
- if ((e.OriginalSource as Image) != null)
- return;
- try
- {
- Point iconPoint = e.GetPosition(this);
- dropHelper?.DragOver(ref iconPoint, e.Effects);
- }
- catch (Exception ex)
- {
- }
- }
- private void MainPage_DragLeave(object sender, DragEventArgs e)
- {
- BtnBlank.IsEnabled = true;
- if ((e.OriginalSource as Image) != null)
- return;
- try
- {
- dropHelper?.DragLeave();
- }
- catch (Exception ex)
- {
- }
- }
- private void DeleteTemplateBtn_Click(object sender, RoutedEventArgs e)
- {
- Button deletetemplatebtn = sender as Button;
- var ls = deletetemplatebtn.DataContext as DataRowView;
- if (ls != null)
- {
- viewModel.removepdffile(viewModel.PDFDataTable.Rows.IndexOf(ls.Row));
- }
- }
- }
- }
|