MeasurementPropertiesDialog.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. using Resources;
  2. using SmartCoalApplication.Annotation;
  3. using SmartCoalApplication.Annotation.Enum;
  4. using SmartCoalApplication.Annotation.Measure;
  5. using SmartCoalApplication.Base.CommTool;
  6. using SmartCoalApplication.Base.SettingModel;
  7. using SmartCoalApplication.Core;
  8. using SmartCoalApplication.PluginAssemblys;
  9. using SmartCoalApplication.Resources;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows.Forms;
  21. namespace SmartCoalApplication.Measure
  22. {
  23. internal class MeasurementPropertiesDialog : Form
  24. {
  25. #region 控件
  26. private GroupBox groupBox2;
  27. private Panel panel3;
  28. private ComboBox comboBox4;
  29. private Label label4;
  30. private ComboBox comboBox3;
  31. private Label label3;
  32. private Panel panel2;
  33. private ComboBox comboBox2;
  34. private Label label2;
  35. private NumericUpDown numericUpDown11;
  36. private ComboBox comboBox21;
  37. private NumericUpDown numericUpDown21;
  38. private Label label61;
  39. private Label label51;
  40. private Panel linePanel;
  41. private Label label41;
  42. private Panel textPanel;
  43. private Label label31;
  44. private Label label21;
  45. private ComboBox comboBox11;
  46. private Label label11;
  47. private GroupBox groupBox1;
  48. //private Button button2;
  49. private Button button3;
  50. private Button button1;
  51. ColorsForm colorsForm;
  52. ColorsForm colorsForm1;
  53. private DocumentWorkspaceWindow documentWorkspaceWindow;
  54. #endregion
  55. /// <summary>
  56. /// 主控件
  57. /// </summary>
  58. private AppWorkspace appWorkspace;
  59. private DrawObject drawObject;
  60. /// <summary>
  61. /// 测量的样式
  62. /// </summary>
  63. private MeasureStyleModel measureStyleModel = Program.instance.measureStyleModel;
  64. /// <summary>
  65. /// 主配置文件的model
  66. /// </summary>
  67. private ConfigModel configModel = Program.instance.configModel;
  68. private NumericUpDown numericUpDown1;
  69. private Label label5;
  70. private ComboBox comboBox5;
  71. private Label label6;
  72. private ComboBox comboBox91;
  73. private System.Windows.Forms.Label label91;
  74. /// <summary>
  75. /// 字体列表
  76. /// </summary>
  77. ArrayList fontsItems = new ArrayList();
  78. public MeasurementPropertiesDialog(AppWorkspace appWorkspace, DrawObject drawObject,DocumentWorkspaceWindow documentWorkspaceWindow = null)
  79. {
  80. this.appWorkspace = appWorkspace;
  81. this.drawObject = drawObject;
  82. InitializeComponent();
  83. this.documentWorkspaceWindow = documentWorkspaceWindow;
  84. this.Icon = PdnInfo.AppIcon;
  85. this.comboBox3.Items.AddRange(new object[] {
  86. PdnResources.GetString("Menu.Upperleft.text"),
  87. PdnResources.GetString("Menu.Uppermiddle.Text"),
  88. PdnResources.GetString("Menu.Upperright.text"),
  89. PdnResources.GetString("Menu.Lowerleft.text"),
  90. PdnResources.GetString("Menu.Themiddleandlower.Text"),
  91. PdnResources.GetString("Menu.Lowerright.text")});
  92. this.comboBox91.Items.AddRange(new object[] {
  93. "度",
  94. "密位"});
  95. this.comboBox4.Items.AddRange(new object[] {
  96. PdnResources.GetString("Menu.Upperleft.text"),
  97. PdnResources.GetString("Menu.Uppermiddle.Text"),
  98. PdnResources.GetString("Menu.Upperright.text"),
  99. PdnResources.GetString("Menu.Lowerleft.text"),
  100. PdnResources.GetString("Menu.Themiddleandlower.Text"),
  101. PdnResources.GetString("Menu.Lowerright.text")});
  102. this.Text = PdnResources.GetString("Menu.MeasureAction." + drawObject.drawToolType.ToString() + ".Text") + "属性设置";
  103. //绑定线样式数据
  104. this.comboBox21.Items.AddRange(InvariantData.dashStyles);
  105. this.colorsForm = new ColorsForm();
  106. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  107. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  108. this.colorsForm1 = new ColorsForm();
  109. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  110. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  111. this.fontsItems.Clear();
  112. //绑定字体数据
  113. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  114. foreach (FontFamily fontFamily in fonts.Families)
  115. {
  116. fontsItems.Add(fontFamily.Name);
  117. }
  118. this.comboBox11.DataSource = fontsItems;
  119. UpdateRightSettingUI();
  120. }
  121. #region 初始化
  122. private void InitializeComponent()
  123. {
  124. this.comboBox91 = new System.Windows.Forms.ComboBox();
  125. this.label91 = new System.Windows.Forms.Label();
  126. this.groupBox2 = new System.Windows.Forms.GroupBox();
  127. this.comboBox5 = new System.Windows.Forms.ComboBox();
  128. this.label6 = new System.Windows.Forms.Label();
  129. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  130. this.label5 = new System.Windows.Forms.Label();
  131. this.panel3 = new System.Windows.Forms.Panel();
  132. this.comboBox4 = new System.Windows.Forms.ComboBox();
  133. this.label4 = new System.Windows.Forms.Label();
  134. this.comboBox3 = new System.Windows.Forms.ComboBox();
  135. this.label3 = new System.Windows.Forms.Label();
  136. this.panel2 = new System.Windows.Forms.Panel();
  137. this.comboBox2 = new System.Windows.Forms.ComboBox();
  138. this.label2 = new System.Windows.Forms.Label();
  139. this.numericUpDown11 = new System.Windows.Forms.NumericUpDown();
  140. this.comboBox21 = new System.Windows.Forms.ComboBox();
  141. this.numericUpDown21 = new System.Windows.Forms.NumericUpDown();
  142. this.label61 = new System.Windows.Forms.Label();
  143. this.label51 = new System.Windows.Forms.Label();
  144. this.linePanel = new System.Windows.Forms.Panel();
  145. this.label41 = new System.Windows.Forms.Label();
  146. this.textPanel = new System.Windows.Forms.Panel();
  147. this.label31 = new System.Windows.Forms.Label();
  148. this.label21 = new System.Windows.Forms.Label();
  149. this.comboBox11 = new System.Windows.Forms.ComboBox();
  150. this.label11 = new System.Windows.Forms.Label();
  151. this.groupBox1 = new System.Windows.Forms.GroupBox();
  152. this.button3 = new System.Windows.Forms.Button();
  153. this.button1 = new System.Windows.Forms.Button();
  154. this.groupBox2.SuspendLayout();
  155. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  156. this.panel3.SuspendLayout();
  157. this.panel2.SuspendLayout();
  158. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown11)).BeginInit();
  159. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown21)).BeginInit();
  160. this.groupBox1.SuspendLayout();
  161. this.SuspendLayout();
  162. //
  163. // comboBox91
  164. //
  165. this.comboBox91.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  166. this.comboBox91.FormattingEnabled = true;
  167. this.comboBox91.Location = new System.Drawing.Point(91, 179);
  168. this.comboBox91.Name = "comboBox91";
  169. this.comboBox91.Size = new System.Drawing.Size(152, 20);
  170. this.comboBox91.TabIndex = 15;
  171. //
  172. // label91
  173. //
  174. this.label91.AutoSize = true;
  175. this.label91.Location = new System.Drawing.Point(14, 182);
  176. this.label91.Name = "label91";
  177. this.label91.Size = new System.Drawing.Size(65, 12);
  178. this.label91.TabIndex = 14;
  179. this.label91.Text = "角度单位:";
  180. //
  181. // groupBox2
  182. //
  183. this.groupBox2.Controls.Add(this.comboBox5);
  184. this.groupBox2.Controls.Add(this.label6);
  185. this.groupBox2.Controls.Add(this.numericUpDown1);
  186. this.groupBox2.Controls.Add(this.label5);
  187. this.groupBox2.Controls.Add(this.panel3);
  188. this.groupBox2.Controls.Add(this.panel2);
  189. this.groupBox2.Controls.Add(this.numericUpDown11);
  190. this.groupBox2.Controls.Add(this.comboBox21);
  191. this.groupBox2.Controls.Add(this.numericUpDown21);
  192. this.groupBox2.Controls.Add(this.label61);
  193. this.groupBox2.Controls.Add(this.label51);
  194. this.groupBox2.Controls.Add(this.linePanel);
  195. this.groupBox2.Controls.Add(this.label41);
  196. this.groupBox2.Controls.Add(this.textPanel);
  197. this.groupBox2.Controls.Add(this.label31);
  198. this.groupBox2.Controls.Add(this.label21);
  199. this.groupBox2.Controls.Add(this.comboBox11);
  200. this.groupBox2.Controls.Add(this.label11);
  201. this.groupBox2.Controls.Add(this.comboBox91);
  202. this.groupBox2.Controls.Add(this.label91);
  203. this.groupBox2.Location = new System.Drawing.Point(10, 76);
  204. this.groupBox2.Name = "groupBox2";
  205. this.groupBox2.Size = new System.Drawing.Size(633, 235);
  206. this.groupBox2.TabIndex = 8;
  207. this.groupBox2.TabStop = false;
  208. this.groupBox2.Text = "设置";
  209. //
  210. // comboBox5
  211. //
  212. this.comboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  213. this.comboBox5.FormattingEnabled = true;
  214. this.comboBox5.Items.AddRange(new object[] {
  215. "随线",
  216. "水平"});
  217. this.comboBox5.Location = new System.Drawing.Point(337, 46);
  218. this.comboBox5.Name = "comboBox5";
  219. this.comboBox5.Size = new System.Drawing.Size(122, 20);
  220. this.comboBox5.TabIndex = 22;
  221. //
  222. // label6
  223. //
  224. this.label6.AutoSize = true;
  225. this.label6.Location = new System.Drawing.Point(260, 50);
  226. this.label6.Name = "label6";
  227. this.label6.Size = new System.Drawing.Size(65, 12);
  228. this.label6.TabIndex = 21;
  229. this.label6.Text = "文字方向:";
  230. //
  231. // numericUpDown1
  232. //
  233. this.numericUpDown1.Location = new System.Drawing.Point(337, 21);
  234. this.numericUpDown1.Name = "numericUpDown1";
  235. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  236. this.numericUpDown1.TabIndex = 20;
  237. //
  238. // label5
  239. //
  240. this.label5.AutoSize = true;
  241. this.label5.Location = new System.Drawing.Point(260, 25);
  242. this.label5.Name = "label5";
  243. this.label5.Size = new System.Drawing.Size(65, 12);
  244. this.label5.TabIndex = 19;
  245. this.label5.Text = "垂线长度:";
  246. //
  247. // panel3
  248. //
  249. this.panel3.Controls.Add(this.comboBox4);
  250. this.panel3.Controls.Add(this.label4);
  251. this.panel3.Controls.Add(this.comboBox3);
  252. this.panel3.Controls.Add(this.label3);
  253. this.panel3.Location = new System.Drawing.Point(9, 175);
  254. this.panel3.Name = "panel3";
  255. this.panel3.Size = new System.Drawing.Size(236, 57);
  256. this.panel3.TabIndex = 16;
  257. //
  258. // comboBox4
  259. //
  260. this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  261. this.comboBox4.FormattingEnabled = true;
  262. this.comboBox4.Location = new System.Drawing.Point(112, 30);
  263. this.comboBox4.Name = "comboBox4";
  264. this.comboBox4.Size = new System.Drawing.Size(122, 20);
  265. this.comboBox4.TabIndex = 17;
  266. //
  267. // label4
  268. //
  269. this.label4.AutoSize = true;
  270. this.label4.Location = new System.Drawing.Point(5, 34);
  271. this.label4.Name = "label4";
  272. this.label4.Size = new System.Drawing.Size(89, 12);
  273. this.label4.TabIndex = 16;
  274. this.label4.Text = "文字位置(点):";
  275. //
  276. // comboBox3
  277. //
  278. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  279. this.comboBox3.FormattingEnabled = true;
  280. this.comboBox3.Location = new System.Drawing.Point(112, 4);
  281. this.comboBox3.Name = "comboBox3";
  282. this.comboBox3.Size = new System.Drawing.Size(122, 20);
  283. this.comboBox3.TabIndex = 15;
  284. //
  285. // label3
  286. //
  287. this.label3.AutoSize = true;
  288. this.label3.Location = new System.Drawing.Point(5, 7);
  289. this.label3.Name = "label3";
  290. this.label3.Size = new System.Drawing.Size(89, 12);
  291. this.label3.TabIndex = 14;
  292. this.label3.Text = "文字位置(线):";
  293. //
  294. // panel2
  295. //
  296. this.panel2.Controls.Add(this.comboBox2);
  297. this.panel2.Controls.Add(this.label2);
  298. this.panel2.Location = new System.Drawing.Point(9, 175);
  299. this.panel2.Name = "panel2";
  300. this.panel2.Size = new System.Drawing.Size(236, 57);
  301. this.panel2.TabIndex = 15;
  302. //
  303. // comboBox2
  304. //
  305. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  306. this.comboBox2.FormattingEnabled = true;
  307. this.comboBox2.Location = new System.Drawing.Point(82, 3);
  308. this.comboBox2.Name = "comboBox2";
  309. this.comboBox2.Size = new System.Drawing.Size(152, 20);
  310. this.comboBox2.TabIndex = 15;
  311. //
  312. // label2
  313. //
  314. this.label2.AutoSize = true;
  315. this.label2.Location = new System.Drawing.Point(5, 7);
  316. this.label2.Name = "label2";
  317. this.label2.Size = new System.Drawing.Size(65, 12);
  318. this.label2.TabIndex = 14;
  319. this.label2.Text = "文字位置:";
  320. //
  321. // numericUpDown11
  322. //
  323. this.numericUpDown11.Location = new System.Drawing.Point(91, 125);
  324. this.numericUpDown11.Name = "numericUpDown11";
  325. this.numericUpDown11.Size = new System.Drawing.Size(152, 21);
  326. this.numericUpDown11.TabIndex = 14;
  327. //
  328. // comboBox21
  329. //
  330. this.comboBox21.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  331. this.comboBox21.FormattingEnabled = true;
  332. this.comboBox21.Location = new System.Drawing.Point(91, 151);
  333. this.comboBox21.Name = "comboBox21";
  334. this.comboBox21.Size = new System.Drawing.Size(152, 20);
  335. this.comboBox21.TabIndex = 13;
  336. //
  337. // numericUpDown21
  338. //
  339. this.numericUpDown21.Location = new System.Drawing.Point(91, 46);
  340. this.numericUpDown21.Name = "numericUpDown21";
  341. this.numericUpDown21.Size = new System.Drawing.Size(152, 21);
  342. this.numericUpDown21.TabIndex = 12;
  343. //
  344. // label61
  345. //
  346. this.label61.AutoSize = true;
  347. this.label61.Location = new System.Drawing.Point(13, 155);
  348. this.label61.Name = "label61";
  349. this.label61.Size = new System.Drawing.Size(65, 12);
  350. this.label61.TabIndex = 9;
  351. this.label61.Text = "线条样式:";
  352. //
  353. // label51
  354. //
  355. this.label51.AutoSize = true;
  356. this.label51.Location = new System.Drawing.Point(13, 128);
  357. this.label51.Name = "label51";
  358. this.label51.Size = new System.Drawing.Size(65, 12);
  359. this.label51.TabIndex = 8;
  360. this.label51.Text = "线条宽度:";
  361. //
  362. // linePanel
  363. //
  364. this.linePanel.BackColor = System.Drawing.SystemColors.Window;
  365. this.linePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  366. this.linePanel.Location = new System.Drawing.Point(91, 99);
  367. this.linePanel.Name = "linePanel";
  368. this.linePanel.Size = new System.Drawing.Size(152, 20);
  369. this.linePanel.TabIndex = 7;
  370. this.linePanel.Click += new System.EventHandler(this.lineColorPanel_Click);
  371. //
  372. // label41
  373. //
  374. this.label41.AutoSize = true;
  375. this.label41.Location = new System.Drawing.Point(13, 99);
  376. this.label41.Name = "label41";
  377. this.label41.Size = new System.Drawing.Size(65, 12);
  378. this.label41.TabIndex = 6;
  379. this.label41.Text = "线条颜色:";
  380. //
  381. // textPanel
  382. //
  383. this.textPanel.BackColor = System.Drawing.SystemColors.Window;
  384. this.textPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  385. this.textPanel.Location = new System.Drawing.Point(91, 73);
  386. this.textPanel.Name = "textPanel";
  387. this.textPanel.Size = new System.Drawing.Size(152, 20);
  388. this.textPanel.TabIndex = 5;
  389. this.textPanel.Click += new System.EventHandler(this.textColorPanel_Click);
  390. //
  391. // label31
  392. //
  393. this.label31.AutoSize = true;
  394. this.label31.Location = new System.Drawing.Point(13, 76);
  395. this.label31.Name = "label31";
  396. this.label31.Size = new System.Drawing.Size(65, 12);
  397. this.label31.TabIndex = 4;
  398. this.label31.Text = "文字颜色:";
  399. //
  400. // label21
  401. //
  402. this.label21.AutoSize = true;
  403. this.label21.Location = new System.Drawing.Point(13, 50);
  404. this.label21.Name = "label21";
  405. this.label21.Size = new System.Drawing.Size(65, 12);
  406. this.label21.TabIndex = 2;
  407. this.label21.Text = "文字字号:";
  408. //
  409. // comboBox11
  410. //
  411. this.comboBox11.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  412. this.comboBox11.FormattingEnabled = true;
  413. this.comboBox11.Location = new System.Drawing.Point(91, 20);
  414. this.comboBox11.Name = "comboBox11";
  415. this.comboBox11.Size = new System.Drawing.Size(152, 20);
  416. this.comboBox11.TabIndex = 1;
  417. //
  418. // label11
  419. //
  420. this.label11.AutoSize = true;
  421. this.label11.Location = new System.Drawing.Point(13, 23);
  422. this.label11.Name = "label11";
  423. this.label11.Size = new System.Drawing.Size(65, 12);
  424. this.label11.TabIndex = 0;
  425. this.label11.Text = "文字字体:";
  426. //
  427. // groupBox1
  428. //
  429. this.groupBox1.Controls.Add(this.button3);
  430. this.groupBox1.Controls.Add(this.button1);
  431. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  432. this.groupBox1.Name = "groupBox1";
  433. this.groupBox1.Size = new System.Drawing.Size(633, 58);
  434. this.groupBox1.TabIndex = 7;
  435. this.groupBox1.TabStop = false;
  436. this.groupBox1.Text = "操作";
  437. //
  438. // button3
  439. //
  440. this.button3.Location = new System.Drawing.Point(541, 20);
  441. this.button3.Name = "button3";
  442. this.button3.Size = new System.Drawing.Size(75, 23);
  443. this.button3.TabIndex = 2;
  444. this.button3.Text = "关闭";
  445. this.button3.UseVisualStyleBackColor = true;
  446. this.button3.Click += new System.EventHandler(this.button3_Click);
  447. //
  448. // button1
  449. //
  450. this.button1.Location = new System.Drawing.Point(460, 20);
  451. this.button1.Name = "button1";
  452. this.button1.Size = new System.Drawing.Size(75, 23);
  453. this.button1.TabIndex = 0;
  454. this.button1.Text = "应用";
  455. this.button1.UseVisualStyleBackColor = true;
  456. this.button1.Click += new System.EventHandler(this.button1_Click);
  457. //
  458. // MeasurementPropertiesDialog
  459. //
  460. this.ClientSize = new System.Drawing.Size(652, 319);
  461. this.Controls.Add(this.groupBox2);
  462. this.Controls.Add(this.groupBox1);
  463. this.MinimizeBox = false;
  464. this.Name = "MeasurementPropertiesDialog";
  465. this.Text = "测量属性";
  466. this.groupBox2.ResumeLayout(false);
  467. this.groupBox2.PerformLayout();
  468. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  469. this.panel3.ResumeLayout(false);
  470. this.panel3.PerformLayout();
  471. this.panel2.ResumeLayout(false);
  472. this.panel2.PerformLayout();
  473. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown11)).EndInit();
  474. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown21)).EndInit();
  475. this.groupBox1.ResumeLayout(false);
  476. this.ResumeLayout(false);
  477. }
  478. #endregion
  479. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  480. {
  481. }
  482. private void textColorPanel_Click(object sender, EventArgs e)
  483. {
  484. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.textPanel.BackColor);
  485. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.textColorChanged));
  486. this.colorsForm.ShowDialog();
  487. }
  488. private void textColorChanged(object sender, EventArgs e)
  489. {
  490. this.textPanel.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  491. //this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  492. this.colorsForm.Close();
  493. }
  494. private void lineColorPanel_Click(object sender, EventArgs e)
  495. {
  496. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.linePanel.BackColor);
  497. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
  498. this.colorsForm1.ShowDialog();
  499. }
  500. private void lineColorChanged(object sender, EventArgs e)
  501. {
  502. this.linePanel.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  503. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  504. this.colorsForm1.Close();
  505. }
  506. /// <summary>
  507. /// 初始化属性画面
  508. /// </summary>
  509. private void UpdateRightSettingUI()
  510. {
  511. switch (this.drawObject.drawToolType)
  512. {
  513. case DrawToolType.MeasureLine: //长度测量直线
  514. MeasureStyleModel.MeasureLine measureLine = this.measureStyleModel.measureLine;
  515. this.panel2.Visible = true;
  516. this.panel3.Visible = false;
  517. this.numericUpDown1.Visible = true;
  518. this.label5.Visible = true;
  519. this.comboBox5.Visible = true;
  520. this.label6.Visible = true;
  521. this.label91.Visible = false;
  522. this.comboBox91.Visible = false;
  523. UpdataFontPosition(false);
  524. this.UpdateMeasureStyleData(measureLine.font, measureLine.fontSize, measureLine.textColor, measureLine.lineColor, measureLine.lineWidth, measureLine.lineStyle, measureLine.linePosition, 0, 0, measureLine.vLineLength, measureLine.followLine);
  525. break;
  526. case DrawToolType.MeasureDistanceLine: //长度测量距离
  527. MeasureStyleModel.MeasureDistanceLine measureDistanceLine = this.measureStyleModel.measureDistanceLine;
  528. this.panel2.Visible = true;
  529. this.panel3.Visible = false;
  530. this.numericUpDown1.Visible = false;
  531. this.label5.Visible = false;
  532. this.comboBox5.Visible = false;
  533. this.label6.Visible = false;
  534. this.label91.Visible = false;
  535. this.comboBox91.Visible = false;
  536. UpdataFontPosition(false);
  537. this.UpdateMeasureStyleData(measureDistanceLine.font, measureDistanceLine.fontSize, measureDistanceLine.textColor, measureDistanceLine.lineColor, measureDistanceLine.lineWidth, measureDistanceLine.lineStyle, measureDistanceLine.linePosition, 0, 0, -1);
  538. break;
  539. case DrawToolType.MeasureLength: //长度测量->长度
  540. MeasureStyleModel.MeasureLength measureLength = this.measureStyleModel.measureLength;
  541. this.panel2.Visible = true;
  542. this.panel3.Visible = false;
  543. this.numericUpDown1.Visible = false;
  544. this.label5.Visible = false;
  545. this.comboBox5.Visible = false;
  546. this.label6.Visible = false;
  547. this.label91.Visible = false;
  548. this.comboBox91.Visible = false;
  549. UpdataFontPosition(false);
  550. this.UpdateMeasureStyleData(measureLength.font, measureLength.fontSize, measureLength.textColor, measureLength.lineColor, measureLength.lineWidth, measureLength.lineStyle, measureLength.linePosition, 0, 0, -1);
  551. break;
  552. case DrawToolType.MeasureHLine: //长度测量->水平线
  553. MeasureStyleModel.MeasureHLine measureHLine = this.measureStyleModel.measureHLine;
  554. this.panel2.Visible = true;
  555. this.panel3.Visible = false;
  556. this.numericUpDown1.Visible = true;
  557. this.label5.Visible = true;
  558. this.comboBox5.Visible = false;
  559. this.label6.Visible = false;
  560. this.label91.Visible = false;
  561. this.comboBox91.Visible = false;
  562. UpdataFontPosition(false);
  563. this.UpdateMeasureStyleData(measureHLine.font, measureHLine.fontSize, measureHLine.textColor, measureHLine.lineColor, measureHLine.lineWidth, measureHLine.lineStyle, measureHLine.linePosition, 0, 0, measureHLine.vLineLength);
  564. break;
  565. case DrawToolType.MeasureVLine: //长度测量->垂线
  566. MeasureStyleModel.MeasureVLine measureVLine = this.measureStyleModel.measureVLine;
  567. this.panel2.Visible = true;
  568. this.panel3.Visible = false;
  569. this.numericUpDown1.Visible = true;
  570. this.label5.Visible = true;
  571. this.comboBox5.Visible = true;
  572. this.label6.Visible = true;
  573. this.label91.Visible = false;
  574. this.comboBox91.Visible = false;
  575. UpdataFontPosition(false);
  576. this.UpdateMeasureStyleData(measureVLine.font, measureVLine.fontSize, measureVLine.textColor, measureVLine.lineColor, measureVLine.lineWidth, measureVLine.lineStyle, measureVLine.linePosition, 0, 0, measureVLine.vLineLength, measureVLine.followLine);
  577. break;
  578. }
  579. }
  580. private void UpdataFontPosition(bool curve)
  581. {
  582. List<string> position = new List<string> { PdnResources.GetString("Menu.Upperleft.text")
  583. , PdnResources.GetString("Menu.Uppermiddle.Text")
  584. , PdnResources.GetString("Menu.Upperright.text")
  585. , PdnResources.GetString("Menu.Lowerleft.text")
  586. , PdnResources.GetString("Menu.Themiddleandlower.Text")
  587. , PdnResources.GetString("Menu.Lowerright.text")};
  588. List<string> position1 = new List<string> { PdnResources.GetString("Menu.hestartingpoint.Text")
  589. , PdnResources.GetString("Menu.Theendpoint.Text")
  590. };
  591. this.comboBox2.DataSource = null;
  592. if (curve)
  593. this.comboBox2.DataSource = position1;
  594. else
  595. this.comboBox2.DataSource = position;
  596. }
  597. /// <summary>
  598. /// 更新显示区域控件的数值
  599. /// </summary>
  600. /// <param name="font"></param>
  601. /// <param name="fontSize"></param>
  602. /// <param name="textColor"></param>
  603. /// <param name="lineColor"></param>
  604. /// <param name="lineWidth"></param>
  605. /// <param name="lineStyle"></param>
  606. private void UpdateMeasureStyleData(string font, int fontSize, int textColor, int lineColor, int lineWidth, int lineStyle, int linePosition, int linePositionL, int linePositionP, int vLineLength, bool followLine = false, bool isAngle = false)
  607. {
  608. //绑定样式默认数据
  609. this.comboBox11.Text = font;
  610. this.numericUpDown21.Value = fontSize;
  611. this.textPanel.BackColor = Color.FromArgb(textColor);
  612. this.linePanel.BackColor = Color.FromArgb(lineColor);
  613. this.numericUpDown11.Value = lineWidth;
  614. this.comboBox21.SelectedIndex = lineStyle;
  615. if (this.comboBox2.Items.Count > 0)
  616. this.comboBox2.SelectedIndex = linePosition;
  617. if (this.comboBox3.Items.Count > 0)
  618. this.comboBox3.SelectedIndex = linePositionL;
  619. if (this.comboBox4.Items.Count > 0)
  620. this.comboBox4.SelectedIndex = linePositionP;
  621. if (vLineLength > -1)
  622. this.numericUpDown1.Value = vLineLength;
  623. if (followLine)
  624. {
  625. this.comboBox5.SelectedIndex = 0;
  626. }
  627. else
  628. {
  629. this.comboBox5.SelectedIndex = 1;
  630. }
  631. this.comboBox91.SelectedIndex = isAngle ? 1 : 0;
  632. }
  633. /// <summary>
  634. /// 保存
  635. /// </summary>
  636. private void button2_Click()
  637. {
  638. //调用检查类型
  639. this.checkSaveModel();
  640. //以下保存xml文件信息
  641. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureStyleModel>(this.measureStyleModel);
  642. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + "Default" + ".xml";
  643. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  644. }
  645. /// <summary>
  646. /// 检查保存类型
  647. /// </summary>
  648. private void checkSaveModel()
  649. {
  650. string font = comboBox11.Text;
  651. int fontSize = Convert.ToInt32(numericUpDown21.Value);
  652. int textColor = Convert.ToInt32(this.textPanel.BackColor.ToArgb());
  653. int lineColor = Convert.ToInt32(this.linePanel.BackColor.ToArgb());
  654. int lineWidth = Convert.ToInt32(numericUpDown11.Value);
  655. int lineStyle = this.comboBox21.SelectedIndex;
  656. int linePosition = this.comboBox2.SelectedIndex;
  657. int linePositionL = this.comboBox3.SelectedIndex;
  658. int linePositionP = this.comboBox4.SelectedIndex;
  659. int vLineLength = Convert.ToInt32(this.numericUpDown1.Value);
  660. bool isAngle = comboBox91.SelectedIndex == 0 ? false : true;
  661. switch (this.drawObject.drawToolType)
  662. {
  663. case DrawToolType.MeasureLine: //长度测量直线
  664. this.measureStyleModel.measureLine.font = font;
  665. this.measureStyleModel.measureLine.fontSize = fontSize;
  666. this.measureStyleModel.measureLine.textColor = textColor;
  667. this.measureStyleModel.measureLine.lineColor = lineColor;
  668. this.measureStyleModel.measureLine.lineWidth = lineWidth;
  669. this.measureStyleModel.measureLine.lineStyle = lineStyle;
  670. this.measureStyleModel.measureLine.linePosition = linePosition;
  671. this.measureStyleModel.measureLine.vLineLength = vLineLength;
  672. this.measureStyleModel.measureLine.followLine = this.comboBox5.SelectedIndex == 0 ? true : false;
  673. break;
  674. case DrawToolType.MeasureDistanceLine: //长度测量距离
  675. this.measureStyleModel.measureDistanceLine.font = font;
  676. this.measureStyleModel.measureDistanceLine.fontSize = fontSize;
  677. this.measureStyleModel.measureDistanceLine.textColor = textColor;
  678. this.measureStyleModel.measureDistanceLine.lineColor = lineColor;
  679. this.measureStyleModel.measureDistanceLine.lineWidth = lineWidth;
  680. this.measureStyleModel.measureDistanceLine.lineStyle = lineStyle;
  681. this.measureStyleModel.measureDistanceLine.linePosition = linePosition;
  682. break;
  683. case DrawToolType.MeasureLength: //长度测量->长度
  684. this.measureStyleModel.measureLength.font = font;
  685. this.measureStyleModel.measureLength.fontSize = fontSize;
  686. this.measureStyleModel.measureLength.textColor = textColor;
  687. this.measureStyleModel.measureLength.lineColor = lineColor;
  688. this.measureStyleModel.measureLength.lineWidth = lineWidth;
  689. this.measureStyleModel.measureLength.lineStyle = lineStyle;
  690. this.measureStyleModel.measureLength.linePosition = linePosition;
  691. break;
  692. case DrawToolType.MeasureHLine: //长度测量->水平线
  693. this.measureStyleModel.measureHLine.font = font;
  694. this.measureStyleModel.measureHLine.fontSize = fontSize;
  695. this.measureStyleModel.measureHLine.textColor = textColor;
  696. this.measureStyleModel.measureHLine.lineColor = lineColor;
  697. this.measureStyleModel.measureHLine.lineWidth = lineWidth;
  698. this.measureStyleModel.measureHLine.lineStyle = lineStyle;
  699. this.measureStyleModel.measureHLine.linePosition = linePosition;
  700. this.measureStyleModel.measureHLine.vLineLength = vLineLength;
  701. break;
  702. case DrawToolType.MeasureVLine: //长度测量->垂线
  703. this.measureStyleModel.measureVLine.font = font;
  704. this.measureStyleModel.measureVLine.fontSize = fontSize;
  705. this.measureStyleModel.measureVLine.textColor = textColor;
  706. this.measureStyleModel.measureVLine.lineColor = lineColor;
  707. this.measureStyleModel.measureVLine.lineWidth = lineWidth;
  708. this.measureStyleModel.measureVLine.lineStyle = lineStyle;
  709. this.measureStyleModel.measureVLine.linePosition = linePosition;
  710. this.measureStyleModel.measureVLine.vLineLength = vLineLength;
  711. this.measureStyleModel.measureVLine.followLine = this.comboBox5.SelectedIndex == 0 ? true : false;
  712. break;
  713. }
  714. }
  715. /// <summary>
  716. /// 应用
  717. /// </summary>
  718. /// <param name="sender"></param>
  719. /// <param name="e"></param>
  720. private void button1_Click(object sender, EventArgs e)
  721. {
  722. button2_Click();
  723. //修改缓存中的样式数据
  724. Program.instance.measureStyleModel = this.measureStyleModel;
  725. //修改主配置文件中的值
  726. configModel.MeasurementStyle = "Default.xml";
  727. //修改主配置文件的xml
  728. string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(this.configModel);
  729. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Config.xml";
  730. FileOperationHelper.WriteStringToFile(configModelXml, filePath, FileMode.Create);
  731. MessageBox.Show(PdnResources.GetString("Menu.Applicationsuccessfully.Text"));
  732. ((MeasureDrawObject)(this.drawObject)).mouseUpAttribute = true;
  733. if (this.appWorkspace.ActiveDocumentWorkspace != null) {
  734. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  735. }
  736. if (documentWorkspaceWindow != null)
  737. {
  738. documentWorkspaceWindow.Refresh();
  739. }
  740. this.appWorkspace.RefreshListView();
  741. this.Close();
  742. }
  743. /// <summary>
  744. /// 关闭
  745. /// </summary>
  746. /// <param name="sender"></param>
  747. /// <param name="e"></param>
  748. private void button3_Click(object sender, EventArgs e)
  749. {
  750. this.Close();
  751. }
  752. }
  753. }