12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using PDF_Office.CustomControl.ScanViewControl;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace PDF_Office.Views.Scan
- {
- /// <summary>
- /// ScanViwer.xaml 的交互逻辑
- /// </summary>
- public partial class ScanViwer : UserControl
- {
- public ScanViwer()
- {
- InitializeComponent();
- }
- double scale = 1;
- private void Grid_MouseWheel(object sender, MouseWheelEventArgs e)
- {
- if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
- {
- if (e.Delta > 0)
- {
- scale += 0.1;
- ImageGrid.Width = 500* scale;
- ImageGrid.Height = 500 * scale;
- }
- else
- {
- if (scale > 0.2)
- {
- scale -= 0.2;
- }
- ImageGrid.Width = 500* scale;
- ImageGrid.Height = 500 * scale;
- }
- }
- RedressControl.Visibility = Visibility.Collapsed;
- }
- private Point MouseDownPos;
- private async void CustomPanel_MouseDown(object sender, MouseButtonEventArgs e)
- {
- RedressControl.Visibility = Visibility.Visible;
- MouseDownPos = e.GetPosition(BitmapPanel);
- HitTestResult hitResult = VisualTreeHelper.HitTest(BitmapPanel, MouseDownPos);
- if (hitResult != null && hitResult.VisualHit is CustomDraw)
- {
- CustomDraw hitChild = (CustomDraw)hitResult.VisualHit;
- BitmapPanel.DisplayContent(hitChild);
- RedressControl.SetValue(Canvas.LeftProperty, hitChild.PaintRect.Left + (hitChild.PaintRect.Width / 2 - RedressControl.ActualWidth / 2));
- if (hitChild.PaintRect.Top - RedressControl.ActualHeight > 0)
- {
- RedressControl.SetValue(Canvas.TopProperty, hitChild.PaintRect.Top - RedressControl.ActualHeight);
- }
- else
- {
- RedressControl.SetValue(Canvas.TopProperty, hitChild.PaintRect.Bottom);
- }
- RedressControl.HitChild = hitChild;
- RedressControl.TextBoxContext = hitChild.PaintText;
- await Task.Delay(5);
- RedressControl.SelectAll();
- return;
- }
- RedressControl.Visibility = Visibility.Collapsed;
- }
- private void RedressControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if (!(bool)e.NewValue)
- {
- BitmapPanel.DisplayContent(null);
- }
- }
- private void RedressControl_ApplyCommandHandler(object sender, EventArgs e)
- {
- RedressControl.HitChild.PaintText = RedressControl.TextBoxContext;
- RedressControl.HitChild.Draw();
- RedressControl.Visibility = Visibility.Collapsed;
- }
- }
- }
|