WatermarkSettingsDialog.cs 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using PaintDotNet.Base.SettingModel;
  5. using System.Collections;
  6. using System.IO;
  7. using PaintDotNet.Base.CommTool;
  8. using System.Collections.Generic;
  9. using System.Drawing.Imaging;
  10. using System.Drawing.Drawing2D;
  11. namespace PaintDotNet.Setting
  12. {
  13. public partial class WatermarkSettingsDialog : PdnBaseForm
  14. {
  15. #region 组件
  16. private System.Windows.Forms.GroupBox groupBox2;
  17. private System.Windows.Forms.Button button2;
  18. private System.Windows.Forms.Button button1;
  19. private System.Windows.Forms.Label label1;
  20. private System.Windows.Forms.ComboBox comboBox1;
  21. private System.Windows.Forms.Button button4;
  22. private System.Windows.Forms.Button button3;
  23. private System.Windows.Forms.GroupBox groupBox1;
  24. private System.Windows.Forms.RadioButton radioButton2;
  25. private System.Windows.Forms.RadioButton radioButton1;
  26. private System.Windows.Forms.GroupBox groupBox3;
  27. private System.Windows.Forms.Label label2;
  28. private System.Windows.Forms.Label label4;
  29. private System.Windows.Forms.Label label3;
  30. private System.Windows.Forms.Label label6;
  31. private System.Windows.Forms.ComboBox comboBox2;
  32. private System.Windows.Forms.Label label5;
  33. private System.Windows.Forms.RadioButton radioButton3;
  34. private CustomControl.UserTextBox userTextBox2;
  35. private System.Windows.Forms.RadioButton radioButton4;
  36. private System.Windows.Forms.TrackBar trackBar1;
  37. private System.Windows.Forms.GroupBox groupBox4;
  38. private System.Windows.Forms.Label label7;
  39. private System.Windows.Forms.RadioButton radioButton5;
  40. private System.Windows.Forms.RadioButton radioButton6;
  41. private System.Windows.Forms.RadioButton radioButton8;
  42. private System.Windows.Forms.RadioButton radioButton7;
  43. private System.Windows.Forms.Label label8;
  44. private System.Windows.Forms.Label label9;
  45. private System.Windows.Forms.ComboBox comboBox3;
  46. private System.Windows.Forms.Panel panel2;
  47. private System.Windows.Forms.Label label10;
  48. private System.Windows.Forms.CheckBox checkBox2;
  49. private System.Windows.Forms.CheckBox checkBox1;
  50. private System.Windows.Forms.GroupBox groupBox5;
  51. private System.Windows.Forms.PictureBox pictureBox2;
  52. private System.Windows.Forms.Button button5;
  53. private CustomControl.UserTextBox userTextBox3;
  54. //private System.Windows.Forms.ColorDialog colorVal;
  55. private System.Windows.Forms.TextBox userTextBox1;
  56. PaintDotNet.ColorsForm colorsForm;
  57. private NumericUpDown numericUpDown1;
  58. /// <summary>
  59. /// Required designer variable.
  60. /// </summary>
  61. private System.ComponentModel.IContainer components = null;
  62. /// <summary>
  63. /// Clean up any resources being used.
  64. /// </summary>
  65. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  66. protected override void Dispose(bool disposing)
  67. {
  68. if (disposing && (components != null))
  69. {
  70. components.Dispose();
  71. }
  72. base.Dispose(disposing);
  73. }
  74. #region Windows Form Designer generated code
  75. private void InitializeLanguageText()
  76. {
  77. this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
  78. this.button4.Text = PdnResources.GetString("Menu.File.SaveAs.Text");
  79. this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  80. this.label1.Text = PdnResources.GetString("Menu.Currentoperationstyle.text") + ":";
  81. this.button2.Text = PdnResources.GetString("Menu.application.text");
  82. this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
  83. this.groupBox1.Text = PdnResources.GetString("Menu.Type.text");
  84. this.radioButton2.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Imagewatermark.text");
  85. this.radioButton1.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Textwatermark.text");
  86. this.groupBox3.Text = PdnResources.GetString("Menu.Set.Watermarksettings.BasicInformation.text");
  87. this.button5.Text = PdnResources.GetString("Menu.browse.Text");
  88. this.radioButton3.Text = PdnResources.GetString("Menu.no.text");
  89. this.radioButton4.Text = PdnResources.GetString("Menu.Yes.text");
  90. this.label6.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Fromtheboundaryvalue.text") + ":";
  91. this.label5.Text = PdnResources.GetString("Menu.transparency.text") + ":";
  92. this.label4.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Tilewatermark.text") + ":";
  93. this.label3.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Watermarkposition.text") + ":";
  94. this.label2.Text = PdnResources.GetString("Menu.LabelAction.DrawWaterMark.Text") + ":";
  95. this.groupBox4.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.label10.Text = PdnResources.GetString("Menu.color.text") + ":";
  99. this.label9.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  100. this.label8.Text = PdnResources.GetString("Menu.Font.text") + ":";
  101. this.radioButton8.Text = PdnResources.GetString("Menu.Set.Watermarksettings.backwardlean.text");
  102. this.radioButton7.Text = PdnResources.GetString("Menu.Verticaldirection.text");
  103. this.label7.Text = PdnResources.GetString("Menu.direction.text") + ":";
  104. this.radioButton5.Text = PdnResources.GetString("Menu.Set.Watermarksettings.battering.text");
  105. this.radioButton6.Text = PdnResources.GetString("Menu.horizontaldirection.text");
  106. this.groupBox5.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Watermarkpreview.text");
  107. this.Text = PdnResources.GetString("Menu.Setting.WatermarkSetting.Text");
  108. }
  109. /// <summary>
  110. /// Required method for Designer support - do not modify
  111. /// the contents of this method with the code editor.
  112. /// </summary>
  113. private void InitializeComponent()
  114. {
  115. this.groupBox2 = new System.Windows.Forms.GroupBox();
  116. this.button4 = new System.Windows.Forms.Button();
  117. this.button3 = new System.Windows.Forms.Button();
  118. this.comboBox1 = new System.Windows.Forms.ComboBox();
  119. this.label1 = new System.Windows.Forms.Label();
  120. this.button2 = new System.Windows.Forms.Button();
  121. this.button1 = new System.Windows.Forms.Button();
  122. this.groupBox1 = new System.Windows.Forms.GroupBox();
  123. this.radioButton2 = new System.Windows.Forms.RadioButton();
  124. this.radioButton1 = new System.Windows.Forms.RadioButton();
  125. this.groupBox3 = new System.Windows.Forms.GroupBox();
  126. this.userTextBox1 = new System.Windows.Forms.TextBox();
  127. this.userTextBox3 = new PaintDotNet.CustomControl.UserTextBox();
  128. this.button5 = new System.Windows.Forms.Button();
  129. this.trackBar1 = new System.Windows.Forms.TrackBar();
  130. this.radioButton3 = new System.Windows.Forms.RadioButton();
  131. this.userTextBox2 = new PaintDotNet.CustomControl.UserTextBox();
  132. this.radioButton4 = new System.Windows.Forms.RadioButton();
  133. this.label6 = new System.Windows.Forms.Label();
  134. this.comboBox2 = new System.Windows.Forms.ComboBox();
  135. this.label5 = new System.Windows.Forms.Label();
  136. this.label4 = new System.Windows.Forms.Label();
  137. this.label3 = new System.Windows.Forms.Label();
  138. this.label2 = new System.Windows.Forms.Label();
  139. this.groupBox4 = new System.Windows.Forms.GroupBox();
  140. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  141. this.checkBox2 = new System.Windows.Forms.CheckBox();
  142. this.checkBox1 = new System.Windows.Forms.CheckBox();
  143. this.panel2 = new System.Windows.Forms.Panel();
  144. this.label10 = new System.Windows.Forms.Label();
  145. this.label9 = new System.Windows.Forms.Label();
  146. this.comboBox3 = new System.Windows.Forms.ComboBox();
  147. this.label8 = new System.Windows.Forms.Label();
  148. this.radioButton8 = new System.Windows.Forms.RadioButton();
  149. this.radioButton7 = new System.Windows.Forms.RadioButton();
  150. this.label7 = new System.Windows.Forms.Label();
  151. this.radioButton5 = new System.Windows.Forms.RadioButton();
  152. this.radioButton6 = new System.Windows.Forms.RadioButton();
  153. this.groupBox5 = new System.Windows.Forms.GroupBox();
  154. this.pictureBox2 = new System.Windows.Forms.PictureBox();
  155. this.groupBox2.SuspendLayout();
  156. this.groupBox1.SuspendLayout();
  157. this.groupBox3.SuspendLayout();
  158. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  159. this.groupBox4.SuspendLayout();
  160. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  161. this.groupBox5.SuspendLayout();
  162. ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
  163. this.SuspendLayout();
  164. //
  165. // groupBox2
  166. //
  167. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  168. | System.Windows.Forms.AnchorStyles.Right)));
  169. this.groupBox2.Controls.Add(this.button4);
  170. this.groupBox2.Controls.Add(this.button3);
  171. this.groupBox2.Controls.Add(this.comboBox1);
  172. this.groupBox2.Controls.Add(this.label1);
  173. this.groupBox2.Controls.Add(this.button2);
  174. this.groupBox2.Controls.Add(this.button1);
  175. this.groupBox2.Location = new System.Drawing.Point(13, 12);
  176. this.groupBox2.Name = "groupBox2";
  177. this.groupBox2.Size = new System.Drawing.Size(613, 58);
  178. this.groupBox2.TabIndex = 2;
  179. this.groupBox2.TabStop = false;
  180. //
  181. // button4
  182. //
  183. this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right;
  184. this.button4.Location = new System.Drawing.Point(361, 21);
  185. this.button4.Name = "button4";
  186. this.button4.Size = new System.Drawing.Size(75, 23);
  187. this.button4.TabIndex = 11;
  188. this.button4.Text = "另存为";
  189. this.button4.UseVisualStyleBackColor = true;
  190. this.button4.Click += new System.EventHandler(this.button4_Click);
  191. //
  192. // button3
  193. //
  194. this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right;
  195. this.button3.Location = new System.Drawing.Point(280, 21);
  196. this.button3.Name = "button3";
  197. this.button3.Size = new System.Drawing.Size(75, 23);
  198. this.button3.TabIndex = 10;
  199. this.button3.Text = "删除";
  200. this.button3.UseVisualStyleBackColor = true;
  201. this.button3.Click += new System.EventHandler(this.button3_Click);
  202. //
  203. // comboBox1
  204. //
  205. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  206. this.comboBox1.FormattingEnabled = true;
  207. this.comboBox1.Location = new System.Drawing.Point(114, 23);
  208. this.comboBox1.Name = "comboBox1";
  209. this.comboBox1.Size = new System.Drawing.Size(135, 20);
  210. this.comboBox1.TabIndex = 9;
  211. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  212. //
  213. // label1
  214. //
  215. this.label1.AutoSize = true;
  216. this.label1.Location = new System.Drawing.Point(19, 26);
  217. this.label1.Name = "label1";
  218. this.label1.Size = new System.Drawing.Size(89, 12);
  219. this.label1.TabIndex = 2;
  220. this.label1.Text = "当前操作样式:";
  221. //
  222. // button2
  223. //
  224. this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  225. this.button2.Location = new System.Drawing.Point(523, 21);
  226. this.button2.Name = "button2";
  227. this.button2.Size = new System.Drawing.Size(75, 23);
  228. this.button2.TabIndex = 1;
  229. this.button2.Text = "应用";
  230. this.button2.UseVisualStyleBackColor = true;
  231. this.button2.Click += new System.EventHandler(this.button2_Click);
  232. //
  233. // button1
  234. //
  235. this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  236. this.button1.Location = new System.Drawing.Point(442, 21);
  237. this.button1.Name = "button1";
  238. this.button1.Size = new System.Drawing.Size(75, 23);
  239. this.button1.TabIndex = 0;
  240. this.button1.Text = "保存";
  241. this.button1.UseVisualStyleBackColor = true;
  242. this.button1.Click += new System.EventHandler(this.button1_Click);
  243. //
  244. // groupBox1
  245. //
  246. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  247. | System.Windows.Forms.AnchorStyles.Right)));
  248. this.groupBox1.Controls.Add(this.radioButton2);
  249. this.groupBox1.Controls.Add(this.radioButton1);
  250. this.groupBox1.Location = new System.Drawing.Point(13, 76);
  251. this.groupBox1.Name = "groupBox1";
  252. this.groupBox1.Size = new System.Drawing.Size(613, 58);
  253. this.groupBox1.TabIndex = 3;
  254. this.groupBox1.TabStop = false;
  255. this.groupBox1.Text = "类型";
  256. //
  257. // radioButton2
  258. //
  259. this.radioButton2.AutoSize = true;
  260. this.radioButton2.Cursor = System.Windows.Forms.Cursors.Hand;
  261. this.radioButton2.Location = new System.Drawing.Point(284, 26);
  262. this.radioButton2.Name = "radioButton2";
  263. this.radioButton2.Size = new System.Drawing.Size(71, 16);
  264. this.radioButton2.TabIndex = 5;
  265. this.radioButton2.Text = "图片水印";
  266. this.radioButton2.UseVisualStyleBackColor = true;
  267. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
  268. //
  269. // radioButton1
  270. //
  271. this.radioButton1.AutoSize = true;
  272. this.radioButton1.Checked = true;
  273. this.radioButton1.Cursor = System.Windows.Forms.Cursors.Hand;
  274. this.radioButton1.Location = new System.Drawing.Point(19, 26);
  275. this.radioButton1.Name = "radioButton1";
  276. this.radioButton1.Size = new System.Drawing.Size(71, 16);
  277. this.radioButton1.TabIndex = 4;
  278. this.radioButton1.TabStop = true;
  279. this.radioButton1.Text = "文字水印";
  280. this.radioButton1.UseVisualStyleBackColor = true;
  281. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  282. //
  283. // groupBox3
  284. //
  285. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  286. | System.Windows.Forms.AnchorStyles.Right)));
  287. this.groupBox3.Controls.Add(this.userTextBox1);
  288. this.groupBox3.Controls.Add(this.userTextBox3);
  289. this.groupBox3.Controls.Add(this.button5);
  290. this.groupBox3.Controls.Add(this.trackBar1);
  291. this.groupBox3.Controls.Add(this.radioButton3);
  292. this.groupBox3.Controls.Add(this.userTextBox2);
  293. this.groupBox3.Controls.Add(this.radioButton4);
  294. this.groupBox3.Controls.Add(this.label6);
  295. this.groupBox3.Controls.Add(this.comboBox2);
  296. this.groupBox3.Controls.Add(this.label5);
  297. this.groupBox3.Controls.Add(this.label4);
  298. this.groupBox3.Controls.Add(this.label3);
  299. this.groupBox3.Controls.Add(this.label2);
  300. this.groupBox3.Location = new System.Drawing.Point(13, 140);
  301. this.groupBox3.Name = "groupBox3";
  302. this.groupBox3.Size = new System.Drawing.Size(613, 167);
  303. this.groupBox3.TabIndex = 4;
  304. this.groupBox3.TabStop = false;
  305. this.groupBox3.Text = "基本信息";
  306. //
  307. // userTextBox1
  308. //
  309. this.userTextBox1.Location = new System.Drawing.Point(90, 24);
  310. this.userTextBox1.MaxLength = 50;
  311. this.userTextBox1.Name = "userTextBox1";
  312. this.userTextBox1.Size = new System.Drawing.Size(508, 21);
  313. this.userTextBox1.TabIndex = 23;
  314. this.userTextBox1.TextChanged += new System.EventHandler(this.userTextBox1_TextChanged_1);
  315. //
  316. // userTextBox3
  317. //
  318. this.userTextBox3.Location = new System.Drawing.Point(375, 122);
  319. this.userTextBox3.Name = "userTextBox3";
  320. this.userTextBox3.ReadOnly = true;
  321. this.userTextBox3.Size = new System.Drawing.Size(46, 21);
  322. this.userTextBox3.TabIndex = 22;
  323. this.userTextBox3.Text = "0";
  324. //
  325. // button5
  326. //
  327. this.button5.Location = new System.Drawing.Point(523, 23);
  328. this.button5.Name = "button5";
  329. this.button5.Size = new System.Drawing.Size(75, 23);
  330. this.button5.TabIndex = 21;
  331. this.button5.UseVisualStyleBackColor = true;
  332. this.button5.Visible = false;
  333. this.button5.Click += new System.EventHandler(this.button5_Click);
  334. //
  335. // trackBar1
  336. //
  337. this.trackBar1.Cursor = System.Windows.Forms.Cursors.Hand;
  338. this.trackBar1.Location = new System.Drawing.Point(78, 116);
  339. this.trackBar1.Maximum = 255;
  340. this.trackBar1.Name = "trackBar1";
  341. this.trackBar1.Size = new System.Drawing.Size(262, 45);
  342. this.trackBar1.TabIndex = 1;
  343. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  344. this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
  345. //
  346. // radioButton3
  347. //
  348. this.radioButton3.AutoSize = true;
  349. this.radioButton3.Location = new System.Drawing.Point(186, 93);
  350. this.radioButton3.Name = "radioButton3";
  351. this.radioButton3.Size = new System.Drawing.Size(35, 16);
  352. this.radioButton3.TabIndex = 7;
  353. this.radioButton3.Text = "否";
  354. this.radioButton3.UseVisualStyleBackColor = true;
  355. this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
  356. //
  357. // userTextBox2
  358. //
  359. this.userTextBox2.Location = new System.Drawing.Point(382, 58);
  360. this.userTextBox2.MaxLength = 10;
  361. this.userTextBox2.Name = "userTextBox2";
  362. this.userTextBox2.Size = new System.Drawing.Size(216, 21);
  363. this.userTextBox2.TabIndex = 20;
  364. this.userTextBox2.TextChanged += new System.EventHandler(this.userTextBox2_TextChanged);
  365. //
  366. // radioButton4
  367. //
  368. this.radioButton4.AutoSize = true;
  369. this.radioButton4.Checked = true;
  370. this.radioButton4.Location = new System.Drawing.Point(90, 93);
  371. this.radioButton4.Name = "radioButton4";
  372. this.radioButton4.Size = new System.Drawing.Size(35, 16);
  373. this.radioButton4.TabIndex = 6;
  374. this.radioButton4.TabStop = true;
  375. this.radioButton4.Text = "是";
  376. this.radioButton4.UseVisualStyleBackColor = true;
  377. this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
  378. //
  379. // label6
  380. //
  381. this.label6.AutoSize = true;
  382. this.label6.Location = new System.Drawing.Point(304, 61);
  383. this.label6.Name = "label6";
  384. this.label6.Size = new System.Drawing.Size(65, 12);
  385. this.label6.TabIndex = 19;
  386. this.label6.Text = "距边界值:";
  387. //
  388. // comboBox2
  389. //
  390. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  391. this.comboBox2.FormattingEnabled = true;
  392. this.comboBox2.Location = new System.Drawing.Point(90, 58);
  393. this.comboBox2.Name = "comboBox2";
  394. this.comboBox2.Size = new System.Drawing.Size(197, 20);
  395. this.comboBox2.TabIndex = 18;
  396. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  397. //
  398. // label5
  399. //
  400. this.label5.AutoSize = true;
  401. this.label5.Location = new System.Drawing.Point(19, 125);
  402. this.label5.Name = "label5";
  403. this.label5.Size = new System.Drawing.Size(53, 12);
  404. this.label5.TabIndex = 17;
  405. this.label5.Text = "透明度:";
  406. //
  407. // label4
  408. //
  409. this.label4.AutoSize = true;
  410. this.label4.Location = new System.Drawing.Point(19, 93);
  411. this.label4.Name = "label4";
  412. this.label4.Size = new System.Drawing.Size(65, 12);
  413. this.label4.TabIndex = 16;
  414. this.label4.Text = "平铺水印:";
  415. //
  416. // label3
  417. //
  418. this.label3.AutoSize = true;
  419. this.label3.Location = new System.Drawing.Point(19, 61);
  420. this.label3.Name = "label3";
  421. this.label3.Size = new System.Drawing.Size(65, 12);
  422. this.label3.TabIndex = 15;
  423. this.label3.Text = "水印位置:";
  424. //
  425. // label2
  426. //
  427. this.label2.AutoSize = true;
  428. this.label2.Location = new System.Drawing.Point(19, 29);
  429. this.label2.Name = "label2";
  430. this.label2.Size = new System.Drawing.Size(41, 12);
  431. this.label2.TabIndex = 6;
  432. this.label2.Text = "水印:";
  433. //
  434. // groupBox4
  435. //
  436. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  437. | System.Windows.Forms.AnchorStyles.Right)));
  438. this.groupBox4.Controls.Add(this.numericUpDown1);
  439. this.groupBox4.Controls.Add(this.checkBox2);
  440. this.groupBox4.Controls.Add(this.checkBox1);
  441. this.groupBox4.Controls.Add(this.panel2);
  442. this.groupBox4.Controls.Add(this.label10);
  443. this.groupBox4.Controls.Add(this.label9);
  444. this.groupBox4.Controls.Add(this.comboBox3);
  445. this.groupBox4.Controls.Add(this.label8);
  446. this.groupBox4.Controls.Add(this.radioButton8);
  447. this.groupBox4.Controls.Add(this.radioButton7);
  448. this.groupBox4.Controls.Add(this.label7);
  449. this.groupBox4.Controls.Add(this.radioButton5);
  450. this.groupBox4.Controls.Add(this.radioButton6);
  451. this.groupBox4.Location = new System.Drawing.Point(13, 313);
  452. this.groupBox4.Name = "groupBox4";
  453. this.groupBox4.Size = new System.Drawing.Size(613, 118);
  454. this.groupBox4.TabIndex = 5;
  455. this.groupBox4.TabStop = false;
  456. this.groupBox4.Text = "扩展信息";
  457. //
  458. // numericUpDown1
  459. //
  460. this.numericUpDown1.Location = new System.Drawing.Point(375, 55);
  461. this.numericUpDown1.Minimum = new decimal(new int[] {
  462. 1,
  463. 0,
  464. 0,
  465. 0});
  466. this.numericUpDown1.Name = "numericUpDown1";
  467. this.numericUpDown1.Size = new System.Drawing.Size(192, 21);
  468. this.numericUpDown1.TabIndex = 26;
  469. this.numericUpDown1.Value = new decimal(new int[] {
  470. 12,
  471. 0,
  472. 0,
  473. 0});
  474. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  475. //
  476. // checkBox2
  477. //
  478. this.checkBox2.AutoSize = true;
  479. this.checkBox2.Location = new System.Drawing.Point(347, 93);
  480. this.checkBox2.Name = "checkBox2";
  481. this.checkBox2.Size = new System.Drawing.Size(48, 16);
  482. this.checkBox2.TabIndex = 25;
  483. this.checkBox2.Text = "斜体";
  484. this.checkBox2.UseVisualStyleBackColor = true;
  485. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  486. //
  487. // checkBox1
  488. //
  489. this.checkBox1.AutoSize = true;
  490. this.checkBox1.Location = new System.Drawing.Point(284, 93);
  491. this.checkBox1.Name = "checkBox1";
  492. this.checkBox1.Size = new System.Drawing.Size(48, 16);
  493. this.checkBox1.TabIndex = 24;
  494. this.checkBox1.Text = "粗体";
  495. this.checkBox1.UseVisualStyleBackColor = true;
  496. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  497. //
  498. // panel2
  499. //
  500. this.panel2.BackColor = System.Drawing.Color.Transparent;
  501. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  502. this.panel2.Location = new System.Drawing.Point(66, 88);
  503. this.panel2.Name = "panel2";
  504. this.panel2.Size = new System.Drawing.Size(191, 21);
  505. this.panel2.TabIndex = 23;
  506. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  507. //
  508. // label10
  509. //
  510. this.label10.AutoSize = true;
  511. this.label10.Location = new System.Drawing.Point(19, 90);
  512. this.label10.Name = "label10";
  513. this.label10.Size = new System.Drawing.Size(41, 12);
  514. this.label10.TabIndex = 22;
  515. this.label10.Text = "颜色:";
  516. //
  517. // label9
  518. //
  519. this.label9.AutoSize = true;
  520. this.label9.Location = new System.Drawing.Point(322, 58);
  521. this.label9.Name = "label9";
  522. this.label9.Size = new System.Drawing.Size(41, 12);
  523. this.label9.TabIndex = 20;
  524. this.label9.Text = "字号:";
  525. //
  526. // comboBox3
  527. //
  528. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  529. this.comboBox3.FormattingEnabled = true;
  530. this.comboBox3.Location = new System.Drawing.Point(66, 55);
  531. this.comboBox3.Name = "comboBox3";
  532. this.comboBox3.Size = new System.Drawing.Size(191, 20);
  533. this.comboBox3.TabIndex = 19;
  534. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  535. //
  536. // label8
  537. //
  538. this.label8.AutoSize = true;
  539. this.label8.Location = new System.Drawing.Point(19, 58);
  540. this.label8.Name = "label8";
  541. this.label8.Size = new System.Drawing.Size(41, 12);
  542. this.label8.TabIndex = 10;
  543. this.label8.Text = "字体:";
  544. //
  545. // radioButton8
  546. //
  547. this.radioButton8.AutoSize = true;
  548. this.radioButton8.Location = new System.Drawing.Point(333, 24);
  549. this.radioButton8.Name = "radioButton8";
  550. this.radioButton8.Size = new System.Drawing.Size(71, 16);
  551. this.radioButton8.TabIndex = 9;
  552. this.radioButton8.Text = "向后倾斜";
  553. this.radioButton8.UseVisualStyleBackColor = true;
  554. this.radioButton8.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
  555. //
  556. // radioButton7
  557. //
  558. this.radioButton7.AutoSize = true;
  559. this.radioButton7.Location = new System.Drawing.Point(159, 24);
  560. this.radioButton7.Name = "radioButton7";
  561. this.radioButton7.Size = new System.Drawing.Size(71, 16);
  562. this.radioButton7.TabIndex = 8;
  563. this.radioButton7.Text = "垂直方向";
  564. this.radioButton7.UseVisualStyleBackColor = true;
  565. this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged);
  566. //
  567. // label7
  568. //
  569. this.label7.AutoSize = true;
  570. this.label7.Location = new System.Drawing.Point(19, 26);
  571. this.label7.Name = "label7";
  572. this.label7.Size = new System.Drawing.Size(41, 12);
  573. this.label7.TabIndex = 7;
  574. this.label7.Text = "方向:";
  575. //
  576. // radioButton5
  577. //
  578. this.radioButton5.AutoSize = true;
  579. this.radioButton5.Location = new System.Drawing.Point(245, 24);
  580. this.radioButton5.Name = "radioButton5";
  581. this.radioButton5.Size = new System.Drawing.Size(71, 16);
  582. this.radioButton5.TabIndex = 5;
  583. this.radioButton5.Text = "向前倾斜";
  584. this.radioButton5.UseVisualStyleBackColor = true;
  585. this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
  586. //
  587. // radioButton6
  588. //
  589. this.radioButton6.AutoSize = true;
  590. this.radioButton6.Checked = true;
  591. this.radioButton6.Location = new System.Drawing.Point(77, 24);
  592. this.radioButton6.Name = "radioButton6";
  593. this.radioButton6.Size = new System.Drawing.Size(71, 16);
  594. this.radioButton6.TabIndex = 4;
  595. this.radioButton6.TabStop = true;
  596. this.radioButton6.Text = "水平方向";
  597. this.radioButton6.UseVisualStyleBackColor = true;
  598. this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
  599. //
  600. // groupBox5
  601. //
  602. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  603. | System.Windows.Forms.AnchorStyles.Right)));
  604. this.groupBox5.Controls.Add(this.pictureBox2);
  605. this.groupBox5.Location = new System.Drawing.Point(13, 437);
  606. this.groupBox5.Name = "groupBox5";
  607. this.groupBox5.Size = new System.Drawing.Size(613, 236);
  608. this.groupBox5.TabIndex = 6;
  609. this.groupBox5.TabStop = false;
  610. this.groupBox5.Text = "水印预览";
  611. //
  612. // pictureBox2
  613. //
  614. this.pictureBox2.Location = new System.Drawing.Point(6, 12);
  615. this.pictureBox2.Name = "pictureBox2";
  616. this.pictureBox2.Size = new System.Drawing.Size(601, 218);
  617. this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  618. this.pictureBox2.TabIndex = 1;
  619. this.pictureBox2.TabStop = false;
  620. //
  621. // WatermarkSettingsDialog
  622. //
  623. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  624. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  625. this.AutoScroll = true;
  626. this.ClientSize = new System.Drawing.Size(637, 691);
  627. this.Controls.Add(this.groupBox5);
  628. this.Controls.Add(this.groupBox4);
  629. this.Controls.Add(this.groupBox3);
  630. this.Controls.Add(this.groupBox1);
  631. this.Controls.Add(this.groupBox2);
  632. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  633. this.MaximizeBox = false;
  634. this.MinimizeBox = false;
  635. this.Name = "WatermarkSettingsDialog";
  636. this.Text = "水印设置";
  637. this.Controls.SetChildIndex(this.groupBox2, 0);
  638. this.Controls.SetChildIndex(this.groupBox1, 0);
  639. this.Controls.SetChildIndex(this.groupBox3, 0);
  640. this.Controls.SetChildIndex(this.groupBox4, 0);
  641. this.Controls.SetChildIndex(this.groupBox5, 0);
  642. this.groupBox2.ResumeLayout(false);
  643. this.groupBox2.PerformLayout();
  644. this.groupBox1.ResumeLayout(false);
  645. this.groupBox1.PerformLayout();
  646. this.groupBox3.ResumeLayout(false);
  647. this.groupBox3.PerformLayout();
  648. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  649. this.groupBox4.ResumeLayout(false);
  650. this.groupBox4.PerformLayout();
  651. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  652. this.groupBox5.ResumeLayout(false);
  653. ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
  654. this.ResumeLayout(false);
  655. }
  656. private void InitializeColorForm()
  657. {
  658. this.colorsForm = new PaintDotNet.ColorsForm();
  659. //
  660. // colorsForm
  661. //
  662. this.colorsForm.AnalyzeSettingModel = null;
  663. this.colorsForm.ClientSize = new System.Drawing.Size(209, 217);
  664. this.colorsForm.EnableInstanceOpacity = true;
  665. this.colorsForm.ForceActiveTitleBar = true;
  666. this.colorsForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  667. this.colorsForm.KeyPreview = true;
  668. this.colorsForm.Location = new System.Drawing.Point(0, 0);
  669. this.colorsForm.MaximizeBox = false;
  670. this.colorsForm.MinimizeBox = false;
  671. this.colorsForm.Name = "colorsForm";
  672. this.colorsForm.ShowInTaskbar = false;
  673. this.colorsForm.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
  674. this.colorsForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  675. this.colorsForm.Visible = false;
  676. this.colorsForm.WhichUserColor = PaintDotNet.WhichUserColor.Primary;
  677. this.colorsForm.Load += new System.EventHandler(this.colorsForm_Load);
  678. }
  679. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  680. {
  681. }
  682. /// <summary>
  683. /// 画板点击
  684. /// </summary>
  685. /// <param name="sender"></param>
  686. /// <param name="e"></param>
  687. private void panel2_Click(object sender, EventArgs e)
  688. {
  689. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  690. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  691. this.colorsForm.ShowDialog();
  692. }
  693. private void panel2Changed(object sender, EventArgs e)
  694. {
  695. this.panel2.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  696. this.watermarkModel.color = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  697. this.pictureBox2.Invalidate();
  698. this.colorsForm.Close();
  699. }
  700. #endregion
  701. #endregion
  702. /// <summary>
  703. /// 另存为文件名
  704. /// </summary>
  705. private string newName;
  706. /// <summary>
  707. /// 操作样式下拉数据
  708. /// </summary>
  709. private List<string> files = new List<string>();
  710. private float localX = 0;
  711. private float localY = 0;
  712. private WatermarkModel watermarkModel = Startup.instance.watermarkModel;
  713. /// <summary>
  714. /// 旋转角度
  715. /// </summary>
  716. private int angle = 0;
  717. /// <summary>
  718. /// 水印位置下拉选
  719. /// </summary>
  720. string[] position = new string[]
  721. { PdnResources.GetString("Menu.Set.Watermarksettings.Topleft.text"),
  722. PdnResources.GetString("Menu.Set.Watermarksettings.Topmiddle.text"),
  723. PdnResources.GetString("Menu.Set.Watermarksettings.Topright.text"),
  724. PdnResources.GetString("Menu.Set.Watermarksettings.Middleleft.text"),
  725. PdnResources.GetString("Menu.nthemiddle.Text"),
  726. PdnResources.GetString("Menu.Set.Watermarksettings.Middleright.text"),
  727. PdnResources.GetString("Menu.Set.Watermarksettings.Bottomleft.text"),
  728. PdnResources.GetString("Menu.Set.Watermarksettings.Bottommiddle.text"),
  729. PdnResources.GetString("Menu.Set.Watermarksettings.Bottomright.text") };
  730. /// <summary>
  731. /// 暂存文字水印信息
  732. /// </summary>
  733. string waterMarkText = "";
  734. /// <summary>
  735. /// 暂存图片水印路径
  736. /// </summary>
  737. string waterMarkImagePath = "";
  738. CreateNameDialog dialog;
  739. public WatermarkSettingsDialog()
  740. {
  741. InitializeComponent();
  742. InitializeLanguageText();
  743. InitializeColorForm();
  744. InitializeControl();
  745. InitializeData();
  746. }
  747. /// <summary>
  748. /// 处理控件
  749. /// </summary>
  750. private void InitializeControl()
  751. {
  752. this.pictureBox2.Paint += new PaintEventHandler(this.pictureBox2_Paint);
  753. }
  754. /// <summary>
  755. /// pictureBox的绘制事件
  756. /// </summary>
  757. /// <param name="sender"></param>
  758. /// <param name="e"></param>
  759. private void pictureBox2_Paint(object sender, PaintEventArgs e)
  760. {
  761. WatermarkModel model = new WatermarkModel();
  762. model = watermarkModel;
  763. if (this.checkBox1.Checked)
  764. {
  765. model.bold = 1;
  766. }
  767. else
  768. {
  769. model.bold = 2;
  770. }
  771. if (this.checkBox2.Checked)
  772. {
  773. model.italic = 1;
  774. }
  775. else
  776. {
  777. model.italic = 2;
  778. }
  779. model.position = this.comboBox2.SelectedIndex + 1;
  780. model.typeface = this.comboBox3.Text;
  781. model.fontSize = Int32.Parse(this.numericUpDown1.Value.ToString());
  782. if (this.radioButton2.Checked)
  783. {
  784. //drawWatermarkImage(e.Graphics, model);
  785. drawWatermarkImage(e.Graphics, model);
  786. }
  787. else
  788. {
  789. drawWatermarkText(e.Graphics, model);
  790. }
  791. }
  792. /// <summary>
  793. /// 初始化数据
  794. /// </summary>
  795. private void InitializeData()
  796. {
  797. //绑定字体下拉
  798. ArrayList fontsItems = new ArrayList();
  799. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  800. foreach (FontFamily fontFamily in fonts.Families)
  801. {
  802. fontsItems.Add(fontFamily.Name);
  803. }
  804. this.comboBox3.DataSource = fontsItems;
  805. //绑定位置下拉
  806. this.comboBox2.DataSource = position;
  807. //绑定样式下拉
  808. InitializeStyleName();
  809. }
  810. /// <summary>
  811. /// 绑定样式下拉
  812. /// </summary>
  813. private void InitializeStyleName()
  814. {
  815. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\");
  816. files.Clear();
  817. foreach (string fileName in fileNames)
  818. {
  819. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  820. files.Add(name);
  821. }
  822. this.comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
  823. this.comboBox1.DataSource = null;
  824. this.comboBox1.DataSource = files;
  825. string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
  826. this.comboBox1.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
  827. watermarkModel = XmlSerializeHelper.DESerializer<WatermarkModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  828. InitializeWaterData();
  829. this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
  830. }
  831. /// <summary>
  832. /// 初始化控件的值
  833. /// </summary>
  834. private void InitializeWaterData()
  835. {
  836. // 水印类型 1文字水印 2图片水印
  837. if (this.watermarkModel.watermarkType == 2)
  838. {
  839. this.radioButton2.Checked = true;
  840. }
  841. else
  842. {
  843. this.radioButton1.Checked = true;
  844. }
  845. // 水印文字
  846. this.userTextBox1.Text = this.watermarkModel.content;
  847. //水印位置
  848. this.comboBox2.SelectedIndex = this.watermarkModel.position - 1;
  849. // 距边界值
  850. this.userTextBox2.Text = this.watermarkModel.margin + "";
  851. // 平铺水印
  852. if (this.watermarkModel.spread == 2)
  853. {
  854. this.radioButton3.Checked = true;
  855. }
  856. else
  857. {
  858. this.radioButton4.Checked = true;
  859. }
  860. // 透明度
  861. this.trackBar1.Value = this.watermarkModel.transparency;
  862. this.userTextBox3.Text = this.watermarkModel.transparency + "";
  863. // 方向
  864. switch (this.watermarkModel.direction)
  865. {
  866. case 1:
  867. this.radioButton6.Checked = true;
  868. break;
  869. case 2:
  870. this.radioButton7.Checked = true;
  871. break;
  872. case 3:
  873. this.radioButton5.Checked = true;
  874. break;
  875. case 4:
  876. this.radioButton8.Checked = true;
  877. break;
  878. default:
  879. this.radioButton6.Checked = true;
  880. break;
  881. }
  882. //字体
  883. this.comboBox3.Text = this.watermarkModel.typeface;
  884. //字号
  885. this.numericUpDown1.Value = this.watermarkModel.fontSize;
  886. // 水印文字-颜色
  887. this.panel2.BackColor = Color.FromArgb(this.watermarkModel.color);
  888. // 粗体
  889. if (this.watermarkModel.bold == 1)
  890. {
  891. this.checkBox1.Checked = true;
  892. }
  893. // 斜体
  894. if (this.watermarkModel.italic == 1)
  895. {
  896. this.checkBox2.Checked = true;
  897. }
  898. this.pictureBox2.Invalidate();
  899. //comboBox1_SelectedIndexChanged(null,null);
  900. }
  901. /// <summary>
  902. /// 当前操作样式
  903. /// </summary>
  904. /// <param name="sender"></param>
  905. /// <param name="e"></param>
  906. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  907. {
  908. watermarkModel = XmlSerializeHelper.DESerializer<WatermarkModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  909. InitializeWaterData();
  910. }
  911. /// <summary>
  912. /// 文字水印
  913. /// </summary>
  914. /// <param name="sender"></param>
  915. /// <param name="e"></param>
  916. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  917. {
  918. if (radioButton1.Checked)
  919. {
  920. waterMarkImagePath = this.userTextBox1.Text;
  921. this.userTextBox1.Text = waterMarkText;
  922. this.userTextBox1.ReadOnly = false;
  923. this.watermarkModel.watermarkType = 1;
  924. this.groupBox4.Visible = true; // 扩展信息
  925. this.button5.Visible = false;
  926. this.userTextBox1.Size = new Size(508, 21);
  927. this.groupBox5.Location = new System.Drawing.Point(12, 437);
  928. }
  929. }
  930. /// <summary>
  931. /// 图片水印
  932. /// </summary>
  933. /// <param name="sender"></param>
  934. /// <param name="e"></param>
  935. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  936. {
  937. if (radioButton2.Checked)
  938. {
  939. waterMarkText = this.userTextBox1.Text;
  940. this.userTextBox1.Text = waterMarkImagePath;
  941. this.userTextBox1.ReadOnly = true;
  942. this.pictureBox2.Refresh();
  943. this.watermarkModel.watermarkType = 2;
  944. this.groupBox4.Visible = false; // 扩展信息
  945. this.button5.Visible = true;
  946. this.userTextBox1.Size = new Size(508 - 75, 21);
  947. this.groupBox5.Location = new System.Drawing.Point(12, 313);
  948. }
  949. }
  950. /// <summary>
  951. /// 基本信息-水印-水印文字
  952. /// </summary>
  953. /// <param name="sender"></param>
  954. /// <param name="e"></param>
  955. private void userTextBox1_TextChanged(object sender, EventArgs e)
  956. {
  957. }
  958. /// <summary>
  959. /// 基本信息-水印-选择图片水印
  960. /// </summary>
  961. /// <param name="sender"></param>
  962. /// <param name="e"></param>
  963. private void button5_Click(object sender, EventArgs e)
  964. {
  965. var openFileDialog1 = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };
  966. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  967. {
  968. this.userTextBox1.Text = openFileDialog1.InitialDirectory + openFileDialog1.FileName;
  969. this.watermarkModel.content = this.userTextBox1.Text;
  970. Image image = Image.FromFile(openFileDialog1.FileName);
  971. }
  972. }
  973. private void userTextBox1_TextChanged_1(object sender, EventArgs e)
  974. {
  975. if (this.watermarkModel.content == "")
  976. {
  977. this.watermarkModel.content = this.userTextBox1.Text;
  978. }
  979. this.pictureBox2.Invalidate();
  980. }
  981. /// <summary>
  982. /// 基本信息-透明度滑块
  983. /// </summary>
  984. /// <param name="sender"></param>
  985. /// <param name="e"></param>
  986. private void trackBar1_Scroll(object sender, EventArgs e)
  987. {
  988. this.userTextBox3.Text = "" + this.trackBar1.Value;
  989. this.watermarkModel.transparency = this.trackBar1.Value;
  990. this.pictureBox2.Invalidate();
  991. }
  992. /// <summary>
  993. /// 距边界值
  994. /// </summary>
  995. /// <param name="sender"></param>
  996. /// <param name="e"></param>
  997. private void userTextBox2_TextChanged(object sender, EventArgs e)
  998. {
  999. if (string.IsNullOrEmpty(this.userTextBox2.Text))
  1000. {
  1001. MessageBox.Show(PdnResources.GetString("Menu.edistancefromtheboundaryaluecanno.Text"));
  1002. return;
  1003. }
  1004. this.watermarkModel.margin = Int32.Parse(this.userTextBox2.Text);
  1005. this.pictureBox2.Invalidate();
  1006. }
  1007. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  1008. {
  1009. this.watermarkModel.spread = 1;
  1010. this.pictureBox2.Invalidate();
  1011. }
  1012. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  1013. {
  1014. this.watermarkModel.spread = 2;
  1015. this.pictureBox2.Invalidate();
  1016. }
  1017. /// <summary>
  1018. /// 扩展信息-方向- 向前倾斜
  1019. /// </summary>
  1020. /// <param name="sender"></param>
  1021. /// <param name="e"></param>
  1022. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  1023. {
  1024. this.angle = -45;
  1025. this.watermarkModel.direction = 3;
  1026. this.pictureBox2.Invalidate();
  1027. }
  1028. private void radioButton6_CheckedChanged(object sender, EventArgs e)
  1029. {
  1030. this.angle = 0;
  1031. this.watermarkModel.direction = 1;
  1032. this.pictureBox2.Invalidate();
  1033. }
  1034. private void radioButton7_CheckedChanged(object sender, EventArgs e)
  1035. {
  1036. this.angle = 90;
  1037. this.watermarkModel.direction = 2;
  1038. this.pictureBox2.Invalidate();
  1039. }
  1040. private void radioButton8_CheckedChanged(object sender, EventArgs e)
  1041. {
  1042. this.angle = 45;
  1043. this.watermarkModel.direction = 4;
  1044. this.pictureBox2.Invalidate();
  1045. }
  1046. /// <summary>
  1047. /// 删除
  1048. /// </summary>
  1049. /// <param name="sender"></param>
  1050. /// <param name="e"></param>
  1051. private void button3_Click(object sender, EventArgs e)
  1052. {
  1053. if ("Default".Equals(this.comboBox1.Text))
  1054. {
  1055. MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1056. return;
  1057. }
  1058. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1059. if (dr == DialogResult.OK)
  1060. {
  1061. int newIndex = 0;
  1062. int selectIndex = this.comboBox1.SelectedIndex;
  1063. int tall = files.Count - 1;
  1064. if (selectIndex < tall)
  1065. {
  1066. newIndex = selectIndex;
  1067. }
  1068. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.Text + ".xml";
  1069. FileInfo fileInfo = new FileInfo(filePath);
  1070. fileInfo.Delete();
  1071. InitializeStyleName();
  1072. this.comboBox1.SelectedIndex = newIndex;
  1073. watermarkModel = XmlSerializeHelper.DESerializer<WatermarkModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  1074. InitializeWaterData();
  1075. }
  1076. else if (dr == DialogResult.Cancel)
  1077. {
  1078. }
  1079. }
  1080. /// <summary>
  1081. /// 另存为
  1082. /// </summary>
  1083. /// <param name="sender"></param>
  1084. /// <param name="e"></param>
  1085. private void button4_Click(object sender, EventArgs e)
  1086. {
  1087. dialog = new CreateNameDialog(this);
  1088. dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
  1089. dialog.StartPosition = FormStartPosition.CenterParent;
  1090. dialog.ShowDialog();
  1091. }
  1092. /// <summary>
  1093. /// 另存配置文件
  1094. /// </summary>
  1095. private void CopyConfigAndRename()
  1096. {
  1097. if (this.checkBox1.Checked)
  1098. {
  1099. this.watermarkModel.bold = 1;
  1100. }
  1101. else
  1102. {
  1103. this.watermarkModel.bold = 2;
  1104. }
  1105. if (this.checkBox2.Checked)
  1106. {
  1107. this.watermarkModel.italic = 1;
  1108. }
  1109. else
  1110. {
  1111. this.watermarkModel.italic = 2;
  1112. }
  1113. this.watermarkModel.content = this.userTextBox1.Text;
  1114. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1115. this.watermarkModel.typeface = this.comboBox3.Text;
  1116. this.watermarkModel.fontSize = Int32.Parse(this.numericUpDown1.Value.ToString());
  1117. string stageModelXml = XmlSerializeHelper.XmlSerialize<WatermarkModel>(this.watermarkModel);
  1118. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.newName + ".xml";
  1119. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1120. }
  1121. /// <summary>
  1122. /// 保存当前配置文件
  1123. /// </summary>
  1124. /// <param name="sender"></param>
  1125. /// <param name="e"></param>
  1126. private void button1_Click(object sender, EventArgs e)
  1127. {
  1128. if (this.checkBox1.Checked)
  1129. {
  1130. this.watermarkModel.bold = 1;
  1131. }
  1132. else
  1133. {
  1134. this.watermarkModel.bold = 2;
  1135. }
  1136. if (this.checkBox2.Checked)
  1137. {
  1138. this.watermarkModel.italic = 1;
  1139. }
  1140. else
  1141. {
  1142. this.watermarkModel.italic = 2;
  1143. }
  1144. this.watermarkModel.content = this.userTextBox1.Text;
  1145. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1146. this.watermarkModel.typeface = this.comboBox3.Text;
  1147. this.watermarkModel.fontSize = Int32.Parse(this.numericUpDown1.Value.ToString());
  1148. string stageModelXml = XmlSerializeHelper.XmlSerialize<WatermarkModel>(this.watermarkModel);
  1149. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.Text + ".xml";
  1150. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1151. this.pictureBox2.Invalidate();
  1152. }
  1153. /// <summary>
  1154. /// 应用当前的水印配置
  1155. /// </summary>
  1156. /// <param name="sender"></param>
  1157. /// <param name="e"></param>
  1158. private void button2_Click(object sender, EventArgs e)
  1159. {
  1160. Startup.instance.watermarkModel = this.watermarkModel;
  1161. }
  1162. public override void GetCreateName(string name)
  1163. {
  1164. this.newName = name;
  1165. if (files.Contains(this.newName))
  1166. {
  1167. MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1168. return;
  1169. }
  1170. CopyConfigAndRename();
  1171. InitializeStyleName();
  1172. dialog.Close();
  1173. }
  1174. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  1175. {
  1176. this.pictureBox2.Invalidate();
  1177. }
  1178. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  1179. {
  1180. this.pictureBox2.Invalidate();
  1181. }
  1182. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1183. {
  1184. this.pictureBox2.Invalidate();
  1185. }
  1186. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1187. {
  1188. this.pictureBox2.Invalidate();
  1189. }
  1190. /// <summary>
  1191. /// 绘制水印-文字
  1192. /// </summary>
  1193. /// <param name="graphics">画布</param>
  1194. /// <param name="model">水印信息</param>
  1195. public void drawWatermarkText(Graphics graphics, WatermarkModel model)
  1196. {
  1197. int width = this.pictureBox2.Width;
  1198. int height = this.pictureBox2.Height;
  1199. int padding = model.margin;
  1200. string text = model.content;
  1201. string fontVal = model.typeface; // 字体
  1202. int fontSize = model.fontSize * 2; // 字号
  1203. int transparency = model.transparency;// 透明度
  1204. Color color = Color.FromArgb(transparency, Color.FromArgb(model.color));// 颜色
  1205. Font font = new Font(fontVal, fontSize, GraphicsUnit.Pixel);
  1206. if (model.bold == 1)
  1207. {
  1208. font = new Font(fontVal, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);//粗体
  1209. }
  1210. if (model.italic == 1)
  1211. {
  1212. font = new Font(fontVal, fontSize, FontStyle.Italic, GraphicsUnit.Pixel);//斜体
  1213. }
  1214. if (model.italic == 1 && model.bold == 1)
  1215. {
  1216. font = new Font(fontVal, fontSize, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Pixel);//加粗斜体
  1217. }
  1218. //获取可以用来绘制水印图片的有效区域
  1219. Rectangle validRect = new Rectangle(padding, padding, width - padding * 2, height - padding * 2);
  1220. if (model.spread == 2)
  1221. {
  1222. SizeF sf = graphics.MeasureString(text, font); //获取需要绘制的字符串大小
  1223. StringFormat format = GetStringFormat(model.position, sf.Width, sf.Height, this.pictureBox2.Width, this.pictureBox2.Height, model.margin); //获取绘画水印文字的格式,即文字对齐方式
  1224. Matrix mtxSave = graphics.Transform; //原始旋转矩阵
  1225. Matrix matrix = graphics.Transform;
  1226. matrix.RotateAt((float)angle, new PointF(localX + sf.Width / 2, localY + sf.Height / 2));
  1227. graphics.Transform = matrix;
  1228. graphics.DrawString(text, font, new SolidBrush(color), localX, localY);
  1229. graphics.Transform = mtxSave; //还原为原始旋转矩阵
  1230. //graphics.DrawString(text, font, new SolidBrush(color), validRect, format);
  1231. }
  1232. else if (model.spread == 1)
  1233. {
  1234. float textLength = font.Size * text.Length + 30;
  1235. float xpos = 0;
  1236. float ypos = 0;
  1237. // 倾斜
  1238. graphics.RotateTransform(this.angle);
  1239. // 循环打印文字水印
  1240. for (float i = -width / 2; i < width * 1.5; i = i + textLength)
  1241. {
  1242. xpos = i;
  1243. for (float j = -3 * height; j < height * 2.5; j += 50)
  1244. {
  1245. ypos = j;
  1246. graphics.DrawString(text, font, new SolidBrush(color), xpos, ypos);
  1247. }
  1248. }
  1249. }
  1250. }
  1251. /// <summary>
  1252. /// 获取文字水印位置
  1253. /// </summary>
  1254. /// <param name="pos">
  1255. /// 左顶,顶中,右顶,左中,居中,右中,左底,底中,右底
  1256. /// 1左上,2中上,3右上
  1257. /// 4左中,5中, 6右中
  1258. /// 7左下,8中下,9右下
  1259. /// </param>
  1260. /// <returns></returns>
  1261. public StringFormat GetStringFormat(int pos, float textwidth, float textheigth, int width, int heigth, int margin)
  1262. {
  1263. StringFormat format = new StringFormat();
  1264. switch (pos)
  1265. {
  1266. case 1:
  1267. format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Near;
  1268. localX = margin;
  1269. localY = margin;
  1270. break;
  1271. case 2:
  1272. format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Near;
  1273. localX = (width - 2 * margin) / 2 - textwidth / 2;
  1274. localY = margin;
  1275. break;
  1276. case 3:
  1277. format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Near;
  1278. localX = (width - 2 * margin) - textwidth;
  1279. localY = margin;
  1280. break;
  1281. case 4:
  1282. format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center;
  1283. localX = margin;
  1284. localY = (heigth - 2 * margin) / 2 - textheigth / 2;
  1285. break;
  1286. case 5:
  1287. localX = (width - 2 * margin) / 2 - textwidth / 2;
  1288. localY = (heigth - 2 * margin) / 2 - textheigth / 2;
  1289. break;
  1290. case 6:
  1291. format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Center;
  1292. localX = (width - 2 * margin) - textwidth;
  1293. localY = (heigth - 2 * margin) / 2 - textheigth / 2;
  1294. break;
  1295. case 7:
  1296. format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Far;
  1297. localX = margin;
  1298. localY = (heigth - 2 * margin) - textheigth;
  1299. break;
  1300. case 8:
  1301. format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Far;
  1302. localX = (width - 2 * margin) / 2 - textwidth / 2;
  1303. localY = (heigth - 2 * margin) - textheigth;
  1304. break;
  1305. case 9:
  1306. format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Far;
  1307. localX = (width - 2 * margin) - textwidth;
  1308. localY = (heigth - 2 * margin) - textheigth;
  1309. break;
  1310. default:
  1311. format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center;
  1312. break;
  1313. }
  1314. return format;
  1315. }
  1316. /// <summary>
  1317. /// 图片透明度属性
  1318. /// </summary>
  1319. /// <param name="opcity"></param>
  1320. /// <returns></returns>
  1321. public ImageAttributes GetAlphaImgAttr(int opcity)
  1322. {
  1323. if (opcity < 0 || opcity > 255)
  1324. {
  1325. throw new ArgumentOutOfRangeException("opcity 值为 0~255");
  1326. }
  1327. //颜色矩阵
  1328. float[][] matrixItems =
  1329. {
  1330. new float[]{1,0,0,0,0},
  1331. new float[]{0,1,0,0,0},
  1332. new float[]{0,0,1,0,0},
  1333. new float[]{0,0,0,(float)opcity / 255, 0},
  1334. new float[]{0,0,0,0,1}
  1335. };
  1336. ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
  1337. ImageAttributes imageAtt = new ImageAttributes();
  1338. imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
  1339. return imageAtt;
  1340. }
  1341. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  1342. {
  1343. this.pictureBox2.Invalidate();
  1344. }
  1345. /// <summary>
  1346. /// 绘制水印-图片
  1347. /// </summary>
  1348. /// <param name="graphics">画布</param>
  1349. /// <param name="model">水印信息</param>
  1350. public void drawWatermarkImage(Graphics graphics, WatermarkModel watermarkModel)
  1351. {
  1352. string waterPath = watermarkModel.content;
  1353. int position = watermarkModel.position; // 设置水印位置,1左上,2中上,3右上,4左中,5中, 6右中,7左下,8中下,9右下
  1354. int padding = watermarkModel.margin;
  1355. int opcity = watermarkModel.transparency;
  1356. Image waterImage = null;
  1357. if (string.IsNullOrEmpty(waterPath))
  1358. {
  1359. return;
  1360. }
  1361. try
  1362. {
  1363. waterImage = Image.FromFile(waterPath, false); //获取水印图片
  1364. }
  1365. catch (Exception)
  1366. {
  1367. return;
  1368. }
  1369. var waterRect = new Rectangle(0, 0, waterImage.Width, waterImage.Height);
  1370. if (opcity <= 0)
  1371. {
  1372. return;
  1373. }
  1374. Rectangle validRect = new Rectangle(padding, padding, this.pictureBox2.Width - padding * 2, this.pictureBox2.Height - padding * 2); //获取可以用来绘制水印图片的有效区域
  1375. ImageAttributes imageAtt = GetAlphaImgAttr(opcity);
  1376. Rectangle destRect = GetRectangleByPostion(validRect, waterRect, position); //计算水印图片的绘制位置
  1377. if (watermarkModel.spread == 2) // 非水印平铺
  1378. {
  1379. //Rectangle destRect = GetRectangleByPostion(validRect, waterRect, position); //计算水印图片的绘制位置
  1380. if (opcity == 255) //如果不透明度=100,那么直接将水印画到当前画布上.
  1381. {
  1382. graphics.DrawImage(waterImage, destRect, waterRect, GraphicsUnit.Pixel);
  1383. }
  1384. else //如果不透明度在0到255之间,设置透明参数
  1385. {
  1386. graphics.DrawImage(waterImage, destRect, 0, 0, waterRect.Width, waterRect.Height, GraphicsUnit.Pixel, imageAtt);//将水印图片画到画布上
  1387. }
  1388. }
  1389. else if (watermarkModel.spread == 1) // 水印平铺
  1390. {
  1391. int width = this.pictureBox2.Width;
  1392. int height = this.pictureBox2.Height;
  1393. float imageLength = waterImage.Width + 10;
  1394. float imageHeight = waterImage.Height + 10;
  1395. float xpos = 0;
  1396. float ypos = 0;
  1397. // 循环打印文字水印
  1398. for (float i = watermarkModel.margin; i <= width; i += imageLength)
  1399. {
  1400. xpos = i;
  1401. for (float j = watermarkModel.margin; j <= height; j += imageHeight)
  1402. {
  1403. ypos = j;
  1404. destRect.X = (int)xpos;
  1405. destRect.Y = (int)ypos;
  1406. graphics.DrawImage(waterImage, destRect, 0, 0, waterRect.Width, waterRect.Height, GraphicsUnit.Pixel, imageAtt);//将水印图片画到画布上
  1407. }
  1408. }
  1409. }
  1410. }
  1411. /// <summary>
  1412. /// 获取图片水印位置,及small在big里的位置
  1413. /// 如果small的高度大于big的高度,返回big的高度
  1414. /// 如果small的宽度大于big的宽度,返回big的宽度
  1415. /// </summary>
  1416. /// <param name="pos">
  1417. /// 1左上,2中上,3右上
  1418. /// 4左中,5中, 6右中
  1419. /// 7左下,8中下,9右下
  1420. /// </param>
  1421. /// <returns></returns>
  1422. public Rectangle GetRectangleByPostion(Rectangle big, Rectangle small, int pos)
  1423. {
  1424. if (big.Width < small.Width)
  1425. {
  1426. small.Width = big.Width;
  1427. }
  1428. if (big.Height < small.Height)
  1429. {
  1430. small.Height = big.Height;
  1431. }
  1432. Rectangle retVal = small;
  1433. switch (pos)
  1434. {
  1435. case 1: retVal.X = 0; retVal.Y = 0; break;
  1436. case 2: retVal.X = (big.Width - small.Width) / 2; retVal.Y = 0; break;
  1437. case 3: retVal.X = big.Width - small.Width; retVal.Y = 0; break;
  1438. case 4: retVal.X = 0; retVal.Y = (big.Height - small.Height) / 2; break;
  1439. case 6: retVal.X = big.Width - small.Width; retVal.Y = (big.Height - small.Height) / 2; break;
  1440. case 7: retVal.X = 0; retVal.Y = big.Height - small.Height; break;
  1441. case 8: retVal.X = (big.Width - small.Width) / 2; retVal.Y = big.Height - small.Height; break;
  1442. case 9: retVal.X = big.Width - small.Width; retVal.Y = big.Height - small.Height; break;
  1443. default: retVal.X = (big.Width - small.Width) / 2; retVal.Y = (big.Height - small.Height) / 2; break;
  1444. }
  1445. retVal.X += big.X;
  1446. retVal.Y += big.Y;
  1447. return retVal;
  1448. }
  1449. private void colorsForm_Load(object sender, EventArgs e)
  1450. {
  1451. }
  1452. }
  1453. }