using PDF_Office.CustomControl;
using PDF_Office.Helper;
using PDF_Office.ViewModels.HomePanel;
using PDF_Office.Views.HomePanel.PDFTools;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace PDF_Office.Views.HomePanel.PDFTools
{
///
/// HomeToolIControl.xaml 的交互逻辑0
///
///
public partial class QuickToolsContent : UserControl
{
private List allToolbars = null;
public QuickToolsContent()
{
InitializeComponent();
allToolbars = new List();
string path = @"pack://application:,,,/Resources/PromotionIcon/Windows.png";
List all = new List() { "PDF转Word", "PDF转Excel", "PDF转PPT", "转档PDF", "OCR", "拆分",
"提取","合并","压缩","图片转PDF","安全", "水印", "页眉页脚","贝茨Bates码","批量处理","打印", "背景","插入","文件对比"};
for (int i = 0; i < 8; i++)
{
QuickToolItem aToolModule = new QuickToolItem();
aToolModule.Id = i + 1;
aToolModule.Name = all[i];
aToolModule.Image = path;
aToolModule.NameInfo = "Batch convert, compress, secure, watermark PDFs.";
allToolbars.Add(aToolModule);
}
ListBoxToolBars.ItemsSource = allToolbars;
}
private void BtnMore_Click(object sender, RoutedEventArgs e)
{
if (GridAllTools.Height != 270)
{
GridAllTools.Height = 270;
ShowToolsUI(false);
}
else
{
GridAllTools.Height = 184;
ShowToolsUI(true);
}
}
///
/// 扩展收缩UI
///
/// 是否收缩
private void ShowToolsUI(bool IsShowConciseContent)
{
foreach (var item in ListBoxToolBars.Items)
{
var listBoxItem = ListBoxToolBars.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
if (listBoxItem != null)
{
var viewItem = listBoxItem.ContentTemplate;
var myContentPresenter = CommonHelper.FindVisualChild(listBoxItem);
var obj = viewItem.FindName("data", myContentPresenter);
var checkNum = obj as HomeToolItem;
if (checkNum != null)
{
checkNum.IsShowConciseContent = IsShowConciseContent;
}
}
}
}
///
/// 编辑工具
///
private void BtnTools_Click(object sender, RoutedEventArgs e)
{
}
private void GridAllTools_SizeChanged(object sender, SizeChangedEventArgs e)
{
ListBoxToolBarsWidthChanged();
}
private void ListBoxToolBarsWidthChanged()
{
double containerWidth = ListBoxToolBars.ActualWidth - 20;
int widthItem = (int)containerWidth / 5;
double margin = widthItem / 3;
int i = 0;
foreach (var item in ListBoxToolBars.Items)
{
i++;
var listBoxItem = ListBoxToolBars.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
if (listBoxItem != null)
{
if (i % 4 != 0)
{
listBoxItem.Margin = new Thickness(0, 0, margin, 20);
}
else
{
listBoxItem.Margin = new Thickness(0, 0, 0, 20);
}
listBoxItem.Width = widthItem;
}
}
}
private void ListBoxShortCuts_SizeChanged(object sender, SizeChangedEventArgs e)
{
}
}
}