Procházet zdrojové kódy

文字注释 - 同步文字预设样式

chenrongqian před 2 roky
rodič
revize
b5380585a8

+ 9 - 0
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreehandAnnotPropertyViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using PDF_Office.Model;
+using PDF_Office.Model.PropertyPanel.AnnotPanel;
 using PDF_Office.ViewModels.Tools;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -92,6 +93,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+      
 
         public AnnotAttribEvent AnnotEvent { get; set; }
         private AnnotHandlerEventArgs Annot;
@@ -113,6 +115,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             SelectedValueChangedCommand = new DelegateCommand<object>(SelectedValueChanged_Command);
             SelectPenThickChangedCommand = new DelegateCommand<object>(SelectPenThickChanged_Command);
             SetEraserThickCommand = new DelegateCommand<object>(SelectEraserThickChanged_Command);
+
+            InitVariable();
+        }
+
+        private void InitVariable()
+        {
+
         }
 
         private void SelectEraserThickChanged_Command(object obj)

+ 85 - 1
PDF Office/ViewModels/PropertyPanel/AnnotPanel/FreetextAnnotPropertyViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using PDF_Office.Model;
+using PDF_Office.Model.PropertyPanel.AnnotPanel;
 using PDF_Office.ViewModels.Tools;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -28,7 +29,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
-        private Brush selectColor = new SolidColorBrush(Colors.Transparent);
+        private Brush selectColor = new SolidColorBrush(Colors.Black);
         public Brush SelectColor
         {
             get { return selectColor; }
@@ -93,7 +94,18 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private List<FontStyleItem> fontStyleList = new List<FontStyleItem>();
+        public List<FontStyleItem> FontStyleList
+        {
+            get { return fontStyleList; }
+            set
+            {
+                SetProperty(ref fontStyleList, value);
+            }
+        }
 
+        public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
+        public DelegateCommand<object> SelectedFontStyleCommand { get; set; }
         public DelegateCommand<object> SelectedColorCommand { get; set; }
         public DelegateCommand<object> SelectedFillColorCommand { get; set; }
         public DelegateCommand<object> FontFamilyChangedCommand { get; set; }
@@ -105,14 +117,60 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
         public event EventHandler<object> LoadPropertyHandler;
         public FreetextAnnotPropertyViewModel()
         {
+            SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity);
+            SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
             SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
             SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColor_Command);
             FontFamilyChangedCommand = new DelegateCommand<object>(FontFamilyChanged_Command);
             FontStyleChangedCommand = new DelegateCommand<object>(FontStyleChanged_Command);
             FontSizeChangedCommand = new DelegateCommand<object>(FontSizeChanged_Command);
             TextAlignChecked = new DelegateCommand<object>(TextAlign_Checked);
+            InitVariable();
+        }
+
+        private void InitVariable()
+        {
+            InitFontStyles();
         }
 
+        private void InitFontStyles()
+        {
+            FontStyleItem custom = new FontStyleItem();
+            custom.mFontSize = 32;
+            custom.mFontStyleName = "自定义";
+
+            FontStyleItem h1 = new FontStyleItem();
+            h1.mFontSize = 24;
+            h1.mFontStyleName = "H1大标题";
+
+            FontStyleItem h2 = new FontStyleItem();
+            h2.mFontSize = 16;
+            h2.mFontStyleName = "h2(标准)";
+
+            FontStyleItem h3 = new FontStyleItem();
+            h3.mFontSize = 10;
+            h3.mFontStyleName = "H3小标题";
+
+            FontStyleItem b1 = new FontStyleItem();
+            b1.mFontSize = 8;
+            b1.mFontStyleName = "B1标题";
+
+            FontStyleItem b2 = new FontStyleItem();
+            b2.mFontSize = 6;
+            b2.mFontStyleName = "B2标题";
+
+            FontStyleItem b3 = new FontStyleItem();
+            b3.mFontSize = 4;
+            b3.mFontStyleName = "B3标题";
+
+            FontStyleList.Add(custom);
+            FontStyleList.Add(h1);
+            FontStyleList.Add(h2);
+            FontStyleList.Add(h3);
+            FontStyleList.Add(b1);
+            FontStyleList.Add(b2);
+            FontStyleList.Add(b3);
+        }
         private void TextAlign_Checked(object obj)
         {
             if (obj != null && (string)obj != null)
@@ -135,6 +193,31 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
             }
         }
 
