Browse Source

编辑PDF - 裁切、对齐、导出、替换、添加文本图像

chenrongqian 2 years ago
parent
commit
89df0d4e1b

+ 1 - 0
PDF Office/App.xaml

@@ -16,6 +16,7 @@
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/CustomBtnStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContainerStyles/ComboxStyle/ComboxItemStyle.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/PathButtonStyle.xaml"/>
+                <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Styles/ContextMenuTextEditStyle.xaml"/>
                 <!--  Enable show customctrol's correctly UI in Xaml Designer  -->
                 <ResourceDictionary Source="pack://application:,,,/PDF Office;component/Themes/Generic.xaml" />
             </ResourceDictionary.MergedDictionaries>

+ 213 - 55
PDF Office/ViewModels/PropertyPanel/TextEditPropertyViewModel.cs

@@ -1,5 +1,6 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.PdfViewer;
+using Microsoft.Win32;
 using PDF_Office.Model;
 using PDF_Office.Model.PropertyPanel.AnnotPanel;
 using Prism.Commands;
@@ -22,6 +23,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
         #region 属性
 
         #region 编辑PDF全局
+
         private bool _isTextEdit = true;
         public bool IsTextEdit
         {
@@ -33,13 +35,24 @@ namespace PDF_Office.ViewModels.PropertyPanel
             }
         }
 
-       
+
         #endregion
 
 
 
         #region 文本属性
 
+        private double _angle;
+        public double Angle
+        {
+            get { return _angle; }
+            set
+            {
+                SetProperty(ref _angle, value);
+
+            }
+        }
+
         private Brush selectColor = new SolidColorBrush(Colors.Black);
         public Brush SelectColor
         {
@@ -172,6 +185,9 @@ namespace PDF_Office.ViewModels.PropertyPanel
         #region Command
 
         #region 文本Command
+        public DelegateCommand AddTextCommand { get; set; }
+        public DelegateCommand AddImgCommand { get; set; }
+
         public DelegateCommand<object> SelectedColorCommand { get; set; }
         public DelegateCommand<object> SelectedFontStyleCommand { get; set; }
         public DelegateCommand<object> FontFamilyChangedCommand { get; set; }
@@ -179,10 +195,16 @@ namespace PDF_Office.ViewModels.PropertyPanel
         public DelegateCommand<object> FontSizeChangedCommand { get; set; }
 
         public DelegateCommand<object> TextAlignCheckedCommand { get; set; }
-        
+
         #endregion
 
         #region 图像Command
+        public DelegateCommand ReplaceImgCommand { get; set; }
+        public DelegateCommand ExportImgCommand { get; set; }
+        public DelegateCommand CropImgCommand { get; set; }
+        public DelegateCommand ImgAlignCheckedCommand { get; set; }
+        
+
         /// <summary>
         /// 逆时针旋转
         /// </summary>
@@ -191,7 +213,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
         /// 顺时针旋转
         /// </summary>
         public DelegateCommand ClockwiseCommand { get; set; }
-        public DelegateCommand CropCommand { get; set; }
+        public DelegateCommand CropModeCommand { get; set; }
         public DelegateCommand CancelCropCommand { get; set; }
 
         #endregion
@@ -217,6 +239,13 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         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(ImgAlignChecked);
+
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor);
             SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
             FontFamilyChangedCommand = new DelegateCommand<object>(FontFamilyChanged);
@@ -226,8 +255,104 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
             AntiClockwiseCommand = new DelegateCommand(AntiClockwise);
             ClockwiseCommand = new DelegateCommand(Clockwise);
-            CropCommand = new DelegateCommand(CropMode);
-            CancelCropCommand = new DelegateCommand(CancelCrop);
+            CropModeCommand = new DelegateCommand(CropMode);
+            CancelCropCommand = new DelegateCommand(CancelCropImg);
+        }
+
+        private void ImgAlignChecked()
+        {
+           
+        }
+
+        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;
+
+            //SaveFileDialog saveFileDialog = new SaveFileDialog();
+            //saveFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
+            //saveFileDialog.FileName = "编辑PDF导出图片";
+
+            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 AddText()
+        {
+            PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
         }
 
         private void TextAlignChecked(object obj)
