Bläddra i källkod

Merge branch 'dev' into practice2

# Conflicts:
#	PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs
#	PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs
#	PDF Office/ViewModels/ViewContentViewModel.cs
#	PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml
OYXH\oyxh 2 år sedan
förälder
incheckning
458e695421

+ 276 - 2
PDF Office/ViewModels/PropertyPanel/AnnotPanel/TextAnnotPropertyViewModel.cs

@@ -1,12 +1,286 @@
-using System;
+using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.Model;
+using PDF_Office.ViewModels.Tools;
+using PDFSettings;
+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.Media;
 
 namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
 {
-    internal class TextAnnotPropertyViewModel
+    public class TextAnnotPropertyViewModel:BindableBase, INavigationAware
     {
+
+        #region 属性
+
+        private double annotOpacity;
+        public double AnnotOpacity
+        {
+            get { return annotOpacity; }
+            set { SetProperty(ref annotOpacity, value); SampleTextBg.Opacity = annotOpacity; SetAnnotProperty();
+                Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                changeData[AnnotType] = annotOpacity;
+                PropertyPanel.DataChangedInvoke(this, changeData);
+            }
+        }
+
+
+        private AnnotArgsType annotType;
+        public AnnotArgsType AnnotType
+        {
+            get { return annotType; }
+            set
+            {
+                SetProperty(ref annotType, value);
+                SetAnnotType();
+            }
+        }
+
+        /// <summary>
+        /// 示例背景
+        /// </summary>
+        private Brush sampleTextBg = new SolidColorBrush(Colors.Transparent);
+        public Brush SampleTextBg
+        {
+            get { return sampleTextBg; }
+            set { SetProperty(ref sampleTextBg, value); SetAnnotProperty(); }
+        }
+
+        private string annotTypeTitle;
+        public string AnnotTypeTitle
+        {
+            get { return annotTypeTitle; }
+            set
+            {
+                SetProperty(ref annotTypeTitle, value);
+            }
+        }
+
+        private Color selectColor;
+        public Color SelectColor
+        {
+            get { return selectColor; }
+            set { SetProperty(ref selectColor, value); SetAnnotProperty(); }
+        }
+
+        #endregion
+
+
+        public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
+        public DelegateCommand<object> OpacityItemCommand { get; set; }
+
+        public TextAnnotPropertyViewModel()
+        {
+            SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
+            OpacityItemCommand = new DelegateCommand<object>(OpacityItemCommand_Click);
+        }
+
+        private void OpacityItemCommand_Click(object obj)
+        {
+            if(obj!= null)
+            {
+                int opacity = -1;
+                if(int.TryParse((string)obj, out opacity))
+                {
+                    AnnotOpacity = opacity/100D;
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotType] = AnnotOpacity;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                }
+            }
+        }
+
+        public void SelectedColorChanged_Click(object color)
+        {
+            if (color != null)
+            {
+                var colorValue = (Color)color;
+                if (colorValue != null)
+                {
+                    SampleTextBg = new SolidColorBrush(colorValue);
+                    switch(AnnotType)
+                    {
+                        case AnnotArgsType.AnnotHighlight:
+                            SampleTextBg.Opacity = AnnotOpacity;
+                            break;
+                        case AnnotArgsType.AnnotUnderline:
+                            SampleTextBg.Opacity = AnnotOpacity;
+                            break;
+                        case AnnotArgsType.AnnotStrikeout:
+                            SampleTextBg.Opacity = AnnotOpacity;
+                            break;
+                        case AnnotArgsType.AnnotSquiggly:
+                            SampleTextBg.Opacity = AnnotOpacity;
+                            break;
+                        case AnnotArgsType.AnnotSticky:
+                            SampleTextBg.Opacity = AnnotOpacity;
+                            break;
+                    }
+                   
+                    Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
+                    changeData[AnnotType] = color;
+                    PropertyPanel.DataChangedInvoke(this, changeData);
+                   // PropertyPanel.DataChanged?.Invoke(this, changeData);
+                }
+            }
+        }
+
+        private void SetAnnotType()
+        {
+            switch (AnnotType)
+            {
+                case AnnotArgsType.AnnotHighlight:
+                    AnnotTypeTitle = "高亮";
+                    break;
+                case AnnotArgsType.AnnotUnderline:
+                    AnnotTypeTitle = "下划线";
+                    break;
+                case AnnotArgsType.AnnotStrikeout:
+                    AnnotTypeTitle = "删除线";
+                    break;
+                case AnnotArgsType.AnnotSquiggly:
+                    AnnotTypeTitle = "波浪线";
+                    break;
+                case AnnotArgsType.AnnotSticky:
+                    AnnotTypeTitle = "??";
+                    break;
+            }
+        }
+
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+        }
+
+
+        private ComPDFKitViewer.PdfViewer.CPDFViewer PDFViewer;
+        private AnnotHandlerEventArgs Annot;
+        private AnnotPropertyPanel PropertyPanel;
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+
+            navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
+            navigationContext.Parameters.TryGetValue<ComPDFKitViewer.PdfViewer.CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            if(PropertyPanel != null)
+            {
+                Annot = PropertyPanel.annot;
+
+                GetAnnotProperty();
+            }
+            
+
+        }
+
+
+        private void GetAnnotProperty()
+        {
+            if (Annot != null)
+            {
+                SampleTextBg = new SolidColorBrush(Colors.Transparent);
+
+                switch (Annot.EventType)
+                {
+                    case AnnotArgsType.AnnotHighlight:
+                        if (Annot is TextHighlightAnnotArgs)
+                        {
+                            var Hightlight = Annot as TextHighlightAnnotArgs;
+                            AnnotOpacity = Hightlight.Transparency;
+                            AnnotType = Hightlight.EventType;
+                            SampleTextBg = new SolidColorBrush(Hightlight.Color);
+
+                        }
+                        break;
+
+                    case AnnotArgsType.AnnotUnderline:
+                        {
+                            var Underline = Annot as TextUnderlineAnnotArgs;
+                            AnnotOpacity = Underline.Transparency;
+                            AnnotType = Underline.EventType;
+                        }
+                        break;
+
+                    case AnnotArgsType.AnnotSquiggly:
+                        {
+                            var Underline = Annot as TextSquigglyAnnotArgs;
+                            AnnotOpacity = Underline.Transparency;
+                            AnnotType = Underline.EventType;
+                        }
+                        break;
+
+                    //case AnnotArgsType.AnnotStrikeout:
+                    //    {
+                    //        var Underline = Annot as TextStrikeoutAnnotArgs;
+                    //        AnnotOpacity = Underline.Transparency;
+                    //        AnnotType = Underline.EventType;
+                    //    }
+                    //    break;
+
+                }
+            }
+        }
+
+
+        private void SetAnnotProperty()
+        {
+            if (Annot != null)
+            {
+                switch (Annot.EventType)
+                {
+                    case AnnotArgsType.AnnotHighlight:
+                        if (Annot is TextHighlightAnnotArgs)
+                        {
+                            var Hightlight = Annot as TextHighlightAnnotArgs;
+
+                            if (Hightlight.Transparency != AnnotOpacity)
+                                Hightlight.Transparency = AnnotOpacity;
+
+                            var c = (SampleTextBg as SolidColorBrush).Color;
+                            if (Hightlight.Color.A != c.A || Hightlight.Color.B != c.B || Hightlight.Color.G != c.G || Hightlight.Color.R != c.R)
+                                Hightlight.Color = (SampleTextBg as SolidColorBrush).Color;
+
+                        }
+                        break;
+
+                    case AnnotArgsType.AnnotUnderline:
+                        {
+                            var Underline = Annot as TextUnderlineAnnotArgs;
+
+                            if (Underline.Transparency != AnnotOpacity)
+                                Underline.Transparency = AnnotOpacity;
+                        }
+                        break;
+
+                    case AnnotArgsType.AnnotSquiggly:
+                        {
+                            var Squiggly = Annot as TextSquigglyAnnotArgs;
+                            if (Squiggly.Transparency != AnnotOpacity)
+                                AnnotOpacity = Squiggly.Transparency;
+                        }
+                        break;
+
+                    case AnnotArgsType.AnnotStrikeout:
+                        {
+                            var Strikeout = Annot as TextStrikeoutAnnotArgs;
+                            if (Strikeout.Transparency != AnnotOpacity)
+                                Strikeout.Transparency = AnnotOpacity;
+                        }
+                        break;
+
+                }
+            }
+        }
+
+
+
     }
 }

