Jelajahi Sumber

EditTools Helper

liuaoran 2 tahun lalu
induk
melakukan
f331cb89fb

+ 76 - 0
PDF Office/Helper/EditToolsHelper.cs

@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+using System.Windows;
+using PDF_Office.Model.EditTools.Background;
+using PDF_Office.Model.EditTools.Watermark;
+
+namespace PDF_Office.Helper
+{
+    public static class EditToolsHelper
+    {
+        public static byte[] ConvertColor(string color)
+        {
+            byte[] rgb_array = new byte[] { 0, 0, 0 };
+            rgb_array[0] = (byte)(color[1] * 15 + color[2]);
+            rgb_array[1] = (byte)(color[3] * 15 + color[4]);
+            rgb_array[2] = (byte)(color[5] * 15 + color[6]);
+            return rgb_array;
+        }
+
+        public static void ChooseFile(string filePath,ref BackgroundInfo backgroundInfo)
+        {
+            using (FileStream fileData = File.OpenRead(filePath))
+            {
+                string fileExt = Path.GetExtension(filePath).ToLower();
+                BitmapFrame frame = null;
+                BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
+                if (decoder != null && decoder.Frames.Count > 0)
+                {
+                    frame = decoder.Frames[0];
+                }
+                if (frame != null)
+                {
+                    backgroundInfo.ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                    backgroundInfo.ImageWidth = frame.PixelWidth;
+                    backgroundInfo.ImageHeight = frame.PixelHeight;
+                    frame.CopyPixels(backgroundInfo.ImageArray, frame.PixelWidth * 4, 0);
+#if DEBUG
+                    Trace.WriteLine("width :" + backgroundInfo.ImageWidth);
+                    Trace.WriteLine("height :" + backgroundInfo.ImageHeight);
+#endif
+                }
+            }
+        }
+
+        public static void ChooseFile(string filePath, ref WatermarkInfo watermarkInfo)
+        {
+            using (FileStream fileData = File.OpenRead(filePath))
+            {
+                string fileExt = Path.GetExtension(filePath).ToLower();
+                BitmapFrame frame = null;
+                BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
+                if (decoder != null && decoder.Frames.Count > 0)
+                {
+                    frame = decoder.Frames[0];
+                }
+                if (frame != null)
+                {
+                    watermarkInfo.ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
+                    watermarkInfo.ImageWidth = frame.PixelWidth;
+                    watermarkInfo.ImageHeight = frame.PixelHeight;
+                    frame.CopyPixels(watermarkInfo.ImageArray, frame.PixelWidth * 4, 0);
+#if DEBUG
+                    Trace.WriteLine("width :" + watermarkInfo.ImageWidth);
+                    Trace.WriteLine("height :" + watermarkInfo.ImageHeight);
+#endif
+                }
+            }
+        }
+    }
+}

+ 4 - 2
PDF Office/Model/EditTools/Background/BackgroundCreateModel.cs