+        private void SelectedFontStyle(object obj)
+        {
+            if (obj != null && (FontStyleItem)obj != null)
+            {
+                var item = (FontStyleItem)obj;
+
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.FontSize, item.mFontSize);
+
+                AnnotEvent?.UpdateAnnot();
+
+            }
+        }
+
+        private void SelectedFillOpacity(object obj)
+        {
+            if (obj != null)
+            {
+                FillOpacity = (double)obj;
+                SelectColor.Opacity = FillOpacity;
+
+                AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, FillOpacity);
+                AnnotEvent?.UpdateAnnot();
+            }
+        }
+
         private void FontSizeChanged_Command(object obj)
         {
             if (obj != null)
@@ -144,6 +227,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
                 if (content != null)
                 {
                     var intData = int.Parse(content);
+                    TextFontSize = intData;
                     AnnotEvent?.UpdateAttrib(AnnotAttrib.FontSize, intData);
                    
                     AnnotEvent?.UpdateAnnot();

+ 0 - 1
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Function.cs

@@ -357,7 +357,6 @@ namespace PDF_Office.ViewModels.Tools
             stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
             stickyAnnotArgs.StickyNote = string.Empty;
             stickyAnnotArgs.Transparency = 1;
-
             DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSticky);
             if (annotProperty != null)
             {

+ 23 - 31
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml

@@ -55,6 +55,11 @@
                 </MenuItem>
             </ContextMenu>
 
+            <DataTemplate x:Key="FontStyleData">
+                <Grid >
+                    <TextBlock Text="{Binding mFontStyleName}" Foreground="Black"/>
+                </Grid>
+            </DataTemplate>
         </ResourceDictionary>
     </UserControl.Resources>
     <Grid Background="#F3F3F3">
@@ -62,8 +67,16 @@
             <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="18" LineHeight="24" HorizontalAlignment="Left" Margin="10,8,0,0">Freetext</TextBlock>
             <Border Width="228" Height="100" BorderThickness="1" CornerRadius="2" BorderBrush="#DDDDDD" Background="White" Margin="0,8,0,0">
                 <Grid>
-                    <Border Name="FreeTextBorder" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="5">
-                        <TextBlock Name="SampleText" Foreground="{Binding SelectColor}" FontFamily="{Binding TextFontFamily}" FontWeight="{Binding TextFontWeights}" FontStyle="{Binding TextFontStyle}" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24">
+                    <Border Name="FreeTextBorder" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="5"
+                            Opacity="{Binding FillOpacity}"
+                            Background="{Binding FillColor}">
+                        <TextBlock Name="SampleText"
+                                   Foreground="{Binding SelectColor}" 
+                                   FontFamily="{Binding TextFontFamily}"
+                                   FontWeight="{Binding TextFontWeights}" 
+                                   FontStyle="{Binding TextFontStyle}"
+                                   FontSize="{Binding TextFontSize}" Opacity="{Binding FillOpacity}"
+                                   Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center">
                         </TextBlock>
                     </Border>
 
@@ -87,35 +100,14 @@
             <Border BorderBrush="#E2E3E6"  Height="32" Margin="12,0,4,0"  BorderThickness="0">
                 <StackPanel Orientation="Horizontal">
                     <ComboBox IsReadOnly="True" Name="FontTitleBox" Background="Transparent" Padding="10 10 0 0"  Width="148"   BorderThickness="1" BorderBrush="#FFE2E3E6"
-                                >
-                        <ComboBox.ItemContainerStyle>
-                            <Style TargetType="{x:Type ComboBoxItem}">
-                                <Setter Property="Padding" Value="10 0 0 0"/>
-                            </Style>
-                        </ComboBox.ItemContainerStyle>
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="H1 大标题"  Tag="Courier"  FontSize="14"/>
-                        </ComboBoxItem>
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="H2标准标题"  Tag="Helvetica" FontSize="14"/>
-                        </ComboBoxItem>
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="H3小标题"  Tag="Times Roman" FontSize="14"/>
-                        </ComboBoxItem>
-
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="H3小标题"  Tag="Times Roman" FontSize="14"/>
-                        </ComboBoxItem>
-
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="B1正文(标准)"  Tag="Times Roman" FontSize="14"/>
-                        </ComboBoxItem>
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="B2正文(小)"  Tag="Times Roman" FontSize="14"/>
-                        </ComboBoxItem>
-                        <ComboBoxItem Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
-                            <TextBlock Text="B3描述"  Tag="Times Roman" FontSize="14"/>
-                        </ComboBoxItem>
+                                ItemsSource="{Binding FontStyleList}"
+                              ItemTemplate="{StaticResource FontStyleData}"
+                              >
+                        <i:Interaction.Triggers>
+                            <i:EventTrigger EventName="SelectionChanged">
+                                <i:InvokeCommandAction Command="{Binding SelectedFontStyleCommand}" CommandParameter="{Binding ElementName=FontTitleBox,Path=SelectedItem}"/>
+                            </i:EventTrigger>
+                        </i:Interaction.Triggers>
                     </ComboBox>
                     <Button Width="32" Height="32" ContextMenu="{StaticResource BtnFlyoutMenu}"/>
                 </StackPanel>

+ 10 - 0
PDF Office/Views/PropertyPanel/AnnotPanel/FreetextAnnotProperty.xaml.cs

@@ -33,6 +33,7 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
             ThicknessBox.SelectionChanged += ThicknessBox_SelectionChanged; 
             this.Loaded += usercontrol_Loaded;
             cusColor.SelectedColorHandler += cusColor_SelectedColorHandler;
+            layerThick.SelectedValueChanged += layerThick_SelectedValue;
         }
 
         private void usercontrol_Loaded(object sender, RoutedEventArgs e)
@@ -53,6 +54,15 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
            
         }
 
+        private void layerThick_SelectedValue(object sender, double e)
+        {
+            var data = this.DataContext as FreetextAnnotPropertyViewModel;
+            if (data != null)
+            {
+                data.SelectedFillOpacityCommand?.Execute(e);
+            }
+        }
+
         private void FontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             var listItem = FontSizeBox.ItemContainerGenerator.ContainerFromItem(FontSizeBox.SelectedItem) as ComboBoxItem;