WatermarkSettingsDialog.cs 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554
  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.Maximum = new decimal(new int[] {
  462. 49000,
  463. 0,
  464. 0,
  465. 0});
  466. this.numericUpDown1.Minimum = new decimal(new int[] {
  467. 1,
  468. 0,
  469. 0,
  470. 0});
  471. this.numericUpDown1.Name = "numericUpDown1";
  472. this.numericUpDown1.Size = new System.Drawing.Size(192, 21);
  473. this.numericUpDown1.TabIndex = 26;
  474. this.numericUpDown1.Value = new decimal(new int[] {
  475. 12,
  476. 0,
  477. 0,
  478. 0});
  479. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  480. //
  481. // checkBox2
  482. //
  483. this.checkBox2.AutoSize = true;
  484. this.checkBox2.Location = new System.Drawing.Point(347, 93);
  485. this.checkBox2.Name = "checkBox2";
  486. this.checkBox2.Size = new System.Drawing.Size(48, 16);
  487. this.checkBox2.TabIndex = 25;
  488. this.checkBox2.Text = "斜体";
  489. this.checkBox2.UseVisualStyleBackColor = true;
  490. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  491. //
  492. // checkBox1
  493. //
  494. this.checkBox1.AutoSize = true;
  495. this.checkBox1.Location = new System.Drawing.Point(284, 93);
  496. this.checkBox1.Name = "checkBox1";
  497. this.checkBox1.Size = new System.Drawing.Size(48, 16);
  498. this.checkBox1.TabIndex = 24;
  499. this.checkBox1.Text = "粗体";
  500. this.checkBox1.UseVisualStyleBackColor = true;
  501. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  502. //
  503. // panel2
  504. //
  505. this.panel2.BackColor = System.Drawing.Color.Transparent;
  506. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  507. this.panel2.Location = new System.Drawing.Point(66, 88);
  508. this.panel2.Name = "panel2";
  509. this.panel2.Size = new System.Drawing.Size(191, 21);
  510. this.panel2.TabIndex = 23;
  511. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  512. //
  513. // label10
  514. //
  515. this.label10.AutoSize = true;
  516. this.label10.Location = new System.Drawing.Point(19, 90);
  517. this.label10.Name = "label10";
  518. this.label10.Size = new System.Drawing.Size(41, 12);
  519. this.label10.TabIndex = 22;
  520. this.label10.Text = "颜色:";
  521. //
  522. // label9
  523. //
  524. this.label9.AutoSize = true;
  525. this.label9.Location = new System.Drawing.Point(322, 58);
  526. this.label9.Name = "label9";
  527. this.label9.Size = new System.Drawing.Size(41, 12);
  528. this.label9.TabIndex = 20;
  529. this.label9.Text = "字号:";
  530. //
  531. // comboBox3
  532. //
  533. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  534. this.comboBox3.FormattingEnabled = true;
  535. this.comboBox3.Location = new System.Drawing.Point(66, 55);
  536. this.comboBox3.Name = "comboBox3";
  537. this.comboBox3.Size = new System.Drawing.Size(191, 20);
  538. this.comboBox3.TabIndex = 19;
  539. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  540. //
  541. // label8
  542. //
  543. this.label8.AutoSize = true;
  544. this.label8.Location = new System.Drawing.Point(19, 58);
  545. this.label8.Name = "label8";
  546. this.label8.Size = new System.Drawing.Size(41, 12);
  547. this.label8.TabIndex = 10;
  548. this.label8.Text = "字体:";
  549. //
  550. // radioButton8
  551. //
  552. this.radioButton8.AutoSize = true;
  553. this.radioButton8.Location = new System.Drawing.Point(333, 24);
  554. this.radioButton8.Name = "radioButton8";
  555. this.radioButton8.Size = new System.Drawing.Size(71, 16);
  556. this.radioButton8.TabIndex = 9;
  557. this.radioButton8.Text = "向后倾斜";
  558. this.radioButton8.UseVisualStyleBackColor = true;
  559. this.radioButton8.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
  560. //
  561. // radioButton7
  562. //
  563. this.radioButton7.AutoSize = true;
  564. this.radioButton7.Location = new System.Drawing.Point(159, 24);
  565. this.radioButton7.Name = "radioButton7";
  566. this.radioButton7.Size = new System.Drawing.Size(71, 16);
  567. this.radioButton7.TabIndex = 8;
  568. this.radioButton7.Text = "垂直方向";
  569. this.radioButton7.UseVisualStyleBackColor = true;
  570. this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged);
  571. //
  572. // label7
  573. //
  574. this.label7.AutoSize = true;
  575. this.label7.Location = new System.Drawing.Point(19, 26);
  576. this.label7.Name = "label7";
  577. this.label7.Size = new System.Drawing.Size(41, 12);
  578. this.label7.TabIndex = 7;
  579. this.label7.Text = "方向:";
  580. //
  581. // radioButton5
  582. //
  583. this.radioButton5.AutoSize = true;
  584. this.radioButton5.Location = new System.Drawing.Point(245, 24);
  585. this.radioButton5.Name = "radioButton5";
  586. this.radioButton5.Size = new System.Drawing.Size(71, 16);
  587. this.radioButton5.TabIndex = 5;
  588. this.radioButton5.Text = "向前倾斜";
  589. this.radioButton5.UseVisualStyleBackColor = true;
  590. this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
  591. //
  592. // radioButton6
  593. //
  594. this.radioButton6.AutoSize = true;
  595. this.radioButton6.Checked = true;
  596. this.radioButton6.Location = new System.Drawing.Point(77, 24);
  597. this.radioButton6.Name = "radioButton6";
  598. this.radioButton6.Size = new System.Drawing.Size(71, 16);
  599. this.radioButton6.TabIndex = 4;
  600. this.radioButton6.TabStop = true;
  601. this.radioButton6.Text = "水平方向";
  602. this.radioButton6.UseVisualStyleBackColor = true;
  603. this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
  604. //
  605. // groupBox5
  606. //
  607. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  608. | System.Windows.Forms.AnchorStyles.Right)));
  609. this.groupBox5.Controls.Add(this.pictureBox2);
  610. this.groupBox5.Location = new System.Drawing.Point(13, 437);
  611. this.groupBox5.Name = "groupBox5";
  612. this.groupBox5.Size = new System.Drawing.Size(613, 236);
  613. this.groupBox5.TabIndex = 6;
  614. this.groupBox5.TabStop = false;
  615. this.groupBox5.Text = "水印预览";
  616. //
  617. // pictureBox2
  618. //
  619. this.pictureBox2.Location = new System.Drawing.Point(6, 12);
  620. this.pictureBox2.Name = "pictureBox2";
  621. this.pictureBox2.Size = new System.Drawing.Size(601, 218);
  622. this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  623. this.pictureBox2.TabIndex = 1;
  624. this.pictureBox2.TabStop = false;
  625. //
  626. // WatermarkSettingsDialog
  627. //
  628. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  629. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  630. this.AutoScroll = true;
  631. this.ClientSize = new System.Drawing.Size(637, 691);
  632. this.Controls.Add(this.groupBox5);
  633. this.Controls.Add(this.groupBox4);
  634. this.Controls.Add(this.groupBox3);
  635. this.Controls.Add(this.groupBox1);
  636. this.Controls.Add(this.groupBox2);
  637. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  638. this.MaximizeBox = false;
  639. this.MinimizeBox = false;
  640. this.Name = "WatermarkSettingsDialog";
  641. this.Text = "水印设置";
  642. this.Controls.SetChildIndex(this.groupBox2, 0);
  643. this.Controls.SetChildIndex(this.groupBox1, 0);
  644. this.Controls.SetChildIndex(this.groupBox3, 0);
  645. this.Controls.SetChildIndex(this.groupBox4, 0);
  646. this.Controls.SetChildIndex(this.groupBox5, 0);
  647. this.groupBox2.ResumeLayout(false);
  648. this.groupBox2.PerformLayout();
  649. this.groupBox1.ResumeLayout(false);
  650. this.groupBox1.PerformLayout();
  651. this.groupBox3.ResumeLayout(false);
  652. this.groupBox3.PerformLayout();
  653. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  654. this.groupBox4.ResumeLayout(false);
  655. this.groupBox4.PerformLayout();
  656. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  657. this.groupBox5.ResumeLayout(false);
  658. ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
  659. this.ResumeLayout(false);
  660. }
  661. private void InitializeColorForm()
  662. {
  663. this.colorsForm = new PaintDotNet.ColorsForm();
  664. //
  665. // colorsForm
  666. //
  667. this.colorsForm.AnalyzeSettingModel = null;
  668. this.colorsForm.ClientSize = new System.Drawing.Size(209, 217);
  669. this.colorsForm.EnableInstanceOpacity = true;
  670. this.colorsForm.ForceActiveTitleBar = true;
  671. this.colorsForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  672. this.colorsForm.KeyPreview = true;
  673. this.colorsForm.Location = new System.Drawing.Point(0, 0);
  674. this.colorsForm.MaximizeBox = false;
  675. this.colorsForm.MinimizeBox = false;
  676. this.colorsForm.Name = "colorsForm";
  677. this.colorsForm.ShowInTaskbar = false;
  678. this.colorsForm.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
  679. this.colorsForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  680. this.colorsForm.Visible = false;
  681. this.colorsForm.WhichUserColor = PaintDotNet.WhichUserColor.Primary;
  682. this.colorsForm.Load += new System.EventHandler(this.colorsForm_Load);
  683. }
  684. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  685. {
  686. }
  687. /// <summary>
  688. /// 画板点击
  689. /// </summary>
  690. /// <param name="sender"></param>
  691. /// <param name="e"></param>
  692. private void panel2_Click(object sender, EventArgs e)
  693. {
  694. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  695. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  696. this.colorsForm.ShowDialog();
  697. }
  698. private void panel2Changed(object sender, EventArgs e)
  699. {
  700. this.panel2.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  701. this.watermarkModel.color = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  702. this.pictureBox2.Invalidate();
  703. this.colorsForm.Close();
  704. }
  705. #endregion
  706. #endregion
  707. /// <summary>
  708. /// 另存为文件名
  709. /// </summary>
  710. private string newName;
  711. /// <summary>
  712. /// 操作样式下拉数据
  713. /// </summary>
  714. private List<string> files = new List<string>();
  715. private float localX = 0;
  716. private float localY = 0;
  717. private WatermarkModel watermarkModel = Startup.instance.watermarkModel;
  718. /// <summary>
  719. /// 旋转角度
  720. /// </summary>
  721. private int angle = 0;
  722. /// <summary>
  723. /// 水印位置下拉选
  724. /// </summary>
  725. string[] position = new string[]
  726. { PdnResources.GetString("Menu.Set.Watermarksettings.Topleft.text"),
  727. PdnResources.GetString("Menu.Set.Watermarksettings.Topmiddle.text"),
  728. PdnResources.GetString("Menu.Set.Watermarksettings.Topright.text"),
  729. PdnResources.GetString("Menu.Set.Watermarksettings.Middleleft.text"),
  730. PdnResources.GetString("Menu.nthemiddle.Text"),
  731. PdnResources.GetString("Menu.Set.Watermarksettings.Middleright.text"),
  732. PdnResources.GetString("Menu.Set.Watermarksettings.Bottomleft.text"),
  733. PdnResources.GetString("Menu.Set.Watermarksettings.Bottommiddle.text"),
  734. PdnResources.GetString("Menu.Set.Watermarksettings.Bottomright.text") };
  735. /// <summary>
  736. /// 暂存文字水印信息
  737. /// </summary>
  738. string waterMarkText = "";
  739. /// <summary>
  740. /// 暂存图片水印路径
  741. /// </summary>
  742. string waterMarkImagePath = "";
  743. CreateNameDialog dialog;
  744. public WatermarkSettingsDialog()
  745. {
  746. InitializeComponent();
  747. InitializeLanguageText();
  748. InitializeColorForm();
  749. InitializeControl();
  750. InitializeData();
  751. }
  752. /// <summary>
  753. /// 处理控件
  754. /// </summary>
  755. private void InitializeControl()
  756. {
  757. this.pictureBox2.Paint += new PaintEventHandler(this.pictureBox2_Paint);
  758. }
  759. /// <summary>
  760. /// pictureBox的绘制事件
  761. /// </summary>
  762. /// <param name="sender"></param>
  763. /// <param name="e"></param>
  764. private void pictureBox2_Paint(object sender, PaintEventArgs e)
  765. {
  766. WatermarkModel model = new WatermarkModel();
  767. model = watermarkModel;
  768. if (this.checkBox1.Checked)
  769. {
  770. model.bold = 1;
  771. }
  772. else
  773. {
  774. model.bold = 2;
  775. }
  776. if (this.checkBox2.Checked)
  777. {
  778. model.italic = 1;
  779. }
  780. else
  781. {
  782. model.italic = 2;
  783. }
  784. model.position = this.comboBox2.SelectedIndex + 1;
  785. model.typeface = this.comboBox3.Text;
  786. model.fontSize = Int32.Parse(this.numericUpDown1.Value.ToString());
  787. if (this.radioButton2.Checked)
  788. {
  789. //drawWatermarkImage(e.Graphics, model);
  790. drawWatermarkImage(e.Graphics, model);
  791. }
  792. else
  793. {
  794. drawWatermarkText(e.Graphics, model);
  795. }
  796. }
  797. /// <summary>
  798. /// 初始化数据
  799. /// </summary>
  800. private void InitializeData()
  801. {
  802. //绑定字体下拉
  803. ArrayList fontsItems = new ArrayList();
  804. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  805. foreach (FontFamily fontFamily in fonts.Families)
  806. {
  807. fontsItems.Add(fontFamily.Name);
  808. }
  809. this.comboBox3.DataSource = fontsItems;
  810. //绑定位置下拉
  811. this.comboBox2.DataSource = position;
  812. //绑定样式下拉
  813. InitializeStyleName();
  814. }
  815. /// <summary>
  816. /// 绑定样式下拉
  817. /// </summary>
  818. private void InitializeStyleName()
  819. {
  820. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\");
  821. files.Clear();
  822. foreach (string fileName in fileNames)
  823. {
  824. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  825. files.Add(name);
  826. }
  827. this.comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
  828. this.comboBox1.DataSource = null;
  829. this.comboBox1.DataSource = files;
  830. string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
  831. this.comboBox1.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
  832. watermarkModel = XmlSerializeHelper.DESerializer<WatermarkModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  833. InitializeWaterData();
  834. this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
  835. }
  836. /// <summary>
  837. /// 初始化控件的值
  838. /// </summary>
  839. private void InitializeWaterData()
  840. {
  841. // 水印类型 1文字水印 2图片水印
  842. if (this.watermarkModel.watermarkType == 2)
  843. {
  844. this.radioButton2.Checked = true;
  845. }
  846. else
  847. {
  848. this.radioButton1.Checked = true;
  849. }
  850. // 水印文字
  851. this.userTextBox1.Text = this.watermarkModel.content;
  852. //水印位置
  853. this.comboBox2.SelectedIndex = this.watermarkModel.position - 1;
  854. // 距边界值
  855. this.userTextBox2.Text = this.watermarkModel.margin + "";
  856. // 平铺水印
  857. if (this.watermarkModel.spread == 2)
  858. {
  859. this.radioButton3.Checked = true;
  860. }
  861. else
  862. {
  863. this.radioButton4.Checked = true;
  864. }
  865. // 透明度
  866. this.trackBar1.Value = this.watermarkModel.transparency;
  867. this.userTextBox3.Text = this.watermarkModel.transparency + "";
  868. // 方向
  869. switch (this.watermarkModel.direction)
  870. {
  871. case 1:
  872. this.radioButton6.Checked = true;
  873. break;
  874. case 2:
  875. this.radioButton7.Checked = true;
  876. break;
  877. case 3:
  878. this.radioButton5.Checked = true;
  879. break;
  880. case 4:
  881. this.radioButton8.Checked = true;
  882. break;
  883. default:
  884. this.radioButton6.Checked = true;
  885. break;
  886. }
  887. //字体
  888. this.comboBox3.Text = this.watermarkModel.typeface;
  889. //字号
  890. this.numericUpDown1.Value = this.watermarkModel.fontSize;
  891. // 水印文字-颜色
  892. this.panel2.BackColor = Color.FromArgb(this.watermarkModel.color);
  893. // 粗体
  894. if (this.watermarkModel.bold == 1)
  895. {
  896. this.checkBox1.Checked = true;
  897. }
  898. // 斜体
  899. if (this.watermarkModel.italic == 1)
  900. {
  901. this.checkBox2.Checked = true;
  902. }
  903. this.pictureBox2.Invalidate();
  904. //comboBox1_SelectedIndexChanged(null,null);
  905. }
  906. /// <summary>
  907. /// 当前操作样式
  908. /// </summary>
  909. /// <param name="sender"></param>
  910. /// <param name="e"></param>
  911. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  912. {
  913. watermarkModel = XmlSerializeHelper.DESerializer<WatermarkModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  914. InitializeWaterData();
  915. }
  916. /// <summary>
  917. /// 文字水印
  918. /// </summary>
  919. /// <param name="sender"></param>
  920. /// <param name="e"></param>
  921. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  922. {
  923. if (radioButton1.Checked)
  924. {
  925. waterMarkImagePath = this.userTextBox1.Text;
  926. this.userTextBox1.Text = waterMarkText;
  927. this.userTextBox1.ReadOnly = false;
  928. this.watermarkModel.watermarkType = 1;
  929. this.groupBox4.Visible = true; // 扩展信息
  930. this.button5.Visible = false;
  931. this.userTextBox1.Size = new Size(508, 21);
  932. this.groupBox5.Location = new System.Drawing.Point(12, 437);
  933. }
  934. }
  935. /// <summary>
  936. /// 图片水印
  937. /// </summary>
  938. /// <param name="sender"></param>
  939. /// <param name="e"></param>
  940. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  941. {
  942. if (radioButton2.Checked)
  943. {
  944. waterMarkText = this.userTextBox1.Text;
  945. this.userTextBox1.Text = waterMarkImagePath;
  946. this.userTextBox1.ReadOnly = true;
  947. this.pictureBox2.Refresh();
  948. this.watermarkModel.watermarkType = 2;
  949. this.groupBox4.Visible = false; // 扩展信息
  950. this.button5.Visible = true;
  951. this.userTextBox1.Size = new Size(508 - 75, 21);
  952. this.groupBox5.Location = new System.Drawing.Point(12, 313);
  953. }
  954. }
  955. /// <summary>
  956. /// 基本信息-水印-水印文字
  957. /// </summary>
  958. /// <param name="sender"></param>
  959. /// <param name="e"></param>
  960. private void userTextBox1_TextChanged(object sender, EventArgs e)
  961. {
  962. }
  963. /// <summary>
  964. /// 基本信息-水印-选择图片水印
  965. /// </summary>
  966. /// <param name="sender"></param>
  967. /// <param name="e"></param>
  968. private void button5_Click(object sender, EventArgs e)
  969. {
  970. var openFileDialog1 = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };
  971. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  972. {
  973. this.userTextBox1.Text = openFileDialog1.InitialDirectory + openFileDialog1.FileName;
  974. this.watermarkModel.content = this.userTextBox1.Text;
  975. Image image = Image.FromFile(openFileDialog1.FileName);
  976. }
  977. }
  978. private void userTextBox1_TextChanged_1(object sender, EventArgs e)
  979. {
  980. if (this.watermarkModel.content == "")
  981. {
  982. this.watermarkModel.content = this.userTextBox1.Text;
  983. }
  984. this.pictureBox2.Invalidate();
  985. }
  986. /// <summary>
  987. /// 基本信息-透明度滑块
  988. /// </summary>
  989. /// <param name="sender"></param>
  990. /// <param name="e"></param>
  991. private void trackBar1_Scroll(object sender, EventArgs e)
  992. {
  993. this.userTextBox3.Text = "" + this.trackBar1.Value;
  994. this.watermarkModel.transparency = this.trackBar1.Value;
  995. this.pictureBox2.Invalidate();
  996. }
  997. /// <summary>
  998. /// 距边界值
  999. /// </summary>
  1000. /// <param name="sender"></param>
  1001. /// <param name="e"></param>
  1002. private void userTextBox2_TextChanged(object sender, EventArgs e)
  1003. {
  1004. if (string.IsNullOrEmpty(this.userTextBox2.Text))
  1005. {
  1006. MessageBox.Show(PdnResources.GetString("Menu.edistancefromtheboundaryaluecanno.Text"));
  1007. return;
  1008. }
  1009. this.watermarkModel.margin = Int32.Parse(this.userTextBox2.Text);
  1010. this.pictureBox2.Invalidate();
  1011. }
  1012. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  1013. {
  1014. this.watermarkModel.spread = 1;
  1015. this.pictureBox2.Invalidate();
  1016. }
  1017. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  1018. {
  1019. this.watermarkModel.spread = 2;
  1020. this.pictureBox2.Invalidate();
  1021. }
  1022. /// <summary>
  1023. /// 扩展信息-方向- 向前倾斜
  1024. /// </summary>
  1025. /// <param name="sender"></param>
  1026. /// <param name="e"></param>
  1027. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  1028. {
  1029. this.angle = -45;
  1030. this.watermarkModel.direction = 3;
  1031. this.pictureBox2.Invalidate();
  1032. }
  1033. private void radioButton6_CheckedChanged(object sender, EventArgs e)
  1034. {
  1035. this.angle = 0;
  1036. this.watermarkModel.direction = 1;
  1037. this.pictureBox2.Invalidate();
  1038. }
  1039. private void radioButton7_CheckedChanged(object sender, EventArgs e)
  1040. {
  1041. this.angle = 90;
  1042. this.watermarkModel.direction = 2;
  1043. this.pictureBox2.Invalidate();
  1044. }
  1045. private void radioButton8_CheckedChanged(object sender, EventArgs e)
  1046. {
  1047. this.angle = 45;
  1048. this.watermarkModel.direction = 4;
  1049. this.pictureBox2.Invalidate();
  1050. }
  1051. /// <summary>
  1052. /// 删除
  1053. /// </summary>
  1054. /// <param name="sender"></param>
  1055. /// <param name="e"></param>
  1056. private void button3_Click(object sender, EventArgs e)
  1057. {
  1058. if ("Default".Equals(this.comboBox1.Text))
  1059. {
  1060. MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1061. return;
  1062. }
  1063. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1064. if (dr == DialogResult.OK)
  1065. {
  1066. int newIndex = 0;
  1067. int selectIndex = this.comboBox1.SelectedIndex;
  1068. int tall = files.Count - 1;
  1069. if (selectIndex < tall)
  1070. {
  1071. newIndex = selectIndex;
  1072. }
  1073. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.Text + ".xml";
  1074. FileInfo fileInfo = new FileInfo(filePath);
  1075. fileInfo.Delete();
  1076. InitializeStyleName();
  1077. this.comboBox1.SelectedIndex = newIndex;
  1078. watermarkModel = XmlSerializeHelper.DESerializer<WatermarkModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  1079. InitializeWaterData();
  1080. }
  1081. else if (dr == DialogResult.Cancel)
  1082. {
  1083. }
  1084. }
  1085. /// <summary>
  1086. /// 另存为
  1087. /// </summary>
  1088. /// <param name="sender"></param>
  1089. /// <param name="e"></param>
  1090. private void button4_Click(object sender, EventArgs e)
  1091. {
  1092. dialog = new CreateNameDialog(this);
  1093. dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
  1094. dialog.StartPosition = FormStartPosition.CenterParent;
  1095. dialog.ShowDialog();
  1096. }
  1097. /// <summary>
  1098. /// 另存配置文件
  1099. /// </summary>
  1100. private void CopyConfigAndRename()
  1101. {
  1102. if (this.checkBox1.Checked)
  1103. {
  1104. this.watermarkModel.bold = 1;
  1105. }
  1106. else
  1107. {
  1108. this.watermarkModel.bold = 2;
  1109. }
  1110. if (this.checkBox2.Checked)
  1111. {
  1112. this.watermarkModel.italic = 1;
  1113. }
  1114. else
  1115. {
  1116. this.watermarkModel.italic = 2;
  1117. }
  1118. this.watermarkModel.content = this.userTextBox1.Text;
  1119. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1120. this.watermarkModel.typeface = this.comboBox3.Text;
  1121. this.watermarkModel.fontSize = Int32.Parse(this.numericUpDown1.Value.ToString());
  1122. string stageModelXml = XmlSerializeHelper.XmlSerialize<WatermarkModel>(this.watermarkModel);
  1123. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.newName + ".xml";
  1124. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1125. }
  1126. /// <summary>
  1127. /// 保存当前配置文件
  1128. /// </summary>
  1129. /// <param name="sender"></param>
  1130. /// <param name="e"></param>
  1131. private void button1_Click(object sender, EventArgs e)
  1132. {
  1133. if (this.checkBox1.Checked)
  1134. {
  1135. this.watermarkModel.bold = 1;
  1136. }
  1137. else
  1138. {
  1139. this.watermarkModel.bold = 2;
  1140. }
  1141. if (this.checkBox2.Checked)
  1142. {
  1143. this.watermarkModel.italic = 1;
  1144. }
  1145. else
  1146. {
  1147. this.watermarkModel.italic = 2;
  1148. }
  1149. this.watermarkModel.content = this.userTextBox1.Text;
  1150. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1151. this.watermarkModel.typeface = this.comboBox3.Text;
  1152. this.watermarkModel.fontSize = Int32.Parse(this.numericUpDown1.Value.ToString());
  1153. string stageModelXml = XmlSerializeHelper.XmlSerialize<WatermarkModel>(this.watermarkModel);
  1154. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Watermark\\" + this.comboBox1.Text + ".xml";
  1155. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1156. this.pictureBox2.Invalidate();
  1157. }
  1158. /// <summary>
  1159. /// 应用当前的水印配置
  1160. /// </summary>
  1161. /// <param name="sender"></param>
  1162. /// <param name="e"></param>
  1163. private void button2_Click(object sender, EventArgs e)
  1164. {
  1165. Startup.instance.watermarkModel = this.watermarkModel;
  1166. Startup.instance.watermarkModel = this.watermarkModel;
  1167. }
  1168. public override void GetCreateName(string name)
  1169. {
  1170. this.newName = name;
  1171. if (files.Contains(this.newName))
  1172. {
  1173. MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1174. return;
  1175. }
  1176. CopyConfigAndRename();
  1177. InitializeStyleName();
  1178. dialog.Close();
  1179. }
  1180. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  1181. {
  1182. this.pictureBox2.Invalidate();
  1183. }
  1184. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  1185. {
  1186. this.pictureBox2.Invalidate();
  1187. }
  1188. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1189. {
  1190. this.pictureBox2.Invalidate();
  1191. }
  1192. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1193. {
  1194. this.pictureBox2.Invalidate();
  1195. }
  1196. /// <summary>
  1197. /// 绘制水印-文字
  1198. /// </summary>
  1199. /// <param name="graphics">画布</param>
  1200. /// <param name="model">水印信息</param>
  1201. public void drawWatermarkText(Graphics graphics, WatermarkModel model)
  1202. {
  1203. int width = this.pictureBox2.Width;
  1204. int height = this.pictureBox2.Height;
  1205. int padding = model.margin;
  1206. string text = model.content;
  1207. string fontVal = model.typeface; // 字体
  1208. int fontSize = model.fontSize * 2; // 字号
  1209. int transparency = model.transparency;// 透明度
  1210. Color color = Color.FromArgb(transparency, Color.FromArgb(model.color));// 颜色
  1211. Font font = new Font(fontVal, fontSize, GraphicsUnit.Pixel);
  1212. if (model.bold == 1)
  1213. {
  1214. font = new Font(fontVal, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);//粗体
  1215. }
  1216. if (model.italic == 1)
  1217. {
  1218. font = new Font(fontVal, fontSize, FontStyle.Italic, GraphicsUnit.Pixel);//斜体
  1219. }
  1220. if (model.italic == 1 && model.bold == 1)
  1221. {
  1222. font = new Font(fontVal, fontSize, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Pixel);//加粗斜体
  1223. }
  1224. //获取可以用来绘制水印图片的有效区域
  1225. Rectangle validRect = new Rectangle(padding, padding, width - padding * 2, height - padding * 2);
  1226. if (model.spread == 2)
  1227. {
  1228. SizeF sf = graphics.MeasureString(text, font); //获取需要绘制的字符串大小
  1229. StringFormat format = GetStringFormat(model.position, sf.Width, sf.Height, this.pictureBox2.Width, this.pictureBox2.Height, model.margin); //获取绘画水印文字的格式,即文字对齐方式
  1230. Matrix mtxSave = graphics.Transform; //原始旋转矩阵
  1231. Matrix matrix = graphics.Transform;
  1232. matrix.RotateAt((float)angle, new PointF(localX + sf.Width / 2, localY + sf.Height / 2));
  1233. graphics.Transform = matrix;
  1234. graphics.DrawString(text, font, new SolidBrush(color), localX, localY);
  1235. graphics.Transform = mtxSave; //还原为原始旋转矩阵
  1236. //graphics.DrawString(text, font, new SolidBrush(color), validRect, format);
  1237. }
  1238. else if (model.spread == 1)
  1239. {
  1240. float textLength = font.Size * text.Length + 30;
  1241. float xpos = 0;
  1242. float ypos = 0;
  1243. // 倾斜
  1244. graphics.RotateTransform(this.angle);
  1245. // 循环打印文字水印
  1246. for (float i = -width / 2; i < width * 1.5; i = i + textLength)
  1247. {
  1248. xpos = i;
  1249. for (float j = -3 * height; j < height * 2.5; j += 50)
  1250. {
  1251. ypos = j;
  1252. graphics.DrawString(text, font, new SolidBrush(color), xpos, ypos);
  1253. }
  1254. }
  1255. }
  1256. }
  1257. /// <summary>
  1258. /// 获取文字水印位置
  1259. /// </summary>
  1260. /// <param name="pos">
  1261. /// 左顶,顶中,右顶,左中,居中,右中,左底,底中,右底
  1262. /// 1左上,2中上,3右上
  1263. /// 4左中,5中, 6右中
  1264. /// 7左下,8中下,9右下
  1265. /// </param>
  1266. /// <returns></returns>
  1267. public StringFormat GetStringFormat(int pos, float textwidth, float textheigth, int width, int heigth, int margin)
  1268. {
  1269. StringFormat format = new StringFormat();
  1270. switch (pos)
  1271. {
  1272. case 1:
  1273. format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Near;
  1274. localX = margin;
  1275. localY = margin;
  1276. break;
  1277. case 2:
  1278. format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Near;
  1279. localX = (width - 2 * margin) / 2 - textwidth / 2;
  1280. localY = margin;
  1281. break;
  1282. case 3:
  1283. format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Near;
  1284. localX = (width - 2 * margin) - textwidth;
  1285. localY = margin;
  1286. break;
  1287. case 4:
  1288. format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center;
  1289. localX = margin;
  1290. localY = (heigth - 2 * margin) / 2 - textheigth / 2;
  1291. break;
  1292. case 5:
  1293. localX = (width - 2 * margin) / 2 - textwidth / 2;
  1294. localY = (heigth - 2 * margin) / 2 - textheigth / 2;
  1295. break;
  1296. case 6:
  1297. format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Center;
  1298. localX = (width - 2 * margin) - textwidth;
  1299. localY = (heigth - 2 * margin) / 2 - textheigth / 2;
  1300. break;
  1301. case 7:
  1302. format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Far;
  1303. localX = margin;
  1304. localY = (heigth - 2 * margin) - textheigth;
  1305. break;
  1306. case 8:
  1307. format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Far;
  1308. localX = (width - 2 * margin) / 2 - textwidth / 2;
  1309. localY = (heigth - 2 * margin) - textheigth;
  1310. break;
  1311. case 9:
  1312. format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Far;
  1313. localX = (width - 2 * margin) - textwidth;
  1314. localY = (heigth - 2 * margin) - textheigth;
  1315. break;
  1316. default:
  1317. format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center;
  1318. break;
  1319. }
  1320. return format;
  1321. }
  1322. /// <summary>
  1323. /// 图片透明度属性
  1324. /// </summary>
  1325. /// <param name="opcity"></param>
  1326. /// <returns></returns>
  1327. public ImageAttributes GetAlphaImgAttr(int opcity)
  1328. {
  1329. if (opcity < 0 || opcity > 255)
  1330. {
  1331. throw new ArgumentOutOfRangeException("opcity 值为 0~255");
  1332. }
  1333. //颜色矩阵
  1334. float[][] matrixItems =
  1335. {
  1336. new float[]{1,0,0,0,0},
  1337. new float[]{0,1,0,0,0},
  1338. new float[]{0,0,1,0,0},
  1339. new float[]{0,0,0,(float)opcity / 255, 0},
  1340. new float[]{0,0,0,0,1}
  1341. };
  1342. ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
  1343. ImageAttributes imageAtt = new ImageAttributes();
  1344. imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
  1345. return imageAtt;
  1346. }
  1347. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  1348. {
  1349. this.pictureBox2.Invalidate();
  1350. }
  1351. /// <summary>
  1352. /// 绘制水印-图片
  1353. /// </summary>
  1354. /// <param name="graphics">画布</param>
  1355. /// <param name="model">水印信息</param>
  1356. public void drawWatermarkImage(Graphics graphics, WatermarkModel watermarkModel)
  1357. {
  1358. string waterPath = watermarkModel.content;
  1359. int position = watermarkModel.position; // 设置水印位置,1左上,2中上,3右上,4左中,5中, 6右中,7左下,8中下,9右下
  1360. int padding = watermarkModel.margin;
  1361. int opcity = watermarkModel.transparency;
  1362. Image waterImage = null;
  1363. if (string.IsNullOrEmpty(waterPath))
  1364. {
  1365. return;
  1366. }
  1367. try
  1368. {
  1369. waterImage = Image.FromFile(waterPath, false); //获取水印图片
  1370. }
  1371. catch (Exception)
  1372. {
  1373. return;
  1374. }
  1375. var waterRect = new Rectangle(0, 0, waterImage.Width, waterImage.Height);
  1376. if (opcity <= 0)
  1377. {
  1378. return;
  1379. }
  1380. Rectangle validRect = new Rectangle(padding, padding, this.pictureBox2.Width - padding * 2, this.pictureBox2.Height - padding * 2); //获取可以用来绘制水印图片的有效区域
  1381. ImageAttributes imageAtt = GetAlphaImgAttr(opcity);
  1382. Rectangle destRect = GetRectangleByPostion(validRect, waterRect, position); //计算水印图片的绘制位置
  1383. if (watermarkModel.spread == 2) // 非水印平铺
  1384. {
  1385. //Rectangle destRect = GetRectangleByPostion(validRect, waterRect, position); //计算水印图片的绘制位置
  1386. if (opcity == 255) //如果不透明度=100,那么直接将水印画到当前画布上.
  1387. {
  1388. graphics.DrawImage(waterImage, destRect, waterRect, GraphicsUnit.Pixel);
  1389. }
  1390. else //如果不透明度在0到255之间,设置透明参数
  1391. {
  1392. graphics.DrawImage(waterImage, destRect, 0, 0, waterRect.Width, waterRect.Height, GraphicsUnit.Pixel, imageAtt);//将水印图片画到画布上
  1393. }
  1394. }
  1395. else if (watermarkModel.spread == 1) // 水印平铺
  1396. {
  1397. int width = this.pictureBox2.Width;
  1398. int height = this.pictureBox2.Height;
  1399. float imageLength = waterImage.Width + 10;
  1400. float imageHeight = waterImage.Height + 10;
  1401. float xpos = 0;
  1402. float ypos = 0;
  1403. // 循环打印文字水印
  1404. for (float i = watermarkModel.margin; i <= width; i += imageLength)
  1405. {
  1406. xpos = i;
  1407. for (float j = watermarkModel.margin; j <= height; j += imageHeight)
  1408. {
  1409. ypos = j;
  1410. destRect.X = (int)xpos;
  1411. destRect.Y = (int)ypos;
  1412. graphics.DrawImage(waterImage, destRect, 0, 0, waterRect.Width, waterRect.Height, GraphicsUnit.Pixel, imageAtt);//将水印图片画到画布上
  1413. }
  1414. }
  1415. }
  1416. }
  1417. /// <summary>
  1418. /// 获取图片水印位置,及small在big里的位置
  1419. /// 如果small的高度大于big的高度,返回big的高度
  1420. /// 如果small的宽度大于big的宽度,返回big的宽度
  1421. /// </summary>
  1422. /// <param name="pos">
  1423. /// 1左上,2中上,3右上
  1424. /// 4左中,5中, 6右中
  1425. /// 7左下,8中下,9右下
  1426. /// </param>
  1427. /// <returns></returns>
  1428. public Rectangle GetRectangleByPostion(Rectangle big, Rectangle small, int pos)
  1429. {
  1430. if (big.Width < small.Width)
  1431. {
  1432. small.Width = big.Width;
  1433. }
  1434. if (big.Height < small.Height)
  1435. {
  1436. small.Height = big.Height;
  1437. }
  1438. Rectangle retVal = small;
  1439. switch (pos)
  1440. {
  1441. case 1: retVal.X = 0; retVal.Y = 0; break;
  1442. case 2: retVal.X = (big.Width - small.Width) / 2; retVal.Y = 0; break;
  1443. case 3: retVal.X = big.Width - small.Width; retVal.Y = 0; break;
  1444. case 4: retVal.X = 0; retVal.Y = (big.Height - small.Height) / 2; break;
  1445. case 6: retVal.X = big.Width - small.Width; retVal.Y = (big.Height - small.Height) / 2; break;
  1446. case 7: retVal.X = 0; retVal.Y = big.Height - small.Height; break;
  1447. case 8: retVal.X = (big.Width - small.Width) / 2; retVal.Y = big.Height - small.Height; break;
  1448. case 9: retVal.X = big.Width - small.Width; retVal.Y = big.Height - small.Height; break;
  1449. default: retVal.X = (big.Width - small.Width) / 2; retVal.Y = (big.Height - small.Height) / 2; break;
  1450. }
  1451. retVal.X += big.X;
  1452. retVal.Y += big.Y;
  1453. return retVal;
  1454. }
  1455. private void colorsForm_Load(object sender, EventArgs e)
  1456. {
  1457. }
  1458. }
  1459. }