소스 검색

Form - ViewModel添加属性

chenrongqian 2 년 전
부모
커밋
dac3afa581

+ 115 - 2
PDF Office/ViewModels/Form/ButtonPropertyViewModel.cs

@@ -1,14 +1,127 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+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.Form
 {
-    public class ButtonPropertyViewModel : BindableBase
+    public class ButtonPropertyViewModel : FormBaseVM, INavigationAware
     {
+        #region 属性
 
+        #region 选项
+        //标签
+        private string _labelContent;
+        public string LabelContent
+        {
+            get { return _labelContent; }
+            set { SetProperty(ref _labelContent, value); }
+        }
+
+        private string _emailContent;
+        public string EmailContent
+        {
+            get { return _emailContent; }
+            set { SetProperty(ref _emailContent, value); }
+        }
+
+        #endregion
+
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetPushButtonArgs pushButtonArgs;
+        #endregion
+
+        #region 初始化
+        public ButtonPropertyViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            pushButtonArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetPushButtonArgs>("WidgetArgs", out pushButtonArgs);
+
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (pushButtonArgs == null)
+            {
+                WidgetPushButtonArgs pushButtonArgs = new WidgetPushButtonArgs();
+                pushButtonArgs.BgColor = Colors.White;
+                pushButtonArgs.FontFamily = "Courier New";
+                pushButtonArgs.FontSize = 12;
+                pushButtonArgs.FontColor = Colors.Black;
+                pushButtonArgs.LineColor = Colors.Black;
+                pushButtonArgs.LineWidth = 1;
+                var action = new Dictionary<ComPDFKit.PDFDocument.Action.C_ACTION_TYPE, string>();
+                action.Add(ComPDFKit.PDFDocument.Action.C_ACTION_TYPE.ACTION_TYPE_URI, "");
+                pushButtonArgs.ActionDict = action;
+                pushButtonArgs.FieldName = "PushButton";
+                pushButtonArgs.Text = "PushButton";
+
+                this.pushButtonArgs = pushButtonArgs;
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool);
+            PDFViewer.SetToolParam(pushButtonArgs);
+        }
+
+
+        #endregion
     }
 }

+ 106 - 2
PDF Office/ViewModels/Form/CheckBoxPropertyViewModel.cs

@@ -1,13 +1,117 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+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.Form
 {
-    public class CheckBoxPropertyViewModel : BindableBase
+
+    public class CheckBoxPropertyViewModel : FormBaseVM, INavigationAware
     {
+        #region 属性
+
+        #region 选项
+
+        //导出值
+        private string _exportValue;
+        public string ExportValue
+        {
+            get { return _exportValue; }
+            set { SetProperty(ref _exportValue, value); }
+        }
+
+        //复选框默认为选中
+        private bool _isDefaultChecked = false;
+        public bool IsDefaultChecked
+        {
+            get { return _isDefaultChecked; }
+            set { SetProperty(ref _isDefaultChecked, value); }
+        }
+
+
+        #endregion
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetCheckBoxArgs checkBoxArgs;
+        #endregion
+
+        #region 初始化
+        public CheckBoxPropertyViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            checkBoxArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetCheckBoxArgs>("WidgetArgs", out checkBoxArgs);
+
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (checkBoxArgs == null)
+            {
+                checkBoxArgs = new WidgetCheckBoxArgs();
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool);
+            PDFViewer.SetToolParam(checkBoxArgs);
+        }
+
+
+        #endregion
     }
 }

+ 100 - 2
PDF Office/ViewModels/Form/ComboxPropertyViewModel.cs

@@ -1,4 +1,8 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using Prism.Mvvm;
+using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,7 +11,101 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.ViewModels.Form
 {
-    public class ComboxPropertyViewModel: BindableBase
+    public class ComboxPropertyViewModel : FormBaseVM, INavigationAware
     {
+        #region 属性
+
+        #region 选项
+        //排序项目
+        private bool _isSortProject = false;
+        public bool IsSortProject
+        {
+            get { return _isSortProject; }
+            set { SetProperty(ref _isSortProject, value); }
+        }
+        //允许用户输入自定义文本
+        private bool _isAllowInOutText = false;
+        public bool IsAllowInOutText
+        {
+            get { return _isAllowInOutText; }
+            set { SetProperty(ref _isAllowInOutText, value); }
+        }
+        #endregion
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetComboBoxArgs comboBoxArgs;
+        #endregion
+
+        #region 初始化
+        public ComboxPropertyViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            comboBoxArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetComboBoxArgs>("WidgetArgs", out comboBoxArgs);
+
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (comboBoxArgs == null)
+            {
+                comboBoxArgs = new WidgetComboBoxArgs();
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool);
+            PDFViewer.SetToolParam(comboBoxArgs);
+        }
+
+
+        #endregion
     }
 }

