HeaderFooterTemplateListContent.xaml.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using PDF_Master.ViewModels.EditTools.Bates;
  2. using PDF_Master.ViewModels.EditTools.HeaderFooter;
  3. using PDFSettings;
  4. using System.Diagnostics;
  5. using System.Windows;
  6. using System;
  7. using System.Windows.Controls;
  8. using System.Windows.Media.Imaging;
  9. using System.IO;
  10. using System.Collections.Generic;
  11. namespace PDF_Master.Views.EditTools.HeaderFooter
  12. {
  13. /// <summary>
  14. /// Interaction logic for HeaderFooterTemplateListContent
  15. /// </summary>
  16. public partial class HeaderFooterTemplateListContent : UserControl
  17. {
  18. private HeaderFooterTemplateListContentViewModel viewModel;
  19. public HeaderFooterTemplateListContent()
  20. {
  21. InitializeComponent();
  22. viewModel = this.DataContext as HeaderFooterTemplateListContentViewModel;
  23. }
  24. private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
  25. {
  26. viewModel.DeleteTemplateItemCommand?.Execute(sender);
  27. }
  28. private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  29. {
  30. var listBox = sender as ListBox;
  31. viewModel.SelectTemplateItemCommand?.Execute(sender);
  32. //listBox.SelectedIndex = -1;
  33. }
  34. private void MenuEdit_Click(object sender, RoutedEventArgs e)
  35. {
  36. viewModel.EditTemplateItemCommand?.Execute(sender);
  37. }
  38. private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e)
  39. {
  40. viewModel.DeleteTemplateItemCommand?.Execute(sender);
  41. }
  42. private void MenuDeleteAll_Click(object sender, RoutedEventArgs e)
  43. {
  44. viewModel.DeleteAllTemplateItemCommand?.Execute();
  45. }
  46. private void EditTemplateBtn_Click(object sender, RoutedEventArgs e)
  47. {
  48. viewModel.EditTemplateItemCommand?.Execute(sender);
  49. }
  50. private void itemPanel_Loaded(object sender, RoutedEventArgs e)
  51. {
  52. try
  53. {
  54. StackPanel panel = sender as StackPanel;
  55. var data = panel.DataContext as BatesHeaderFooterItem;
  56. var TemplateIndex = panel.FindName("TemplateIndexTextBox") as TextBlock;
  57. var LeftHeader = panel.FindName("LeftHeaderTextBox") as TextBlock;
  58. var RightHeader = panel.FindName("RightHeaderTextBox") as TextBlock;
  59. var CenterHeader = panel.FindName("CenterHeaderTextBox") as TextBlock;
  60. var LeftFooter = panel.FindName("LeftFooterTextBox") as TextBlock;
  61. var RightFooter = panel.FindName("RightFooterTextBox") as TextBlock;
  62. var CenterFooter = panel.FindName("CenterFooterTextBox") as TextBlock;
  63. List<TextBlock> textBlocks=new List<TextBlock>() { LeftHeader, RightHeader, CenterHeader , LeftFooter , RightFooter , CenterFooter };
  64. if (data.TextData != null)
  65. {
  66. TemplateIndex.Text = data.ItemName;
  67. foreach (var textBlock in textBlocks) {
  68. textBlock.Text = data.TextData[textBlocks.IndexOf(textBlock)].text;
  69. if (textBlock.Text == "") { textBlock.Visibility = Visibility.Collapsed; }
  70. else { textBlock.Visibility = Visibility.Visible; }
  71. }
  72. }
  73. }
  74. catch { }
  75. }
  76. }
  77. }