123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using PDF_Office.CustomControl;
- using PDF_Office.Helper;
- using PDF_Office.Model.PDFTool;
- 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
- {
- /// <summary>
- /// HomeToolIControl.xaml 的交互逻辑0
- ///
- /// </summary>
- public partial class QuickToolsContent : UserControl
- {
- PDFToolsHelper PDFtools;
- public QuickToolsContent()
- {
- InitializeComponent();
- PDFtools = new PDFToolsHelper();
- ListBoxToolBars.ItemsSource = PDFtools.QuickTools;
- }
-
- private void BtnMore_Click(object sender, RoutedEventArgs e)
- {
- if (GridAllTools.Height != 270)
- {
- GridAllTools.Height = 270;
- ShowToolsUI(false);
- }
- else
- {
- GridAllTools.Height = 184;
- ShowToolsUI(true);
- }
-
- }
- /// <summary>
- /// 扩展收缩UI
- /// </summary>
- /// <param name="IsShowConciseContent">是否收缩</param>
- 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<ContentPresenter>(listBoxItem);
- var obj = viewItem.FindName("data", myContentPresenter);
- var checkNum = obj as PDFToolItem;
- if (checkNum != null)
- {
- checkNum.IsShowConciseContent = IsShowConciseContent;
- }
- }
- }
-
- }
-
- /// <summary>
- /// 编辑工具
- /// </summary>
- 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)
- {
-
- }
- private void QuickTools_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- var toolItem = (sender as FrameworkElement).DataContext as ToolItem;
- var veiwModel = this.DataContext as HomeGuidContentViewModel;
- if (veiwModel != null && toolItem != null)
- {
- veiwModel.QuickToolsCommand.Execute(toolItem);
- }
- }
- }
- }
|