+ 206 - 8
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.cs

@@ -24,17 +24,105 @@ using System.Windows.Media;
 
 namespace PDF_Office.ViewModels.Tools
 {
+    public class AnnotPropertyPanel
+    {
+        public AnnotHandlerEventArgs annot;
+        public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
+        public event EventHandler<object> DefaultStored;
+        public AnnotPropertyPanel()
+        {
+        }
+
+        public void  DataChangedInvoke(object sender,Dictionary<AnnotArgsType, object> keyValues)
+        {
+            DataChanged?.Invoke(sender,keyValues);
+        }
+
+
+    }
     public class AnnotToolContentViewModel : BindableBase, INavigationAware
     {
+
+
+        #region 注释工具
+
+        private Brush highLightColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
+        public Brush HighLightColor
+        {
+            get { return highLightColor; }
+            set { SetProperty(ref highLightColor, value); }
+        }
+
+
+        private double highLightOpacity = 1;
+        public double HighLightOpacity
+        {
+            get { return highLightOpacity; }
+            set { SetProperty(ref highLightOpacity, value); }
+        }
+
+
+        private Brush underLine = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
+        public Brush UnderLineColor
+        {
+            get { return underLine; }
+            set { SetProperty(ref underLine, value); }
+        }
+
+
+        private double underLineOpacity = 1;
+        public double UnderLineOpacity
+        {
+            get { return underLineOpacity; }
+            set { SetProperty(ref underLineOpacity, value); }
+        }
+
+
+
+        private Brush squigglyColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
+        public Brush SquigglyColor
+        {
+            get { return squigglyColor; }
+            set { SetProperty(ref squigglyColor, value); }
+        }
+
+
+        private double squigglyOpacity = 1;
+        public double SquigglyOpacity
+        {
+            get { return squigglyOpacity; }
+            set { SetProperty(ref squigglyOpacity, value); }
+        }
+
+
+
+        private Brush strikeoutColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
+        public Brush StrikeoutColor
+        {
+            get { return strikeoutColor; }
+            set { SetProperty(ref strikeoutColor, value); }
+        }
+
+
+        private double strikeoutOpacity = 1;
+        public double StrikeoutOpacity
+        {
+            get { return strikeoutOpacity; }
+            set { SetProperty(ref strikeoutOpacity, value); }
+        }
+
+        #endregion
+
         private CPDFViewer PDFViewer;
         private ViewContentViewModel viewContentViewModel;
-        private PropertyPanelContentViewModel propertyPanelContentViewModel;
         public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }
 
-        public AnnotToolContentViewModel()
+        public AnnotToolContentViewModel(IRegionManager regionManager)
         {
+            region = regionManager;
 
             MyToolsCommand = new DelegateCommand<CustomIconToggleBtn>(BtnMyTools_Click);
+            PropertyRegionName = Guid.NewGuid().ToString();
         }
 
         private Dictionary<string, bool> ToolExpandDict = new Dictionary<string, bool>();
@@ -68,16 +156,20 @@ namespace PDF_Office.ViewModels.Tools
                             annotAttribsList[AnnotAttrib.Color] = highlightArgs.Color;
                             annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
                             annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
-
-                            TextAnnotProperty textAnnotProperty = new TextAnnotProperty();
                             annotArgs = highlightArgs;
 
                             if (!ToolExpandDict.ContainsKey("HighLight"))
                             {
                                 ToolExpandDict["HighLight"] = true;
                             }
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = highlightArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("TextAnnotProperty", propertyPanel);
                         }
 
