فهرست منبع

编辑-透明度下拉框设置bug和图片右键菜单替换刷新属性面板bug

lvle 1 سال پیش
والد
کامیت
60f9784f8c

+ 30 - 11
PDF Office/CustomControl/CompositeControl/SlidComboControl.xaml.cs

@@ -36,8 +36,19 @@ namespace PDF_Master.CustomControl.CompositeControl
       
         public static readonly DependencyProperty TitleProperty =
             DependencyProperty.Register("Title", typeof(string), typeof(SlidComboControl), new PropertyMetadata("Line Width"));
+        //public int IndexSelected
+        //{
+        //    get { return (int)GetValue(IndexSelectedProperty); }
+        //    set
+        //    {
+        //        SetValue(IndexSelectedProperty, value);
+        //    }
+        //}
 
 
+        //public static readonly DependencyProperty IndexSelectedProperty =
+        //    DependencyProperty.Register("IndexSelected", typeof(int), typeof(SlidComboControl), new PropertyMetadata(0));
+
         public string Unit
         { 
             get { return (string)GetValue(UnitProperty); }
@@ -46,7 +57,7 @@ namespace PDF_Master.CustomControl.CompositeControl
 
 
         public static readonly DependencyProperty UnitProperty =
-            DependencyProperty.Register("Unit", typeof(string), typeof(SlidComboControl), new PropertyMetadata("pt"));
+            DependencyProperty.Register("Unit", typeof(string), typeof(SlidComboControl), new PropertyMetadata("pt"));
 
         public SlidComboControl()
         {
@@ -143,15 +154,23 @@ namespace PDF_Master.CustomControl.CompositeControl
                     ValueChanged?.Invoke((double)sender, null);
                 }
             }
+        }
+        //事件重复SelectedValuePropertyChanged 2023/4/4
+        //private void ThicknessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
+        //{
+        //    combox.SelectedItems = new ComboDataItem(Value);
+        //  //  ValueChanged?.Invoke(Value, null);
+        //}
+
+        //暂无作用,后续准备
+        public int SelectedIndex
+        {
+            get { return (int)GetValue(SelectedIndexProperty); }
+            set { SetValue(SelectedIndexProperty, value);
+            }
         }
-        //事件重复SelectedValuePropertyChanged 2023/4/4
-        //private void ThicknessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
-        //{
-        //    combox.SelectedItems = new ComboDataItem(Value);
-        //  //  ValueChanged?.Invoke(Value, null);
-        //}
-
-
+        public static readonly DependencyProperty SelectedIndexProperty =
+           DependencyProperty.Register("SelectedIndex", typeof(int), typeof(SlidComboControl), new PropertyMetadata(0));
         public double Value
         {
             get { return (double)GetValue(ValueProperty); }
@@ -165,9 +184,9 @@ namespace PDF_Master.CustomControl.CompositeControl
             var value = (double)e.NewValue;
             if (control != null)
             {
+            
                 Trace.WriteLine("SelectedValuePropertyChanged" + value);
-                control.combox.SelectedItems = new ComboDataItem(value, control.Unit);
-                
+                control.combox.SelectedItems = new ComboDataItem(value, control.Unit);
             }
         }
 

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

@@ -73,6 +73,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             get { return _opacity; }
             set { SetProperty(ref _opacity, value); }
         }
+        private int _OpacitySelectedIndex ;
+        public int OpacitySelectedIndex
+        {
+            get { return _OpacitySelectedIndex; }
+            set { SetProperty(ref _OpacitySelectedIndex, value); }
+        }
         private double _transpent;
         public double Transpent
         {
@@ -80,7 +86,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             set
             {
                 SetProperty(ref _transpent, value);
-                
+                if (Transpent == 100|| Transpent == 75||Transpent == 50|| (Transpent == 25))
+                {
+                    TextEditEvent.Transparency = (int)(_transpent * 2.55);
+                    TextEditEvent.UpdatePDFEditByEventArgs();
+                    OpacityUI = _transpent / 100.0;
+                }
             }
         }
         //是否为图片裁剪状态
@@ -101,6 +112,14 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             {
                 IsCrop = _viewModel1.flg;
             }
+            if(e.PropertyName== "ReplaceImgflg")
+            {
+                if(_viewModel1.ReplaceImgflg==true)
+                {
+                    ReplaceImg();
+                    _viewModel1.ReplaceImgflg = false;
+                }
+            }
         }
 
         //选中的图像
@@ -248,7 +267,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
             {
                 TextEditEvent.ClipImage = false;
                 TextEditEvent.CancelClip();
-  
                 TextEditEvent.UpdatePDFEditByEventArgs();
                 IsCrop = false;
             }

+ 17 - 19
PDF Office/ViewModels/Tools/TextEditToolContentViewModel.cs

