using PDF_Master.ViewModels.EditTools.Background;
using PDF_Master.ViewModels.EditTools.Bates;
using PDFSettings;
using System.Diagnostics;
using System.Windows;
using System;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.IO;
using System.Collections.Generic;
namespace PDF_Master.Views.EditTools.Bates
{
///
/// Interaction logic for BatesTemplateListContentContent
///
public partial class BatesTemplateListContent : UserControl
{
private BatesTemplateListContentViewModel viewModel;
public BatesTemplateListContent()
{
InitializeComponent();
viewModel = this.DataContext as BatesTemplateListContentViewModel;
}
private void DeleteTemplateBtn_Click(object sender, System.Windows.RoutedEventArgs e)
{
viewModel.DeleteTemplateItemCommand?.Execute(sender);
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var listBox = sender as ListBox;
viewModel.SelectTemplateItemCommand?.Execute(sender);
//listBox.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 BatesHeaderFooterItem;
var TemplateIndex = panel.FindName("TemplateIndexTextBox") as TextBlock;
var LeftHeader = panel.FindName("LeftHeaderTextBox") as TextBlock;
var RightHeader = panel.FindName("RightHeaderTextBox") as TextBlock;
var CenterHeader = panel.FindName("CenterHeaderTextBox") as TextBlock;
var LeftFooter = panel.FindName("LeftFooterTextBox") as TextBlock;
var RightFooter = panel.FindName("RightFooterTextBox") as TextBlock;
var CenterFooter = panel.FindName("CenterFooterTextBox") as TextBlock;
List textBlocks = new List() { LeftHeader, RightHeader, CenterHeader, LeftFooter, RightFooter, CenterFooter };
if (data.TextData != null)
{
TemplateIndex.Text = data.ItemName;
foreach (var textBlock in textBlocks)
{
textBlock.Text = data.TextData[textBlocks.IndexOf(textBlock)].text;
if (textBlock.Text == "") { textBlock.Visibility = Visibility.Collapsed; }
else { textBlock.Visibility = Visibility.Visible; }
}
}
}
catch { }
}
}
}