Browse Source

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

ZhouJieSheng 2 years ago
parent
commit
8b7047814a

+ 2 - 0
PDF Office/App.xaml.cs

@@ -240,6 +240,8 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<TextAnnotProperty>();
             containerRegistry.RegisterForNavigation<ImageEditProperty>();
             containerRegistry.RegisterForNavigation<TextEditProperty>();
+            containerRegistry.RegisterForNavigation<ImageEditProperty>();
+            containerRegistry.RegisterForNavigation<ImageTextEditProperty>();
             containerRegistry.RegisterForNavigation<ScanPropertyPanel>();
             containerRegistry.RegisterForNavigation<BatesContent>();
             containerRegistry.RegisterForNavigation<BatesTemplateListContent>();

+ 16 - 16
PDF Office/CustomControl/Form/LayoutAglinContent.xaml

@@ -39,7 +39,7 @@
         </Grid.ColumnDefinitions>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignLeft"
+                x:Name="LayoutAlignLeft"
                 Grid.Row="0"
                 Grid.Column="0"
                 Width="32"
@@ -56,12 +56,12 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M2.01367 15V1H3.51367V15H2.01367ZM5 4H11V7H5V4ZM14 9H5V12H14V9Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignLeft, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignLeft, Path=Foreground}" />
             </RadioButton.Content>
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignHorizonCenter"
+                x:Name="LayoutAlignHorizonCenter"
                 Grid.Row="0"
                 Grid.Column="1"
                 Width="32"
@@ -78,12 +78,12 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M8.75 7L8.75 9L12 9L12 12L8.75 12L8.75 15L7.25 15L7.25 12L4 12L4 9L7.25 9L7.25 7L2 7L2 4L7.25 4L7.25 0.999999L8.75 1L8.75 4L14 4L14 7L8.75 7Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignHorizonCenter, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignHorizonCenter, Path=Foreground}" />
             </RadioButton.Content>
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignRight"
+                x:Name="LayoutAlignRight"
                 Grid.Row="0"
                 Grid.Column="2"
                 Width="32"
@@ -100,12 +100,12 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M14 1L14 15L12.5 15L12.5 1L14 1ZM11 12L2 12L2 9L11 9L11 12ZM4 7L11 7L11 4L4 4L4 7Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignRight, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignRight, Path=Foreground}" />
             </RadioButton.Content>
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignDistributeHorizontal"
+                x:Name="LayoutAlignDistributeHorizontal"
                 Grid.Row="0"
                 Grid.Column="3"
                 Width="32"
@@ -122,13 +122,13 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M15 12.5L1 12.5L1 14L15 14L15 12.5ZM12 9.5L4 9.5L4 6.5L12 6.5L12 9.5ZM1 2L15 2L15 3.5L1 3.5L1 2Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignDistributeHorizontal, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignDistributeHorizontal, Path=Foreground}" />
             </RadioButton.Content>
            
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignTop"
+                x:Name="LayoutAlignTop"
                 Grid.Row="1"
                 Grid.Column="0"
                 Width="32"
@@ -145,13 +145,13 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M15 2L1 2L1 3.5L15 3.5L15 2ZM12 5L12 11L9 11L9 5L12 5ZM7 5L7 14L4 14L4 5L7 5Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignTop, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignTop, Path=Foreground}" />
             </RadioButton.Content>
            
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignVerticalCenter"
+                x:Name="LayoutAlignVerticalCenter"
                 Grid.Row="1"
                 Grid.Column="1"
                 Width="32"
@@ -168,13 +168,13 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M7 7.25L9 7.25L9 4L12 4L12 7.25L15 7.25L15 8.75L12 8.75L12 12L9 12L9 8.75L7 8.75L7 14L4 14L4 8.75L1 8.75L1 7.25L4 7.25L4 2L7 2L7 7.25Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignVerticalCenter, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignVerticalCenter, Path=Foreground}" />
             </RadioButton.Content>
            
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutAlignBottom"
+                x:Name="LayoutAlignBottom"
                 Grid.Row="1"
                 Grid.Column="2"
                 Width="32"
@@ -191,13 +191,13 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M9 2H12V11H9V2ZM4 5H7V11H4V5ZM1 14H15V12.5H1V14Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignBottom, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutAlignBottom, Path=Foreground}" />
             </RadioButton.Content>
            
         </RadioButton>
 
         <RadioButton
-                x:Name="BtnImgLayoutDistributeVertical"
+                x:Name="LayoutDistributeVertical"
                 Grid.Row="1"
                 Grid.Column="3"
                 Width="32"
@@ -214,7 +214,7 @@
                 <Path
                         Margin="5,0,0,0"
                         Data="M2 15V1H3.5V15H2ZM6.5 4H9.5V12H6.5V4ZM12.5 1V15H14V1H12.5Z"
-                        Fill="{Binding ElementName=BtnImgLayoutDistributeVertical, Path=Foreground}" />
+                        Fill="{Binding ElementName=LayoutDistributeVertical, Path=Foreground}" />
             </RadioButton.Content>
         </RadioButton>
 

+ 12 - 0
PDF Office/CustomControl/Form/LayoutAglinContent.xaml.cs

@@ -26,6 +26,18 @@ namespace PDF_Office.CustomControl.Form
             InitializeComponent();
         }
 