+                       
                         break;
 
                     case "UnderLine":
@@ -100,8 +192,13 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["UnderLine"] = true;
                             }
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = underlineArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("TextAnnotProperty", propertyPanel);
                         }
-                       
+                      
                         break;
 
                     case "Squiggly":
@@ -125,7 +222,13 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["Squiggly"] = true;
                             }
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = squigglyArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("TextAnnotProperty", propertyPanel);
                         }
+
                         break;
 
                     case "Strikeout":
@@ -148,7 +251,14 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["Strikeout"] = true;
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = strikeoutArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("TextAnnotProperty", propertyPanel);
                         }
+ 
                         break;
 
                     case "Freehand":
@@ -174,6 +284,12 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["Freehand"] = true;
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = freehandArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("FreehandAnnotProperty", propertyPanel);
                         }
                         break;
 
@@ -230,7 +346,14 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["Freetext"] = true;
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = freetextArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("FreetextAnnotProperty", propertyPanel);
                         }
+
                         break;
 
                     case "StickyNote":
@@ -257,7 +380,14 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["StickyNote"] = true;
                             }
-                        }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = stickyAnnotArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("FreetextAnnotProperty", propertyPanel);
+                        }  
+
                         break;
 
                     case "Rect":
@@ -302,7 +432,14 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["Rect"] = true;
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = squareArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("SharpsAnnotProperty", propertyPanel);
                         }
