LabelWaterMarkStyleDialog.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. using PaintDotNet.Annotation;
  2. using PaintDotNet.Annotation.Label;
  3. using PaintDotNet.Base.CommTool;
  4. using PaintDotNet.Base.SettingModel;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. namespace PaintDotNet.ImageLabel
  16. {
  17. internal class LabelWaterMarkStyleDialog : PdnBaseForm
  18. {
  19. private Button button2;
  20. private Button button1;
  21. private GroupBox groupBox2;
  22. private GroupBox groupBox3;
  23. private Label label4;
  24. private Label label3;
  25. private Label label2;
  26. private Label label1;
  27. private CustomControl.UserTextBox userTextBox1;
  28. private ComboBox comboBox1;
  29. private Label label5;
  30. private CustomControl.UserTextBox userTextBox2;
  31. private RadioButton radioButton1;
  32. private RadioButton radioButton2;
  33. private TrackBar trackBar1;
  34. private CustomControl.UserTextBox userTextBox3;
  35. private Label label8;
  36. private Label label7;
  37. private Label label6;
  38. private RadioButton radioButton6;
  39. private RadioButton radioButton5;
  40. private RadioButton radioButton4;
  41. private RadioButton radioButton3;
  42. private ComboBox comboBox2;
  43. private Panel panel1;
  44. private Label label9;
  45. private CheckBox checkBox2;
  46. private CheckBox checkBox1;
  47. private Button button3;
  48. private GroupBox groupBox1;
  49. private AppWorkspace appWorkspace;
  50. private DrawObject drawObject;
  51. private ParentStyleModel parentStyleModel;
  52. private WatermarkModel waterMarkModel;
  53. private int nowWaterMarkType = 0;
  54. /// <summary>
  55. /// 水印位置下拉选
  56. /// </summary>
  57. string[] position = new string[] { PdnResources.GetString("Menu.Set.Watermarksettings.Topleft.text"),
  58. 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") };
  59. /// <summary>
  60. /// 水印字号下拉选
  61. /// </summary>
  62. int[] fontSizes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  63. private NumericUpDown comboBox3;
  64. /// <summary>
  65. /// 调色板
  66. /// </summary>
  67. PaintDotNet.ColorsForm colorsForm;
  68. /// <summary>
  69. /// 标注列表 水印样式
  70. /// </summary>
  71. public LabelWaterMarkStyleDialog(AppWorkspace appWorkspace, DrawObject drawObject)
  72. {
  73. this.appWorkspace = appWorkspace;
  74. this.drawObject = drawObject;
  75. this.parentStyleModel = DrawRulerHelper.DeepCopyByReflect(this.drawObject.GetStyle());
  76. InitializeComponent();
  77. InitializeLanguageText();
  78. InitializeControlData();
  79. InitializeWaterMarkModel();
  80. }
  81. private void InitializeLanguageText()
  82. {
  83. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  84. this.button2.Text = PdnResources.GetString("Menu.File.Close.Text");
  85. this.button1.Text = PdnResources.GetString("Menu.application.text");
  86. this.groupBox2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.BasicInformation.text");
  87. this.radioButton2.Text = PdnResources.GetString("Menu.no.text");
  88. this.radioButton1.Text = PdnResources.GetString("Menu.Yes.text");
  89. this.label5.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Fromtheboundaryvalue.text") + ":";
  90. this.label4.Text = PdnResources.GetString("Menu.transparency.text") + ":";
  91. this.label3.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Tilewatermark.text") + ":";
  92. this.label2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Watermarkposition.text") + ":";
  93. this.label1.Text = PdnResources.GetString("Menu.LabelAction.DrawWaterMark.Text") + ":";
  94. this.button3.Text = PdnResources.GetString("Menu.browse.Text");
  95. this.groupBox3.Text = PdnResources.GetString("Menu.Set.Watermarksettings.ExtendInformation.text");
  96. this.checkBox2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Italic.text");
  97. this.checkBox1.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Bold.text");
  98. this.label9.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  99. this.radioButton6.Text = PdnResources.GetString("Menu.Set.Watermarksettings.backwardlean.text");
  100. this.radioButton5.Text = PdnResources.GetString("Menu.Set.Watermarksettings.battering.text");
  101. this.radioButton4.Text = PdnResources.GetString("Menu.Verticaldirection.text");
  102. this.radioButton3.Text = PdnResources.GetString("Menu.horizontaldirection.text");
  103. this.label8.Text = PdnResources.GetString("Menu.color.text") + ":";
  104. this.label7.Text = PdnResources.GetString("Menu.Font.text") + ":";
  105. this.label6.Text = PdnResources.GetString("Menu.direction.text") + ":";
  106. this.Text = PdnResources.GetString("Menu.Setting.WatermarkSetting.Text");
  107. }
  108. private void InitializeComponent()
  109. {
  110. this.groupBox1 = new System.Windows.Forms.GroupBox();
  111. this.button2 = new System.Windows.Forms.Button();
  112. this.button1 = new System.Windows.Forms.Button();
  113. this.groupBox2 = new System.Windows.Forms.GroupBox();
  114. this.userTextBox3 = new PaintDotNet.CustomControl.UserTextBox();
  115. this.trackBar1 = new System.Windows.Forms.TrackBar();
  116. this.radioButton2 = new System.Windows.Forms.RadioButton();
  117. this.radioButton1 = new System.Windows.Forms.RadioButton();
  118. this.userTextBox2 = new PaintDotNet.CustomControl.UserTextBox();
  119. this.label5 = new System.Windows.Forms.Label();
  120. this.comboBox1 = new System.Windows.Forms.ComboBox();
  121. this.userTextBox1 = new PaintDotNet.CustomControl.UserTextBox();
  122. this.label4 = new System.Windows.Forms.Label();
  123. this.label3 = new System.Windows.Forms.Label();
  124. this.label2 = new System.Windows.Forms.Label();
  125. this.label1 = new System.Windows.Forms.Label();
  126. this.button3 = new System.Windows.Forms.Button();
  127. this.groupBox3 = new System.Windows.Forms.GroupBox();
  128. this.checkBox2 = new System.Windows.Forms.CheckBox();
  129. this.checkBox1 = new System.Windows.Forms.CheckBox();
  130. this.label9 = new System.Windows.Forms.Label();
  131. this.panel1 = new System.Windows.Forms.Panel();
  132. this.comboBox2 = new System.Windows.Forms.ComboBox();
  133. this.radioButton6 = new System.Windows.Forms.RadioButton();
  134. this.radioButton5 = new System.Windows.Forms.RadioButton();
  135. this.radioButton4 = new System.Windows.Forms.RadioButton();
  136. this.radioButton3 = new System.Windows.Forms.RadioButton();
  137. this.label8 = new System.Windows.Forms.Label();
  138. this.label7 = new System.Windows.Forms.Label();
  139. this.label6 = new System.Windows.Forms.Label();
  140. this.comboBox3 = new System.Windows.Forms.NumericUpDown();
  141. this.groupBox1.SuspendLayout();
  142. this.groupBox2.SuspendLayout();
  143. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  144. this.groupBox3.SuspendLayout();
  145. ((System.ComponentModel.ISupportInitialize)(this.comboBox3)).BeginInit();
  146. this.SuspendLayout();
  147. //
  148. // groupBox1
  149. //
  150. this.groupBox1.Controls.Add(this.button2);
  151. this.groupBox1.Controls.Add(this.button1);
  152. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  153. this.groupBox1.Name = "groupBox1";
  154. this.groupBox1.Size = new System.Drawing.Size(613, 52);
  155. this.groupBox1.TabIndex = 1;
  156. this.groupBox1.TabStop = false;
  157. this.groupBox1.Text = "操作";
  158. //
  159. // button2
  160. //
  161. this.button2.Location = new System.Drawing.Point(504, 20);
  162. this.button2.Name = "button2";
  163. this.button2.Size = new System.Drawing.Size(75, 23);
  164. this.button2.TabIndex = 1;
  165. this.button2.Text = "关闭";
  166. this.button2.UseVisualStyleBackColor = true;
  167. this.button2.Click += new System.EventHandler(this.button2_Click);
  168. //
  169. // button1
  170. //
  171. this.button1.Location = new System.Drawing.Point(389, 20);
  172. this.button1.Name = "button1";
  173. this.button1.Size = new System.Drawing.Size(75, 23);
  174. this.button1.TabIndex = 0;
  175. this.button1.Text = "应用";
  176. this.button1.UseVisualStyleBackColor = true;
  177. this.button1.Click += new System.EventHandler(this.button1_Click);
  178. //
  179. // groupBox2
  180. //
  181. this.groupBox2.Controls.Add(this.userTextBox3);
  182. this.groupBox2.Controls.Add(this.trackBar1);
  183. this.groupBox2.Controls.Add(this.radioButton2);
  184. this.groupBox2.Controls.Add(this.radioButton1);
  185. this.groupBox2.Controls.Add(this.userTextBox2);
  186. this.groupBox2.Controls.Add(this.label5);
  187. this.groupBox2.Controls.Add(this.comboBox1);
  188. this.groupBox2.Controls.Add(this.userTextBox1);
  189. this.groupBox2.Controls.Add(this.label4);
  190. this.groupBox2.Controls.Add(this.label3);
  191. this.groupBox2.Controls.Add(this.label2);
  192. this.groupBox2.Controls.Add(this.label1);
  193. this.groupBox2.Controls.Add(this.button3);
  194. this.groupBox2.Location = new System.Drawing.Point(12, 70);
  195. this.groupBox2.Name = "groupBox2";
  196. this.groupBox2.Size = new System.Drawing.Size(613, 167);
  197. this.groupBox2.TabIndex = 2;
  198. this.groupBox2.TabStop = false;
  199. this.groupBox2.Text = "基本信息";
  200. //
  201. // userTextBox3
  202. //
  203. this.userTextBox3.BackColor = System.Drawing.SystemColors.Control;
  204. this.userTextBox3.Location = new System.Drawing.Point(363, 117);
  205. this.userTextBox3.Name = "userTextBox3";
  206. this.userTextBox3.ReadOnly = true;
  207. this.userTextBox3.Size = new System.Drawing.Size(46, 21);
  208. this.userTextBox3.TabIndex = 11;
  209. this.userTextBox3.Text = "0";
  210. //
  211. // trackBar1
  212. //
  213. this.trackBar1.Cursor = System.Windows.Forms.Cursors.Hand;
  214. this.trackBar1.Location = new System.Drawing.Point(77, 117);
  215. this.trackBar1.Maximum = 255;
  216. this.trackBar1.Name = "trackBar1";
  217. this.trackBar1.Size = new System.Drawing.Size(262, 45);
  218. this.trackBar1.TabIndex = 10;
  219. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  220. this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
  221. //
  222. // radioButton2
  223. //
  224. this.radioButton2.AutoSize = true;
  225. this.radioButton2.Location = new System.Drawing.Point(161, 90);
  226. this.radioButton2.Name = "radioButton2";
  227. this.radioButton2.Size = new System.Drawing.Size(35, 16);
  228. this.radioButton2.TabIndex = 9;
  229. this.radioButton2.TabStop = true;
  230. this.radioButton2.Text = "否";
  231. this.radioButton2.UseVisualStyleBackColor = true;
  232. //
  233. // radioButton1
  234. //
  235. this.radioButton1.AutoSize = true;
  236. this.radioButton1.Checked = true;
  237. this.radioButton1.Location = new System.Drawing.Point(90, 90);
  238. this.radioButton1.Name = "radioButton1";
  239. this.radioButton1.Size = new System.Drawing.Size(35, 16);
  240. this.radioButton1.TabIndex = 8;
  241. this.radioButton1.TabStop = true;
  242. this.radioButton1.Text = "是";
  243. this.radioButton1.UseVisualStyleBackColor = true;
  244. //
  245. // userTextBox2
  246. //
  247. this.userTextBox2.Location = new System.Drawing.Point(372, 53);
  248. this.userTextBox2.Name = "userTextBox2";
  249. this.userTextBox2.Size = new System.Drawing.Size(223, 21);
  250. this.userTextBox2.TabIndex = 7;
  251. this.userTextBox2.TextChanged += new System.EventHandler(this.userTextBox2_TextChanged);
  252. //
  253. // label5
  254. //
  255. this.label5.AutoSize = true;
  256. this.label5.Location = new System.Drawing.Point(303, 56);
  257. this.label5.Name = "label5";
  258. this.label5.Size = new System.Drawing.Size(65, 12);
  259. this.label5.TabIndex = 6;
  260. this.label5.Text = "距边界值:";
  261. //
  262. // comboBox1
  263. //
  264. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  265. this.comboBox1.DropDownWidth = 197;
  266. this.comboBox1.FormattingEnabled = true;
  267. this.comboBox1.Location = new System.Drawing.Point(87, 51);
  268. this.comboBox1.Name = "comboBox1";
  269. this.comboBox1.Size = new System.Drawing.Size(197, 20);
  270. this.comboBox1.TabIndex = 5;
  271. //
  272. // userTextBox1
  273. //
  274. this.userTextBox1.Location = new System.Drawing.Point(87, 15);
  275. this.userTextBox1.Name = "userTextBox1";
  276. this.userTextBox1.Size = new System.Drawing.Size(508, 21);
  277. this.userTextBox1.TabIndex = 4;
  278. //
  279. // label4
  280. //
  281. this.label4.AutoSize = true;
  282. this.label4.Location = new System.Drawing.Point(18, 122);
  283. this.label4.Name = "label4";
  284. this.label4.Size = new System.Drawing.Size(53, 12);
  285. this.label4.TabIndex = 3;
  286. this.label4.Text = "透明度:";
  287. //
  288. // label3
  289. //
  290. this.label3.AutoSize = true;
  291. this.label3.Location = new System.Drawing.Point(18, 90);
  292. this.label3.Name = "label3";
  293. this.label3.Size = new System.Drawing.Size(65, 12);
  294. this.label3.TabIndex = 2;
  295. this.label3.Text = "平铺水印:";
  296. //
  297. // label2
  298. //
  299. this.label2.AutoSize = true;
  300. this.label2.Location = new System.Drawing.Point(18, 54);
  301. this.label2.Name = "label2";
  302. this.label2.Size = new System.Drawing.Size(65, 12);
  303. this.label2.TabIndex = 1;
  304. this.label2.Text = "水印位置:";
  305. //
  306. // label1
  307. //
  308. this.label1.AutoSize = true;
  309. this.label1.Location = new System.Drawing.Point(18, 22);
  310. this.label1.Name = "label1";
  311. this.label1.Size = new System.Drawing.Size(41, 12);
  312. this.label1.TabIndex = 0;
  313. this.label1.Text = "水印:";
  314. //
  315. // button3
  316. //
  317. this.button3.Location = new System.Drawing.Point(520, 14);
  318. this.button3.Name = "button3";
  319. this.button3.Size = new System.Drawing.Size(75, 23);
  320. this.button3.TabIndex = 12;
  321. this.button3.UseVisualStyleBackColor = true;
  322. this.button3.Click += new System.EventHandler(this.button3_Click);
  323. //
  324. // groupBox3
  325. //
  326. this.groupBox3.Controls.Add(this.comboBox3);
  327. this.groupBox3.Controls.Add(this.checkBox2);
  328. this.groupBox3.Controls.Add(this.checkBox1);
  329. this.groupBox3.Controls.Add(this.label9);
  330. this.groupBox3.Controls.Add(this.panel1);
  331. this.groupBox3.Controls.Add(this.comboBox2);
  332. this.groupBox3.Controls.Add(this.radioButton6);
  333. this.groupBox3.Controls.Add(this.radioButton5);
  334. this.groupBox3.Controls.Add(this.radioButton4);
  335. this.groupBox3.Controls.Add(this.radioButton3);
  336. this.groupBox3.Controls.Add(this.label8);
  337. this.groupBox3.Controls.Add(this.label7);
  338. this.groupBox3.Controls.Add(this.label6);
  339. this.groupBox3.Location = new System.Drawing.Point(12, 245);
  340. this.groupBox3.Name = "groupBox3";
  341. this.groupBox3.Size = new System.Drawing.Size(613, 118);
  342. this.groupBox3.TabIndex = 3;
  343. this.groupBox3.TabStop = false;
  344. this.groupBox3.Text = "扩展信息";
  345. //
  346. // checkBox2
  347. //
  348. this.checkBox2.AutoSize = true;
  349. this.checkBox2.Location = new System.Drawing.Point(403, 85);
  350. this.checkBox2.Name = "checkBox2";
  351. this.checkBox2.Size = new System.Drawing.Size(48, 16);
  352. this.checkBox2.TabIndex = 12;
  353. this.checkBox2.Text = "斜体";
  354. this.checkBox2.UseVisualStyleBackColor = true;
  355. //
  356. // checkBox1
  357. //
  358. this.checkBox1.AutoSize = true;
  359. this.checkBox1.Location = new System.Drawing.Point(330, 86);
  360. this.checkBox1.Name = "checkBox1";
  361. this.checkBox1.Size = new System.Drawing.Size(48, 16);
  362. this.checkBox1.TabIndex = 11;
  363. this.checkBox1.Text = "粗体";
  364. this.checkBox1.UseVisualStyleBackColor = true;
  365. //
  366. // label9
  367. //
  368. this.label9.AutoSize = true;
  369. this.label9.Location = new System.Drawing.Point(328, 53);
  370. this.label9.Name = "label9";
  371. this.label9.Size = new System.Drawing.Size(41, 12);
  372. this.label9.TabIndex = 9;
  373. this.label9.Text = "字号:";
  374. //
  375. // panel1
  376. //
  377. this.panel1.BackColor = System.Drawing.Color.Transparent;
  378. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  379. this.panel1.Location = new System.Drawing.Point(68, 83);
  380. this.panel1.Name = "panel1";
  381. this.panel1.Size = new System.Drawing.Size(191, 21);
  382. this.panel1.TabIndex = 8;
  383. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  384. //
  385. // comboBox2
  386. //
  387. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  388. this.comboBox2.FormattingEnabled = true;
  389. this.comboBox2.Location = new System.Drawing.Point(68, 49);
  390. this.comboBox2.Name = "comboBox2";
  391. this.comboBox2.Size = new System.Drawing.Size(191, 20);
  392. this.comboBox2.TabIndex = 7;
  393. //
  394. // radioButton6
  395. //
  396. this.radioButton6.AutoSize = true;
  397. this.radioButton6.Location = new System.Drawing.Point(299, 20);
  398. this.radioButton6.Name = "radioButton6";
  399. this.radioButton6.Size = new System.Drawing.Size(71, 16);
  400. this.radioButton6.TabIndex = 6;
  401. this.radioButton6.TabStop = true;
  402. this.radioButton6.Text = "向后倾斜";
  403. this.radioButton6.UseVisualStyleBackColor = true;
  404. //
  405. // radioButton5
  406. //
  407. this.radioButton5.AutoSize = true;
  408. this.radioButton5.Location = new System.Drawing.Point(222, 20);
  409. this.radioButton5.Name = "radioButton5";
  410. this.radioButton5.Size = new System.Drawing.Size(71, 16);
  411. this.radioButton5.TabIndex = 5;
  412. this.radioButton5.TabStop = true;
  413. this.radioButton5.Text = "向前倾斜";
  414. this.radioButton5.UseVisualStyleBackColor = true;
  415. //
  416. // radioButton4
  417. //
  418. this.radioButton4.AutoSize = true;
  419. this.radioButton4.Location = new System.Drawing.Point(145, 20);
  420. this.radioButton4.Name = "radioButton4";
  421. this.radioButton4.Size = new System.Drawing.Size(71, 16);
  422. this.radioButton4.TabIndex = 4;
  423. this.radioButton4.TabStop = true;
  424. this.radioButton4.Text = "垂直方向";
  425. this.radioButton4.UseVisualStyleBackColor = true;
  426. //
  427. // radioButton3
  428. //
  429. this.radioButton3.AutoSize = true;
  430. this.radioButton3.Checked = true;
  431. this.radioButton3.Location = new System.Drawing.Point(68, 20);
  432. this.radioButton3.Name = "radioButton3";
  433. this.radioButton3.Size = new System.Drawing.Size(71, 16);
  434. this.radioButton3.TabIndex = 3;
  435. this.radioButton3.TabStop = true;
  436. this.radioButton3.Text = "水平方向";
  437. this.radioButton3.UseVisualStyleBackColor = true;
  438. //
  439. // label8
  440. //
  441. this.label8.AutoSize = true;
  442. this.label8.Location = new System.Drawing.Point(21, 85);
  443. this.label8.Name = "label8";
  444. this.label8.Size = new System.Drawing.Size(41, 12);
  445. this.label8.TabIndex = 2;
  446. this.label8.Text = "颜色:";
  447. //
  448. // label7
  449. //
  450. this.label7.AutoSize = true;
  451. this.label7.Location = new System.Drawing.Point(21, 53);
  452. this.label7.Name = "label7";
  453. this.label7.Size = new System.Drawing.Size(41, 12);
  454. this.label7.TabIndex = 1;
  455. this.label7.Text = "字体:";
  456. //
  457. // label6
  458. //
  459. this.label6.AutoSize = true;
  460. this.label6.Location = new System.Drawing.Point(21, 22);
  461. this.label6.Name = "label6";
  462. this.label6.Size = new System.Drawing.Size(41, 12);
  463. this.label6.TabIndex = 0;
  464. this.label6.Text = "方向:";
  465. //
  466. // comboBox3
  467. //
  468. this.comboBox3.Location = new System.Drawing.Point(372, 49);
  469. this.comboBox3.Maximum = new decimal(new int[] {
  470. 49000,
  471. 0,
  472. 0,
  473. 0});
  474. this.comboBox3.Minimum = new decimal(new int[] {
  475. 1,
  476. 0,
  477. 0,
  478. 0});
  479. this.comboBox3.Name = "comboBox3";
  480. this.comboBox3.Size = new System.Drawing.Size(223, 21);
  481. this.comboBox3.TabIndex = 21;
  482. this.comboBox3.Value = new decimal(new int[] {
  483. 1,
  484. 0,
  485. 0,
  486. 0});
  487. //
  488. // LabelWaterMarkStyleDialog
  489. //
  490. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  491. this.ClientSize = new System.Drawing.Size(637, 375);
  492. this.Controls.Add(this.groupBox3);
  493. this.Controls.Add(this.groupBox2);
  494. this.Controls.Add(this.groupBox1);
  495. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  496. this.MaximizeBox = false;
  497. this.MinimizeBox = false;
  498. this.Name = "LabelWaterMarkStyleDialog";
  499. this.Controls.SetChildIndex(this.groupBox1, 0);
  500. this.Controls.SetChildIndex(this.groupBox2, 0);
  501. this.Controls.SetChildIndex(this.groupBox3, 0);
  502. this.groupBox1.ResumeLayout(false);
  503. this.groupBox2.ResumeLayout(false);
  504. this.groupBox2.PerformLayout();
  505. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  506. this.groupBox3.ResumeLayout(false);
  507. this.groupBox3.PerformLayout();
  508. ((System.ComponentModel.ISupportInitialize)(this.comboBox3)).EndInit();
  509. this.ResumeLayout(false);
  510. }
  511. /// <summary>
  512. /// 关闭
  513. /// </summary>
  514. private void button2_Click(object sender, EventArgs e)
  515. {
  516. this.Close();
  517. }
  518. /// <summary>
  519. /// 初始化数据
  520. /// </summary>
  521. private void InitializeControlData()
  522. {
  523. //绑定字体下拉
  524. ArrayList fontsItems = new ArrayList();
  525. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  526. foreach (FontFamily fontFamily in fonts.Families)
  527. {
  528. fontsItems.Add(fontFamily.Name);
  529. }
  530. this.comboBox2.DataSource = fontsItems;
  531. //绑定水印位置下拉
  532. this.comboBox1.DataSource = position;
  533. //绑定字号下拉
  534. //this.comboBox3.DataSource = fontSizes;
  535. this.colorsForm = new ColorsForm();
  536. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  537. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  538. }
  539. /// <summary>
  540. /// 初始化水印样式信息
  541. /// </summary>
  542. private void InitializeWaterMarkModel()
  543. {
  544. waterMarkModel = (WatermarkModel)this.parentStyleModel;
  545. this.userTextBox1.Text = waterMarkModel.content;
  546. this.comboBox1.SelectedIndex = waterMarkModel.position - 1;
  547. this.userTextBox2.Text = waterMarkModel.margin + "";
  548. // 平铺水印
  549. if (waterMarkModel.spread == 2)
  550. {
  551. this.radioButton2.Checked = true;
  552. }
  553. else
  554. {
  555. this.radioButton1.Checked = true;
  556. }
  557. this.trackBar1.Value = waterMarkModel.transparency;
  558. this.userTextBox3.Text = waterMarkModel.transparency + "";
  559. switch (waterMarkModel.direction)
  560. {
  561. case 1:
  562. this.radioButton3.Checked = true;
  563. break;
  564. case 2:
  565. this.radioButton4.Checked = true;
  566. break;
  567. case 3:
  568. this.radioButton5.Checked = true;
  569. break;
  570. case 4:
  571. this.radioButton6.Checked = true;
  572. break;
  573. default:
  574. this.radioButton3.Checked = true;
  575. break;
  576. }
  577. this.comboBox2.Text = waterMarkModel.typeface;
  578. this.comboBox3.Value = decimal.Parse(waterMarkModel.fontSize + "");
  579. this.panel1.BackColor = Color.FromArgb(waterMarkModel.color);
  580. if (waterMarkModel.bold == 1)
  581. {
  582. this.checkBox1.Checked = true;
  583. }
  584. if (waterMarkModel.italic == 1)
  585. {
  586. this.checkBox2.Checked = true;
  587. }
  588. //文字水印的窗体变更
  589. if (waterMarkModel.watermarkType == 1)
  590. {
  591. this.userTextBox1.ReadOnly = false;
  592. this.userTextBox1.Size = new Size(508, 21);
  593. this.button3.Visible = false;
  594. this.groupBox3.Visible = true;//扩展信息
  595. this.nowWaterMarkType = 1;
  596. }
  597. //图片水印的窗体变更
  598. if (waterMarkModel.watermarkType == 2)
  599. {
  600. this.userTextBox1.ReadOnly = true;
  601. this.userTextBox1.Size = new Size(508 - 85, 21);
  602. this.button3.Visible = true;
  603. this.groupBox3.Visible = false;
  604. this.nowWaterMarkType = 2;
  605. }
  606. }
  607. /// <summary>
  608. /// 选择图片水印
  609. /// </summary>
  610. /// <param name="sender"></param>
  611. /// <param name="e"></param>
  612. private void button3_Click(object sender, EventArgs e)
  613. {
  614. var openFileDialog1 = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };
  615. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  616. {
  617. this.userTextBox1.Text = openFileDialog1.InitialDirectory + openFileDialog1.FileName;
  618. }
  619. }
  620. /// <summary>
  621. /// 透明度滑块
  622. /// </summary>
  623. /// <param name="sender"></param>
  624. /// <param name="e"></param>
  625. private void trackBar1_Scroll(object sender, EventArgs e)
  626. {
  627. this.userTextBox3.Text = "" + this.trackBar1.Value;
  628. }
  629. /// <summary>
  630. /// 画板点击
  631. /// </summary>
  632. /// <param name="sender"></param>
  633. /// <param name="e"></param>
  634. private void panel1_Click(object sender, EventArgs e)
  635. {
  636. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  637. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  638. this.colorsForm.ShowDialog();
  639. }
  640. private void panel1Changed(object sender, EventArgs e)
  641. {
  642. this.panel1.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  643. this.colorsForm.Close();
  644. }
  645. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  646. {
  647. }
  648. /// <summary>
  649. /// 距边界值
  650. /// </summary>
  651. /// <param name="sender"></param>
  652. /// <param name="e"></param>
  653. private void userTextBox2_TextChanged(object sender, EventArgs e)
  654. {
  655. if (string.IsNullOrEmpty(this.userTextBox2.Text))
  656. {
  657. MessageBox.Show(PdnResources.GetString("Menu.edistancefromtheboundaryaluecanno.Text"));
  658. return;
  659. }
  660. }
  661. /// <summary>
  662. /// 应用
  663. /// </summary>
  664. /// <param name="sender"></param>
  665. /// <param name="e"></param>
  666. private void button1_Click(object sender, EventArgs e)
  667. {
  668. waterMarkModel = new WatermarkModel();
  669. waterMarkModel.watermarkType = this.nowWaterMarkType;
  670. waterMarkModel.content = this.userTextBox1.Text;
  671. waterMarkModel.position = this.comboBox1.SelectedIndex + 1;
  672. if (string.IsNullOrEmpty(this.userTextBox2.Text))
  673. {
  674. waterMarkModel.margin = 0;
  675. }
  676. else
  677. {
  678. waterMarkModel.margin = Int32.Parse(this.userTextBox2.Text);
  679. }
  680. if (this.radioButton2.Checked)
  681. {
  682. waterMarkModel.spread = 2;
  683. }
  684. else
  685. {
  686. waterMarkModel.spread = 1;
  687. }
  688. waterMarkModel.transparency = this.trackBar1.Value;
  689. if (radioButton3.Checked)
  690. {
  691. waterMarkModel.direction = 1;
  692. }
  693. else if (radioButton4.Checked)
  694. {
  695. waterMarkModel.direction = 2;
  696. }
  697. else if (radioButton5.Checked)
  698. {
  699. waterMarkModel.direction = 3;
  700. }
  701. else
  702. {
  703. waterMarkModel.direction = 4;
  704. }
  705. waterMarkModel.typeface = this.comboBox2.Text;
  706. waterMarkModel.fontSize = Convert.ToInt32(this.comboBox3.Text);
  707. waterMarkModel.color = Convert.ToInt32(this.panel1.BackColor.ToArgb());
  708. if (this.checkBox1.Checked)
  709. {
  710. waterMarkModel.bold = 1;
  711. }
  712. else
  713. {
  714. waterMarkModel.bold = 2;
  715. }
  716. if (this.checkBox2.Checked)
  717. {
  718. waterMarkModel.italic = 1;
  719. }
  720. else
  721. {
  722. waterMarkModel.italic = 2;
  723. }
  724. DrawWaterMark drawWaterMark = (DrawWaterMark)this.drawObject;
  725. drawWaterMark.waterMarkModel = this.waterMarkModel;
  726. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  727. this.Close();
  728. }
  729. }
  730. }