+        public void ClearCheckedBtn()
+        {
+            foreach (var item in LayoutAlignGrid.Children)
+            {
+                var radioBtn = item as RadioButton;
+                if (radioBtn != null)
+                {
+                    radioBtn.IsChecked = false;
+                }
+            }
+        }
+
         public bool IsLayoutAvgAlign
         {
             get { return (bool)GetValue(IsLayoutAvgAlignProperty); }

+ 9 - 0
PDF Office/PDF Office.csproj

@@ -484,6 +484,8 @@
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureAnnotPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\AnnotPanel\SignatureCreateDialogViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\ImageEditPropertyViewModel.cs" />
+    <Compile Include="ViewModels\PropertyPanel\PDFEdit\ImageTextEditPropertyViewModel.cs" />
+    <Compile Include="ViewModels\PropertyPanel\PDFEdit\PDFEditVM.cs" />
     <Compile Include="ViewModels\PropertyPanel\PDFEdit\TextEditPropertyViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\Scan\ScanPropertyPanelViewModel.cs" />
     <Compile Include="ViewModels\PropertyPanel\ViewModular\ReadViewContentViewModel.cs" />
@@ -991,6 +993,9 @@
     <Compile Include="Views\PropertyPanel\PDFEdit\ImageEditProperty.xaml.cs">
       <DependentUpon>ImageEditProperty.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\PropertyPanel\PDFEdit\ImageTextEditProperty.xaml.cs">
+      <DependentUpon>ImageTextEditProperty.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\PropertyPanel\PDFEdit\TextEditProperty.xaml.cs">
       <DependentUpon>TextEditProperty.xaml</DependentUpon>
     </Compile>
@@ -1721,6 +1726,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Views\PropertyPanel\PDFEdit\ImageTextEditProperty.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="Views\PropertyPanel\PDFEdit\TextEditProperty.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 372 - 2
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageEditPropertyViewModel.cs

@@ -1,12 +1,382 @@
-using System;
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using Microsoft.Win32;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
+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.Input;
 
 namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 {
-    internal class ImageEditPropertyViewModel
+    public class ImageEditPropertyViewModel : PDFEditVM, INavigationAware
     {
+      
+
+        #region 图像属性
+        private bool _isCrop = false;
+        public bool IsCrop{get { return _isCrop; } set{SetProperty(ref _isCrop, value); }}
+        //选中的图像
+        private System.Windows.Media.Imaging.BitmapSource _currentImg;
+        public System.Windows.Media.Imaging.BitmapSource CurrentImg {get { return _currentImg; } set{   SetProperty(ref _currentImg, value); }}
+
+        private bool _isMultiSelectImage = false;
+        public bool IsMultiSelectImage { get { return _isMultiSelectImage; } set { SetProperty(ref _isMultiSelectImage, value); }}
+        #endregion
+
+        #region 图像Command
+        public DelegateCommand ReplaceImgCommand { get; set; }
+        public DelegateCommand ExportImgCommand { get; set; }
+        public DelegateCommand CropImgCommand { get; set; }
+        public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
+
+
+        /// <summary>
+        /// 逆时针旋转
+        /// </summary>
+        public DelegateCommand AntiClockwiseCommand { get; set; }
+        /// <summary>
+        /// 顺时针旋转
+        /// </summary>
+        public DelegateCommand ClockwiseCommand { get; set; }
+        public DelegateCommand CropModeCommand { get; set; }
+        public DelegateCommand CancelCropCommand { get; set; }
+        public DelegateCommand AddTextCommand { get; set; }
+        public DelegateCommand AddImgCommand { get; set; }
+        #endregion
+
+        public ImageEditPropertyViewModel()
+        {
+           
+            InitCommand();
+        }
+
+        private void InitCommand()
+        {
+            AddTextCommand = new DelegateCommand(AddText);
+            AddImgCommand = new DelegateCommand(AddImg);
+
+            ReplaceImgCommand = new DelegateCommand(ReplaceImg);
+            ExportImgCommand = new DelegateCommand(ExportImg);
+            CropImgCommand = new DelegateCommand(CropImg);
+            ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
+
+            AntiClockwiseCommand = new DelegateCommand(AntiClockwise);
+            ClockwiseCommand = new DelegateCommand(Clockwise);
+            CropModeCommand = new DelegateCommand(CropMode);
+            CancelCropCommand = new DelegateCommand(CancelCropImg);
+        }
+        private void AddText()
+        {
+            PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
+        }
+
+        #region 图像处理
+
+        private void CancelCropImg()
+        {
+            if (TextEditEvent != null)
+            {
+                TextEditEvent.ClipImage = false;
+                TextEditEvent.CancelClip();
+
+                TextEditEvent.UpdatePDFEditByEventArgs();
+                IsCrop = false;
+            }
+        }
+
+        private void CropImg()
+        {
+            if (TextEditEvent != null)
+            {
+                TextEditEvent.SaveClip();
+                TextEditEvent.ClipImage = false;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+                IsCrop = false;
+            }
+        }
+
+        private void ExportImg()
+        {
+            if (PDFViewer == null || TextEditEvent == null || TextEditEvent.EditType != ComPDFKit.PDFPage.CPDFEditType.EditImage) return;
+
+            System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog();
+            folder.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
+
+            if (folder.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                if (string.IsNullOrEmpty(folder.SelectedPath))
+                    return;
+
+                var keyValueList = PDFViewer.GetSelectedImages();
+                int i = 0;
+                foreach (var bitmap in keyValueList)
+                {
+                    foreach (var bitmapItem in bitmap.Value)
+                    {
+                        bitmapItem.Save(folder.SelectedPath + "\\" + i + ".png", System.Drawing.Imaging.ImageFormat.Png);
+                        i++;
+                    }
+                }
+
+
+
+            }
+        }
+
+        private void AddImg()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            openFileDialog.Multiselect = true;
+            if ((bool)openFileDialog.ShowDialog())
+            {
+                if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
+                {
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+                    PDFViewer.AddPDFEditImage(openFileDialog.FileName);
+                }
+            }
+        }
+
+        private void ReplaceImg()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            openFileDialog.Multiselect = true;
+            if ((bool)openFileDialog.ShowDialog())
+            {
+                if (string.IsNullOrEmpty(openFileDialog.FileName) == false)
+                {
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
+                    TextEditEvent.ReplaceImagePath = openFileDialog.FileName;
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                }
+            }
+        }
+
+        private void CropMode()
+        {
+            IsCrop = true;
+            if (TextEditEvent != null)
+            {
+                TextEditEvent.ClipImage = true;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+            }
+        }
+
+        private void Clockwise()
+        {
+            TextEditEvent.Rotate = TextEditEvent.Rotate + 90;
+            TextEditEvent.UpdatePDFEditByEventArgs();
+            GetImagePreView();
+        }
+
+        private void AntiClockwise()
+        {
+            TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
+            TextEditEvent?.UpdatePDFEditByEventArgs();
+            GetImagePreView();
+        }
+
+        #endregion
+
+        #region 布局处理
+        private void ImgAlignChecked(object obj)
+        {
+            if (obj != null)
+            {
+                switch ((string)obj)
+                {
+                    case "AlignLeft":
+                        PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
+                        break;
+                    case "AlignHorizonCenter":
+                        PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
+                        break;
+                    case "AlignRight":
+                        PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
+                        break;
+                    case "DistributeHorizontal":
+                        PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
+                        break;
+                    case "AlignTop":
+                        PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
+                        break;
+                    case "AlignVerticalCenter":
+                        PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
+                        break;
+                    case "AlignBottom":
+                        PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
+                        break;
+                    case "DistributeVertical":
+                        PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
+                        break;
+                }
+
+            }
+        }
+
+        private void ReLoadLayoutAlign(int count)
+        {
+            if (count >= 2)
+                IsLayoutAlign = true;
+            else
+                IsLayoutAlign = false;
+
+            if (count >= 3)
+                IsLayoutAvgAlign = true;
+            else
+                IsLayoutAvgAlign = false;
+        }
+        #endregion
+        protected List<PDFEditEvent> TextEditEventList;
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
+            if (PDFViewer != null)
+            {
+                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
+                if (TextEditEventList != null && TextEditEventList.Count > 0)
+                {
+                    TextEditEvent = TextEditEventList[0];
+                    if(TextEditEventList.Count >1)
+                    {
+                       IsMultiSelectImage = true;
+                    }
+                    else
+                    {
+                        GetImagePreView();
+                    }
+                    GetPDFEdit();
+                }
+            }
+        }
+        private void GetPDFEdit()
+        {
+           
+
+        }
+        //点击空白处时
+        private ContextMenu EmptyStateMenu(object sender)
+        {
+            var popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
+            if (popMenu != null && popMenu.Items.Count == 3)
+            {
+                //粘贴
+                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, ApplicationCommands.Paste);
+                //添加文本
+                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, AddTextCommand);
+                //添加图像
+                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, AddImgCommand);
+            }
+
+            return popMenu;
+        }
+        //选中图像时
+        private ContextMenu SelectImgPDFEdit(object sender)
+        {
+            var popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
+            if (popMenu != null && popMenu.Items.Count == 7)
+            {
+                //复制
+                SetPopMenuItem(popMenu.Items[0] as MenuItem, sender, ApplicationCommands.Copy);
+                //剪切
+                SetPopMenuItem(popMenu.Items[1] as MenuItem, sender, ApplicationCommands.Cut);
+                //粘贴
+                SetPopMenuItem(popMenu.Items[2] as MenuItem, sender, ApplicationCommands.Paste);
+                //删除
+                SetPopMenuItem(popMenu.Items[3] as MenuItem, sender, ApplicationCommands.Delete);
+                //裁剪
+                SetPopMenuItem(popMenu.Items[4] as MenuItem, sender, CropModeCommand);
+                //替换
+                SetPopMenuItem(popMenu.Items[5] as MenuItem, sender, ReplaceImgCommand);
+                //导出
+                SetPopMenuItem(popMenu.Items[6] as MenuItem, sender, ExportImgCommand);
+            }
+            return popMenu;
+        }
+
+        private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
+        {
+
+            if (e == null)
+                return;
+
+            switch (e.CommandType)
+            {
+                case CommandType.Context:
+
+                    if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
+                    {
+                        e.PopupMenu = EmptyStateMenu(sender);
+
+                    }
+                    else if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
+                    {
+                        e.PopupMenu = SelectImgPDFEdit(sender);
+                    }
+                    break;
+
+                default:
+                    e.DoCommand();
+                    break;
+
+            }
+            if (e.PopupMenu != null)
+            {
+                e.Handle = true;
+            }
+        }
+
+        private void GetImagePreView()
+        {
+            var list = PDFViewer.GetSelectedImages();
+            if (list != null && list.Count > 0)
+            {
+                System.Drawing.Bitmap bitmap = null;
+                foreach (var item in list)
+                {
+                    if (item.Value.Count > 0)
+                    {
+                        bitmap = item.Value[0];
+                        break;
+                    }
+                }
+
+                if (bitmap != null)
+                {
+                    IntPtr ip = bitmap.GetHbitmap();
+                    System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, Int32Rect.Empty,
+                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
+                    CurrentImg = bitmapSource;
+                }
+
+            }
+        }
+        #region 全局
+
+        public event EventHandler ClearCheckedAglin;
+        #endregion
+        public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
+
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            IsMultiSelectImage = false;
+            TextEditEvent = null;
+            ClearCheckedAglin?.Invoke(null, null);
+            PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+        }
     }
 }