+
                         break;
 
                     case "Circle":
@@ -348,6 +485,12 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict["Circle"] = true;
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = circleAnnotArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("SharpsAnnotProperty", propertyPanel);
                         }
                         break;
 
@@ -414,7 +557,14 @@ namespace PDF_Office.ViewModels.Tools
                             {
                                 ToolExpandDict[annotBtn.Tag.ToString()] = true; 
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = lineArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("SharpsAnnotProperty", propertyPanel);
                         }
+
                         break;
 
                     case "Stamp":
@@ -425,8 +575,14 @@ namespace PDF_Office.ViewModels.Tools
                             stampAnnotArgs.Type = StampType.STANDARD_STAMP;
 
                             annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
-                           
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = stampAnnotArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("StampAnnotProperty", propertyPanel);
                         }
+
                         break;
 
                     case "Image":
@@ -443,13 +599,21 @@ namespace PDF_Office.ViewModels.Tools
                  
                                 annotArgs = stampArgs;
                             }
+
+                            AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
+                            propertyPanel.annot = stampArgs;
+                            propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
+                            propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
+                            viewContentViewModel.SelectedPrpoertyPanel("ImageAnnotProperty", propertyPanel);
                         }
+
                         break;
 
                     case "Signature":
                         break;
 
                     case "Link":
+                      //  viewContentViewModel.SelectedPrpoertyPanel("LinkAnnotProperty");
                         break;
 
                 }
@@ -467,11 +631,43 @@ namespace PDF_Office.ViewModels.Tools
             else
             {
                 PDFViewer.SetMouseMode(MouseModes.PanTool);
+                viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent",null);  
             }
 
           
         }
 
+        private void AnnotProperty_DefaultStored(object sender, object e)
+        {
+           
+        }
+
+        private void AnnotPropertyPanel_DataChanged(object sender, Dictionary<AnnotArgsType, object> e)
+        {
+            if (e != null)
+            {
+                foreach (AnnotArgsType argsType in e.Keys)
+                {
+                    switch (argsType)
+                    {
+                        case AnnotArgsType.AnnotHighlight:
+                            if (e[argsType] is Color)
+                            {
+                                HighLightColor = new SolidColorBrush((Color)e[argsType]);
+                            }
+                            if (e[argsType] is double)
+                            {
+                                HighLightOpacity = (double)e[argsType];
+                            }
+                            break;
+                    }
+                }
+            }
+        }
+
+        public IRegionManager region;
+        public string PropertyRegionName { get; set; }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;
@@ -486,8 +682,10 @@ namespace PDF_Office.ViewModels.Tools
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
             navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
 
