| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768 | using PaintDotNet.Annotation;using PaintDotNet.Annotation.Label;using PaintDotNet.Base.CommTool;using PaintDotNet.Base.SettingModel;using System;using System.Collections;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace PaintDotNet.ImageLabel{    internal class LabelWaterMarkStyleDialog : PdnBaseForm    {        private Button button2;        private Button button1;        private GroupBox groupBox2;        private GroupBox groupBox3;        private Label label4;        private Label label3;        private Label label2;        private Label label1;        private CustomControl.UserTextBox userTextBox1;        private ComboBox comboBox1;        private Label label5;        private CustomControl.UserTextBox userTextBox2;        private RadioButton radioButton1;        private RadioButton radioButton2;        private TrackBar trackBar1;        private CustomControl.UserTextBox userTextBox3;        private Label label8;        private Label label7;        private Label label6;        private RadioButton radioButton6;        private RadioButton radioButton5;        private RadioButton radioButton4;        private RadioButton radioButton3;        private ComboBox comboBox2;        private Panel panel1;        private Label label9;        private CheckBox checkBox2;        private CheckBox checkBox1;        private Button button3;        private GroupBox groupBox1;        private AppWorkspace appWorkspace;        private DrawObject drawObject;        private ParentStyleModel parentStyleModel;        private WatermarkModel waterMarkModel;        private int nowWaterMarkType = 0;        /// <summary>        /// 水印位置下拉选        /// </summary>        string[] position = new string[] { PdnResources.GetString("Menu.Set.Watermarksettings.Topleft.text"),            PdnResources.GetString("Menu.Set.Watermarksettings.Topmiddle.text"), PdnResources.GetString("Menu.Set.Watermarksettings.Topright.text"), PdnResources.GetString("Menu.Set.Watermarksettings.Middleleft.text"), PdnResources.GetString("Menu.nthemiddle.Text"), PdnResources.GetString("Menu.Set.Watermarksettings.Middleright.text"), PdnResources.GetString("Menu.Set.Watermarksettings.Bottomleft.text"), PdnResources.GetString("Menu.Set.Watermarksettings.Bottommiddle.text"), PdnResources.GetString("Menu.Set.Watermarksettings.Bottomright.text") };        /// <summary>        /// 水印字号下拉选        /// </summary>        int[] fontSizes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };        private NumericUpDown comboBox3;        /// <summary>        /// 调色板        /// </summary>        PaintDotNet.ColorsForm colorsForm;        /// <summary>        /// 标注列表 水印样式        /// </summary>        public LabelWaterMarkStyleDialog(AppWorkspace appWorkspace, DrawObject drawObject)        {            this.appWorkspace = appWorkspace;            this.drawObject = drawObject;            this.parentStyleModel = DrawRulerHelper.DeepCopyByReflect(this.drawObject.GetStyle());            InitializeComponent();            InitializeLanguageText();            InitializeControlData();            InitializeWaterMarkModel();        }        private void InitializeLanguageText()        {            this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");            this.button2.Text = PdnResources.GetString("Menu.File.Close.Text");            this.button1.Text = PdnResources.GetString("Menu.application.text");            this.groupBox2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.BasicInformation.text");            this.radioButton2.Text = PdnResources.GetString("Menu.no.text");            this.radioButton1.Text = PdnResources.GetString("Menu.Yes.text");            this.label5.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Fromtheboundaryvalue.text") + ":";            this.label4.Text = PdnResources.GetString("Menu.transparency.text") + ":";            this.label3.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Tilewatermark.text") + ":";            this.label2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Watermarkposition.text") + ":";            this.label1.Text = PdnResources.GetString("Menu.LabelAction.DrawWaterMark.Text") + ":";            this.button3.Text = PdnResources.GetString("Menu.browse.Text");            this.groupBox3.Text = PdnResources.GetString("Menu.Set.Watermarksettings.ExtendInformation.text");            this.checkBox2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Italic.text");            this.checkBox1.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Bold.text");            this.label9.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";            this.radioButton6.Text = PdnResources.GetString("Menu.Set.Watermarksettings.backwardlean.text");            this.radioButton5.Text = PdnResources.GetString("Menu.Set.Watermarksettings.battering.text");            this.radioButton4.Text = PdnResources.GetString("Menu.Verticaldirection.text");            this.radioButton3.Text = PdnResources.GetString("Menu.horizontaldirection.text");            this.label8.Text = PdnResources.GetString("Menu.color.text") + ":";            this.label7.Text = PdnResources.GetString("Menu.Font.text") + ":";            this.label6.Text = PdnResources.GetString("Menu.direction.text") + ":";            this.Text = PdnResources.GetString("Menu.Setting.WatermarkSetting.Text");        }        private void InitializeComponent()        {            this.groupBox1 = new System.Windows.Forms.GroupBox();            this.button2 = new System.Windows.Forms.Button();            this.button1 = new System.Windows.Forms.Button();            this.groupBox2 = new System.Windows.Forms.GroupBox();            this.userTextBox3 = new PaintDotNet.CustomControl.UserTextBox();            this.trackBar1 = new System.Windows.Forms.TrackBar();            this.radioButton2 = new System.Windows.Forms.RadioButton();            this.radioButton1 = new System.Windows.Forms.RadioButton();            this.userTextBox2 = new PaintDotNet.CustomControl.UserTextBox();            this.label5 = new System.Windows.Forms.Label();            this.comboBox1 = new System.Windows.Forms.ComboBox();            this.userTextBox1 = new PaintDotNet.CustomControl.UserTextBox();            this.label4 = new System.Windows.Forms.Label();            this.label3 = new System.Windows.Forms.Label();            this.label2 = new System.Windows.Forms.Label();            this.label1 = new System.Windows.Forms.Label();            this.button3 = new System.Windows.Forms.Button();            this.groupBox3 = new System.Windows.Forms.GroupBox();            this.checkBox2 = new System.Windows.Forms.CheckBox();            this.checkBox1 = new System.Windows.Forms.CheckBox();            this.label9 = new System.Windows.Forms.Label();            this.panel1 = new System.Windows.Forms.Panel();            this.comboBox2 = new System.Windows.Forms.ComboBox();            this.radioButton6 = new System.Windows.Forms.RadioButton();            this.radioButton5 = new System.Windows.Forms.RadioButton();            this.radioButton4 = new System.Windows.Forms.RadioButton();            this.radioButton3 = new System.Windows.Forms.RadioButton();            this.label8 = new System.Windows.Forms.Label();            this.label7 = new System.Windows.Forms.Label();            this.label6 = new System.Windows.Forms.Label();            this.comboBox3 = new System.Windows.Forms.NumericUpDown();            this.groupBox1.SuspendLayout();            this.groupBox2.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();            this.groupBox3.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.comboBox3)).BeginInit();            this.SuspendLayout();            //             // groupBox1            //             this.groupBox1.Controls.Add(this.button2);            this.groupBox1.Controls.Add(this.button1);            this.groupBox1.Location = new System.Drawing.Point(12, 12);            this.groupBox1.Name = "groupBox1";            this.groupBox1.Size = new System.Drawing.Size(613, 52);            this.groupBox1.TabIndex = 1;            this.groupBox1.TabStop = false;            this.groupBox1.Text = "操作";            //             // button2            //             this.button2.Location = new System.Drawing.Point(504, 20);            this.button2.Name = "button2";            this.button2.Size = new System.Drawing.Size(75, 23);            this.button2.TabIndex = 1;            this.button2.Text = "关闭";            this.button2.UseVisualStyleBackColor = true;            this.button2.Click += new System.EventHandler(this.button2_Click);            //             // button1            //             this.button1.Location = new System.Drawing.Point(389, 20);            this.button1.Name = "button1";            this.button1.Size = new System.Drawing.Size(75, 23);            this.button1.TabIndex = 0;            this.button1.Text = "应用";            this.button1.UseVisualStyleBackColor = true;            this.button1.Click += new System.EventHandler(this.button1_Click);            //             // groupBox2            //             this.groupBox2.Controls.Add(this.userTextBox3);            this.groupBox2.Controls.Add(this.trackBar1);            this.groupBox2.Controls.Add(this.radioButton2);            this.groupBox2.Controls.Add(this.radioButton1);            this.groupBox2.Controls.Add(this.userTextBox2);            this.groupBox2.Controls.Add(this.label5);            this.groupBox2.Controls.Add(this.comboBox1);            this.groupBox2.Controls.Add(this.userTextBox1);            this.groupBox2.Controls.Add(this.label4);            this.groupBox2.Controls.Add(this.label3);            this.groupBox2.Controls.Add(this.label2);            this.groupBox2.Controls.Add(this.label1);            this.groupBox2.Controls.Add(this.button3);            this.groupBox2.Location = new System.Drawing.Point(12, 70);            this.groupBox2.Name = "groupBox2";            this.groupBox2.Size = new System.Drawing.Size(613, 167);            this.groupBox2.TabIndex = 2;            this.groupBox2.TabStop = false;            this.groupBox2.Text = "基本信息";            //             // userTextBox3            //             this.userTextBox3.BackColor = System.Drawing.SystemColors.Control;            this.userTextBox3.Location = new System.Drawing.Point(363, 117);            this.userTextBox3.Name = "userTextBox3";            this.userTextBox3.ReadOnly = true;            this.userTextBox3.Size = new System.Drawing.Size(46, 21);            this.userTextBox3.TabIndex = 11;            this.userTextBox3.Text = "0";            //             // trackBar1            //             this.trackBar1.Cursor = System.Windows.Forms.Cursors.Hand;            this.trackBar1.Location = new System.Drawing.Point(77, 117);            this.trackBar1.Maximum = 255;            this.trackBar1.Name = "trackBar1";            this.trackBar1.Size = new System.Drawing.Size(262, 45);            this.trackBar1.TabIndex = 10;            this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;            this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);            //             // radioButton2            //             this.radioButton2.AutoSize = true;            this.radioButton2.Location = new System.Drawing.Point(161, 90);            this.radioButton2.Name = "radioButton2";            this.radioButton2.Size = new System.Drawing.Size(35, 16);            this.radioButton2.TabIndex = 9;            this.radioButton2.TabStop = true;            this.radioButton2.Text = "否";            this.radioButton2.UseVisualStyleBackColor = true;            //             // radioButton1            //             this.radioButton1.AutoSize = true;            this.radioButton1.Checked = true;            this.radioButton1.Location = new System.Drawing.Point(90, 90);            this.radioButton1.Name = "radioButton1";            this.radioButton1.Size = new System.Drawing.Size(35, 16);            this.radioButton1.TabIndex = 8;            this.radioButton1.TabStop = true;            this.radioButton1.Text = "是";            this.radioButton1.UseVisualStyleBackColor = true;            //             // userTextBox2            //             this.userTextBox2.Location = new System.Drawing.Point(372, 53);            this.userTextBox2.Name = "userTextBox2";            this.userTextBox2.Size = new System.Drawing.Size(223, 21);            this.userTextBox2.TabIndex = 7;            this.userTextBox2.TextChanged += new System.EventHandler(this.userTextBox2_TextChanged);            //             // label5            //             this.label5.AutoSize = true;            this.label5.Location = new System.Drawing.Point(303, 56);            this.label5.Name = "label5";            this.label5.Size = new System.Drawing.Size(65, 12);            this.label5.TabIndex = 6;            this.label5.Text = "距边界值:";            //             // comboBox1            //             this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;            this.comboBox1.DropDownWidth = 197;            this.comboBox1.FormattingEnabled = true;            this.comboBox1.Location = new System.Drawing.Point(87, 51);            this.comboBox1.Name = "comboBox1";            this.comboBox1.Size = new System.Drawing.Size(197, 20);            this.comboBox1.TabIndex = 5;            //             // userTextBox1            //             this.userTextBox1.Location = new System.Drawing.Point(87, 15);            this.userTextBox1.Name = "userTextBox1";            this.userTextBox1.Size = new System.Drawing.Size(508, 21);            this.userTextBox1.TabIndex = 4;            //             // label4            //             this.label4.AutoSize = true;            this.label4.Location = new System.Drawing.Point(18, 122);            this.label4.Name = "label4";            this.label4.Size = new System.Drawing.Size(53, 12);            this.label4.TabIndex = 3;            this.label4.Text = "透明度:";            //             // label3            //             this.label3.AutoSize = true;            this.label3.Location = new System.Drawing.Point(18, 90);            this.label3.Name = "label3";            this.label3.Size = new System.Drawing.Size(65, 12);            this.label3.TabIndex = 2;            this.label3.Text = "平铺水印:";            //             // label2            //             this.label2.AutoSize = true;            this.label2.Location = new System.Drawing.Point(18, 54);            this.label2.Name = "label2";            this.label2.Size = new System.Drawing.Size(65, 12);            this.label2.TabIndex = 1;            this.label2.Text = "水印位置:";            //             // label1            //             this.label1.AutoSize = true;            this.label1.Location = new System.Drawing.Point(18, 22);            this.label1.Name = "label1";            this.label1.Size = new System.Drawing.Size(41, 12);            this.label1.TabIndex = 0;            this.label1.Text = "水印:";            //             // button3            //             this.button3.Location = new System.Drawing.Point(520, 14);            this.button3.Name = "button3";            this.button3.Size = new System.Drawing.Size(75, 23);            this.button3.TabIndex = 12;            this.button3.UseVisualStyleBackColor = true;            this.button3.Click += new System.EventHandler(this.button3_Click);            //             // groupBox3            //             this.groupBox3.Controls.Add(this.comboBox3);            this.groupBox3.Controls.Add(this.checkBox2);            this.groupBox3.Controls.Add(this.checkBox1);            this.groupBox3.Controls.Add(this.label9);            this.groupBox3.Controls.Add(this.panel1);            this.groupBox3.Controls.Add(this.comboBox2);            this.groupBox3.Controls.Add(this.radioButton6);            this.groupBox3.Controls.Add(this.radioButton5);            this.groupBox3.Controls.Add(this.radioButton4);            this.groupBox3.Controls.Add(this.radioButton3);            this.groupBox3.Controls.Add(this.label8);            this.groupBox3.Controls.Add(this.label7);            this.groupBox3.Controls.Add(this.label6);            this.groupBox3.Location = new System.Drawing.Point(12, 245);            this.groupBox3.Name = "groupBox3";            this.groupBox3.Size = new System.Drawing.Size(613, 118);            this.groupBox3.TabIndex = 3;            this.groupBox3.TabStop = false;            this.groupBox3.Text = "扩展信息";            //             // checkBox2            //             this.checkBox2.AutoSize = true;            this.checkBox2.Location = new System.Drawing.Point(403, 85);            this.checkBox2.Name = "checkBox2";            this.checkBox2.Size = new System.Drawing.Size(48, 16);            this.checkBox2.TabIndex = 12;            this.checkBox2.Text = "斜体";            this.checkBox2.UseVisualStyleBackColor = true;            //             // checkBox1            //             this.checkBox1.AutoSize = true;            this.checkBox1.Location = new System.Drawing.Point(330, 86);            this.checkBox1.Name = "checkBox1";            this.checkBox1.Size = new System.Drawing.Size(48, 16);            this.checkBox1.TabIndex = 11;            this.checkBox1.Text = "粗体";            this.checkBox1.UseVisualStyleBackColor = true;            //             // label9            //             this.label9.AutoSize = true;            this.label9.Location = new System.Drawing.Point(328, 53);            this.label9.Name = "label9";            this.label9.Size = new System.Drawing.Size(41, 12);            this.label9.TabIndex = 9;            this.label9.Text = "字号:";            //             // panel1            //             this.panel1.BackColor = System.Drawing.Color.Transparent;            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;            this.panel1.Location = new System.Drawing.Point(68, 83);            this.panel1.Name = "panel1";            this.panel1.Size = new System.Drawing.Size(191, 21);            this.panel1.TabIndex = 8;            this.panel1.Click += new System.EventHandler(this.panel1_Click);            //             // comboBox2            //             this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;            this.comboBox2.FormattingEnabled = true;            this.comboBox2.Location = new System.Drawing.Point(68, 49);            this.comboBox2.Name = "comboBox2";            this.comboBox2.Size = new System.Drawing.Size(191, 20);            this.comboBox2.TabIndex = 7;            //             // radioButton6            //             this.radioButton6.AutoSize = true;            this.radioButton6.Location = new System.Drawing.Point(299, 20);            this.radioButton6.Name = "radioButton6";            this.radioButton6.Size = new System.Drawing.Size(71, 16);            this.radioButton6.TabIndex = 6;            this.radioButton6.TabStop = true;            this.radioButton6.Text = "向后倾斜";            this.radioButton6.UseVisualStyleBackColor = true;            //             // radioButton5            //             this.radioButton5.AutoSize = true;            this.radioButton5.Location = new System.Drawing.Point(222, 20);            this.radioButton5.Name = "radioButton5";            this.radioButton5.Size = new System.Drawing.Size(71, 16);            this.radioButton5.TabIndex = 5;            this.radioButton5.TabStop = true;            this.radioButton5.Text = "向前倾斜";            this.radioButton5.UseVisualStyleBackColor = true;            //             // radioButton4            //             this.radioButton4.AutoSize = true;            this.radioButton4.Location = new System.Drawing.Point(145, 20);            this.radioButton4.Name = "radioButton4";            this.radioButton4.Size = new System.Drawing.Size(71, 16);            this.radioButton4.TabIndex = 4;            this.radioButton4.TabStop = true;            this.radioButton4.Text = "垂直方向";            this.radioButton4.UseVisualStyleBackColor = true;            //             // radioButton3            //             this.radioButton3.AutoSize = true;            this.radioButton3.Checked = true;            this.radioButton3.Location = new System.Drawing.Point(68, 20);            this.radioButton3.Name = "radioButton3";            this.radioButton3.Size = new System.Drawing.Size(71, 16);            this.radioButton3.TabIndex = 3;            this.radioButton3.TabStop = true;            this.radioButton3.Text = "水平方向";            this.radioButton3.UseVisualStyleBackColor = true;            //             // label8            //             this.label8.AutoSize = true;            this.label8.Location = new System.Drawing.Point(21, 85);            this.label8.Name = "label8";            this.label8.Size = new System.Drawing.Size(41, 12);            this.label8.TabIndex = 2;            this.label8.Text = "颜色:";            //             // label7            //             this.label7.AutoSize = true;            this.label7.Location = new System.Drawing.Point(21, 53);            this.label7.Name = "label7";            this.label7.Size = new System.Drawing.Size(41, 12);            this.label7.TabIndex = 1;            this.label7.Text = "字体:";            //             // label6            //             this.label6.AutoSize = true;            this.label6.Location = new System.Drawing.Point(21, 22);            this.label6.Name = "label6";            this.label6.Size = new System.Drawing.Size(41, 12);            this.label6.TabIndex = 0;            this.label6.Text = "方向:";            //             // comboBox3            //             this.comboBox3.Location = new System.Drawing.Point(372, 49);            this.comboBox3.Maximum = new decimal(new int[] {            49000,            0,            0,            0});            this.comboBox3.Minimum = new decimal(new int[] {            1,            0,            0,            0});            this.comboBox3.Name = "comboBox3";            this.comboBox3.Size = new System.Drawing.Size(223, 21);            this.comboBox3.TabIndex = 21;            this.comboBox3.Value = new decimal(new int[] {            1,            0,            0,            0});            //             // LabelWaterMarkStyleDialog            //             this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);            this.ClientSize = new System.Drawing.Size(637, 375);            this.Controls.Add(this.groupBox3);            this.Controls.Add(this.groupBox2);            this.Controls.Add(this.groupBox1);            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;            this.MaximizeBox = false;            this.MinimizeBox = false;            this.Name = "LabelWaterMarkStyleDialog";            this.Controls.SetChildIndex(this.groupBox1, 0);            this.Controls.SetChildIndex(this.groupBox2, 0);            this.Controls.SetChildIndex(this.groupBox3, 0);            this.groupBox1.ResumeLayout(false);            this.groupBox2.ResumeLayout(false);            this.groupBox2.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();            this.groupBox3.ResumeLayout(false);            this.groupBox3.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.comboBox3)).EndInit();            this.ResumeLayout(false);        }        /// <summary>        /// 关闭        /// </summary>        private void button2_Click(object sender, EventArgs e)        {            this.Close();        }        /// <summary>        /// 初始化数据        /// </summary>        private void InitializeControlData()        {            //绑定字体下拉            ArrayList fontsItems = new ArrayList();            System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();            foreach (FontFamily fontFamily in fonts.Families)            {                fontsItems.Add(fontFamily.Name);            }            this.comboBox2.DataSource = fontsItems;            //绑定水印位置下拉            this.comboBox1.DataSource = position;            //绑定字号下拉            //this.comboBox3.DataSource = fontSizes;            this.colorsForm = new ColorsForm();            this.colorsForm.StartPosition = FormStartPosition.CenterScreen;            this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);        }        /// <summary>        /// 初始化水印样式信息        /// </summary>        private void InitializeWaterMarkModel()        {            waterMarkModel = (WatermarkModel)this.parentStyleModel;            this.userTextBox1.Text = waterMarkModel.content;            this.comboBox1.SelectedIndex = waterMarkModel.position - 1;            this.userTextBox2.Text = waterMarkModel.margin + "";            // 平铺水印            if (waterMarkModel.spread == 2)            {                this.radioButton2.Checked = true;            }            else            {                this.radioButton1.Checked = true;            }            this.trackBar1.Value = waterMarkModel.transparency;            this.userTextBox3.Text = waterMarkModel.transparency + "";            switch (waterMarkModel.direction)            {                case 1:                    this.radioButton3.Checked = true;                    break;                case 2:                    this.radioButton4.Checked = true;                    break;                case 3:                    this.radioButton5.Checked = true;                    break;                case 4:                    this.radioButton6.Checked = true;                    break;                default:                    this.radioButton3.Checked = true;                    break;            }            this.comboBox2.Text = waterMarkModel.typeface;            this.comboBox3.Value = decimal.Parse(waterMarkModel.fontSize + "");            this.panel1.BackColor = Color.FromArgb(waterMarkModel.color);            if (waterMarkModel.bold == 1)            {                this.checkBox1.Checked = true;            }            if (waterMarkModel.italic == 1)            {                this.checkBox2.Checked = true;            }            //文字水印的窗体变更            if (waterMarkModel.watermarkType == 1)            {                this.userTextBox1.ReadOnly = false;                this.userTextBox1.Size = new Size(508, 21);                this.button3.Visible = false;                this.groupBox3.Visible = true;//扩展信息                this.nowWaterMarkType = 1;            }            //图片水印的窗体变更            if (waterMarkModel.watermarkType == 2)            {                this.userTextBox1.ReadOnly = true;                this.userTextBox1.Size = new Size(508 - 85, 21);                this.button3.Visible = true;                this.groupBox3.Visible = false;                this.nowWaterMarkType = 2;            }        }        /// <summary>        /// 选择图片水印        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button3_Click(object sender, EventArgs e)        {            var openFileDialog1 = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };            if (openFileDialog1.ShowDialog() == DialogResult.OK)            {                this.userTextBox1.Text = openFileDialog1.InitialDirectory + openFileDialog1.FileName;            }        }        /// <summary>        /// 透明度滑块        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void trackBar1_Scroll(object sender, EventArgs e)        {            this.userTextBox3.Text = "" + this.trackBar1.Value;        }        /// <summary>        /// 画板点击        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void panel1_Click(object sender, EventArgs e)        {            this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);            this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));            this.colorsForm.ShowDialog();        }        private void panel1Changed(object sender, EventArgs e)        {            this.panel1.BackColor = this.colorsForm.UserPrimaryColor.ToColor();            this.colorsForm.Close();        }        private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)        {        }        /// <summary>        /// 距边界值        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void userTextBox2_TextChanged(object sender, EventArgs e)        {            if (string.IsNullOrEmpty(this.userTextBox2.Text))            {                MessageBox.Show(PdnResources.GetString("Menu.edistancefromtheboundaryaluecanno.Text"));                return;            }        }        /// <summary>        /// 应用        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button1_Click(object sender, EventArgs e)        {            waterMarkModel = new WatermarkModel();            waterMarkModel.watermarkType = this.nowWaterMarkType;            waterMarkModel.content = this.userTextBox1.Text;            waterMarkModel.position = this.comboBox1.SelectedIndex + 1;            if (string.IsNullOrEmpty(this.userTextBox2.Text))            {                waterMarkModel.margin = 0;            }            else            {                waterMarkModel.margin = Int32.Parse(this.userTextBox2.Text);            }            if (this.radioButton2.Checked)            {                waterMarkModel.spread = 2;            }            else            {                waterMarkModel.spread = 1;            }            waterMarkModel.transparency = this.trackBar1.Value;            if (radioButton3.Checked)            {                waterMarkModel.direction = 1;            }            else if (radioButton4.Checked)            {                waterMarkModel.direction = 2;            }            else if (radioButton5.Checked)            {                waterMarkModel.direction = 3;            }            else            {                waterMarkModel.direction = 4;            }            waterMarkModel.typeface = this.comboBox2.Text;            waterMarkModel.fontSize = Convert.ToInt32(this.comboBox3.Text);            waterMarkModel.color = Convert.ToInt32(this.panel1.BackColor.ToArgb());            if (this.checkBox1.Checked)            {                waterMarkModel.bold = 1;            }            else            {                waterMarkModel.bold = 2;            }            if (this.checkBox2.Checked)            {                waterMarkModel.italic = 1;            }            else            {                waterMarkModel.italic = 2;            }            DrawWaterMark drawWaterMark = (DrawWaterMark)this.drawObject;            drawWaterMark.waterMarkModel = this.waterMarkModel;            this.appWorkspace.ActiveDocumentWorkspace.Refresh();            this.Close();        }    }}
 |