LabelWaterMarkStyleDialog.cs 31 KB

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