+ 39 - 0
PDF Office/ViewModels/PropertyPanel/PDFEdit/ImageTextEditPropertyViewModel.cs

@@ -0,0 +1,39 @@
+using Prism.Mvvm;
+using Prism.Regions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
+{
+    public class ImageTextEditPropertyViewModel : PDFEditVM, INavigationAware
+    {
+        public ImageTextEditPropertyViewModel()
+        {
+
+           
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+            //navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            //if (PDFViewer != null)
+            //{
+            //    PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+            //    PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
+
+            //    PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+            //    PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
+
+            //}
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
+
+
+        public void OnNavigatedFrom(NavigationContext navigationContext) { }
+    }
+}

+ 51 - 0
PDF Office/ViewModels/PropertyPanel/PDFEdit/PDFEditVM.cs

@@ -0,0 +1,51 @@
+using ComPDFKitViewer;
+using ComPDFKitViewer.PdfViewer;
+using Prism.Mvvm;
+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.Input;
+
+namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
+{
+    public class PDFEditVM: BindableBase
+    {
+       
+        #region 变量
+        protected PDFEditEvent TextEditEvent;
+        protected CPDFViewer PDFViewer;
+        #endregion
+
+        #region 编辑PDF全局
+
+        //多选时,选中的既是文本也是图像
+        private bool _isSelectTextAndImg = false;
+        public bool IsSelectTextAndImg { get { return _isSelectTextAndImg; } set { SetProperty(ref _isSelectTextAndImg, value); } }
+
+        //平均对齐布局
+        private bool _isLayoutAvgAlign = false;
+        public bool IsLayoutAvgAlign { get { return _isLayoutAvgAlign; } set { SetProperty(ref _isLayoutAvgAlign, value); } }
+        //对齐布局
+
+        private bool _isLayoutAlign = false;
+        public bool IsLayoutAlign { get { return _isLayoutAlign; } set { SetProperty(ref _isLayoutAlign, value); } }
+        //是否为文本
+
+        private bool _isTextEdit = true;
+        public bool IsTextEdit { get { return _isTextEdit; } set { SetProperty(ref _isTextEdit, value); } }
+
+
+        #endregion
+        protected void SetPopMenuItem(MenuItem menu, object sender, ICommand command)
+        {
+            MenuItem menuItem = menu;
+            menuItem.CommandTarget = (UIElement)sender;
+            menuItem.Command = command;
+        }
+      
+    }
+}

+ 110 - 117
PDF Office/ViewModels/PropertyPanel/PDFEdit/TextEditPropertyViewModel.cs

@@ -18,31 +18,11 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 {
-    public class TextEditPropertyViewModel : BindableBase, INavigationAware
+    public class TextEditPropertyViewModel : PDFEditVM, INavigationAware
     {
+      
         #region 属性
 
-        #region 编辑PDF全局
-        //多选时,选中的既是文本也是图像
-        private bool _isSelectTextAndImg = false;
-        public bool IsSelectTextAndImg{get { return _isSelectTextAndImg; } set {SetProperty(ref _isSelectTextAndImg, value);}}
-
-        //平均对齐布局
-        private bool _isLayoutAvgAlign = false;
-        public bool IsLayoutAvgAlign { get { return _isLayoutAvgAlign; }set {SetProperty(ref _isLayoutAvgAlign, value); }}
-        //对齐布局
-
-        private bool _isLayoutAlign = false;
-        public bool IsLayoutAlign {get { return _isLayoutAlign; }set{SetProperty(ref _isLayoutAlign, value);}}
-        //是否为文本
-
-        private bool _isTextEdit = true;
-        public bool IsTextEdit {get { return _isTextEdit; }set{ SetProperty(ref _isTextEdit, value);} }
-
-
-        #endregion
-
-
         #region 文本属性
 
         private double _angle;
@@ -172,10 +152,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
         #region Command
 
-        #region 全局
-
-        public event EventHandler ClearCheckedAglin;
-        #endregion
+       
 
         #region 文本Command
         public DelegateCommand AddTextCommand { get; set; }
@@ -215,11 +192,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
 
         #endregion
 
-        #region 变量
-        private PDFEditEvent TextEditEvent;
-        private CPDFViewer PDFViewer;
-        #endregion
-
         #region 初始化
         public TextEditPropertyViewModel()
         {
@@ -630,13 +602,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
             return popMenu;
         }
 
-        private void SetPopMenuItem(MenuItem menu, object sender, ICommand command)
-        {
-            MenuItem menuItem = menu;
-            menuItem.CommandTarget = (UIElement)sender;
-            menuItem.Command = command;
-        }
-
         #endregion
 
 
@@ -690,104 +655,132 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
                 e.Handle = true;
             }
         }
-        /// <summary>
-        /// 选中编辑PDF内容的事件
-        /// </summary>
-        private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
-        {
-            if (e != null && e.Count > 0)
-            {
-
-                ReLoadLayoutAlign(e.Count);
-
-                IsTextEdit = (e[0].EditType == ComPDFKit.PDFPage.CPDFEditType.EditText);
-                TextEditEvent = e[0];
-
-                if (IsTextEdit == false)
-                {
-                    var list = PDFViewer.GetSelectedImages();
-                    if (list != null && list.Count > 0)
-                    {
-                        System.Drawing.Bitmap bitmap = null;
-                        foreach (var item in list)
-                        {
-                            if (item.Value.Count > 0)
-                            {
-                                bitmap = item.Value[0];
-                                break;
-                            }
-                        }
-
-                        if (bitmap != null)
-                        {
-                            IntPtr ip = bitmap.GetHbitmap();
-                            System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, Int32Rect.Empty,
-                            System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
-                            CurrentImg = bitmapSource;
-                        }
-
-                    }
-
+        ///// <summary>
+        ///// 选中编辑PDF内容的事件
+        ///// </summary>
+        //private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
+        //{
+        //    if (e != null && e.Count > 0)
+        //    {
+
+        //        ReLoadLayoutAlign(e.Count);
+
+        //        IsTextEdit = (e[0].EditType == ComPDFKit.PDFPage.CPDFEditType.EditText);
+        //        TextEditEvent = e[0];
+
+        //        if (IsTextEdit == false)
+        //        {
+        //            var list = PDFViewer.GetSelectedImages();
+        //            if (list != null && list.Count > 0)
+        //            {
+        //                System.Drawing.Bitmap bitmap = null;
+        //                foreach (var item in list)
+        //                {
+        //                    if (item.Value.Count > 0)
+        //                    {
+        //                        bitmap = item.Value[0];
+        //                        break;
+        //                    }
+        //                }
+
+        //                if (bitmap != null)
+        //                {
+        //                    IntPtr ip = bitmap.GetHbitmap();
+        //                    System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, Int32Rect.Empty,
+        //                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
+        //                    CurrentImg = bitmapSource;
+        //                }
+
+        //            }
+
+
+        //        }
+
+        //        bool isText = false;
+        //        bool isImg = false;
+
+        //        foreach (var item in e)
+        //        {
+        //            if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
+        //            {
+        //                isText = true;
+        //            }
+
+        //            if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
+        //            {
+        //                isImg = true;
+        //            }
+
+        //        }
+
+        //        if (isImg == true && isText == true)
+        //            IsSelectTextAndImg = true;
+        //        else
+        //            IsSelectTextAndImg = false;
+
+        //    }
+        //    else
+        //    {
+        //        IsLayoutAlign = false;
+        //        IsLayoutAvgAlign = false;
+        //        IsSelectTextAndImg = false;
+        //        IsTextEdit = true;
+
+        //        ClearCheckedAglin?.Invoke(null, null);
+
+        //    }
+        //}
+        #region 全局
 
-                }
+        public event EventHandler ClearCheckedAglin;
+        #endregion
+        #endregion
 
-                bool isText = false;
-                bool isImg = false;
+        protected List<PDFEditEvent> TextEditEventList;
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
 
-                foreach (var item in e)
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
+            if (PDFViewer != null)
+            {
+                if (TextEditEventList != null && TextEditEventList.Count > 0)
                 {
-                    if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
-                    {
-                        isText = true;
-                    }
-
-                    if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
-                    {
-                        isImg = true;
-                    }
-
+                    TextEditEvent = TextEditEventList[0];
+                    GetPDFEdit();
                 }
 
-                if (isImg == true && isText == true)
-                    IsSelectTextAndImg = true;
-                else
-                    IsSelectTextAndImg = false;
+                //PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+                //PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
 
-            }
-            else
-            {
-                IsLayoutAlign = false;
-                IsLayoutAvgAlign = false;
-                IsSelectTextAndImg = false;
-                IsTextEdit = true;
-
-                ClearCheckedAglin?.Invoke(null, null);
+                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
 
             }
         }
 
-        #endregion
-
-
-        public void OnNavigatedTo(NavigationContext navigationContext)
+        private void  GetPDFEdit()
         {
-
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
-            if (PDFViewer != null)
+            if(TextEditEvent != null)
             {
-                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
-                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
-
-                PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
-                PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
-               
+                TextFontFamily = TextEditEvent.FontFamily;
+                TextFontSize = (int)TextEditEvent.FontSize;
+                TextFontStyle = TextEditEvent.FontStyle;
+                TextFontWeights = TextEditEvent.FontWeight;
+                SelectColor = new SolidColorBrush(TextEditEvent.FontColor);
+                
             }
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext){   return true; }
 
        
-        public void OnNavigatedFrom(NavigationContext navigationContext){}
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        { 
+            TextEditEvent = null; 
+            ClearCheckedAglin?.Invoke(null, null);
+            PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
+        }
 
 
 

+ 82 - 3
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -14,6 +14,7 @@ using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model;
 using Microsoft.Win32;
 using PDF_Office.CustomControl;
+using ComPDFKitViewer;
 
 namespace PDF_Office.ViewModels.Tools
 {
@@ -23,9 +24,40 @@ namespace PDF_Office.ViewModels.Tools
         public DelegateCommand<object> AddContentCommand { get; set; }
 
         #endregion
-        public TextEditToolContentViewModel()
+        private IRegionManager regions;
+        private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
+        public TextEditToolContentViewModel(IRegionManager regionManager)
         {
+            regions = regionManager;
             InitCommand();
+            InitBtnToProperty();
+        }
+        private void InitBtnToProperty()
+        {
+            btnToProperty.Add("Text", "TextEditProperty");
+            btnToProperty.Add("Image", "ImageEditProperty");
+            btnToProperty.Add("TextAndImage", "ImageTextEditProperty");
+            btnToProperty.Add("PropertyPanelContent", "PropertyPanelContent");
+        }
+
+        private void AddToPropertyPanel(string type,  List<PDFEditEvent> e)
+        {
+            if (btnToProperty.ContainsKey(type))
+            {
+                NavigationParameters parameters = new NavigationParameters();
+                parameters.Add(ParameterNames.PDFViewer, PDFViewer);
+                parameters.Add(ParameterNames.AnnotEvent, e);
+                System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+                {
+                    regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
+                }));
+
+                ShowPropertyPanel(true);
+            }
+        }
+        private void ShowPropertyPanel(bool show = true)
+        {
+            viewContentViewModel.IsPropertyOpen = show;
         }
 
         private void InitCommand()
@@ -70,16 +102,62 @@ namespace PDF_Office.ViewModels.Tools
 
 
         }