@@ -258,24 +383,25 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         private void Clockwise()
         {
-            TextEditEvent.Rotate = TextEditEvent.Rotate + 90;
+            Angle = TextEditEvent.Rotate = TextEditEvent.Rotate + 90;
             TextEditEvent.UpdatePDFEditByEventArgs();
         }
 
         private void AntiClockwise()
         {
-            TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
+            Angle = TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
             TextEditEvent.UpdatePDFEditByEventArgs();
         }
 
-        private void CancelCrop()
-        {
-            IsCrop = false;
-        }
 
         private void CropMode()
         {
             IsCrop = true;
+            if(TextEditEvent != null)
+            {
+                TextEditEvent.ClipImage = true;
+                TextEditEvent.UpdatePDFEditByEventArgs();
+            }
         }
 
         private void SelectedColor(object obj)
@@ -407,7 +533,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
             if(PDFViewer != null)
             {
                 PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
-                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
+                PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler; 
 
                 PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
                 PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
@@ -417,56 +543,88 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
         {
-            ContextMenu popMenu = new ContextMenu();
-            var menu = new MenuItem();
-            menu.Header = "Cut";
-            popMenu.Items.Add(menu);
-            menu = new MenuItem();
-            menu.Header = "Copy";
-            popMenu.Items.Add(menu);
-            menu = new MenuItem();
-            menu.Header = "Paste";
-            popMenu.Items.Add(menu);
-            menu = new MenuItem();
-            menu.Header = "Delete";
-            popMenu.Items.Add(menu);
-            menu = new MenuItem();
-            menu.Header = "SelectAll";
-            popMenu.Items.Add(menu);
-
+           
+            ContextMenu popMenu = null;
 
             switch (e.CommandType)
             {
                 case CommandType.Context:
-                    if (popMenu.Items.Count == 5)
+                   
+                    if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
                     {
-                        MenuItem menuItem = popMenu.Items[0] as MenuItem;
-                        menuItem.CommandTarget = (UIElement)sender;
-                        menuItem.Command = ApplicationCommands.Cut;
-
-                        menuItem = popMenu.Items[1] as MenuItem;
-                        menuItem.CommandTarget = (UIElement)sender;
-                        menuItem.Command = ApplicationCommands.Copy;
-
-                        menuItem = popMenu.Items[2] as MenuItem;
-                        menuItem.CommandTarget = (UIElement)sender;
-                        menuItem.Command = ApplicationCommands.Paste;
-
-                        menuItem = popMenu.Items[3] as MenuItem;
-                        menuItem.CommandTarget = (UIElement)sender;
-                        menuItem.Command = ApplicationCommands.Delete;
-
-                        menuItem = popMenu.Items[4] as MenuItem;
-                        menuItem.CommandTarget = (UIElement)sender;
-                        menuItem.Command = ApplicationCommands.SelectAll;
-
-                        e.PopupMenu = popMenu;
-                        if (e.PopupMenu != null)
+                        popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
+                        if(popMenu != null && popMenu.Items.Count == 4)
+                        {
+                            //复制
+                            MenuItem menuItem = popMenu.Items[0] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Copy;
+                            //添加文本
+                            menuItem = popMenu.Items[1] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = AddTextCommand; 
+                            //添加图像
+                             menuItem = popMenu.Items[2] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = AddImgCommand;
+                            //删除
+                            menuItem = popMenu.Items[3] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Delete;
+
+                            e.PopupMenu = popMenu;
+                            if (e.PopupMenu != null)
+                            {
+                                e.Handle = true;
+                            }
+                        }
+                    }
+                    else if(e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
+                    {
+                        popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
+                        if (popMenu != null && popMenu.Items.Count == 8)
                         {
-                            e.Handle = true;
+                            //复制
+                            MenuItem menuItem = popMenu.Items[0] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Copy;
+                            //剪切
+                            menuItem = popMenu.Items[1] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Cut;
+                            //粘贴
+                            menuItem = popMenu.Items[2] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Paste;
+                            //删除
+                            menuItem = popMenu.Items[3] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Delete;
+                            //裁剪
+                            menuItem = popMenu.Items[4] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = CropModeCommand;
+                            //替换
+                            menuItem = popMenu.Items[5] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ReplaceImgCommand;
+                            //导出
+                            menuItem = popMenu.Items[6] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ExportImgCommand;
+                            //排列
+                            menuItem = popMenu.Items[7] as MenuItem;
+                            menuItem.CommandTarget = (UIElement)sender;
+                            menuItem.Command = ApplicationCommands.Cut;
+                            e.PopupMenu = popMenu;
+                            if (e.PopupMenu != null)
+                            {
+                                e.Handle = true;
+                            }
                         }
                     }
-                    break;
+
+            break;
 
                 default:
                     e.DoCommand();
@@ -481,7 +639,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
             {
                 IsTextEdit = (e[0].EditType == ComPDFKit.PDFPage.CPDFEditType.EditText);
                 TextEditEvent = e[0];
-
+                
                 if (IsTextEdit == false)
                 {
 

+ 1 - 1
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -56,9 +56,9 @@ namespace PDF_Office.ViewModels.Tools
                         {
                             PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditImage);
                             PDFViewer.AddPDFEditImage(openFileDialog.FileName);
-                            btn.IsChecked = false;
                         }
                     }
+                    btn.IsChecked = false;
 
                 }
             }

+ 119 - 27
PDF Office/Views/PropertyPanel/TextEditProperty.xaml

@@ -25,7 +25,7 @@
 
             <Convert:BoolToVisible x:Key="BoolToVisible"/>
             <Convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
-            
+            <Convert:InvertBoolConvert x:Key="InvertBoolConvert"/>
             <ContextMenu x:Key="BtnFlyoutMenu" FontSize="14"
                         >
                 <ContextMenu.ItemContainerStyle>
@@ -301,19 +301,6 @@
                 </Border>
             </Grid>
 
-
-            <!--<Grid Margin="0,18,0,0">
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="auto"/>
-                    <RowDefinition/>
-                </Grid.RowDefinitions>
-                <CompositeControl:SlidContent x:Name="layerThick" HorizontalAlignment="Right"/>
-                <CompositeControl:ColorContent Grid.Row="1" x:Name="cusColor"/>
-            </Grid>-->
-
-
-
-
             <TextBlock x:Name="AlignText" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="14" LineHeight="20" Margin="12,14,0,0" >Thickness</TextBlock>
             <Grid Width="150" HorizontalAlignment="Left" Margin="0,10,0,0">
                 <Grid.RowDefinitions>
@@ -328,14 +315,109 @@
                     <ColumnDefinition Width="*"/>
                 </Grid.ColumnDefinitions>
 
-                <Button Grid.Row="0" Grid.Column="0" Width="32" Height="32"/>
-                <Button Grid.Row="0" Grid.Column="1" Width="32" Height="32"/>
-                <Button Grid.Row="0" Grid.Column="2" Width="32" Height="32"/>
-                <Button Grid.Row="0" Grid.Column="3" Width="32" Height="32"/>
-                <Button Grid.Row="1" Grid.Column="0" Margin="0,10,0,0" Width="32" Height="32"/>
-                <Button Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" Width="32" Height="32"/>
-                <Button Grid.Row="1" Grid.Column="2" Margin="0,10,0,0" Width="32" Height="32"/>
-                <Button Grid.Row="1" Grid.Column="3" Margin="0,10,0,0" Width="32" Height="32"/>
+                <RadioButton x:Name="BtnImgAlign"  Grid.Row="0" Grid.Column="0" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <RadioButton.Content>
+                        <Path Margin="5,0,0,0" Data="M2.01367 15V1H3.51367V15H2.01367ZM5 4H11V7H5V4ZM14 9H5V12H14V9Z"
+                              Stroke="{Binding ElementName=BtnImgAlign,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign2"  Grid.Row="0" Grid.Column="1" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <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" 
+                              Stroke="{Binding ElementName=BtnImgAlign2,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign2,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign3"  Grid.Row="0" Grid.Column="2" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <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" 
+                              Stroke="{Binding ElementName=BtnImgAlign3,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign3,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign4"  Grid.Row="0" Grid.Column="3" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <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" 
+                              Stroke="{Binding ElementName=BtnImgAlign4,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign4,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign5"  Grid.Row="1" Grid.Column="0" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <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"
+                              Stroke="{Binding ElementName=BtnImgAlign5,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign5,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign6"  Grid.Row="1" Grid.Column="1" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <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" 
+                              Stroke="{Binding ElementName=BtnImgAlign6,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign6,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign7"  Grid.Row="1" Grid.Column="2" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <RadioButton.Content>
+                        <Path Margin="5,0,0,0" Data="M9 2H12V11H9V2ZM4 5H7V11H4V5ZM1 14H15V12.5H1V14Z" Stroke="{Binding ElementName=BtnImgAlign7,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign7,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+                <RadioButton x:Name="BtnImgAlign8"  Grid.Row="1" Grid.Column="3" Tag="Align" GroupName="TextAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"     
+                             Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                    <RadioButton.Content>
+                        <Path Margin="5,0,0,0" Data="M2 15V1H3.5V15H2ZM6.5 4H9.5V12H6.5V4ZM12.5 1V15H14V1H12.5Z" Stroke="{Binding ElementName=BtnImgAlign8,Path=Foreground}"/>
+                    </RadioButton.Content>
+                    <i:Interaction.Triggers>
+                        <i:EventTrigger EventName="Checked">
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign8,Path=Tag}"/>
+                        </i:EventTrigger>
+                    </i:Interaction.Triggers>
+                </RadioButton>
+
+
             </Grid>
 
         </StackPanel>
@@ -345,7 +427,11 @@
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
                 <Grid>
                     <Border Name="FreeTextBorder1" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="5" >
-                        <Image x:Name="ImgExmple" Source="{Binding CurrentImg}"/>
+                        <Image x:Name="ImgExmple" Source="{Binding CurrentImg}">
+                            <Image.RenderTransform>
+                                <RotateTransform x:Name="test"  Angle="{Binding Angle}"/>
+                            </Image.RenderTransform>
+                        </Image>
                     </Border>
                 </Grid>
             </Border>
@@ -359,7 +445,7 @@
                 <Grid x:Name="GridCrop">
                     <cus:CustomIconToggleBtn x:Name="BtnCrop" Tag="Crop" BorderBrush="#DFE1E5" BorderThickness="1" Style="{StaticResource ToggleBtnViewModeStyle}" 
                                              Foreground="Black" ContentStringFormat="156" 
-                                             Command="{Binding CropCommand}"
+                                             Command="{Binding CropModeCommand}"
                                              Visibility="{Binding IsCrop,Converter={StaticResource InvertBoolToVisibleConvert}}"
                                              
                                              >
@@ -372,19 +458,25 @@
                             <ColumnDefinition Width="*"/>
                         </Grid.ColumnDefinitions>
 
-                        <Button Content="Confirm" Background="#1770F4" Height="32"/>
+                        <Button Content="Confirm" Background="#1770F4" Height="32" Command="{Binding CropImgCommand}"/>
                         <Button Grid.Column="2" Content="Cancel" Background="White" BorderBrush="#DFE1E5" BorderThickness="1"
                                 Command="{Binding CancelCropCommand}"
                                 />
                     </Grid>
                 </Grid>
                 <cus:CustomIconToggleBtn x:Name="BtnReplace"  Margin="0,13,0,0" Tag="Replace" BorderBrush="#DFE1E5" BorderThickness="1" Style="{StaticResource ToggleBtnViewModeStyle}" 
-                                         Foreground="Black" ContentStringFormat="156">
+                                         Foreground="Black" ContentStringFormat="156"
+                                         IsEnabled="{Binding IsCrop,Converter={StaticResource InvertBoolConvert}}"
+                                         Command="{Binding ReplaceImgCommand}"
+                                         >
                     <TextBlock Text="Replace"/>
                 </cus:CustomIconToggleBtn>
 
                 <cus:CustomIconToggleBtn x:Name="BtnExtract" Margin="0,13,0,0" Tag="Extract" BorderBrush="#DFE1E5" BorderThickness="1" Style="{StaticResource ToggleBtnViewModeStyle}" 
-                                         Foreground="Black" ContentStringFormat="156">
+                                         Foreground="Black" ContentStringFormat="156"
+                                         IsEnabled="{Binding IsCrop,Converter={StaticResource InvertBoolConvert}}"
+                                         Command="{Binding ExportImgCommand}"
+                                         >
                     <TextBlock Text="Extract"/>
                 </cus:CustomIconToggleBtn>
             </StackPanel>

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

@@ -43,7 +43,7 @@ namespace PDF_Office.Views.PropertyPanel
             FontTitleBox.SelectedIndex = 0;
             FontFamilyBox.SelectedIndex = 0;
             FontStyleBox.SelectedIndex = 0;
-            FontSizeBox.SelectedIndex = 0;
+            FontSizeBox.SelectedIndex = 0; 
         }
 
         private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)