BatesTemplateListContent.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using PDF_Master.ViewModels.EditTools.Background;
  2. using PDF_Master.ViewModels.EditTools.Bates;
  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.Bates
  12. {
  13. /// <summary>
  14. /// Interaction logic for BatesTemplateListContentContent
  15. /// </summary>
  16. public partial class BatesTemplateListContent : UserControl
  17. {
  18. private BatesTemplateListContentViewModel viewModel;
  19. public BatesTemplateListContent()
  20. {
  21. InitializeComponent();
  22. viewModel = this.DataContext as BatesTemplateListContentViewModel;
  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. {
  69. textBlock.Text = data.TextData[textBlocks.IndexOf(textBlock)].text;
  70. if (textBlock.Text == "") { textBlock.Visibility = Visibility.Collapsed; }
  71. else { textBlock.Visibility = Visibility.Visible; }
  72. }
  73. }
  74. }
  75. catch { }
  76. }
  77. }
  78. }