-
+        public ViewContentViewModel viewContentViewModel;
         private CPDFViewer PDFViewer;
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
+
             if (PDFViewer != null)
             {
+                PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
+
+            }
+        }
+
+        private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
+        {
+  
+            if (e != null && e.Count > 0)
+            {
+                bool isText = false;
+                bool isImg = false;
+                foreach (var item in e)
+                {
+
+                    if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
+                    {
+                        isImg = true;
+                    }
+
+                    if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
+                    {
+                        isText = true;
+                    }
 
+                }
 
+
+                if (isText == true && isImg == false)
+                {
+                    AddToPropertyPanel("Text", e);
+                }
+                if (isText == false && isImg == true)
+                {
+                    AddToPropertyPanel("Image", e);
+                }
+                if (isText == true && isImg == true)
+                {
+                    AddToPropertyPanel("TextAndImage", e);
+                }
             }
+            else
+            {
+                AddToPropertyPanel("PropertyPanelContent", null);
+            }
+
         }
 
         public bool IsNavigationTarget(NavigationContext navigationContext)
@@ -90,7 +168,8 @@ namespace PDF_Office.ViewModels.Tools
       
         public void OnNavigatedFrom(NavigationContext navigationContext)
         {
-          
+            PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
+            ShowPropertyPanel(false);
         }
 
     }

