MeasureSettingDialog.cs 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  1. using Resources;
  2. using SmartCoalApplication.Annotation.Enum;
  3. using SmartCoalApplication.Annotation.relationModel;
  4. using SmartCoalApplication.Base;
  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 MeasureSettingDialog : PdnBaseForm
  24. {
  25. /// <summary>
  26. /// 测量一二级关系
  27. /// </summary>
  28. private static List<MeasureRelationModel> list;
  29. /// <summary>
  30. /// 当前选中的二级标注
  31. /// </summary>
  32. private DrawToolType drawToolType;
  33. /// <summary>
  34. /// 测量的样式
  35. /// </summary>
  36. private MeasureStyleModel measureStyleModel = Program.instance.measureStyleModel;
  37. /// <summary>
  38. /// 主配置文件的model
  39. /// </summary>
  40. private ConfigModel configModel = Program.instance.configModel;
  41. /// <summary>
  42. /// 操作区控件
  43. /// </summary>
  44. private GroupBox groupBox1;
  45. private Label label1;
  46. private ComboBox comboBox1;
  47. private Button button4;
  48. private Button button3;
  49. private Button button2;
  50. private Panel panel1;
  51. private ListBox listBox1;
  52. private GroupBox groupBox3;
  53. private GroupBox groupBox2;
  54. private GroupBox groupBox4;
  55. private ConfigModel config = Program.instance.configModel;
  56. /// <summary>
  57. /// 设置区控件
  58. /// </summary>
  59. private System.Windows.Forms.Label label11;
  60. private System.Windows.Forms.ComboBox comboBox11;
  61. private System.Windows.Forms.Label label21;
  62. private System.Windows.Forms.Label label31;
  63. private System.Windows.Forms.Panel textPanel;
  64. private System.Windows.Forms.Panel linePanel;
  65. private System.Windows.Forms.Label label41;
  66. private System.Windows.Forms.Label label51;
  67. private System.Windows.Forms.Label label61;
  68. private System.Windows.Forms.Label label71;
  69. /// <summary>
  70. /// 测量样式
  71. /// </summary>
  72. private NumericUpDown numericUpDown21;
  73. private ComboBox comboBox21;
  74. private NumericUpDown numericUpDown11;
  75. private NumericUpDown numericUpDown71;
  76. private Button button5;
  77. /// <summary>
  78. /// 字体列表
  79. /// </summary>
  80. ArrayList fontsItems = new ArrayList();
  81. /// <summary>
  82. /// 另存为弹出框显示
  83. /// </summary>
  84. private CreateNameDialog dialog;
  85. /// <summary>
  86. /// 操作样式下拉数据
  87. /// </summary>
  88. private List<string> files = new List<string>();
  89. /// <summary>
  90. /// 另存为文件名
  91. /// </summary>
  92. private string newName;
  93. /// <summary>
  94. /// 选中的测量类型
  95. /// </summary>
  96. private int selectId;
  97. ColorsForm colorsForm;
  98. ColorsForm colorsForm1;
  99. private Panel panel2;
  100. private ComboBox comboBox2;
  101. private Label label2;
  102. private Panel panel3;
  103. private ComboBox comboBox4;
  104. private Label label4;
  105. private ComboBox comboBox3;
  106. private ComboBox comboBox91;
  107. private Label label3;
  108. private Button button6;
  109. private NumericUpDown numericUpDown1;
  110. private Label label5;
  111. private ComboBox comboBox5;
  112. private Label label6;
  113. private int initflag = 0;
  114. private AppWorkspace appWorkspace;
  115. private System.Windows.Forms.Label label91;
  116. public MeasureSettingDialog(AppWorkspace appWorkspace)
  117. {
  118. if (list == null)
  119. {
  120. list = InvariantData.GetMeasureRelations();
  121. }
  122. this.appWorkspace = appWorkspace;
  123. InitializeComponent();
  124. InitializeLanguageText();
  125. InitializeComponent2();
  126. this.Icon = PdnInfo.AppIcon;
  127. //绑定线样式数据
  128. this.comboBox21.Items.AddRange(InvariantData.dashStyles);
  129. InitializeData();
  130. }
  131. private void InitializeLanguageText()
  132. {
  133. this.label1.Text = PdnResources.GetString("Menu.Currentoperationstyle.text") + ":";
  134. this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  135. this.button3.Text = PdnResources.GetString("Menu.File.SaveAs.Text");
  136. this.button2.Text = PdnResources.GetString("Menu.File.Save.Text");
  137. this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text");
  138. this.groupBox4.Text = PdnResources.GetString("Menu.Setting.Text");
  139. this.comboBox3.Items.AddRange(new object[] {
  140. PdnResources.GetString("Menu.Upperleft.text"),
  141. PdnResources.GetString("Menu.Uppermiddle.Text"),
  142. PdnResources.GetString("Menu.Upperright.text"),
  143. PdnResources.GetString("Menu.Lowerleft.text"),
  144. PdnResources.GetString("Menu.Themiddleandlower.Text"),
  145. PdnResources.GetString("Menu.Lowerright.text")});
  146. this.comboBox91.Items.AddRange(new object[] {
  147. PdnResources.GetString("NewDegree"),
  148. PdnResources.GetString("NewSecretPlace")});
  149. this.comboBox4.Items.AddRange(new object[] {
  150. PdnResources.GetString("Menu.Upperleft.text"),
  151. PdnResources.GetString("Menu.Uppermiddle.Text"),
  152. PdnResources.GetString("Menu.Upperright.text"),
  153. PdnResources.GetString("Menu.Lowerleft.text"),
  154. PdnResources.GetString("Menu.Themiddleandlower.Text"),
  155. PdnResources.GetString("Menu.Lowerright.text")});
  156. this.label4.Text = PdnResources.GetString("Menu.Set.Rulersettings.Textposition.text") + "(" + PdnResources.GetString("Menu.Generalanalysis.Integrator.point.text") + "):";
  157. this.label3.Text = PdnResources.GetString("Menu.Textpositionli.Text") + ":";
  158. this.label2.Text = PdnResources.GetString("Menu.Set.Rulersettings.Textposition.text") + ":";
  159. this.label5.Text = PdnResources.GetString("NewVerticalLength") + ":";
  160. this.label61.Text = PdnResources.GetString("Menu.Linestyle.Text") + ":";
  161. this.label71.Text = PdnResources.GetString("NewMarkerPointSize") + ":";
  162. this.label51.Text = PdnResources.GetString("Menu.Set.Rulersettings.Linewidth.text") + ":";
  163. this.label41.Text = PdnResources.GetString("Menu.Set.Rulersettings.Linecolor.text") + ":";
  164. this.label31.Text = PdnResources.GetString("Menu.Textcolor.text") + ":";
  165. this.label21.Text = PdnResources.GetString("Menu.Set.Rulersettings.Fontsize.text") + ":";
  166. this.label11.Text = PdnResources.GetString("Menu.Textfont.text") + ":";
  167. this.button6.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
  168. this.groupBox3.Text = PdnResources.GetString("Menu.Type.text");
  169. this.Text = PdnResources.GetString("Menu.Setting.MeasureSetting.Text");
  170. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  171. }
  172. private void InitializeComponent()
  173. {
  174. this.groupBox1 = new System.Windows.Forms.GroupBox();
  175. this.label1 = new System.Windows.Forms.Label();
  176. this.comboBox1 = new System.Windows.Forms.ComboBox();
  177. this.button4 = new System.Windows.Forms.Button();
  178. this.button3 = new System.Windows.Forms.Button();
  179. this.button2 = new System.Windows.Forms.Button();
  180. this.panel1 = new System.Windows.Forms.Panel();
  181. this.groupBox2 = new System.Windows.Forms.GroupBox();
  182. this.comboBox5 = new System.Windows.Forms.ComboBox();
  183. this.label6 = new System.Windows.Forms.Label();
  184. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  185. this.label5 = new System.Windows.Forms.Label();
  186. this.panel3 = new System.Windows.Forms.Panel();
  187. this.comboBox4 = new System.Windows.Forms.ComboBox();
  188. this.label4 = new System.Windows.Forms.Label();
  189. this.comboBox3 = new System.Windows.Forms.ComboBox();
  190. this.label3 = new System.Windows.Forms.Label();
  191. this.panel2 = new System.Windows.Forms.Panel();
  192. this.comboBox2 = new System.Windows.Forms.ComboBox();
  193. this.label2 = new System.Windows.Forms.Label();
  194. this.numericUpDown11 = new System.Windows.Forms.NumericUpDown();
  195. this.comboBox21 = new System.Windows.Forms.ComboBox();
  196. this.numericUpDown21 = new System.Windows.Forms.NumericUpDown();
  197. this.label61 = new System.Windows.Forms.Label();
  198. this.label51 = new System.Windows.Forms.Label();
  199. this.linePanel = new System.Windows.Forms.Panel();
  200. this.label41 = new System.Windows.Forms.Label();
  201. this.textPanel = new System.Windows.Forms.Panel();
  202. this.label31 = new System.Windows.Forms.Label();
  203. this.label91 = new System.Windows.Forms.Label();
  204. this.comboBox91 = new System.Windows.Forms.ComboBox();
  205. this.label21 = new System.Windows.Forms.Label();
  206. this.comboBox11 = new System.Windows.Forms.ComboBox();
  207. this.label11 = new System.Windows.Forms.Label();
  208. this.groupBox4 = new System.Windows.Forms.GroupBox();
  209. this.label71 = new System.Windows.Forms.Label();
  210. this.numericUpDown71 = new System.Windows.Forms.NumericUpDown();
  211. this.button6 = new System.Windows.Forms.Button();
  212. this.listBox1 = new System.Windows.Forms.ListBox();
  213. this.groupBox3 = new System.Windows.Forms.GroupBox();
  214. this.button5 = new System.Windows.Forms.Button();
  215. this.groupBox1.SuspendLayout();
  216. this.groupBox2.SuspendLayout();
  217. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  218. this.panel3.SuspendLayout();
  219. this.panel2.SuspendLayout();
  220. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown11)).BeginInit();
  221. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown21)).BeginInit();
  222. this.groupBox4.SuspendLayout();
  223. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown71)).BeginInit();
  224. this.groupBox3.SuspendLayout();
  225. this.SuspendLayout();
  226. //
  227. // groupBox1
  228. //
  229. this.groupBox1.Controls.Add(this.label1);
  230. this.groupBox1.Controls.Add(this.comboBox1);
  231. this.groupBox1.Controls.Add(this.button4);
  232. this.groupBox1.Controls.Add(this.button3);
  233. this.groupBox1.Controls.Add(this.button2);
  234. this.groupBox1.Location = new System.Drawing.Point(137, 12);
  235. this.groupBox1.Name = "groupBox1";
  236. this.groupBox1.Size = new System.Drawing.Size(716, 58);
  237. this.groupBox1.TabIndex = 3;
  238. this.groupBox1.TabStop = false;
  239. this.groupBox1.Text = "操作";
  240. //
  241. // label1
  242. //
  243. this.label1.AutoSize = true;
  244. this.label1.Location = new System.Drawing.Point(172, 25);
  245. this.label1.Name = "label1";
  246. this.label1.Size = new System.Drawing.Size(0, 12);
  247. this.label1.TabIndex = 5;
  248. //
  249. // comboBox1
  250. //
  251. this.comboBox1.FormattingEnabled = true;
  252. this.comboBox1.Location = new System.Drawing.Point(351, 21);
  253. this.comboBox1.Name = "comboBox1";
  254. this.comboBox1.Size = new System.Drawing.Size(116, 20);
  255. this.comboBox1.TabIndex = 4;
  256. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  257. this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
  258. //
  259. // button4
  260. //
  261. this.button4.Location = new System.Drawing.Point(473, 20);
  262. this.button4.Name = "button4";
  263. this.button4.Size = new System.Drawing.Size(75, 23);
  264. this.button4.TabIndex = 3;
  265. this.button4.Text = "删除";
  266. this.button4.UseVisualStyleBackColor = true;
  267. this.button4.Click += new System.EventHandler(this.Button4_Click);
  268. //
  269. // button3
  270. //
  271. this.button3.Location = new System.Drawing.Point(554, 20);
  272. this.button3.Name = "button3";
  273. this.button3.Size = new System.Drawing.Size(75, 23);
  274. this.button3.TabIndex = 2;
  275. this.button3.Text = "另存为";
  276. this.button3.UseVisualStyleBackColor = true;
  277. this.button3.Click += new System.EventHandler(this.Button3_Click);
  278. //
  279. // button2
  280. //
  281. this.button2.Location = new System.Drawing.Point(635, 20);
  282. this.button2.Name = "button2";
  283. this.button2.Size = new System.Drawing.Size(75, 23);
  284. this.button2.TabIndex = 1;
  285. this.button2.Text = "保存";
  286. this.button2.UseVisualStyleBackColor = true;
  287. this.button2.Click += new System.EventHandler(this.Button2_Click);
  288. //
  289. // panel1
  290. //
  291. this.panel1.Location = new System.Drawing.Point(137, 76);
  292. this.panel1.Name = "panel1";
  293. this.panel1.Size = new System.Drawing.Size(633, 36);
  294. this.panel1.TabIndex = 8;
  295. //
  296. // groupBox2
  297. //
  298. this.groupBox2.Controls.Add(this.comboBox5);
  299. this.groupBox2.Controls.Add(this.label6);
  300. this.groupBox2.Controls.Add(this.numericUpDown1);
  301. this.groupBox2.Controls.Add(this.label5);
  302. this.groupBox2.Controls.Add(this.panel3);
  303. this.groupBox2.Controls.Add(this.panel2);
  304. this.groupBox2.Controls.Add(this.numericUpDown11);
  305. this.groupBox2.Controls.Add(this.comboBox21);
  306. this.groupBox2.Controls.Add(this.numericUpDown21);
  307. this.groupBox2.Controls.Add(this.label61);
  308. this.groupBox2.Controls.Add(this.label51);
  309. this.groupBox2.Controls.Add(this.linePanel);
  310. this.groupBox2.Controls.Add(this.label41);
  311. this.groupBox2.Controls.Add(this.textPanel);
  312. this.groupBox2.Controls.Add(this.label31);
  313. this.groupBox2.Controls.Add(this.label91);
  314. this.groupBox2.Controls.Add(this.comboBox91);
  315. this.groupBox2.Controls.Add(this.label21);
  316. this.groupBox2.Controls.Add(this.comboBox11);
  317. this.groupBox2.Controls.Add(this.label11);
  318. this.groupBox2.Location = new System.Drawing.Point(137, 118);
  319. this.groupBox2.Name = "groupBox2";
  320. this.groupBox2.Size = new System.Drawing.Size(716, 235);
  321. this.groupBox2.TabIndex = 6;
  322. this.groupBox2.TabStop = false;
  323. this.groupBox2.Text = "设置";
  324. //
  325. // comboBox5
  326. //
  327. this.comboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  328. this.comboBox5.FormattingEnabled = true;
  329. this.comboBox5.Items.AddRange(new object[] {
  330. PdnResources.GetString("NewFollowingTheLine"),
  331. PdnResources.GetString("NewLevel")});
  332. this.comboBox5.Location = new System.Drawing.Point(342, 46);
  333. this.comboBox5.Name = "comboBox5";
  334. this.comboBox5.Size = new System.Drawing.Size(122, 20);
  335. this.comboBox5.TabIndex = 20;
  336. //
  337. // label6
  338. //
  339. this.label6.AutoSize = true;
  340. this.label6.Location = new System.Drawing.Point(265, 50);
  341. this.label6.Name = "label6";
  342. this.label6.Size = new System.Drawing.Size(65, 12);
  343. this.label6.TabIndex = 19;
  344. this.label6.Text = "文字方向:";
  345. //
  346. // numericUpDown1
  347. //
  348. this.numericUpDown1.Location = new System.Drawing.Point(342, 19);
  349. this.numericUpDown1.Name = "numericUpDown1";
  350. this.numericUpDown1.Size = new System.Drawing.Size(152, 21);
  351. this.numericUpDown1.TabIndex = 18;
  352. //
  353. // label5
  354. //
  355. this.label5.AutoSize = true;
  356. this.label5.Location = new System.Drawing.Point(265, 23);
  357. this.label5.Name = "label5";
  358. this.label5.Size = new System.Drawing.Size(65, 12);
  359. this.label5.TabIndex = 17;
  360. this.label5.Text = "垂线长度:";
  361. //
  362. // panel3
  363. //
  364. this.panel3.Controls.Add(this.comboBox4);
  365. this.panel3.Controls.Add(this.label4);
  366. this.panel3.Controls.Add(this.comboBox3);
  367. this.panel3.Controls.Add(this.label3);
  368. this.panel3.Location = new System.Drawing.Point(9, 175);
  369. this.panel3.Name = "panel3";
  370. this.panel3.Size = new System.Drawing.Size(236, 57);
  371. this.panel3.TabIndex = 16;
  372. //
  373. // comboBox4
  374. //
  375. this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  376. this.comboBox4.FormattingEnabled = true;
  377. this.comboBox4.Location = new System.Drawing.Point(112, 30);
  378. this.comboBox4.Name = "comboBox4";
  379. this.comboBox4.Size = new System.Drawing.Size(122, 20);
  380. this.comboBox4.TabIndex = 17;
  381. //
  382. // label4
  383. //
  384. this.label4.AutoSize = true;
  385. this.label4.Location = new System.Drawing.Point(5, 34);
  386. this.label4.Name = "label4";
  387. this.label4.Size = new System.Drawing.Size(89, 12);
  388. this.label4.TabIndex = 16;
  389. this.label4.Text = "文字位置(点):";
  390. //
  391. // comboBox3
  392. //
  393. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  394. this.comboBox3.FormattingEnabled = true;
  395. this.comboBox3.Location = new System.Drawing.Point(112, 4);
  396. this.comboBox3.Name = "comboBox3";
  397. this.comboBox3.Size = new System.Drawing.Size(122, 20);
  398. this.comboBox3.TabIndex = 15;
  399. //
  400. // label3
  401. //
  402. this.label3.AutoSize = true;
  403. this.label3.Location = new System.Drawing.Point(5, 7);
  404. this.label3.Name = "label3";
  405. this.label3.Size = new System.Drawing.Size(89, 12);
  406. this.label3.TabIndex = 14;
  407. this.label3.Text = "文字位置(线):";
  408. //
  409. // panel2
  410. //
  411. this.panel2.Controls.Add(this.comboBox2);
  412. this.panel2.Controls.Add(this.label2);
  413. this.panel2.Location = new System.Drawing.Point(9, 175);
  414. this.panel2.Name = "panel2";
  415. this.panel2.Size = new System.Drawing.Size(236, 57);
  416. this.panel2.TabIndex = 15;
  417. //
  418. // comboBox2
  419. //
  420. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  421. this.comboBox2.FormattingEnabled = true;
  422. this.comboBox2.Location = new System.Drawing.Point(82, 3);
  423. this.comboBox2.Name = "comboBox2";
  424. this.comboBox2.Size = new System.Drawing.Size(152, 20);
  425. this.comboBox2.TabIndex = 15;
  426. //
  427. // label2
  428. //
  429. this.label2.AutoSize = true;
  430. this.label2.Location = new System.Drawing.Point(5, 7);
  431. this.label2.Name = "label2";
  432. this.label2.Size = new System.Drawing.Size(0, 12);
  433. this.label2.TabIndex = 14;
  434. //
  435. // numericUpDown11
  436. //
  437. this.numericUpDown11.Location = new System.Drawing.Point(91, 125);
  438. this.numericUpDown11.Name = "numericUpDown11";
  439. this.numericUpDown11.Size = new System.Drawing.Size(152, 21);
  440. this.numericUpDown11.TabIndex = 14;
  441. //
  442. // comboBox21
  443. //
  444. this.comboBox21.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  445. this.comboBox21.FormattingEnabled = true;
  446. this.comboBox21.Location = new System.Drawing.Point(91, 151);
  447. this.comboBox21.Name = "comboBox21";
  448. this.comboBox21.Size = new System.Drawing.Size(152, 20);
  449. this.comboBox21.TabIndex = 13;
  450. //
  451. // numericUpDown21
  452. //
  453. this.numericUpDown21.Location = new System.Drawing.Point(91, 46);
  454. this.numericUpDown21.Name = "numericUpDown21";
  455. this.numericUpDown21.Size = new System.Drawing.Size(152, 21);
  456. this.numericUpDown21.TabIndex = 12;
  457. //
  458. // label61
  459. //
  460. this.label61.AutoSize = true;
  461. this.label61.Location = new System.Drawing.Point(13, 155);
  462. this.label61.Name = "label61";
  463. this.label61.Size = new System.Drawing.Size(65, 12);
  464. this.label61.TabIndex = 9;
  465. this.label61.Text = "线条样式:";
  466. //
  467. // label51
  468. //
  469. this.label51.AutoSize = true;
  470. this.label51.Location = new System.Drawing.Point(13, 128);
  471. this.label51.Name = "label51";
  472. this.label51.Size = new System.Drawing.Size(65, 12);
  473. this.label51.TabIndex = 8;
  474. this.label51.Text = "线条宽度:";
  475. //
  476. // linePanel
  477. //
  478. this.linePanel.BackColor = System.Drawing.SystemColors.Window;
  479. this.linePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  480. this.linePanel.Location = new System.Drawing.Point(91, 99);
  481. this.linePanel.Name = "linePanel";
  482. this.linePanel.Size = new System.Drawing.Size(152, 20);
  483. this.linePanel.TabIndex = 7;
  484. this.linePanel.Click += new System.EventHandler(this.lineColorPanel_Click);
  485. //
  486. // label41
  487. //
  488. this.label41.AutoSize = true;
  489. this.label41.Location = new System.Drawing.Point(13, 99);
  490. this.label41.Name = "label41";
  491. this.label41.Size = new System.Drawing.Size(65, 12);
  492. this.label41.TabIndex = 6;
  493. this.label41.Text = "线条颜色:";
  494. //
  495. // textPanel
  496. //
  497. this.textPanel.BackColor = System.Drawing.SystemColors.Window;
  498. this.textPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  499. this.textPanel.Location = new System.Drawing.Point(91, 73);
  500. this.textPanel.Name = "textPanel";
  501. this.textPanel.Size = new System.Drawing.Size(152, 20);
  502. this.textPanel.TabIndex = 5;
  503. this.textPanel.Click += new System.EventHandler(this.textColorPanel_Click);
  504. //
  505. // label31
  506. //
  507. this.label31.AutoSize = true;
  508. this.label31.Location = new System.Drawing.Point(13, 76);
  509. this.label31.Name = "label31";
  510. this.label31.Size = new System.Drawing.Size(65, 12);
  511. this.label31.TabIndex = 4;
  512. this.label31.Text = "文字颜色:";
  513. //
  514. // label91
  515. //
  516. this.label91.AutoSize = true;
  517. this.label91.Location = new System.Drawing.Point(14, 182);
  518. this.label91.Name = "label91";
  519. this.label91.Size = new System.Drawing.Size(65, 12);
  520. this.label91.TabIndex = 14;
  521. this.label91.Text = "角度单位:";
  522. //
  523. // comboBox91
  524. //
  525. this.comboBox91.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  526. this.comboBox91.FormattingEnabled = true;
  527. this.comboBox91.Location = new System.Drawing.Point(91, 179);
  528. this.comboBox91.Name = "comboBox91";
  529. this.comboBox91.Size = new System.Drawing.Size(152, 20);
  530. this.comboBox91.TabIndex = 15;
  531. //
  532. // label21
  533. //
  534. this.label21.AutoSize = true;
  535. this.label21.Location = new System.Drawing.Point(13, 50);
  536. this.label21.Name = "label21";
  537. this.label21.Size = new System.Drawing.Size(65, 12);
  538. this.label21.TabIndex = 2;
  539. this.label21.Text = "文字字号:";
  540. //
  541. // comboBox11
  542. //
  543. this.comboBox11.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  544. this.comboBox11.FormattingEnabled = true;
  545. this.comboBox11.Location = new System.Drawing.Point(91, 20);
  546. this.comboBox11.Name = "comboBox11";
  547. this.comboBox11.Size = new System.Drawing.Size(152, 20);
  548. this.comboBox11.TabIndex = 1;
  549. //
  550. // label11
  551. //
  552. this.label11.AutoSize = true;
  553. this.label11.Location = new System.Drawing.Point(13, 23);
  554. this.label11.Name = "label11";
  555. this.label11.Size = new System.Drawing.Size(65, 12);
  556. this.label11.TabIndex = 0;
  557. this.label11.Text = "文字字体:";
  558. //
  559. // groupBox4
  560. //
  561. this.groupBox4.Controls.Add(this.label71);
  562. this.groupBox4.Controls.Add(this.numericUpDown71);
  563. this.groupBox4.Location = new System.Drawing.Point(137, 76);
  564. this.groupBox4.Name = "groupBox4";
  565. this.groupBox4.Size = new System.Drawing.Size(716, 277);
  566. this.groupBox4.TabIndex = 6;
  567. this.groupBox4.TabStop = false;
  568. this.groupBox4.Text = "设置";
  569. this.groupBox4.Visible = false;
  570. //
  571. // label71
  572. //
  573. this.label71.AutoSize = true;
  574. this.label71.Location = new System.Drawing.Point(13, 23);
  575. this.label71.Name = "label71";
  576. this.label71.Size = new System.Drawing.Size(77, 12);
  577. this.label71.TabIndex = 0;
  578. this.label71.Text = "标记点大小:";
  579. //
  580. // numericUpDown71
  581. //
  582. this.numericUpDown71.Location = new System.Drawing.Point(91, 23);
  583. this.numericUpDown71.Maximum = new decimal(new int[] {
  584. 100000,
  585. 0,
  586. 0,
  587. 0});
  588. this.numericUpDown71.Name = "numericUpDown71";
  589. this.numericUpDown71.Size = new System.Drawing.Size(152, 21);
  590. this.numericUpDown71.TabIndex = 14;
  591. //
  592. // button6
  593. //
  594. this.button6.Location = new System.Drawing.Point(778, 76);
  595. this.button6.Name = "button6";
  596. this.button6.Size = new System.Drawing.Size(75, 23);
  597. this.button6.TabIndex = 17;
  598. this.button6.Text = "保存全部";
  599. this.button6.UseVisualStyleBackColor = true;
  600. this.button6.Click += new System.EventHandler(this.button6_Click);
  601. //
  602. // listBox1
  603. //
  604. this.listBox1.FormattingEnabled = true;
  605. this.listBox1.ItemHeight = 12;
  606. this.listBox1.Location = new System.Drawing.Point(6, 20);
  607. this.listBox1.Name = "listBox1";
  608. this.listBox1.Size = new System.Drawing.Size(103, 316);
  609. this.listBox1.TabIndex = 0;
  610. this.listBox1.SelectedValueChanged += new System.EventHandler(this.listBox1_SelectedValueChanged);
  611. //
  612. // groupBox3
  613. //
  614. this.groupBox3.Controls.Add(this.listBox1);
  615. this.groupBox3.Location = new System.Drawing.Point(12, 12);
  616. this.groupBox3.Name = "groupBox3";
  617. this.groupBox3.Size = new System.Drawing.Size(115, 341);
  618. this.groupBox3.TabIndex = 9;
  619. this.groupBox3.TabStop = false;
  620. this.groupBox3.Text = "类型";
  621. //
  622. // button5
  623. //
  624. this.button5.Location = new System.Drawing.Point(0, 0);
  625. this.button5.Name = "button5";
  626. this.button5.Size = new System.Drawing.Size(75, 23);
  627. this.button5.TabIndex = 0;
  628. //
  629. // MeasureSettingDialog
  630. //
  631. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  632. this.ClientSize = new System.Drawing.Size(865, 358);
  633. this.Controls.Add(this.button6);
  634. this.Controls.Add(this.groupBox3);
  635. this.Controls.Add(this.panel1);
  636. this.Controls.Add(this.groupBox4);
  637. this.Controls.Add(this.groupBox2);
  638. this.Controls.Add(this.groupBox1);
  639. this.MinimizeBox = false;
  640. this.Name = "MeasureSettingDialog";
  641. this.Text = "测量设置";
  642. this.Controls.SetChildIndex(this.groupBox1, 0);
  643. this.Controls.SetChildIndex(this.groupBox2, 0);
  644. this.Controls.SetChildIndex(this.groupBox4, 0);
  645. this.Controls.SetChildIndex(this.panel1, 0);
  646. this.Controls.SetChildIndex(this.groupBox3, 0);
  647. this.Controls.SetChildIndex(this.button6, 0);
  648. this.groupBox1.ResumeLayout(false);
  649. this.groupBox1.PerformLayout();
  650. this.groupBox2.ResumeLayout(false);
  651. this.groupBox2.PerformLayout();
  652. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  653. this.panel3.ResumeLayout(false);
  654. this.panel3.PerformLayout();
  655. this.panel2.ResumeLayout(false);
  656. this.panel2.PerformLayout();
  657. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown11)).EndInit();
  658. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown21)).EndInit();
  659. this.groupBox4.ResumeLayout(false);
  660. this.groupBox4.PerformLayout();
  661. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown71)).EndInit();
  662. this.groupBox3.ResumeLayout(false);
  663. this.ResumeLayout(false);
  664. }
  665. #region InitializeComponent2
  666. /// <summary>
  667. /// 初始化组件
  668. /// </summary>
  669. private void InitializeComponent2()
  670. {
  671. this.colorsForm = new ColorsForm();
  672. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  673. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  674. this.colorsForm1 = new ColorsForm();
  675. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  676. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  677. }
  678. #endregion
  679. /// <summary>
  680. /// 初始化数据
  681. /// </summary>
  682. private void InitializeData()
  683. {
  684. this.listBox1.Items.Clear();
  685. //绑定左侧listbox数据
  686. foreach (MeasureRelationModel model in list)
  687. {
  688. if (model.id > 0)
  689. this.listBox1.Items.Add(model.name);
  690. }
  691. this.listBox1.SelectedIndex = 0;
  692. this.fontsItems.Clear();
  693. //绑定字体数据
  694. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  695. foreach (FontFamily fontFamily in fonts.Families)
  696. {
  697. fontsItems.Add(fontFamily.Name);
  698. }
  699. this.comboBox11.DataSource = fontsItems;
  700. //绑定样式默认数据
  701. this.comboBox11.Text = this.measureStyleModel.measureLine.font;
  702. this.numericUpDown21.Value = this.measureStyleModel.measureLine.fontSize;
  703. this.textPanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.textColor);
  704. this.linePanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.lineColor);
  705. this.numericUpDown11.Value = this.measureStyleModel.measureLine.lineWidth;
  706. this.comboBox21.SelectedIndex = this.measureStyleModel.measureLine.lineStyle;
  707. this.comboBox2.SelectedIndex = this.measureStyleModel.measureLine.linePosition;
  708. this.numericUpDown1.Value = this.measureStyleModel.measureLine.vLineLength;
  709. this.numericUpDown71.Value = this.config.MarkpointWidth;
  710. //绑定样式下拉 todo
  711. if (initflag++ == 0)
  712. {
  713. InitializeStyleName();
  714. }
  715. }
  716. /// <summary>
  717. /// 左侧listbox选择事件
  718. /// </summary>
  719. /// <param name="sender"></param>
  720. /// <param name="e"></param>
  721. private void listBox1_SelectedValueChanged(object sender, EventArgs e)
  722. {
  723. //首先更新右侧分类部分
  724. UpdateRightCatalog();
  725. //更新右侧设置界面
  726. UpdateRightSettingUI();
  727. //刷新右侧预览
  728. UpdateRightPreview();
  729. }
  730. /// <summary>
  731. /// 更新右侧分类
  732. /// </summary>
  733. private void UpdateRightCatalog()
  734. {
  735. this.panel1.Controls.Clear();
  736. MeasureRelationModel model = list[this.listBox1.SelectedIndex + 1];
  737. this.selectId = model.id;
  738. if (this.selectId == 10)
  739. {
  740. groupBox2.Visible = false;
  741. groupBox4.Visible = true;
  742. panel1.Visible = false;
  743. button6.Visible = false;
  744. comboBox1.Visible = false;
  745. button4.Visible = false;
  746. button3.Visible = false;
  747. label1.Visible = false;
  748. }
  749. else
  750. {
  751. groupBox2.Visible = true;
  752. groupBox4.Visible = false;
  753. panel1.Visible = true;
  754. button6.Visible = true;
  755. comboBox1.Visible = true;
  756. button4.Visible = true;
  757. button3.Visible = true;
  758. label1.Visible = true;
  759. }
  760. int postion = 0;
  761. foreach (MeasureRelationModel.ChildLabel child in model.childLabel)
  762. {
  763. if ((int)child.drawToolType > 0)
  764. {
  765. Button button = new Button();
  766. button.Size = new Size(75, 23);
  767. button.Location = new Point(postion * 75 + 5, 0);
  768. button.Text = child.name;
  769. button.Tag = child;
  770. button.Click += new EventHandler(ChildButton_Click);
  771. this.panel1.Controls.Add(button);
  772. if (postion == 0)
  773. {
  774. this.drawToolType = child.drawToolType;
  775. button.Focus();
  776. }
  777. postion++;
  778. }
  779. }
  780. }
  781. /// <summary>
  782. /// 二级分类按钮点击事件
  783. /// </summary>
  784. /// <param name="sender"></param>
  785. /// <param name="e"></param>
  786. private void ChildButton_Click(object sender, EventArgs e)
  787. {
  788. Button button = (Button)sender;
  789. MeasureRelationModel.ChildLabel child = (MeasureRelationModel.ChildLabel)button.Tag;
  790. this.drawToolType = child.drawToolType;
  791. this.UpdateRightSettingUI();
  792. }
  793. # region 更新右侧设置
  794. /// <summary>
  795. /// 更新右侧设置
  796. /// </summary>
  797. private void UpdateRightSettingUI()
  798. {
  799. switch (this.drawToolType)
  800. {
  801. case DrawToolType.MeasureLine: //长度测量直线
  802. MeasureStyleModel.MeasureLine measureLine = this.measureStyleModel.measureLine;
  803. this.panel2.Visible = true;
  804. this.panel3.Visible = false;
  805. this.label5.Visible = true;
  806. this.label6.Visible = true;
  807. this.comboBox5.Visible = true;
  808. this.numericUpDown1.Visible = true;
  809. this.label91.Visible = false;
  810. this.comboBox91.Visible = false;
  811. UpdataFontPosition(false);
  812. this.UpdateMeasureStyleData(measureLine.font, measureLine.fontSize, measureLine.textColor, measureLine.lineColor, measureLine.lineWidth, measureLine.lineStyle, measureLine.linePosition, 0, 0, measureLine.vLineLength, measureLine.followLine);
  813. break;
  814. case DrawToolType.MeasureDistanceLine: //长度测量距离
  815. MeasureStyleModel.MeasureDistanceLine measureDistanceLine = this.measureStyleModel.measureDistanceLine;
  816. this.panel2.Visible = true;
  817. this.panel3.Visible = false;
  818. this.label5.Visible = false;
  819. this.numericUpDown1.Visible = false;
  820. this.label6.Visible = false;
  821. this.comboBox5.Visible = false;
  822. this.label91.Visible = false;
  823. this.comboBox91.Visible = false;
  824. UpdataFontPosition(false);
  825. this.UpdateMeasureStyleData(measureDistanceLine.font, measureDistanceLine.fontSize, measureDistanceLine.textColor, measureDistanceLine.lineColor, measureDistanceLine.lineWidth, measureDistanceLine.lineStyle, measureDistanceLine.linePosition, 0, 0, -1);
  826. break;
  827. case DrawToolType.MeasureLength: //长度测量->长度
  828. MeasureStyleModel.MeasureLength measureLength = this.measureStyleModel.measureLength;
  829. this.panel2.Visible = true;
  830. this.panel3.Visible = false;
  831. this.label5.Visible = false;
  832. this.numericUpDown1.Visible = false;
  833. this.label6.Visible = false;
  834. this.comboBox5.Visible = false;
  835. this.label91.Visible = false;
  836. this.comboBox91.Visible = false;
  837. UpdataFontPosition(false);
  838. this.UpdateMeasureStyleData(measureLength.font, measureLength.fontSize, measureLength.textColor, measureLength.lineColor, measureLength.lineWidth, measureLength.lineStyle, measureLength.linePosition, 0, 0, -1);
  839. break;
  840. case DrawToolType.MeasureHLine: //长度测量->水平线
  841. MeasureStyleModel.MeasureHLine measureHLine = this.measureStyleModel.measureHLine;
  842. this.panel2.Visible = true;
  843. this.panel3.Visible = false;
  844. this.label5.Visible = true;
  845. this.numericUpDown1.Visible = true;
  846. this.label6.Visible = false;
  847. this.comboBox5.Visible = false;
  848. this.label91.Visible = false;
  849. this.comboBox91.Visible = false;
  850. UpdataFontPosition(false);
  851. this.UpdateMeasureStyleData(measureHLine.font, measureHLine.fontSize, measureHLine.textColor, measureHLine.lineColor, measureHLine.lineWidth, measureHLine.lineStyle, measureHLine.linePosition, 0, 0, measureHLine.vLineLength);
  852. break;
  853. case DrawToolType.MeasureVLine: //长度测量->垂线
  854. MeasureStyleModel.MeasureVLine measureVLine = this.measureStyleModel.measureVLine;
  855. this.panel2.Visible = true;
  856. this.panel3.Visible = false;
  857. this.label5.Visible = true;
  858. this.numericUpDown1.Visible = true;
  859. this.label6.Visible = true;
  860. this.comboBox5.Visible = true;
  861. this.label91.Visible = false;
  862. this.comboBox91.Visible = false;
  863. UpdataFontPosition(false);
  864. this.UpdateMeasureStyleData(measureVLine.font, measureVLine.fontSize, measureVLine.textColor, measureVLine.lineColor, measureVLine.lineWidth, measureVLine.lineStyle, measureVLine.linePosition, 0, 0, measureVLine.vLineLength, measureVLine.followLine);
  865. break;
  866. }
  867. }
  868. #endregion
  869. private void UpdataFontPosition(bool curve)
  870. {
  871. List<string> position = new List<string> { PdnResources.GetString("Menu.Upperleft.text")
  872. , PdnResources.GetString("Menu.Uppermiddle.Text")
  873. , PdnResources.GetString("Menu.Upperright.text")
  874. , PdnResources.GetString("Menu.Lowerleft.text")
  875. , PdnResources.GetString("Menu.Themiddleandlower.Text")
  876. , PdnResources.GetString("Menu.Lowerright.text")};
  877. List<string> position1 = new List<string> { PdnResources.GetString("Menu.hestartingpoint.Text")
  878. , PdnResources.GetString("Menu.Theendpoint.Text")
  879. };
  880. this.comboBox2.DataSource = null;
  881. if (curve)
  882. this.comboBox2.DataSource = position1;
  883. else
  884. this.comboBox2.DataSource = position;
  885. }
  886. /// <summary>
  887. /// 刷新右侧预览图
  888. /// </summary>
  889. private void UpdateRightPreview()
  890. {
  891. }
  892. /// <summary>
  893. /// 更新显示区域控件的数值
  894. /// </summary>
  895. /// <param name="font"></param>
  896. /// <param name="fontSize"></param>
  897. /// <param name="textColor"></param>
  898. /// <param name="lineColor"></param>
  899. /// <param name="lineWidth"></param>
  900. /// <param name="lineStyle"></param>
  901. 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)
  902. {
  903. //绑定样式默认数据
  904. this.comboBox11.Text = font;
  905. this.numericUpDown21.Value = fontSize;
  906. this.textPanel.BackColor = Color.FromArgb(textColor);
  907. this.linePanel.BackColor = Color.FromArgb(lineColor);
  908. this.numericUpDown11.Value = lineWidth;
  909. this.comboBox21.SelectedIndex = lineStyle;
  910. if (this.comboBox2.Items.Count > 0)
  911. this.comboBox2.SelectedIndex = linePosition;
  912. if (this.comboBox3.Items.Count > 0)
  913. this.comboBox3.SelectedIndex = linePositionL;
  914. if (this.comboBox4.Items.Count > 0)
  915. this.comboBox4.SelectedIndex = linePositionP;
  916. if (vLineLength > -1)
  917. this.numericUpDown1.Value = vLineLength;
  918. if (followLine)
  919. {
  920. this.comboBox5.SelectedIndex = 0;
  921. }
  922. else
  923. {
  924. this.comboBox5.SelectedIndex = 1;
  925. }
  926. this.comboBox91.SelectedIndex = isAngle ? 1 : 0;
  927. }
  928. /// <summary>
  929. /// 保存按钮
  930. /// </summary>
  931. /// <param name="sender"></param>
  932. /// <param name="e"></param>
  933. private void Button2_Click(object sender, EventArgs e)
  934. {
  935. //调用检查类型
  936. this.checkSaveModel();
  937. //以下保存xml文件信息
  938. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureStyleModel>(this.measureStyleModel);
  939. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.comboBox1.Text + ".xml";
  940. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  941. this.config.MarkpointWidth = Convert.ToInt32(this.numericUpDown71.Value);
  942. string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(config);
  943. FileOperationHelper.WriteStringToFile(configModelXml, Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Config.xml", FileMode.Create);
  944. MarkPointRect.markPointRectWidth = configModel.MarkpointWidth;
  945. if (this.appWorkspace.DocumentWorkspaces != null)
  946. {
  947. foreach (var item in this.appWorkspace.DocumentWorkspaces)
  948. {
  949. if (item != null && item.GraphicsList != null)
  950. foreach (var graObject in item.GraphicsList.graphicsList)
  951. {
  952. graObject.smallRectangleWidth = this.config.MarkpointWidth;
  953. }
  954. item.Refresh();
  955. }
  956. }
  957. ApplicationSetting();
  958. }
  959. /// <summary>
  960. ///另存为按钮点击
  961. /// </summary>
  962. /// <param name="sender"></param>
  963. /// <param name="e"></param>
  964. private void Button3_Click(object sender, EventArgs e)
  965. {
  966. dialog = new CreateNameDialog(this);
  967. dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
  968. dialog.StartPosition = FormStartPosition.CenterParent;
  969. dialog.ShowDialog();
  970. }
  971. /// <summary>
  972. /// 当前操作样式
  973. /// </summary>
  974. /// <param name="sender"></param>
  975. /// <param name="e"></param>
  976. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  977. {
  978. measureStyleModel = XmlSerializeHelper.DESerializer<MeasureStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  979. InitializeData();
  980. }
  981. /// <summary>
  982. /// 绑定样式下拉
  983. /// </summary>
  984. private void InitializeStyleName()
  985. {
  986. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\");
  987. files.Clear();
  988. foreach (string fileName in fileNames)
  989. {
  990. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  991. files.Add(name);
  992. }
  993. this.comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
  994. this.comboBox1.DataSource = null;
  995. this.comboBox1.DataSource = files;
  996. string nowModelName = Program.instance.configModel.Watermark.Substring(0, Program.instance.configModel.Watermark.LastIndexOf("."));
  997. this.comboBox1.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
  998. measureStyleModel = XmlSerializeHelper.DESerializer<MeasureStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  999. // InitializeData();
  1000. this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
  1001. }
  1002. /// <summary>
  1003. /// 删除按钮
  1004. /// </summary>
  1005. /// <param name="sender"></param>
  1006. /// <param name="e"></param>
  1007. private void Button4_Click(object sender, EventArgs e)
  1008. {
  1009. if ("Default".Equals(this.comboBox1.Text))
  1010. {
  1011. MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1012. return;
  1013. }
  1014. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1015. if (dr == DialogResult.OK)
  1016. {
  1017. int newIndex = 0;
  1018. int selectIndex = this.comboBox1.SelectedIndex;
  1019. int tall = files.Count - 1;
  1020. if (selectIndex < tall)
  1021. {
  1022. newIndex = selectIndex;
  1023. }
  1024. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.comboBox1.Text + ".xml";
  1025. FileInfo fileInfo = new FileInfo(filePath);
  1026. fileInfo.Delete();
  1027. InitializeStyleName();
  1028. this.comboBox1.SelectedIndex = newIndex;
  1029. measureStyleModel = XmlSerializeHelper.DESerializer<MeasureStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  1030. InitializeData();
  1031. }
  1032. else if (dr == DialogResult.Cancel)
  1033. {
  1034. }
  1035. }
  1036. /// <summary>
  1037. /// 弹出另存为框点击保存效果
  1038. /// </summary>
  1039. /// <param name="name"></param>
  1040. public override void GetCreateName(string name)
  1041. {
  1042. string currentcomboBox = this.comboBox1.Text;
  1043. this.newName = name;
  1044. if (files.Contains(this.newName))
  1045. {
  1046. MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1047. return;
  1048. }
  1049. CopyConfigAndRename();
  1050. InitializeStyleName();
  1051. this.comboBox1.Text = currentcomboBox;
  1052. dialog.Close();
  1053. }
  1054. /// <summary>
  1055. /// 另存配置文件
  1056. /// </summary>
  1057. private void CopyConfigAndRename()
  1058. {
  1059. /*if (this.checkBox1.Checked)
  1060. {
  1061. this.watermarkModel.bold = 1;
  1062. }
  1063. else
  1064. {
  1065. this.watermarkModel.bold = 2;
  1066. }
  1067. if (this.checkBox2.Checked)
  1068. {
  1069. this.watermarkModel.italic = 1;
  1070. }
  1071. else
  1072. {
  1073. this.watermarkModel.italic = 2;
  1074. }
  1075. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1076. this.watermarkModel.typeface = this.comboBox3.Text;
  1077. this.watermarkModel.fontSize = Int32.Parse(this.comboBox4.Text);*/
  1078. //检查保存类型
  1079. this.checkSaveModel();
  1080. //另存为
  1081. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureStyleModel>(this.measureStyleModel);
  1082. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.newName + ".xml";
  1083. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1084. }
  1085. /// <summary>
  1086. /// 应用按钮
  1087. /// </summary>
  1088. /// <param name="sender"></param>
  1089. /// <param name="e"></param>
  1090. private void ApplicationSetting()
  1091. {
  1092. //修改缓存中的样式数据
  1093. Program.instance.measureStyleModel = this.measureStyleModel;
  1094. //修改主配置文件中的值
  1095. configModel.MeasurementStyle = this.comboBox1.Text + ".xml";
  1096. //修改主配置文件的xml
  1097. string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(this.configModel);
  1098. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Config.xml";
  1099. FileOperationHelper.WriteStringToFile(configModelXml, filePath, FileMode.Create);
  1100. MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
  1101. }
  1102. private void textColorPanel_Click(object sender, EventArgs e)
  1103. {
  1104. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.textPanel.BackColor);
  1105. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.textColorChanged));
  1106. this.colorsForm.ShowDialog();
  1107. }
  1108. private void textColorChanged(object sender, EventArgs e)
  1109. {
  1110. this.textPanel.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  1111. //this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  1112. this.colorsForm.Close();
  1113. }
  1114. private void lineColorPanel_Click(object sender, EventArgs e)
  1115. {
  1116. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.linePanel.BackColor);
  1117. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
  1118. this.colorsForm1.ShowDialog();
  1119. }
  1120. private void lineColorChanged(object sender, EventArgs e)
  1121. {
  1122. this.linePanel.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  1123. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  1124. this.colorsForm1.Close();
  1125. }
  1126. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1127. {
  1128. }
  1129. /// <summary>
  1130. /// 检查保存类型
  1131. /// </summary>
  1132. private void checkSaveModel()
  1133. {
  1134. string font = comboBox11.Text;
  1135. int fontSize = Convert.ToInt32(numericUpDown21.Value);
  1136. int textColor = Convert.ToInt32(this.textPanel.BackColor.ToArgb());
  1137. int lineColor = Convert.ToInt32(this.linePanel.BackColor.ToArgb());
  1138. int lineWidth = Convert.ToInt32(numericUpDown11.Value);
  1139. int lineStyle = this.comboBox21.SelectedIndex;
  1140. int linePosition = this.comboBox2.SelectedIndex;
  1141. int linePositionL = this.comboBox3.SelectedIndex;
  1142. int linePositionP = this.comboBox4.SelectedIndex;
  1143. int vLineLength = Convert.ToInt32(this.numericUpDown1.Value);
  1144. bool isAngle = comboBox91.SelectedIndex == 0 ? false : true;
  1145. switch (this.drawToolType)
  1146. {
  1147. case DrawToolType.MeasureLine: //长度测量直线
  1148. this.measureStyleModel.measureLine.font = font;
  1149. this.measureStyleModel.measureLine.fontSize = fontSize;
  1150. this.measureStyleModel.measureLine.textColor = textColor;
  1151. this.measureStyleModel.measureLine.lineColor = lineColor;
  1152. this.measureStyleModel.measureLine.lineWidth = lineWidth;
  1153. this.measureStyleModel.measureLine.lineStyle = lineStyle;
  1154. this.measureStyleModel.measureLine.linePosition = linePosition;
  1155. this.measureStyleModel.measureLine.vLineLength = vLineLength;
  1156. this.measureStyleModel.measureLine.followLine = this.comboBox5.SelectedIndex == 0 ? true : false;
  1157. break;
  1158. case DrawToolType.MeasureDistanceLine: //距离
  1159. this.measureStyleModel.measureDistanceLine.font = font;
  1160. this.measureStyleModel.measureDistanceLine.fontSize = fontSize;
  1161. this.measureStyleModel.measureDistanceLine.textColor = textColor;
  1162. this.measureStyleModel.measureDistanceLine.lineColor = lineColor;
  1163. this.measureStyleModel.measureDistanceLine.lineWidth = lineWidth;
  1164. this.measureStyleModel.measureDistanceLine.lineStyle = lineStyle;
  1165. this.measureStyleModel.measureDistanceLine.linePosition = linePosition;
  1166. break;
  1167. case DrawToolType.MeasureLength: //长度测量->长度
  1168. this.measureStyleModel.measureLength.font = font;
  1169. this.measureStyleModel.measureLength.fontSize = fontSize;
  1170. this.measureStyleModel.measureLength.textColor = textColor;
  1171. this.measureStyleModel.measureLength.lineColor = lineColor;
  1172. this.measureStyleModel.measureLength.lineWidth = lineWidth;
  1173. this.measureStyleModel.measureLength.lineStyle = lineStyle;
  1174. this.measureStyleModel.measureLength.linePosition = linePosition;
  1175. break;
  1176. case DrawToolType.MeasureHLine: //长度测量->水平线
  1177. this.measureStyleModel.measureHLine.font = font;
  1178. this.measureStyleModel.measureHLine.fontSize = fontSize;
  1179. this.measureStyleModel.measureHLine.textColor = textColor;
  1180. this.measureStyleModel.measureHLine.lineColor = lineColor;
  1181. this.measureStyleModel.measureHLine.lineWidth = lineWidth;
  1182. this.measureStyleModel.measureHLine.lineStyle = lineStyle;
  1183. this.measureStyleModel.measureHLine.linePosition = linePosition;
  1184. this.measureStyleModel.measureHLine.vLineLength = vLineLength;
  1185. break;
  1186. case DrawToolType.MeasureVLine: //长度测量->垂线
  1187. this.measureStyleModel.measureVLine.font = font;
  1188. this.measureStyleModel.measureVLine.fontSize = fontSize;
  1189. this.measureStyleModel.measureVLine.textColor = textColor;
  1190. this.measureStyleModel.measureVLine.lineColor = lineColor;
  1191. this.measureStyleModel.measureVLine.lineWidth = lineWidth;
  1192. this.measureStyleModel.measureVLine.lineStyle = lineStyle;
  1193. this.measureStyleModel.measureVLine.linePosition = linePosition;
  1194. this.measureStyleModel.measureVLine.vLineLength = vLineLength;
  1195. this.measureStyleModel.measureVLine.followLine = this.comboBox5.SelectedIndex == 0 ? true : false;
  1196. break;
  1197. }
  1198. }
  1199. /// <summary>
  1200. /// 应用全部
  1201. /// </summary>
  1202. /// <param name="sender"></param>
  1203. /// <param name="e"></param>
  1204. private void button6_Click(object sender, EventArgs e)
  1205. {
  1206. string font = comboBox11.Text;
  1207. int fontSize = Convert.ToInt32(numericUpDown21.Value);
  1208. int textColor = Convert.ToInt32(this.textPanel.BackColor.ToArgb());
  1209. int lineColor = Convert.ToInt32(this.linePanel.BackColor.ToArgb());
  1210. int lineWidth = Convert.ToInt32(numericUpDown11.Value);
  1211. int lineStyle = this.comboBox21.SelectedIndex;
  1212. int linePosition = this.comboBox2.SelectedIndex;
  1213. int linePositionL = this.comboBox3.SelectedIndex;
  1214. int linePositionP = this.comboBox4.SelectedIndex;
  1215. int vLineLength = Convert.ToInt32(this.numericUpDown1.Value);
  1216. bool isAngle = comboBox91.SelectedIndex == 0 ? false : true;
  1217. switch (this.selectId)
  1218. {
  1219. // 直线测量
  1220. case 1:
  1221. this.measureStyleModel.measureLine.font = font;
  1222. this.measureStyleModel.measureLine.fontSize = fontSize;
  1223. this.measureStyleModel.measureLine.textColor = textColor;
  1224. this.measureStyleModel.measureLine.lineColor = lineColor;
  1225. this.measureStyleModel.measureLine.lineWidth = lineWidth;
  1226. this.measureStyleModel.measureLine.lineStyle = lineStyle;
  1227. this.measureStyleModel.measureLine.linePosition = linePosition;
  1228. this.measureStyleModel.measureLine.vLineLength = vLineLength;
  1229. this.measureStyleModel.measureLine.followLine = this.comboBox5.SelectedIndex == 0 ? true : false;
  1230. this.measureStyleModel.measureDistanceLine.font = font;
  1231. this.measureStyleModel.measureDistanceLine.fontSize = fontSize;
  1232. this.measureStyleModel.measureDistanceLine.textColor = textColor;
  1233. this.measureStyleModel.measureDistanceLine.lineColor = lineColor;
  1234. this.measureStyleModel.measureDistanceLine.lineWidth = lineWidth;
  1235. this.measureStyleModel.measureDistanceLine.lineStyle = lineStyle;
  1236. this.measureStyleModel.measureDistanceLine.linePosition = linePosition;
  1237. this.measureStyleModel.measureLength.font = font;
  1238. this.measureStyleModel.measureLength.fontSize = fontSize;
  1239. this.measureStyleModel.measureLength.textColor = textColor;
  1240. this.measureStyleModel.measureLength.lineColor = lineColor;
  1241. this.measureStyleModel.measureLength.lineWidth = lineWidth;
  1242. this.measureStyleModel.measureLength.lineStyle = lineStyle;
  1243. this.measureStyleModel.measureLength.linePosition = linePosition;
  1244. this.measureStyleModel.measureHLine.font = font;
  1245. this.measureStyleModel.measureHLine.fontSize = fontSize;
  1246. this.measureStyleModel.measureHLine.textColor = textColor;
  1247. this.measureStyleModel.measureHLine.lineColor = lineColor;
  1248. this.measureStyleModel.measureHLine.lineWidth = lineWidth;
  1249. this.measureStyleModel.measureHLine.lineStyle = lineStyle;
  1250. this.measureStyleModel.measureHLine.linePosition = linePosition;
  1251. this.measureStyleModel.measureHLine.vLineLength = vLineLength;
  1252. this.measureStyleModel.measureVLine.font = font;
  1253. this.measureStyleModel.measureVLine.fontSize = fontSize;
  1254. this.measureStyleModel.measureVLine.textColor = textColor;
  1255. this.measureStyleModel.measureVLine.lineColor = lineColor;
  1256. this.measureStyleModel.measureVLine.lineWidth = lineWidth;
  1257. this.measureStyleModel.measureVLine.lineStyle = lineStyle;
  1258. this.measureStyleModel.measureVLine.linePosition = linePosition;
  1259. this.measureStyleModel.measureVLine.vLineLength = vLineLength;
  1260. this.measureStyleModel.measureVLine.followLine = this.comboBox5.SelectedIndex == 0 ? true : false;
  1261. break;
  1262. }
  1263. //以下保存xml文件信息
  1264. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureStyleModel>(this.measureStyleModel);
  1265. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Measure\\" + this.comboBox1.Text + ".xml";
  1266. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1267. ApplicationSetting();
  1268. }
  1269. }
  1270. }