+ 79 - 3
PDF Office/ViewModels/Form/FormsToolContentViewModel.cs

@@ -1,4 +1,6 @@
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
 using PDF_Office.Model;
 using Prism.Commands;
 using Prism.Mvvm;
@@ -67,13 +69,76 @@ namespace PDF_Office.ViewModels.Form
         /// </summary>
         /// <param name="type"></param>
         private void CheckedEvent(string type)
+        {
+            AddToPropertyPanel(type);
+
+        }
+
+        private void AddToPropertyPanel(string type, WidgetArgs widget = null)
         {
             if (btnToProperty.ContainsKey(type))
             {
-                regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type]);
+                NavigationParameters parameters = new NavigationParameters();
+                parameters.Add(ParameterNames.PDFViewer, PDFViewer);
+                parameters.Add("WidgetArgs", widget);
+                regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
+                ShowPropertyPanel(true);
             }
         }
 
+        #region 获取Form
+
+        private void GetTextField()
+        {
+            
+        }
+
+        private void GetButton()
+        {
+
+        }
+
+        private void GeCheckBox()
+        {
+
+        }
+
+        private void GetCombox()
+        {
+
+        }
+
+        private void GetListBox()
+        {
+
+        }
+
+        private void GetRadioButton()
+        {
+
+        }
+
+        private void GetSign()
+        {
+
+        }
+
+
+        #endregion
+
+        private void ShowPropertyPanel(bool show = true)
+        {
+            viewContentViewModel.IsPropertyOpen = show;
+        }
+
+        #region 表单内部触发的事件(比如选中表单行为等)
+        private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
+        {
+
+        }
+
+        #endregion
+
         #region Navegation
         public bool IsNavigationTarget(NavigationContext navigationContext)
         {
@@ -88,7 +153,18 @@ namespace PDF_Office.ViewModels.Form
         public void OnNavigatedTo(NavigationContext navigationContext)
         {
             navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel,out viewContentViewModel);
-            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.ViewContentViewModel, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+
+            BindingFormHandler();
+        }
+
+        private void BindingFormHandler()
+        {
+            if(PDFViewer != null)
+            {
+                PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
+                PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
+            }
         }
         #endregion
     }

+ 104 - 2
PDF Office/ViewModels/Form/ListBoxPropertyViewModel.cs

@@ -1,4 +1,8 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using Prism.Mvvm;
+using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,7 +11,105 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.ViewModels.Form
 {
-    public class ListBoxPropertyViewModel: BindableBase
+
+    public class ListBoxPropertyViewModel : FormBaseVM, INavigationAware
     {
+        #region 属性
+
+        #region 选项
+
+        //排序项目
+        private bool _isSortProject = false;
+        public bool IsSortProject
+        {
+            get { return _isSortProject; }
+            set { SetProperty(ref _isSortProject, value); }
+        }
+
+        //多重选择的
+        private bool _multipleSelection = false;
+        public bool MultipleSelection
+        {
+            get { return _multipleSelection; }
+            set { SetProperty(ref _multipleSelection, value); }
+        }
+
+        #endregion
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetListBoxArgs listBoxArgs;
+        #endregion
+
+        #region 初始化
+        public ListBoxPropertyViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            listBoxArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetListBoxArgs>("WidgetArgs", out listBoxArgs);
+
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (listBoxArgs == null)
+            {
+                listBoxArgs = new WidgetListBoxArgs();
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool);
+            PDFViewer.SetToolParam(listBoxArgs);
+        }
+
+
+        #endregion
     }
 }

+ 103 - 2
PDF Office/ViewModels/Form/RadioButtonPropertyViewModel.cs