+ 2 - 2
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -561,8 +561,8 @@ namespace PDF_Office.ViewModels
                 if (PDFViewer != null)
                 {
                     PDFViewer.SetMouseMode(MouseModes.PDFEdit);
-                    SelectedPrpoertyPanel("TextEditProperty", null);
-                    IsPropertyOpen = true;
+                    //SelectedPrpoertyPanel("TextEditProperty", null);
+                    //IsPropertyOpen = true;
                 }
             }
             else

+ 159 - 1
PDF Office/Views/PropertyPanel/PDFEdit/ImageEditProperty.xaml

@@ -3,10 +3,168 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:prism="http://prismlibrary.com/"
+             xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+             xmlns:FormControl="clr-namespace:PDF_Office.CustomControl.Form"
+              xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
+             prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.PDFEdit"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="../../../Styles/SliderStyle.xaml" />
+                <ResourceDictionary Source="../../../Styles/CustomBtnStyle.xaml" />
+                <ResourceDictionary Source="../../../Styles/RadioButtonStyle.xaml" />
+            </ResourceDictionary.MergedDictionaries>
+
+            <Convert:BoolToVisible x:Key="BoolToVisible" />
+            <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
+            <Convert:InvertBoolConvert x:Key="InvertBoolConvert" />
+
+          
+        </ResourceDictionary>
+    </UserControl.Resources>
     <Grid>