-            navigationContext.Parameters.TryGetValue<PropertyPanelContentViewModel>(ParameterNames.PropertyPanelContentViewModel, out propertyPanelContentViewModel);
+          //  navigationContext.Parameters.TryGetValue<PropertyPanelContentViewModel>(ParameterNames.PropertyPanelContentViewModel, out propertyPanelContentViewModel);
+
 
+        
             if (PDFViewer != null)
             {
 

+ 16 - 0
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -16,6 +16,9 @@ using PDF_Office.Model;
 using System.Windows;
 using System.Windows.Controls;
 using System.IO;
+using PDFSettings;
+using ComPDFKitViewer.AnnotEvent;
+using PDF_Office.ViewModels.Tools;
 
 namespace PDF_Office.ViewModels
 {
@@ -436,6 +439,19 @@ namespace PDF_Office.ViewModels
             ));
         }
 
+        public void SelectedPrpoertyPanel(string Content, AnnotPropertyPanel annotPropertyPanel)
+        {
+            System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
+            {
+                NavigationParameters parameters = new NavigationParameters();
+                parameters.Add(ParameterNames.PDFViewer, PDFViewer);
+                parameters.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
+                region.RequestNavigate(PropertyRegionName, Content, parameters);
+            }
+         ));
+
+        }
+
         /// <summary>
         /// 将PDFViwer添加到Region
         /// </summary>

+ 44 - 7
PDF Office/Views/PropertyPanel/AnnotPanel/TextAnnotProperty.xaml

@@ -5,6 +5,11 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel"
              xmlns:cus="clr-namespace:PDF_Office.CustomControl"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:prism="http://prismlibrary.com/"             
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             xmlns:AnnotPanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
+             d:DataContext="{d:DesignInstance Type=AnnotPanel:TextAnnotPropertyViewModel}"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
@@ -16,10 +21,14 @@
     </UserControl.Resources>
     <Grid  VerticalAlignment="Stretch" Background="Wheat">
         <StackPanel Margin="12 0 12 0">
-            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Center" Margin="0,8,0,0"></TextBlock>
+            <TextBlock Name="AnnotTypeTitle" FontFamily="Segoe UI" FontWeight="Bold" FontSize="18" LineHeight="24" HorizontalAlignment="Center" Margin="0,8,0,0"
+                       Text="{Binding AnnotTypeTitle}"
+                       ></TextBlock>
             <Border Width="232" Height="80" BorderThickness="1" BorderBrush="#E2E3E6" Margin="0,8,0,0">
                 <Grid>
-                    <TextBlock Name="SampleText" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontFamily="Segoe UI" FontSize="18">
+                    <TextBlock Name="SampleText" Text="Sample" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" FontFamily="Segoe UI" FontSize="18"
+                             Background="{Binding SampleTextBg}" 
+                               >
                     </TextBlock>
                     <Path Name="UnderlinePath" HorizontalAlignment="Center" StrokeThickness="2" Margin="0,51,0,0" Visibility="Collapsed">
                         <Path.Data>
@@ -49,7 +58,8 @@
                 </Grid.ColumnDefinitions>
                 <TextBlock x:Name="colorText"  LineHeight="20" TextAlignment="Left" VerticalAlignment="Center">Color</TextBlock>
                 <cus:ColorDropBox x:Name="ColorDropPicker" Grid.Column="1" BorderThickness="1"  HorizontalAlignment="Right"
-                                BorderBrush="#E2E3E6" Width="80" Height="32"  ></cus:ColorDropBox>
+                                BorderBrush="#E2E3E6" Width="80" Height="32" SelectedColorChanged="ColorDropPicker_SelectedColorChanged">
+                </cus:ColorDropBox>
             </Grid>
 
             <TextBlock x:Name="opacityText"  TextAlignment="Left" LineHeight="20" Margin="0,14,0,0" >Opacity</TextBlock>
