ZhouJieSheng пре 2 година
родитељ
комит
c5ede1a015

+ 16 - 0
PDF Office/CustomControl/Form/FormFieldCombox.xaml

@@ -0,0 +1,16 @@
+<UserControl
+    x:Class="PDF_Office.CustomControl.Form.FormFieldCombox"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:local="clr-namespace:PDF_Office.CustomControl.Form"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    mc:Ignorable="d">
+    <ComboBox
+        Name="Combox"
+        VerticalContentAlignment="Center"
+        SelectedIndex="0"
+        SelectionChanged="Combox_SelectionChanged" />
+</UserControl>

+ 83 - 0
PDF Office/CustomControl/Form/FormFieldCombox.xaml.cs

@@ -0,0 +1,83 @@
+using PDF_Office.Model.From;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PDF_Office.CustomControl.Form
+{
+    /// <summary>
+    /// FormFieldCombox.xaml 的交互逻辑
+    /// 用于表单显示字段的下拉控件
+    /// </summary>
+    public partial class FormFieldCombox : UserControl
+    {
+        public FormFieldCombox()
+        {
+            InitializeComponent();
+            InitCombox();
+        }
+
+
+
+        public FormFieldType Type
+        {
+            get { return (FormFieldType)GetValue(TypeProperty); }
+            set { SetValue(TypeProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty TypeProperty =
+            DependencyProperty.Register("MyProperty", typeof(FormFieldType), typeof(FormFieldCombox), new PropertyMetadata(FormFieldType.visible));
+
+
+
+        public FormFieldType SetType
+        {
+            get { return (FormFieldType)GetValue(SetTypeProperty); }
+            set { SetValue(SetTypeProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for SetType.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty SetTypeProperty =
+            DependencyProperty.Register("SetType", typeof(FormFieldType), typeof(FormFieldCombox), new PropertyMetadata(FormFieldType.visible,(d,e)=> {
+                (d as FormFieldCombox).SetIndexBySetType((FormFieldType)e.NewValue);
+            }));
+
+
+        /// <summary>
+        /// 根据settype 设置combox索引
+        /// </summary>
+        private void SetIndexBySetType(FormFieldType type)
+        {
+            Combox.SelectedIndex=(int)type;
+        }
+
+
+
+        private void InitCombox()
+        {
+            List<string> list = new List<string>();
+            list.Add("可见");
+            list.Add("隐藏");
+            list.Add("可见但不可打印");
+            list.Add("隐藏但可打印");
+            Combox.ItemsSource = list;
+        }
+
+        private void Combox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            Type = (FormFieldType)Combox.SelectedIndex;
+        }
+    }
+}

+ 31 - 0
PDF Office/Model/From/FormFieldType.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PDF_Office.Model.From
+{
+    /// <summary>
+    /// 表单栏位字段
+    /// </summary>
+    public enum FormFieldType
+    {
+        /// <summary>
+        /// 可见
+        /// </summary>
+        visible,
+        /// <summary>
+        /// 隐藏
+        /// </summary>
+        hidden,
+        /// <summary>
+        /// 可见但不可打印
+        /// </summary>
+        visibleCantPrint,
+        /// <summary>
+        /// 隐藏但可打印
+        /// </summary>
+        hiddenCanPrint
+    }
+}