瀏覽代碼

编辑PDF - 布局对齐

chenrongqian 2 年之前
父節點
當前提交
d044580a1f

+ 53 - 0
PDF Office/Styles/ContextMenuStyle.xaml

@@ -20,4 +20,57 @@
         </MenuItem>
 
     </ContextMenu>
+
+    <ContextMenu x:Key="SelectAnnotContextMenu" FontSize="14">
+        <ContextMenu.ItemContainerStyle>
+            <Style TargetType="MenuItem">
+                <Setter Property="Padding" Value="0,7,0,7"/>
+                <Setter Property="VerticalContentAlignment" Value="Center"/>
+            </Style>
+        </ContextMenu.ItemContainerStyle>
+        <MenuItem Name="CutAnnotMenuItem" Header="剪切" IsEnabled="True">
+            <MenuItem.Icon>
+                <Path Fill="Black"
+                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                    <Path.RenderTransform>
+                        <TranslateTransform X="3.0000" Y="0"/>
+                    </Path.RenderTransform>
+                </Path>
+            </MenuItem.Icon>
+        </MenuItem>
+
+        <MenuItem Name="CopyAnnotMenuItem" Header="复制" IsEnabled="True">
+            <MenuItem.Icon>
+                <Path Fill="Black"
+                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                    <Path.RenderTransform>
+                        <TranslateTransform X="3.0000" Y="0"/>
+                    </Path.RenderTransform>
+                </Path>
+            </MenuItem.Icon>
+        </MenuItem>
+
+        <MenuItem Name="DeleteAnnotMenuItem" Header="删除" IsEnabled="True">
+            <MenuItem.Icon>
+                <Path Fill="Black"
+                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                    <Path.RenderTransform>
+                        <TranslateTransform X="3.0000" Y="0"/>
+                    </Path.RenderTransform>
+                </Path>
+            </MenuItem.Icon>
+        </MenuItem>
+
+        <MenuItem Name="NoteAnnotMenuItem" Header="笔记" IsEnabled="True">
+            <MenuItem.Icon>
+                <Path Fill="Black"
+                                              Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z">
+                    <Path.RenderTransform>
+                        <TranslateTransform X="3.0000" Y="0"/>
+                    </Path.RenderTransform>
+                </Path>
+            </MenuItem.Icon>
+        </MenuItem>
+    </ContextMenu>
+    
 </ResourceDictionary>

+ 1 - 1
PDF Office/Styles/RadioButtonStyle.xaml

@@ -282,7 +282,7 @@
 
                         </Trigger>
                         <Trigger Property="IsEnabled" Value="false">
-
+                            <Setter Property="Opacity" TargetName="templateRoot" Value="0.5"/>
                         </Trigger>
                         <Trigger Property="IsPressed" Value="true">
 

+ 146 - 62
PDF Office/ViewModels/PropertyPanel/TextEditPropertyViewModel.cs

@@ -24,6 +24,28 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         #region 编辑PDF全局
 
+        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
         {
@@ -202,7 +224,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
         public DelegateCommand ReplaceImgCommand { get; set; }
         public DelegateCommand ExportImgCommand { get; set; }
         public DelegateCommand CropImgCommand { get; set; }
-        public DelegateCommand ImgAlignCheckedCommand { get; set; }
+        public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
         
 
         /// <summary>
@@ -218,6 +240,8 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         #endregion
 
+        public event EventHandler ClearCheckedAglin;
+
         #endregion
 
         private ComPDFKitViewer.PDFEditEvent TextEditEvent;
@@ -244,7 +268,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
             ReplaceImgCommand = new DelegateCommand(ReplaceImg);
             ExportImgCommand = new DelegateCommand(ExportImg);
             CropImgCommand = new DelegateCommand(CropImg);
-            ImgAlignCheckedCommand = new DelegateCommand(ImgAlignChecked);
+            ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
 
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor);
             SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
@@ -259,9 +283,39 @@ namespace PDF_Office.ViewModels.PropertyPanel
             CancelCropCommand = new DelegateCommand(CancelCropImg);
         }
 
-        private void ImgAlignChecked()
+        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 CancelCropImg()
@@ -527,7 +581,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
                 PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
                 PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
-
+               
             }
         }
 