@@ -1,13 +1,114 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+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.Form
 {
-    public class RadioButtonPropertyViewModel: BindableBase
+
+    public class RadioButtonPropertyViewModel : FormBaseVM, INavigationAware
     {
+        #region 属性
+
+        #region 选项
+        //单选按钮选项
+        private string _OptionContent;
+        public string OptionContent
+        {
+            get { return _OptionContent; }
+            set { SetProperty(ref _OptionContent, value); }
+        }
+
+        private bool _isDefaultChecked = false;
+        public bool IsDefaultChecked
+        {
+            get { return _isDefaultChecked; }
+            set { SetProperty(ref _isDefaultChecked, value); }
+        }
+        #endregion
+
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetRadioButtonArgs radioButtonArgs;
+        #endregion
+
+        #region 初始化
+        public RadioButtonPropertyViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            radioButtonArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetRadioButtonArgs>("WidgetArgs", out radioButtonArgs);
+
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (radioButtonArgs == null)
+            {
+                radioButtonArgs = new WidgetRadioButtonArgs();
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool);
+            PDFViewer.SetToolParam(radioButtonArgs);
+        }
+
+
+        #endregion
     }
 }

+ 83 - 2
PDF Office/ViewModels/Form/SignPropertyViewModel.cs

@@ -1,4 +1,8 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+using Prism.Mvvm;
+using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -7,7 +11,84 @@ using System.Threading.Tasks;
 
 namespace PDF_Office.ViewModels.Form
 {
-    public class SignPropertyViewModel : BindableBase
+    public class SignPropertyViewModel : BindableBase, INavigationAware
     {
+        #region 属性
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetSignArgs signArgs;
+        #endregion
+
+        #region 初始化
+        public SignPropertyViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            signArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetSignArgs>("WidgetArgs", out signArgs);
+
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (signArgs == null)
+            {
+                signArgs = new WidgetSignArgs();
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool);
+            PDFViewer.SetToolParam(signArgs);
+        }
+
+
+        #endregion
     }
 }

+ 115 - 3
PDF Office/ViewModels/Form/TextFieldPropertyViewModel.cs

@@ -1,17 +1,129 @@
-using Prism.Mvvm;
+using ComPDFKitViewer.AnnotEvent;
+using ComPDFKitViewer.PdfViewer;
+using PDF_Office.Model;
+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.Form
 {
-    public class TextFieldPropertyViewModel : BindableBase
+    public class TextFieldPropertyViewModel : FormBaseVM, INavigationAware
     {
+        #region 属性
+
+
+        #region 选项
+        //默认值
+        private string _defaultValue;
+        public string DefaultValue
+        {
+            get { return _defaultValue; }
+            set { SetProperty(ref _defaultValue, value); }
+        }
+
+        //多行
+        private bool _isMultiline = false;
+        public bool IsMultiline
+        {
+            get { return _isMultiline; }
+            set { SetProperty(ref _isMultiline, value); }
+        }
+
+        //滚动显示长文本
+        private bool _isScrollText = false;
+        public bool IsScrollText
+        {
+            get { return _isScrollText; }
+            set { SetProperty(ref _isScrollText, value); }
+        }
+
+        #endregion
+
+        #endregion
+
+        #region Command
+
+        #endregion
+
+        #region 变量
+        private CPDFViewer PDFViewer;
+        private WidgetTextBoxArgs textBoxArgs;
+        #endregion
+
+        #region 初始化
         public TextFieldPropertyViewModel()
         {
-            
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitVariable()
+        {
+
+        }
+
+        private void InitCommand()
+        {
+
+        }
+
+        #endregion
+
+
+        #region 一般处理
+
+        #endregion
+
+        #region 外观处理
+
+        #endregion
+
+        #region 选项处理
+
+        #endregion
+
+        #region Navegation
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
         }
+
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+            textBoxArgs = null;
+        }
+
+        public void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
+            navigationContext.Parameters.TryGetValue<WidgetTextBoxArgs>("WidgetArgs", out textBoxArgs);
+           
+            GetWidgeText();
+        }
+
+        private void GetWidgeText()
+        {
+            if (textBoxArgs == null)
+            {
+                WidgetTextBoxArgs textArgs = new WidgetTextBoxArgs();
+                textArgs.BgColor = Colors.Transparent;
+                textArgs.FontSize = 12;
+                textArgs.FontFamily = "Courier New";
+                textArgs.FontColor = Colors.Black;
+                textArgs.FieldName = "TextBox";
+                textBoxArgs = textArgs;
+            }
+
+            PDFViewer.SetMouseMode(MouseModes.FormEditTool); 
+            PDFViewer.SetToolParam(textBoxArgs);
+        }
+
+       
+        #endregion
     }
 }