@@ -60,6 +70,7 @@
                     <ColumnDefinition Width="auto"></ColumnDefinition>
                 </Grid.ColumnDefinitions>
                 <Slider Name="OpacitySlider" HorizontalAlignment="Left" VerticalAlignment="Center" Minimum="0" Maximum="1" IsSelectionRangeEnabled="True" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True"
+                     Value="{Binding AnnotOpacity}"
                     Style="{StaticResource RoundThumbSlider}" Width="148" TickFrequency="0.01" ValueChanged="OpacitySlider_ValueChanged" Thumb.DragStarted="OpacitySlider_DragStarted" 
                     Thumb.DragCompleted="OpacitySlider_DragCompleted">
                     <Slider.Resources>
@@ -71,11 +82,37 @@
                 <Border Grid.Column="1" HorizontalAlignment="Right" Background="Transparent" BorderBrush="#E2E3E6"  Width="80" Height="32"  BorderThickness="0">
                     <Grid>
                         <ComboBox Name="OpacityDropBox" BorderThickness="1" Background="Transparent" BorderBrush="#FFE2E3E6">
-                            <ComboBoxItem Content="25%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}"/>
-                            <ComboBoxItem Content="50%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}" />
-                            <ComboBoxItem Content="75%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}" />
-                            <ComboBoxItem Content="100%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}" />
+                            <ComboBoxItem Content="25%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="PreviewMouseDown">
+                                        <i:InvokeCommandAction Command="{Binding OpacityItemCommand}" CommandParameter="25"/>
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </ComboBoxItem>
+
+                            <ComboBoxItem Content="50%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}" >
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="PreviewMouseDown">
+                                        <i:InvokeCommandAction Command="{Binding OpacityItemCommand}" CommandParameter="50"/>
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </ComboBoxItem>
+                            <ComboBoxItem Content="75%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}">
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="PreviewMouseDown">
+                                        <i:InvokeCommandAction Command="{Binding OpacityItemCommand}" CommandParameter="75"/>
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </ComboBoxItem>
+                            <ComboBoxItem Content="100%" Height="32" VerticalContentAlignment="Center" Template="{StaticResource comboxitem}" >
+                                <i:Interaction.Triggers>
+                                    <i:EventTrigger EventName="PreviewMouseDown">
+                                        <i:InvokeCommandAction Command="{Binding OpacityItemCommand}" CommandParameter="100"/>
+                                    </i:EventTrigger>
+                                </i:Interaction.Triggers>
+                            </ComboBoxItem>
                         </ComboBox>
+                        
                         <TextBox FontFamily="Segoe UI" FontSize="14" Background="White" Height="20" Margin="2,0,23,0" IsReadOnly="True"
                              BorderThickness="0" VerticalAlignment="Center" TextAlignment="Center">
                             <TextBox.Style>

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

@@ -1,6 +1,7 @@
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using PDF_Office.Properties;
+using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
 using PDFSettings;
 using System;
 using System.Collections.Generic;
@@ -43,6 +44,15 @@ namespace PDF_Office.Views.PropertyPanel.AnnotPanel
         {
 
         }
+
+        private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
+        {
+            var data = this.DataContext as TextAnnotPropertyViewModel;
+            if(data != null)
+            {
+                data.SelectedColorChangedCommand?.Execute(e.Value);
+            }
+        }
     }
     //public partial class TextAnnotProperty : UserControl
     //{

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 5 - 4
PDF Office/Views/Tools/AnnotToolContent.xaml


+ 4 - 1
PDF Office/Views/ViewContent.xaml

@@ -198,7 +198,10 @@
                 HorizontalAlignment="Stretch"
                 prism:RegionManager.RegionName="{Binding ViwerRegionName}" />
             <ToggleButton Name="TbtnProperty" Grid.Column="3" />
-            <ContentControl Grid.Column="4" prism:RegionManager.RegionName="{Binding PropertyRegionName}" />
+            <ScrollViewer Grid.Column="4">
+                <ContentControl  prism:RegionManager.RegionName="{Binding PropertyRegionName}" />
+            </ScrollViewer>
+            
         </Grid>
 
         <local:BottomToolContent Grid.Row="3" />