@@ -543,8 +597,7 @@ namespace PDF_Office.ViewModels.PropertyPanel
 
         private void PDFViewer_PDFEditCommandHandler(object sender, PDFEditCommand e)
         {
-           
-            ContextMenu popMenu = null;
+
             if (e == null)
                 return;
 
@@ -554,66 +607,18 @@ namespace PDF_Office.ViewModels.PropertyPanel
                    
                     if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
                     {
-                        popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
-                        if(popMenu != null && popMenu.Items.Count == 3)
+                        e.PopupMenu = EmptyStateMenu(sender);
+                        if (e.PopupMenu != null)
                         {
-                            //复制
-                            MenuItem menuItem = popMenu.Items[0] as MenuItem;
-                            menuItem.CommandTarget = (UIElement)sender;
-                            menuItem.Command = ApplicationCommands.Paste;
-                            //添加文本
-                            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;
-                            e.PopupMenu = popMenu;
-                            if (e.PopupMenu != null)
-                            {
-                                e.Handle = true;
-                            }
+                            e.Handle = true;
                         }
                     }
                     else if(e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
                     {
-                        popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
-                        if (popMenu != null && popMenu.Items.Count == 7)
+                        e.PopupMenu = SelectPDFEdit(sender);
+                        if (e.PopupMenu != null)
                         {
-                            //复制
-                            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;
-                            e.PopupMenu = popMenu;
-                            if (e.PopupMenu != null)
-                            {
-                                e.Handle = true;
-                            }
+                            e.Handle = true;
                         }
                     }
                     else if(e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
@@ -630,16 +635,77 @@ namespace PDF_Office.ViewModels.PropertyPanel
             }
         }
 
+        private ContextMenu EmptyStateMenu(object sender)
+        {
+            var popMenu = App.Current.FindResource("NoneMenu") as ContextMenu;
+            if (popMenu != null && popMenu.Items.Count == 3)
+            {
+                //复制
+                MenuItem menuItem = popMenu.Items[0] as MenuItem;
+                menuItem.CommandTarget = (UIElement)sender;
+                menuItem.Command = ApplicationCommands.Paste;
+                //添加文本
+                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;
+            }
+            return popMenu;
+        }
+
+        private ContextMenu SelectPDFEdit(object sender)
+        {
+            var popMenu = App.Current.FindResource("SelectImgMenu") as ContextMenu;
+            if (popMenu != null && popMenu.Items.Count == 7)
+            {
+                //复制
+                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;
+                
+            }
+            return popMenu;
+        }
+
         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)
                     {
@@ -669,8 +735,26 @@ namespace PDF_Office.ViewModels.PropertyPanel
             }
             else
             {
+                IsLayoutAlign = false;
+                IsLayoutAvgAlign = false;
+                ClearCheckedAglin?.Invoke(null, null);
                 IsTextEdit = true;
             }
         }
+
+        private void ReLoadLayoutAlign(int count)
+        {
+            if (count >= 2)
+                IsLayoutAlign = true;
+            else
+                IsLayoutAlign = false;
+
+            if (count >= 3)
+                IsLayoutAvgAlign = true;
+            else
+                IsLayoutAvgAlign = false;
+
+        }
+
     }
 }

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

@@ -522,7 +522,7 @@ namespace PDF_Office.ViewModels
                 if (PDFViewer != null && PDFViewer.MouseMode == MouseModes.PDFEdit)
                 {
                     IsPropertyOpen = false;
-                    PDFViewer.SetMouseMode(MouseModes.None);
+                    PDFViewer.SetMouseMode(MouseModes.PanTool);
                 }
             }
         }

+ 40 - 32
PDF Office/Views/PropertyPanel/TextEditProperty.xaml

@@ -302,7 +302,7 @@
             </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 x:Name="LayoutAlignGrid" Width="150" HorizontalAlignment="Left" Margin="0,10,0,0">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="*"/>
                     <RowDefinition Height="*"/>
@@ -315,107 +315,115 @@
                     <ColumnDefinition Width="*"/>
                 </Grid.ColumnDefinitions>
 
-                <RadioButton x:Name="BtnImgAlign"  Grid.Row="0" Grid.Column="0" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignLeft"  Grid.Row="0" Grid.Column="0" Tag="AlignLeft" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAlign}"       
+                             Style="{DynamicResource GreyBgRadioBtnStyle}" >
                     <RadioButton.Content>
                         <Path Margin="5,0,0,0" Data="M2.01367 15V1H3.51367V15H2.01367ZM5 4H11V7H5V4ZM14 9H5V12H14V9Z"