@@ -20,13 +20,15 @@ namespace PDF_Office.Model.EditTools.Background
     public class BackgroundInfo
     {
         public EnumBackgroundType EnumBackgroundType { get; set; }
-        public string Color { get; set; }
-        public string Rotation { get; set; }
+        public byte[] Color { get; set; }
+        public int Rotation { get; set; }
         public byte Opacity { get; set; }
         public bool IsRelativeRatio { get; set; }
         public int RelativeRatio { get; set; }
         public int VerticalMove { get; set; }
         public int HorizontalMove { get; set; }
+        public int ImageWidth { get; set; }
+        public int ImageHeight { get; set; }
         public C_Background_Vertalign BackgroundVertalign { get; set; }
         public C_Background_Horizalign BackgroundHorizalign { get; set; }
         public C_Background_Type BackgroundType { get; set; }

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -220,6 +220,7 @@
     <Compile Include="EventAggregators\PageEditNotifyEvent.cs" />
     <Compile Include="EventAggregators\PageEditRefreshEvent.cs" />
     <Compile Include="Helper\ConverterHelper.cs" />
+    <Compile Include="Helper\EditToolsHelper.cs" />
     <Compile Include="Helper\HomePageEditHelper.cs" />
     <Compile Include="Helper\ObservableDictionary.cs" />
     <Compile Include="Helper\PasswordBoxHelper.cs" />

+ 3 - 3
PDF Office/SDKLisence.xml

@@ -1,7 +1,7 @@
 <Lisences
-	devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34="
-    devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg=="
-	userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
+	  devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY="
+    devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh"
+   userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
 	userSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/"
 	ConverterDevKey="Eahwo7OZAYHJaCF7TJQYKSVqC62MzfBdllVXnC5BRR5BQFDKnQ1FJtCRVdug+VNg/ti+/DeA5Sq4IH2CBpQjAZst5705uk5Sz0ZwRu8Qdn9HFGwh2pG6dJEIrl7lOccoZS6+1IxgOTcTeHqYpym3NsmtbhBWE848Pvme3scpW28="
 	ConverterDevSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8EiR4IKrcJxus3VRNu+jx8P7CGq2BlSjPVXRHBI1lV8ukpCIUGmcK+P+Z0QbYdkAHAm6NPgs2c4tp1jOFPPbnUkTtX7riDb9xRCx1YNm3/+xd96PzrVCcmtTizZP+elkr8="

+ 80 - 20
PDF Office/ViewModels/EditTools/Background/BackgroundCreateColorContentViewModel.cs

@@ -17,6 +17,9 @@ namespace PDF_Office.ViewModels.EditTools.Background
 
     public class BackgroundCreateColorContentViewModel : BindableBase, INavigationAware
     {
+        private string RedColorBtn = "RedColorBtn";
+        private string GreenColorBtn = "GreenColorBtn";
+
         private List<string> _rotationList = new List<string>();
         public List<string> RotationList
         {
@@ -44,35 +47,61 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
-        private int _rotationNumber = 0;
-        public int RotationNumber
+        private int _rotationValue = 0;
+        public int RotationValue
+        {
+            get { return _rotationValue; }
+            set
+            {
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.Rotation = value;
+            }
+        }
+
+        private int _opacityValue = 100;
+        public int OpacityValue
+        {
+            get { return _opacityValue; }
+            set
+            {
+                SetProperty(ref _opacityValue, value);
+                BackgroundInfo.Opacity = (byte)((float)(value / 100) * 255);
+            }
+        }
+
+        private int _relativeRatioValue = 0;
+        public int RelativeRatioValue
         {
-            get { return _rotationNumber; }
+            get { return _relativeRatioValue; }
             set
             {
-                SetProperty(ref _rotationNumber, value);
+                SetProperty(ref _rotationValue, value);
+                BackgroundInfo.RelativeRatio = value;
             }
         }
 
-        private int _opacityNumber = 100;
-        public int OpacityNumber
+        private int _horizontalOffsetValue = 0;
+        public int HorizontalOffsetValue
         {
-            get { return _opacityNumber; }
-            set { SetProperty(ref _opacityNumber, value); }
+            get { return _horizontalOffsetValue; }
+            set
+            {
+                SetProperty(ref _horizontalOffsetValue, value);
+
+            }
         }
 
-        private int _relativeRatioNumber = 0;
-        public int RelativeRatioNumber
+        private int _verticalOffsetValue = 0;
+        public int VerticalOffsetValue
         {
-            get { return _relativeRatioNumber; }
-            set { SetProperty(ref _rotationNumber, value); }
+            get { return _verticalOffsetValue; }
+            set { SetProperty(ref _verticalOffsetValue, value); }
         }
 
         private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
         public ObservableDictionary<string, bool> GetLocationFromNumber
         {
-            get { return _getLocationFromNumber;}
-            set { _getLocationFromNumber = value; }
+            get { return _getLocationFromNumber; }
         }
 
         private BackgroundInfo _backgroundInfo = new BackgroundInfo();
@@ -82,11 +111,27 @@ namespace PDF_Office.ViewModels.EditTools.Background
             set { _backgroundInfo = value; }
         }
 
+        private string _stringColor = "#FFFF0000";
+        public string StringColor
+        {
+            get
+            {
+                return _stringColor;
+            }
+            set
+            {
+                SetProperty(ref _stringColor, value);
+                BackgroundInfo.Color = EditToolsHelper.ConvertColor(value); ;
+            }
+        }
 
         public DelegateCommand<object> ChangeLocationCommand { get; set; }
+        public DelegateCommand<object> ChangeColorCommand { get; set; }
 
-        public BackgroundCreateColorContentViewModel(){
+        public BackgroundCreateColorContentViewModel()
+        {
             ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            ChangeColorCommand = new DelegateCommand<object>(ChangeColor);
             InitComponent();
             BackgroundInfo.BackgroundHorizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER;
             BackgroundInfo.BackgroundVertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
@@ -123,24 +168,23 @@ namespace PDF_Office.ViewModels.EditTools.Background
             RelativeRatioList.Clear();
             for (int defaultRelativeRatioList = 10; defaultRelativeRatioList <= 100; defaultRelativeRatioList += 10)
             {
-                OpacityList.Add(defaultRelativeRatioList.ToString() + " %");
+                RelativeRatioList.Add(defaultRelativeRatioList.ToString() + " %");
             }
         }
 
         private void InitLocationButtonMatrix()
         {
             GetLocationFromNumber.Clear();
-            for(var temp = 0; temp <= 22; temp++)
+            for (var temp = 0; temp <= 22; temp++)
             {
                 GetLocationFromNumber.Add(temp.ToString(), true);
-                if(temp%10 == 2)
+                if (temp % 10 == 2)
                 {
                     temp += 7;
                 }
             }
-            int Num =(int)BackgroundInfo.BackgroundVertalign * 10 + (int)BackgroundInfo.BackgroundHorizalign;
+            int Num = (int)BackgroundInfo.BackgroundVertalign * 10 + (int)BackgroundInfo.BackgroundHorizalign;
             GetLocationFromNumber[Num.ToString()] = false;
-            
         }
 
         public void ChangeLocation(object e)
@@ -154,6 +198,22 @@ namespace PDF_Office.ViewModels.EditTools.Background
             }
         }
 
+        public void ChangeColor(object e)
+        {
+            var args = e as System.Windows.Controls.Button;
+            if (args != null)
+            {
+                if (args.Name == RedColorBtn)
+                {
+                    StringColor = "#FF0000";
+                }
+                else if (args.Name == GreenColorBtn)
+                {
+                    StringColor = "#008000";
+                }
+            }
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;

+ 138 - 2
PDF Office/ViewModels/EditTools/Background/BackgroundCreateFileContentViewModel.cs

@@ -1,4 +1,9 @@
-using Prism.Regions;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Helper;
+using PDF_Office.Model.EditTools.Background;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,8 +12,139 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.ViewModels.EditTools.Background
 {
-    internal class BackgroundCreateFileContentViewModel : INavigationAware
+    public class BackgroundCreateFileContentViewModel : BindableBase, INavigationAware
     {
+        public BackgroundInfo BackgroundInfo { get; set; } = new BackgroundInfo();
+
+        private List<string> _rotationList = new List<string>();
+        public List<string> RotationList
+        {
+            get { return _rotationList; }
+            set { SetProperty(ref _rotationList, value); }
+        }
+
+        private List<string> _opacityList = new List<string>();
+        public List<string> OpacityList
+        {
+            get { return _opacityList; }
+            set
+            {
+                SetProperty(ref _opacityList, value);
+            }
+        }
+
+        private List<string> _relativeRatioList = new List<string>();
+        public List<string> RelativeRatioList
+        {
+            get { return _relativeRatioList; }
+            set
+            {
+                SetProperty(ref _relativeRatioList, value);
+            }
+        }
+
+        private int _rotationNumber = 0;
+        public int RotationNumber
+        {
+            get { return _rotationNumber; }
+            set
+            {
+                SetProperty(ref _rotationNumber, value);
+            }
+        }
+
+        private int _opacityNumber = 100;
+        public int OpacityNumber
+        {
+            get { return _opacityNumber; }
+            set { SetProperty(ref _opacityNumber, value); }
+        }
+
+        private int _relativeRatioNumber = 0;
+        public int RelativeRatioNumber
+        {
+            get { return _relativeRatioNumber; }
+            set { SetProperty(ref _rotationNumber, value); }
+        }
+
+        private ObservableDictionary<string, bool> _getLocationFromNumber = new ObservableDictionary<string, bool>();
+        public ObservableDictionary<string, bool> GetLocationFromNumber
+        {
+            get { return _getLocationFromNumber; }
+        }
+
+        public BackgroundCreateFileContentViewModel()
+        {
+            ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
+            InitComponent();
+            BackgroundInfo.BackgroundHorizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER;
+            BackgroundInfo.BackgroundVertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER;
+            InitLocationButtonMatrix();
+        }
+
+        public void InitComponent()
+        {
+            InitOpacityList();
+            InitRotationList();
+            InitRelativeRatioList();
+        }
+
+        private void InitRotationList()
+        {
+            OpacityList.Clear();
+            for (int defaultRotation = -45; defaultRotation <= 45; defaultRotation += 15)
+            {
+                RotationList.Add(defaultRotation.ToString());
+            }
+        }
+
+        private void InitOpacityList()
+        {
+            OpacityList.Clear();
+            for (int defaultOpacity = 10; defaultOpacity <= 100; defaultOpacity += 10)
+            {
+                OpacityList.Add(defaultOpacity.ToString() + " %");
+            }
+        }
+
+        private void InitRelativeRatioList()
+        {
+            RelativeRatioList.Clear();
+            for (int defaultRelativeRatioList = 10; defaultRelativeRatioList <= 100; defaultRelativeRatioList += 10)
+            {
+                RelativeRatioList.Add(defaultRelativeRatioList.ToString() + " %");
+            }
+        }
+
+        private void InitLocationButtonMatrix()
+        {
+            GetLocationFromNumber.Clear();
+            for (var temp = 0; temp <= 22; temp++)
+            {
+                GetLocationFromNumber.Add(temp.ToString(), true);
+                if (temp % 10 == 2)
+                {
+                    temp += 7;
+                }
+            }
+            int Num = (int)BackgroundInfo.BackgroundVertalign * 10 + (int)BackgroundInfo.BackgroundHorizalign;
+            GetLocationFromNumber[Num.ToString()] = false;
+
+        }
+
+        public DelegateCommand<object> ChangeLocationCommand { get; set; }
+
+        public void ChangeLocation(object e)
+        {
+            string args = e as string;
+            if (args != null)
+            {
+                BackgroundInfo.BackgroundVertalign = (C_Background_Vertalign)(int.Parse(args) / 10);
+                BackgroundInfo.BackgroundHorizalign = (C_Background_Horizalign)(int.Parse(args) % 10);
+                InitLocationButtonMatrix();
+            }
+        }
+
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
             return true;

+ 11 - 7
PDF Office/Views/EditTools/Background/BackgroundCreateColorContent.xaml

@@ -30,7 +30,10 @@
                     <Button Name="RedColorBtn" Height="32" Width="32" Margin="0,0,8,0" Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=RedColorBtn}">
                         <Rectangle Height="22" Width="22" Fill="Red" RadiusX="20" RadiusY="20"></Rectangle>
                     </Button>
-                    <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
+                    <Button Name="GreenColorBtn" Height="32" Width="32" Margin="0,0,8,0"  Command="{Binding ChangeColorCommand}" CommandParameter="{Binding ElementName=GreenColorBtn}">
+                        <Rectangle Height="22" Width="22" Fill="#008000" RadiusX="20" RadiusY="20"></Rectangle>
+
+                    </Button>
                     <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
                     <Button Height="32" Width="32" Margin="0,0,8,0"></Button>
                     <Button Height="32" Width="66">
@@ -40,7 +43,7 @@
                                 <ColumnDefinition></ColumnDefinition>
                             </Grid.ColumnDefinitions>
                             <Grid Grid.Column="0" Height="22" Width="22">
-                                <Rectangle Fill="AliceBlue" RadiusX="20" RadiusY="20"></Rectangle>
+                                <Rectangle Fill="{Binding StringColor, Mode=TwoWay}" RadiusX="20" RadiusY="20"></Rectangle>
                             </Grid>
                         </Grid>
                     </Button>
@@ -52,17 +55,17 @@
                 <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
                 <StackPanel Orientation="Horizontal">
                     <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Value="{Binding RotationNumber, Mode=TwoWay}" Text="0" ></cus:CommonWritableComboBox>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Value="{Binding RotationValue, Mode=TwoWay}" Text="0" ></cus:CommonWritableComboBox>
                     
                     <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" TypeSouce="{Binding OpacityList, Mode=TwoWay}" Value="{Binding OpacityNumber, Mode=TwoWay}" Text="100 %"></cus:CommonWritableComboBox>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" TypeSouce="{Binding OpacityList, Mode=TwoWay}" Value="{Binding OpacityValue, Mode=TwoWay}" Text="100 %"></cus:CommonWritableComboBox>
                 </StackPanel>
                 <StackPanel Orientation="Horizontal"></StackPanel>
                 <Grid Margin="0,19,0,0">
 
                     <CheckBox Grid.Column="0" Style="{StaticResource CheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22" ></CheckBox>
                 </Grid>
-                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,0,0" TypeSouce="{Binding RelativeRatioList}" Value="{Binding RelativeRatioNumber, Mode=TwoWay}" Text="50 %"></cus:CommonWritableComboBox>
+                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,0,0" TypeSouce="{Binding RelativeRatioList,Mode=TwoWay}" Value="{Binding RelativeRatioValue, Mode=TwoWay}" Text="50 %"></cus:CommonWritableComboBox>
 
 
             </StackPanel>
@@ -96,11 +99,12 @@
                     <StackPanel Orientation="Vertical" Margin="70,0,0,0">
                         <StackPanel Orientation="Horizontal">
                             <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
-                            <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizontalOffsetValue, Mode=TwoWay}" ></cus:NumericUpDown>
+
                         </StackPanel>
                         <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                             <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
-                            <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding VerticalOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
                         </StackPanel>
                     </StackPanel>
 

+ 14 - 14
PDF Office/Views/EditTools/Background/BackgroundCreateFileContent.xaml

@@ -34,15 +34,15 @@
                 <TextBlock Text="外观" Margin="0,16,0,8" Foreground="#666666"></TextBlock>
                 <StackPanel Orientation="Horizontal">
                     <TextBlock Height="24" Width="24" Background= "Bisque" Margin="0,0,8,0"></TextBlock>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}"></cus:CommonWritableComboBox>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Text="0"></cus:CommonWritableComboBox>
                     <TextBlock Height="24" Width="24" Background="CadetBlue" Margin="0,0,8,0"></TextBlock>
-                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}"></cus:CommonWritableComboBox>
+                    <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,0,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}" Text="100 %"></cus:CommonWritableComboBox>
                 </StackPanel>
                 <StackPanel Orientation="Horizontal"></StackPanel>
                 <Grid Margin="0,19,0,0">
                     <CheckBox Grid.Column="0" Style="{StaticResource CheckBoxStyle}" Content="相对目标页面的比例" Margin="0,0,0,0" Height="22"></CheckBox>
                 </Grid>