@@ -52,6 +52,17 @@ namespace PDF_Master.ViewModels.Tools
             get { return _flg; }
             set { SetProperty(ref _flg, value); }
         }
+
+        /// <summary>
+        /// 替换图片指令
+        /// </summary>
+        private bool _ReplaceImgflg = false;
+        public bool ReplaceImgflg
+        {
+            get { return _ReplaceImgflg; }
+            set { SetProperty(ref _ReplaceImgflg, value); }
+        }
+       
         #endregion
 
         #region Command
@@ -450,27 +461,10 @@ namespace PDF_Master.ViewModels.Tools
             //替换图片
             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)
-                {
-                    TextEditEvent.ReplaceImagePath = openFileDialog.FileName;
-                    TextEditEvent.UpdatePDFEditByEventArgs();
-                    ReplaceimgTask();
-                }
-            }
+            ReplaceImgflg = true;
         }
 
-        //此处只有异步 ReplaceimgTask()才有作用
-        async Task ReplaceimgTask()
-        {
-            await Task.Delay(100);
-            GetImagePreView();
-
-        }
+      
         //选中的图像
         private System.Windows.Media.Imaging.BitmapSource _currentImg;
         public System.Windows.Media.Imaging.BitmapSource CurrentImg { get { return _currentImg; } set { SetProperty(ref _currentImg, value); } }
@@ -547,6 +541,10 @@ namespace PDF_Master.ViewModels.Tools
                 {
                     IsImgEdit = false;
                     IsTextEdit = false;
+                    PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.None);
+                    PDFViewer.SetPDFEditType(ComPDFKit.PDFPage.CPDFEditType.None);
+                    PDFViewer.ReloadDocument();
+                    AddToPropertyPanel("PropertyPanelContent", null);
                     ShowPropertyPanel(false);
                 }
             }

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

@@ -108,6 +108,7 @@
                 IsEnabled="{Binding IsCrop, Converter={StaticResource InvertBoolConvert}}"
                 Title="{Binding Opacity,Mode=TwoWay}"
                 Unit="%"
+                SelectedIndex="{Binding OpacitySelectedIndex,Mode=TwoWay}"
                 Value="{Binding Transpent, Mode=TwoWay}" >
                 <i:Interaction.Triggers>
                     <i:EventTrigger EventName="PreviewMouseLeftButtonUp">

+ 75 - 2
PDFSettings/PDFEditList.cs

@@ -10,11 +10,84 @@ namespace PDFSettings
 {
     public class PDFEditList
     {
-        public string mTag { get; set; }
+        public string mTag { get; set; }= "Custom";
         public string mTagContent { get; set; }
-        public int mFontSize { get; set; }
+        public static int mFontSize1 { get; set; } = 1;
         public FontFamily mFontFamily { get; set; }
         public FontStyle mFontStyle { get; set; }
         public FontWeight mFontWeight { get; set; }
+
+
+
+        public struct PresetFontItem
+        {
+            public string mTag;
+            public string mTagContent;
+            public int mFontSize;
+            public int mFontSize1;
+            public FontFamily mFontFamily;
+            public FontStyle mFontStyle;
+            public FontWeight mFontWeight;
+        }
+       public List<PresetFontItem> fontStyleList = new List<PresetFontItem>() {
+    new PresetFontItem() {
+        mTag = "Custom",
+        mTagContent = "PresetTextStyle_Customize",
+        mFontSize = 16,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Normal
+    },
+    new PresetFontItem() {
+        mTag = "H1",
+        mTagContent = "PresetTextStyle_H1Title",
+        mFontSize = mFontSize1,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Bold
+    },
+    new PresetFontItem() {
+        mTag = "H2",
+        mTagContent = "PresetTextStyle_H2Title",
+        mFontSize = 24,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Bold
+    },
+    new PresetFontItem() {
+        mTag = "H3",
+        mTagContent = "PresetTextStyle_H3Title",
+        mFontSize = 18,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Bold
+    },
+    new PresetFontItem() {
+        mTag = "B1",
+        mTagContent = "PresetTextStyle_B1NormalTextStandard",
+        mFontSize = 14,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Regular
+    },
+    new PresetFontItem() {
+        mTag = "B2",
+        mTagContent = "PresetTextStyle_B2NormalTextSmall",
+        mFontSize = 12,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Regular
+    },
+    new PresetFontItem() {
+        mTag = "B3",
+        mTagContent = "PresetTextStyle_B3Description",
+        mFontSize = 11,
+        mFontFamily = new FontFamily("Helvetica"),
+        mFontStyle = FontStyles.Normal,
+        mFontWeight = FontWeights.Regular
+    }
+};
+
     }
+   
 }