-                              Fill="{Binding ElementName=BtnImgAlign,Path=Foreground}"/>
+                              Fill="{Binding ElementName=BtnImgLayoutAlignLeft,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignLeft,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign2"  Grid.Row="0" Grid.Column="1" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignHorizonCenter"  Grid.Row="0" Grid.Column="1" Tag="AlignHorizonCenter" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAlign}"           
+                             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" 
-                            Fill="{Binding ElementName=BtnImgAlign2,Path=Foreground}"/>
+                            Fill="{Binding ElementName=BtnImgLayoutAlignHorizonCenter,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign2,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignHorizonCenter,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign3"  Grid.Row="0" Grid.Column="2" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignRight"  Grid.Row="0" Grid.Column="2" Tag="AlignRight" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAlign}"            
+                             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" 
-                               Fill="{Binding ElementName=BtnImgAlign3,Path=Foreground}"/>
+                               Fill="{Binding ElementName=BtnImgLayoutAlignRight,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign3,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignRight,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign4"  Grid.Row="0" Grid.Column="3" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignDistributeHorizontal"  Grid.Row="0" Grid.Column="3" Tag="DistributeHorizontal" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAvgAlign}"         
+                             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" 
-                              Fill="{Binding ElementName=BtnImgAlign4,Path=Foreground}"/>
+                              Fill="{Binding ElementName=BtnImgLayoutAlignDistributeHorizontal,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign4,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignDistributeHorizontal,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign5"  Grid.Row="1" Grid.Column="0" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignTop"  Grid.Row="1" Grid.Column="0" Tag="AlignTop" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAlign}"           
+                             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"
-                              Fill="{Binding ElementName=BtnImgAlign5,Path=Foreground}"/>
+                              Fill="{Binding ElementName=BtnImgLayoutAlignTop,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign5,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignTop,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign6"  Grid.Row="1" Grid.Column="1" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignVerticalCenter"  Grid.Row="1" Grid.Column="1" Tag="AlignVerticalCenter" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAlign}"           
+                             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" 
-                              Fill="{Binding ElementName=BtnImgAlign6,Path=Foreground}"/>
+                              Fill="{Binding ElementName=BtnImgLayoutAlignVerticalCenter,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign6,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignVerticalCenter,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign7"  Grid.Row="1" Grid.Column="2" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
-                                      Style="{DynamicResource GreyBgRadioBtnStyle}" >
+                <RadioButton x:Name="BtnImgLayoutAlignBottom"  Grid.Row="1" Grid.Column="2" Tag="AlignBottom" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"
+                             IsEnabled="{Binding IsLayoutAlign}"         
+                             Style="{DynamicResource GreyBgRadioBtnStyle}" >
                     <RadioButton.Content>
                         <Path Margin="5,0,0,0" Data="M9 2H12V11H9V2ZM4 5H7V11H4V5ZM1 14H15V12.5H1V14Z" 
-                              Fill="{Binding ElementName=BtnImgAlign7,Path=Foreground}"/>
+                              Fill="{Binding ElementName=BtnImgLayoutAlignBottom,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign7,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutAlignBottom,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>
 
-                <RadioButton x:Name="BtnImgAlign8"  Grid.Row="1" Grid.Column="3" Tag="Align" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"     
+                <RadioButton x:Name="BtnImgLayoutDistributeVertical"  Grid.Row="1" Grid.Column="3" Tag="DistributeVertical" GroupName="ImgAlign" Width="32" Height="32" Foreground="#616469" Background="Transparent" VerticalContentAlignment="Center"     
+                             IsEnabled="{Binding IsLayoutAvgAlign}"
                              Style="{DynamicResource GreyBgRadioBtnStyle}" >
                     <RadioButton.Content>
                         <Path Margin="5,0,0,0" Data="M2 15V1H3.5V15H2ZM6.5 4H9.5V12H6.5V4ZM12.5 1V15H14V1H12.5Z"
                               
-                              Fill="{Binding ElementName=BtnImgAlign8,Path=Foreground}"/>
+                              Fill="{Binding ElementName=BtnImgLayoutDistributeVertical,Path=Foreground}"/>
                     </RadioButton.Content>
                     <i:Interaction.Triggers>
                         <i:EventTrigger EventName="Checked">
-                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgAlign8,Path=Tag}"/>
+                            <i:InvokeCommandAction Command="{Binding ImgAlignCheckedCommand}" CommandParameter="{Binding ElementName=BtnImgLayoutDistributeVertical,Path=Tag}"/>
                         </i:EventTrigger>
                     </i:Interaction.Triggers>
                 </RadioButton>

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

@@ -21,12 +21,19 @@ namespace PDF_Office.Views.PropertyPanel
     /// </summary>
     public partial class TextEditProperty : UserControl
     {
+        public TextEditPropertyViewModel ViewModel => DataContext as TextEditPropertyViewModel;
         public TextEditProperty()
         {
             InitializeComponent();
         }
 
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            InitEventHandler();
+            InitVariable();
+        }
+
+        private void InitEventHandler()
         {
             FontFamilyBox.SelectionChanged -= FontFamilyBox_SelectionChanged;
             FontStyleBox.SelectionChanged -= FontStyleBox_SelectionChanged;
@@ -40,10 +47,31 @@ namespace PDF_Office.Views.PropertyPanel
 
             FontColorBox.SelectedColorHandler += FontColorBox_SelectedColorHandler;
 
+            if(ViewModel != null)
+            {
+                ViewModel.ClearCheckedAglin -= ViewModel_ClearCheckedAglin;
+                ViewModel.ClearCheckedAglin += ViewModel_ClearCheckedAglin;
+            }
+        }
+
+        private void InitVariable()
+        {
             FontTitleBox.SelectedIndex = 0;
             FontFamilyBox.SelectedIndex = 0;
             FontStyleBox.SelectedIndex = 0;
-            FontSizeBox.SelectedIndex = 0; 
+            FontSizeBox.SelectedIndex = 0;
+        }
+
+        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;
+                }
+            }
         }
 
         private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)