using ComPDFKitViewer; using PDF_Master.ViewModels.EditTools.Watermark; using PDFSettings; using System.Diagnostics; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Imaging; using System.IO; namespace PDF_Master.Views.EditTools.Watermark { /// /// Interaction logic for WatermarkTemplateListTextContent /// public partial class WatermarkTemplateListTextContent : UserControl { private WatermarkTemplateListTextContentViewModel viewModel; public WatermarkTemplateListTextContent() { InitializeComponent(); viewModel = this.DataContext as WatermarkTemplateListTextContentViewModel; } private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e) { viewModel.DeleteTemplateItemCommand?.Execute(sender); } private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { viewModel.SelectTemplateItemCommand?.Execute(sender); //TextWatermarkListbox.SelectedIndex = -1; } private void MenuEdit_Click(object sender, RoutedEventArgs e) { viewModel.EditTemplateItemCommand?.Execute(sender); } private void MenuDeleteCurrent_Click(object sender, RoutedEventArgs e) { viewModel.DeleteTemplateItemCommand?.Execute(sender); } private void MenuDeleteAll_Click(object sender, RoutedEventArgs e) { viewModel.DeleteAllTemplateItemCommand?.Execute(); } private void EditTemplateBtn_Click(object sender, RoutedEventArgs e) { viewModel.EditTemplateItemCommand?.Execute(sender); } private void itemPanel_Loaded(object sender, RoutedEventArgs e) { try { StackPanel panel = sender as StackPanel; var data = panel.DataContext as WatermarkItem; var img = panel.FindName("WatermarkPreview") as Image; Trace.WriteLine(data.previewImagePath); if (!string.IsNullOrEmpty(data.previewImagePath) && File.Exists(data.previewImagePath)) { BitmapSource bmp = new BitmapImage(new Uri(data.previewImagePath)); img.Source = bmp; } } catch { } } } }