-                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}"></cus:CommonWritableComboBox>
+                <cus:CommonWritableComboBox HorizontalAlignment="Left" Width="66" Height="32" Margin="0,11,28,0" TypeSouce="{Binding RotationList, Mode=TwoWay}"  Text="100 %"></cus:CommonWritableComboBox>
             </StackPanel>
         </Grid>
         <Grid  Grid.Row="2" Margin="0,16,0,0" VerticalAlignment="Bottom">
@@ -64,24 +64,24 @@
                             <RowDefinition></RowDefinition>
                             <RowDefinition></RowDefinition>
                         </Grid.RowDefinitions>
-                        <Button Grid.Column="0" Grid.Row="0"></Button>
-                        <Button Grid.Column="1" Grid.Row="0"></Button>
-                        <Button Grid.Column="2" Grid.Row="0"></Button>
-                        <Button Grid.Column="0" Grid.Row="1"></Button>
-                        <Button Grid.Column="1" Grid.Row="1" Background="Black"></Button>
-                        <Button Grid.Column="2" Grid.Row="1"></Button>
-                        <Button Grid.Column="0" Grid.Row="2"></Button>
-                        <Button Grid.Column="1" Grid.Row="2"></Button>
-                        <Button Grid.Column="2" Grid.Row="2"></Button>
+                        <Button Grid.Column="0" Grid.Row="0" Tag="0" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}" IsEnabled="{Binding GetLocationFromNumber[0],Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="0" Tag="1" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[1], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="0" Tag="2" Command="{Binding ChangeLocationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[2], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="1" Tag="10" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[10], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="1" Tag="11" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[11], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="1" Tag="12" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[12], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="0" Grid.Row="2" Tag="20" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[20], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="1" Grid.Row="2" Tag="21" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[21], Mode=TwoWay}"></Button>
+                        <Button Grid.Column="2" Grid.Row="2" Tag="22" Command="{Binding ChangeLocationCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Tag}"  IsEnabled="{Binding GetLocationFromNumber[22], Mode=TwoWay}"></Button>
                     </Grid>
                     <StackPanel Orientation="Vertical" Margin="70,0,0,0">
                         <StackPanel Orientation="Horizontal">
                             <TextBlock Text="X"  Width="9" Height="20" VerticalAlignment="Center"/>
-                            <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
                         </StackPanel>
                         <StackPanel Orientation="Horizontal" Margin="0,8,0,0">
                             <TextBlock Text="Y" Width="9" Height="20" VerticalAlignment="Center"/>
-                            <TextBox Width="66" Height="32" Margin="9,0,0,0"></TextBox>
+                            <cus:NumericUpDown Width="66" Height="32" Margin="9,0,0,0"  Text="{Binding HorizOffsetValue, Mode=TwoWay}"></cus:NumericUpDown>
                         </StackPanel>
                     </StackPanel>