-            
+        <StackPanel >
+            <TextBlock
+                    Name="AnnotTypeTitle1"
+                    Margin="10,8,0,0"
+                    HorizontalAlignment="Left"
+                    FontFamily="Segoe UI Semibold"
+                    FontSize="18"
+                    FontWeight="SemiBold"
+                    LineHeight="24">
+                    Image
+            </TextBlock>
+            <Border Visibility="{Binding IsMultiSelectImage,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                    Width="228"
+                    Height="100"
+                    Margin="0,8,0,0"
+                    Background="White"
+                    BorderBrush="#DDDDDD"
+                    BorderThickness="1"
+                    CornerRadius="2">
+                <Grid>
+                    <Border
+                            Name="FreeTextBorder1"
+                            Padding="5"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center">
+                        <Image x:Name="ImgExmple" Source="{Binding CurrentImg}">
+                            <!--<Image.RenderTransform>
+                                <RotateTransform x:Name="test" Angle="{Binding Angle}" />
+                            </Image.RenderTransform>-->
+                        </Image>
+                    </Border>
+                </Grid>
+            </Border>
+            <StackPanel
+                    Margin="0,18,0,0"
+                    HorizontalAlignment="Center"
+                    Orientation="Horizontal">
+                <Button
+                        Width="32"
+                        Height="32"
+                        Margin="0,0,20,0"
+                        Command="{Binding AntiClockwiseCommand}"
+                        Content="逆转"
+                        IsEnabled="{Binding IsCrop, Converter={StaticResource InvertBoolConvert}}" />
+                <Button
+                        Width="32"
+                        Height="32"
+                        Command="{Binding ClockwiseCommand}"
+                        Content="顺转"
+                        IsEnabled="{Binding IsCrop, Converter={StaticResource InvertBoolConvert}}" />
+            </StackPanel>
+
+            <CompositeControl:SlidComboControl IsEnabled="{Binding IsCrop, Converter={StaticResource InvertBoolConvert}}" />
+            <StackPanel
+                    Width="228"
+                    Margin="0,20,0,0"
+                    HorizontalAlignment="Center">
+                <Grid x:Name="GridCrop" Visibility="{Binding IsMultiSelectImage,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                    <cus:CustomIconToggleBtn
+                            x:Name="BtnCrop"
+                            BorderBrush="#DFE1E5"
+                            BorderThickness="1"
+                            Command="{Binding CropModeCommand}"
+                            ContentStringFormat="156"
+                            Foreground="Black"
+                            Style="{StaticResource ToggleBtnViewModeStyle}"
+                            Tag="Crop"
+                            Visibility="{Binding IsCrop, Converter={StaticResource InvertBoolToVisibleConvert}}">
+                        <TextBlock Text="Crop" />
+                    </cus:CustomIconToggleBtn>
+                    <Grid Visibility="{Binding IsCrop, Converter={StaticResource BoolToVisible}}">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="8" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+
+                        <Button
+                                Height="32"
+                                Background="#1770F4"
+                                Command="{Binding CropImgCommand}"
+                                Content="Confirm" />
+                        <Button
+                                Grid.Column="2"
+                                Background="White"
+                                BorderBrush="#DFE1E5"
+                                BorderThickness="1"
+                                Command="{Binding CancelCropCommand}"
+                                Content="Cancel" />
+                    </Grid>
+                </Grid>
+                <cus:CustomIconToggleBtn
+                        x:Name="BtnReplace"
+                        Margin="0,13,0,0"
+                        BorderBrush="#DFE1E5"
+                        BorderThickness="1"
+                        Command="{Binding ReplaceImgCommand}"
+                        ContentStringFormat="156"
+                        Foreground="Black"
+                        IsEnabled="{Binding IsCrop, Converter={StaticResource InvertBoolConvert}}"
+                        Visibility="{Binding IsMultiSelectImage,Converter={StaticResource InvertBoolToVisibleConvert}}"
+                        Style="{StaticResource ToggleBtnViewModeStyle}"
+                        Tag="Replace">
+                    <TextBlock Text="Replace" />
+                </cus:CustomIconToggleBtn>
+
+                <cus:CustomIconToggleBtn
+                        x:Name="BtnExtract"
+                        Margin="0,13,0,0"
+                        BorderBrush="#DFE1E5"
+                        BorderThickness="1"
+                        Command="{Binding ExportImgCommand}"
+                        ContentStringFormat="156"
+                        Foreground="Black"
+                        IsEnabled="{Binding IsCrop, Converter={StaticResource InvertBoolConvert}}"
+                        Style="{StaticResource ToggleBtnViewModeStyle}"
+                        Tag="Extract">
+                    <TextBlock Text="Extract" />
+                </cus:CustomIconToggleBtn>
+            </StackPanel>
+            <TextBlock
+                    x:Name="AlignImg"
+                    Margin="12,14,0,0"
+                    FontFamily="Segoe UI Semibold"
+                    FontSize="14"
+                    FontWeight="SemiBold"
+                    LineHeight="20">
+                    Align
+            </TextBlock>
+            <FormControl:LayoutAglinContent x:Name="laoutAglin" Grid.Row="1" IsLayoutAlign="{Binding IsLayoutAlign}" IsLayoutAvgAlign="{Binding IsLayoutAvgAlign}">
+                <i:Interaction.Triggers>
+                    <i:EventTrigger EventName="ValueChanged">
+                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=laoutAglin, Path=Btntag}" />
+                    </i:EventTrigger>
+                </i:Interaction.Triggers>
+            </FormControl:LayoutAglinContent>
+        </StackPanel>
     </Grid>
 </UserControl>

+ 22 - 0
PDF Office/Views/PropertyPanel/PDFEdit/ImageTextEditProperty.xaml

@@ -0,0 +1,22 @@
+<UserControl x:Class="PDF_Office.Views.PropertyPanel.PDFEdit.ImageTextEditProperty"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:FormControl="clr-namespace:PDF_Office.CustomControl.Form"
+             xmlns:prism="http://prismlibrary.com/"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.PDFEdit"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid VerticalAlignment="Top">
+        <FormControl:LayoutAglinContent x:Name="laoutAglin" Grid.Row="1" IsLayoutAlign="{Binding IsLayoutAlign}" IsLayoutAvgAlign="{Binding IsLayoutAvgAlign}">
+            <i:Interaction.Triggers>
+                <i:EventTrigger EventName="ValueChanged">
+                    <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=laoutAglin, Path=Btntag}" />
+                </i:EventTrigger>
+            </i:Interaction.Triggers>
+        </FormControl:LayoutAglinContent>
+    </Grid>
+</UserControl>

+ 28 - 0
PDF Office/Views/PropertyPanel/PDFEdit/ImageTextEditProperty.xaml.cs

@@ -0,0 +1,28 @@
+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.PropertyPanel.PDFEdit
+{
+    /// <summary>
+    /// ImageTextEditProperty.xaml 的交互逻辑
+    /// </summary>
+    public partial class ImageTextEditProperty : UserControl
+    {
+        public ImageTextEditProperty()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 13 - 232
PDF Office/Views/PropertyPanel/PDFEdit/TextEditProperty.xaml

@@ -3,6 +3,7 @@
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:CompositeControl="clr-namespace:PDF_Office.CustomControl.CompositeControl"
+    xmlns:FormControl="clr-namespace:PDF_Office.CustomControl.Form"
     xmlns:Convert="clr-namespace:PDF_Office.DataConvert"
     xmlns:cus="clr-namespace:PDF_Office.CustomControl"
     xmlns:cusColor="clr-namespace:PDF_Office.CustomControl.CompositeControl"
@@ -12,12 +13,13 @@
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:pdfedit="clr-namespace:PDF_Office.Views.PropertyPanel.PDFEdit"
     xmlns:prism="http://prismlibrary.com/"
-    d:DataContext="{d:DesignInstance Type=pdfedit:TextEditPropertyViewModel}"
+    prism:ViewModelLocator.AutoWireViewModel="True"
     d:DesignHeight="450"
     d:DesignWidth="800"
-    prism:ViewModelLocator.AutoWireViewModel="True"
+    
     Loaded="UserControl_Loaded"
     mc:Ignorable="d">
+    <!--d:DataContext="{d:DesignInstance Type=pdfedit:TextEditPropertyViewModel}"-->
     <UserControl.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
@@ -693,7 +695,7 @@
                 </TextBlock>
             </StackPanel>
 
-            <StackPanel Visibility="{Binding IsTextEdit, Converter={StaticResource InvertBoolToVisibleConvert}}">
+            <!--<StackPanel Visibility="{Binding IsTextEdit, Converter={StaticResource InvertBoolToVisibleConvert}}">
                 <TextBlock
                     Name="AnnotTypeTitle1"
                     Margin="10,8,0,0"
@@ -821,7 +823,7 @@
                     LineHeight="20">
                     Align
                 </TextBlock>
-            </StackPanel>
+            </StackPanel>-->
 
         </Grid>
 
@@ -845,233 +847,12 @@
                 Align
             </TextBlock>
         </StackPanel>
-
-        <Grid
-            x:Name="LayoutAlignGrid"
-            Grid.Row="1"
-            Width="150"
-            Margin="0,10,0,0"
-            HorizontalAlignment="Left">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="*" />
-                <RowDefinition Height="*" />
-            </Grid.RowDefinitions>
-
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="*" />
-                <ColumnDefinition Width="*" />
-                <ColumnDefinition Width="*" />
-                <ColumnDefinition Width="*" />
-            </Grid.ColumnDefinitions>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignLeft"
-                Grid.Row="0"
-                Grid.Column="0"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="AlignLeft">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M2.01367 15V1H3.51367V15H2.01367ZM5 4H11V7H5V4ZM14 9H5V12H14V9Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignLeft, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignLeft, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignHorizonCenter"
-                Grid.Row="0"
-                Grid.Column="1"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="AlignHorizonCenter">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M8.75 7L8.75 9L12 9L12 12L8.75 12L8.75 15L7.25 15L7.25 12L4 12L4 9L7.25 9L7.25 7L2 7L2 4L7.25 4L7.25 0.999999L8.75 1L8.75 4L14 4L14 7L8.75 7Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignHorizonCenter, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignHorizonCenter, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignRight"
-                Grid.Row="0"
-                Grid.Column="2"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="AlignRight">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M14 1L14 15L12.5 15L12.5 1L14 1ZM11 12L2 12L2 9L11 9L11 12ZM4 7L11 7L11 4L4 4L4 7Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignRight, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignRight, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignDistributeHorizontal"
-                Grid.Row="0"
-                Grid.Column="3"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAvgAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="DistributeHorizontal">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M15 12.5L1 12.5L1 14L15 14L15 12.5ZM12 9.5L4 9.5L4 6.5L12 6.5L12 9.5ZM1 2L15 2L15 3.5L1 3.5L1 2Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignDistributeHorizontal, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignDistributeHorizontal, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignTop"
-                Grid.Row="1"
-                Grid.Column="0"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="AlignTop">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M15 2L1 2L1 3.5L15 3.5L15 2ZM12 5L12 11L9 11L9 5L12 5ZM7 5L7 14L4 14L4 5L7 5Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignTop, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignTop, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignVerticalCenter"
-                Grid.Row="1"
-                Grid.Column="1"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="AlignVerticalCenter">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M7 7.25L9 7.25L9 4L12 4L12 7.25L15 7.25L15 8.75L12 8.75L12 12L9 12L9 8.75L7 8.75L7 14L4 14L4 8.75L1 8.75L1 7.25L4 7.25L4 2L7 2L7 7.25Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignVerticalCenter, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignVerticalCenter, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutAlignBottom"
-                Grid.Row="1"
-                Grid.Column="2"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="AlignBottom">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M9 2H12V11H9V2ZM4 5H7V11H4V5ZM1 14H15V12.5H1V14Z"
-                        Fill="{Binding ElementName=BtnImgLayoutAlignBottom, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignBottom, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-            <RadioButton
-                x:Name="BtnImgLayoutDistributeVertical"
-                Grid.Row="1"
-                Grid.Column="3"
-                Width="32"
-                Height="32"
-                VerticalContentAlignment="Center"
-                Background="Transparent"
-                Foreground="#616469"
-                GroupName="ImgAlign"
-                IsEnabled="{Binding IsLayoutAvgAlign}"
-                Style="{DynamicResource GreyBgRadioBtnStyle}"
-                Tag="DistributeVertical">
-                <RadioButton.Content>
-                    <Path
-                        Margin="5,0,0,0"
-                        Data="M2 15V1H3.5V15H2ZM6.5 4H9.5V12H6.5V4ZM12.5 1V15H14V1H12.5Z"
-                        Fill="{Binding ElementName=BtnImgLayoutDistributeVertical, Path=Foreground}" />
-                </RadioButton.Content>
-                <i:Interaction.Triggers>
-                    <i:EventTrigger EventName="Checked">
-                        <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutDistributeVertical, Path=Tag}" />
-                    </i:EventTrigger>
-                </i:Interaction.Triggers>
-            </RadioButton>
-
-        </Grid>
+        <FormControl:LayoutAglinContent x:Name="laoutAglin" Grid.Row="1" IsLayoutAlign="{Binding IsLayoutAlign}" IsLayoutAvgAlign="{Binding IsLayoutAvgAlign}">
+            <i:Interaction.Triggers>
+                <i:EventTrigger EventName="ValueChanged">
+                    <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=laoutAglin, Path=Btntag}" />
+                </i:EventTrigger>
+            </i:Interaction.Triggers>
+        </FormControl:LayoutAglinContent>
     </Grid>
 </UserControl>

+ 1 - 8
PDF Office/Views/PropertyPanel/PDFEdit/TextEditProperty.xaml.cs

@@ -65,14 +65,7 @@ namespace PDF_Office.Views.PropertyPanel.PDFEdit
 
         private void ViewModel_ClearCheckedAglin(object sender, EventArgs e)
         {
-            foreach (var item in LayoutAlignGrid.Children)
-            {
-                var radioBtn = item as RadioButton;
-                if (radioBtn != null)
-                {
-                    radioBtn.IsChecked = false;
-                }
-            }
+            laoutAglin.ClearCheckedBtn();
         }
 
         private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

+ 1 - 1
PDF Office/Views/PropertyPanel/PropertyPanelContent.xaml

@@ -18,7 +18,7 @@
     <Grid  VerticalAlignment="Stretch">
  
         <Grid>
-            
+            <TextBlock Text="空" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center"/>
         </Grid>
      
     </Grid>