MeasureAreaDialog.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. using Resources;
  2. using SmartCoalApplication.Base;
  3. using SmartCoalApplication.Base.CommTool;
  4. using SmartCoalApplication.Base.SettingModel;
  5. using SmartCoalApplication.Core;
  6. using SmartCoalApplication.PluginAssemblys;
  7. using SmartCoalApplication.Resources;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using System.Windows.Forms;
  18. namespace SmartCoalApplication.Measure
  19. {
  20. internal class MeasureAreaDialog : PdnBaseForm
  21. {
  22. /// <summary>
  23. /// 主配置文件的model
  24. /// </summary>
  25. private ConfigModel configModel = Program.instance.configModel;
  26. /// <summary>
  27. /// 操作区控件
  28. /// </summary>
  29. private GroupBox groupBox1;
  30. private Label label1;
  31. private ComboBox comboBox1;
  32. private Button button4;
  33. private Button button3;
  34. private Button button2;
  35. private GroupBox groupBox2;
  36. private ConfigModel config = Program.instance.configModel;
  37. private System.Windows.Forms.Panel linePanel;
  38. private System.Windows.Forms.Label label41;
  39. private System.Windows.Forms.Label label51;
  40. private System.Windows.Forms.Label label61;
  41. private ComboBox comboBox21;
  42. private NumericUpDown numericUpDown11;
  43. private Button button5;
  44. /// <summary>
  45. /// 测量的样式
  46. /// </summary>
  47. private MeasureAreaModel measureAreaModel = Program.instance.measureAreaModel;
  48. /// <summary>
  49. /// 另存为弹出框显示
  50. /// </summary>
  51. private CreateNameDialog dialog;
  52. /// <summary>
  53. /// 操作样式下拉数据
  54. /// </summary>
  55. private List<string> files = new List<string>();
  56. /// <summary>
  57. /// 另存为文件名
  58. /// </summary>
  59. private string newName;
  60. /// <summary>
  61. /// 选中的测量类型
  62. /// </summary>
  63. private int selectId;
  64. private int initflag = 0;
  65. private AppWorkspace appWorkspace;
  66. ColorsForm colorsForm1;
  67. private DocumentWorkspaceWindow documentWorkspaceWindow;
  68. public MeasureAreaDialog(AppWorkspace appWorkspace,DocumentWorkspaceWindow documentWorkspaceWindow = null)
  69. {
  70. this.appWorkspace = appWorkspace;
  71. this.documentWorkspaceWindow = documentWorkspaceWindow;
  72. InitializeComponent();
  73. InitializeLanguageText();
  74. InitializeComponent2();
  75. this.Icon = PdnInfo.AppIcon;
  76. //绑定线样式数据
  77. this.comboBox21.Items.AddRange(InvariantData.dashStyles);
  78. InitializeData();
  79. if (this.documentWorkspaceWindow != null)
  80. {
  81. this.label1.Visible = false;
  82. this.comboBox1.Visible = false;
  83. this.button3.Visible = false;
  84. this.button4.Visible = false;
  85. }
  86. else {
  87. this.label1.Visible = true;
  88. this.comboBox1.Visible = true;
  89. this.button3.Visible = true;
  90. this.button4.Visible = true;
  91. }
  92. }
  93. private void InitializeLanguageText()
  94. {
  95. this.label1.Text = PdnResources.GetString("Menu.Currentoperationstyle.text") + ":";
  96. this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  97. this.button3.Text = PdnResources.GetString("Menu.File.SaveAs.Text");
  98. this.button2.Text = PdnResources.GetString("Menu.File.Save.Text");
  99. this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text");
  100. this.label61.Text = PdnResources.GetString("Menu.Linestyle.Text") + ":";
  101. this.label51.Text = PdnResources.GetString("Menu.Set.Rulersettings.Linewidth.text") + ":";
  102. this.label41.Text = PdnResources.GetString("Menu.Set.Rulersettings.Linecolor.text") + ":";
  103. this.Text = PdnResources.GetString("Menu.Setting.MeasureSetting.Text");
  104. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  105. }
  106. private void InitializeComponent()
  107. {
  108. this.groupBox1 = new System.Windows.Forms.GroupBox();
  109. this.label1 = new System.Windows.Forms.Label();
  110. this.comboBox1 = new System.Windows.Forms.ComboBox();
  111. this.button4 = new System.Windows.Forms.Button();
  112. this.button3 = new System.Windows.Forms.Button();
  113. this.button2 = new System.Windows.Forms.Button();
  114. this.groupBox2 = new System.Windows.Forms.GroupBox();
  115. this.numericUpDown11 = new System.Windows.Forms.NumericUpDown();
  116. this.comboBox21 = new System.Windows.Forms.ComboBox();
  117. this.label61 = new System.Windows.Forms.Label();
  118. this.label51 = new System.Windows.Forms.Label();
  119. this.linePanel = new System.Windows.Forms.Panel();
  120. this.label41 = new System.Windows.Forms.Label();
  121. this.button5 = new System.Windows.Forms.Button();
  122. this.groupBox1.SuspendLayout();
  123. this.groupBox2.SuspendLayout();
  124. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown11)).BeginInit();
  125. this.SuspendLayout();
  126. //
  127. // groupBox1
  128. //
  129. this.groupBox1.Controls.Add(this.label1);
  130. this.groupBox1.Controls.Add(this.comboBox1);
  131. this.groupBox1.Controls.Add(this.button4);
  132. this.groupBox1.Controls.Add(this.button3);
  133. this.groupBox1.Controls.Add(this.button2);
  134. this.groupBox1.Location = new System.Drawing.Point(15, 15);
  135. this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  136. this.groupBox1.Name = "groupBox1";
  137. this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  138. this.groupBox1.Size = new System.Drawing.Size(639, 72);
  139. this.groupBox1.TabIndex = 3;
  140. this.groupBox1.TabStop = false;
  141. this.groupBox1.Text = "操作";
  142. //
  143. // label1
  144. //
  145. this.label1.AutoSize = true;
  146. this.label1.Location = new System.Drawing.Point(25, 31);
  147. this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  148. this.label1.Name = "label1";
  149. this.label1.Size = new System.Drawing.Size(112, 15);
  150. this.label1.TabIndex = 5;
  151. this.label1.Text = "当前操作样式:";
  152. //
  153. // comboBox1
  154. //
  155. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  156. this.comboBox1.FormattingEnabled = true;
  157. this.comboBox1.Location = new System.Drawing.Point(144, 28);
  158. this.comboBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  159. this.comboBox1.Name = "comboBox1";
  160. this.comboBox1.Size = new System.Drawing.Size(144, 23);
  161. this.comboBox1.TabIndex = 4;
  162. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  163. //
  164. // button4
  165. //
  166. this.button4.Location = new System.Drawing.Point(319, 25);
  167. this.button4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  168. this.button4.Name = "button4";
  169. this.button4.Size = new System.Drawing.Size(94, 29);
  170. this.button4.TabIndex = 3;
  171. this.button4.Text = "删除";
  172. this.button4.UseVisualStyleBackColor = true;
  173. this.button4.Click += new System.EventHandler(this.Button4_Click);
  174. //
  175. // button3
  176. //
  177. this.button3.Location = new System.Drawing.Point(422, 25);
  178. this.button3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  179. this.button3.Name = "button3";
  180. this.button3.Size = new System.Drawing.Size(94, 29);
  181. this.button3.TabIndex = 2;
  182. this.button3.Text = "另存为";
  183. this.button3.UseVisualStyleBackColor = true;
  184. this.button3.Click += new System.EventHandler(this.Button3_Click);
  185. //
  186. // button2
  187. //
  188. this.button2.Location = new System.Drawing.Point(524, 25);
  189. this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  190. this.button2.Name = "button2";
  191. this.button2.Size = new System.Drawing.Size(94, 29);
  192. this.button2.TabIndex = 1;
  193. this.button2.Text = "保存";
  194. this.button2.UseVisualStyleBackColor = true;
  195. this.button2.Click += new System.EventHandler(this.Button2_Click);
  196. //
  197. // groupBox2
  198. //
  199. this.groupBox2.Controls.Add(this.numericUpDown11);
  200. this.groupBox2.Controls.Add(this.comboBox21);
  201. this.groupBox2.Controls.Add(this.label61);
  202. this.groupBox2.Controls.Add(this.label51);
  203. this.groupBox2.Controls.Add(this.linePanel);
  204. this.groupBox2.Controls.Add(this.label41);
  205. this.groupBox2.Location = new System.Drawing.Point(15, 95);
  206. this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  207. this.groupBox2.Name = "groupBox2";
  208. this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
  209. this.groupBox2.Size = new System.Drawing.Size(639, 136);
  210. this.groupBox2.TabIndex = 6;
  211. this.groupBox2.TabStop = false;
  212. this.groupBox2.Text = "设置";
  213. //
  214. // numericUpDown11
  215. //
  216. this.numericUpDown11.Location = new System.Drawing.Point(110, 61);
  217. this.numericUpDown11.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  218. this.numericUpDown11.Name = "numericUpDown11";
  219. this.numericUpDown11.Size = new System.Drawing.Size(190, 25);
  220. this.numericUpDown11.TabIndex = 14;
  221. //
  222. // comboBox21
  223. //
  224. this.comboBox21.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  225. this.comboBox21.FormattingEnabled = true;
  226. this.comboBox21.Location = new System.Drawing.Point(110, 94);
  227. this.comboBox21.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  228. this.comboBox21.Name = "comboBox21";
  229. this.comboBox21.Size = new System.Drawing.Size(189, 23);
  230. this.comboBox21.TabIndex = 13;
  231. //
  232. // label61
  233. //
  234. this.label61.AutoSize = true;
  235. this.label61.Location = new System.Drawing.Point(12, 99);
  236. this.label61.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  237. this.label61.Name = "label61";
  238. this.label61.Size = new System.Drawing.Size(82, 15);
  239. this.label61.TabIndex = 9;
  240. this.label61.Text = "线条样式:";
  241. //
  242. // label51
  243. //
  244. this.label51.AutoSize = true;
  245. this.label51.Location = new System.Drawing.Point(12, 65);
  246. this.label51.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  247. this.label51.Name = "label51";
  248. this.label51.Size = new System.Drawing.Size(82, 15);
  249. this.label51.TabIndex = 8;
  250. this.label51.Text = "线条宽度:";
  251. //
  252. // linePanel
  253. //
  254. this.linePanel.BackColor = System.Drawing.SystemColors.Window;
  255. this.linePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  256. this.linePanel.Location = new System.Drawing.Point(110, 29);
  257. this.linePanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
  258. this.linePanel.Name = "linePanel";
  259. this.linePanel.Size = new System.Drawing.Size(190, 24);
  260. this.linePanel.TabIndex = 7;
  261. this.linePanel.Click += new System.EventHandler(this.lineColorPanel_Click);
  262. //
  263. // label41
  264. //
  265. this.label41.AutoSize = true;
  266. this.label41.Location = new System.Drawing.Point(12, 29);
  267. this.label41.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
  268. this.label41.Name = "label41";
  269. this.label41.Size = new System.Drawing.Size(82, 15);
  270. this.label41.TabIndex = 6;
  271. this.label41.Text = "线条颜色:";
  272. //
  273. // button5
  274. //
  275. this.button5.Location = new System.Drawing.Point(0, 0);
  276. this.button5.Name = "button5";
  277. this.button5.Size = new System.Drawing.Size(75, 23);
  278. this.button5.TabIndex = 0;
  279. //
  280. // MeasureAreaDialog
  281. //
  282. this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
  283. this.ClientSize = new System.Drawing.Size(672, 244);
  284. this.Controls.Add(this.groupBox2);
  285. this.Controls.Add(this.groupBox1);
  286. this.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
  287. this.MinimizeBox = false;
  288. this.Name = "MeasureAreaDialog";
  289. this.Text = "测量设置";
  290. this.Controls.SetChildIndex(this.groupBox1, 0);
  291. this.Controls.SetChildIndex(this.groupBox2, 0);
  292. this.groupBox1.ResumeLayout(false);
  293. this.groupBox1.PerformLayout();
  294. this.groupBox2.ResumeLayout(false);
  295. this.groupBox2.PerformLayout();
  296. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown11)).EndInit();
  297. this.ResumeLayout(false);
  298. }
  299. #region InitializeComponent2
  300. /// <summary>
  301. /// 初始化组件
  302. /// </summary>
  303. private void InitializeComponent2()
  304. {
  305. this.colorsForm1 = new ColorsForm();
  306. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  307. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  308. }
  309. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  310. {
  311. }
  312. #endregion
  313. /// <summary>
  314. /// 初始化数据
  315. /// </summary>
  316. private void InitializeData()
  317. {
  318. this.linePanel.BackColor = Color.FromArgb(this.measureAreaModel.lineColor);
  319. this.numericUpDown11.Value = this.measureAreaModel.lineWidth;
  320. this.comboBox21.SelectedIndex = this.measureAreaModel.lineStyle;
  321. //this.fzxRBT.Checked = this.measureAreaModel.reportOutput ? true : false;
  322. //this.fzxRBF.Checked = this.measureAreaModel.reportOutput ? false : true;
  323. //绑定样式下拉 todo
  324. if (initflag++ == 0)
  325. {
  326. InitializeStyleName();
  327. }
  328. }
  329. /// <summary>
  330. /// 保存按钮
  331. /// </summary>
  332. /// <param name="sender"></param>
  333. /// <param name="e"></param>
  334. private void Button2_Click(object sender, EventArgs e)
  335. {
  336. this.measureAreaModel.lineColor = linePanel.BackColor.ToArgb();
  337. this.measureAreaModel.lineWidth = Convert.ToInt32(numericUpDown11.Value);
  338. //this.measureAreaModel.reportOutput = fzxRBT.Checked ? true : false;
  339. this.measureAreaModel.lineStyle = this.comboBox21.SelectedIndex;
  340. //以下保存xml文件信息
  341. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureAreaModel>(this.measureAreaModel);
  342. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\" + this.comboBox1.Text + ".xml";
  343. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  344. string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(config);
  345. FileOperationHelper.WriteStringToFile(configModelXml, Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Config.xml", FileMode.Create);
  346. MarkPointRect.markPointRectWidth = configModel.MarkpointWidth;
  347. if (this.appWorkspace.DocumentWorkspaces != null)
  348. {
  349. foreach (var item in this.appWorkspace.DocumentWorkspaces)
  350. {
  351. if (item != null && item.GraphicsList != null)
  352. foreach (var graObject in item.GraphicsList.graphicsList)
  353. {
  354. graObject.smallRectangleWidth = this.config.MarkpointWidth;
  355. }
  356. item.Refresh();
  357. }
  358. }
  359. if (this.documentWorkspaceWindow != null)
  360. {
  361. Program.instance.measureAreaModel = this.measureAreaModel;
  362. this.documentWorkspaceWindow.Refresh();
  363. }
  364. ApplicationSetting();
  365. }
  366. /// <summary>
  367. ///另存为按钮点击
  368. /// </summary>
  369. /// <param name="sender"></param>
  370. /// <param name="e"></param>
  371. private void Button3_Click(object sender, EventArgs e)
  372. {
  373. dialog = new CreateNameDialog(this);
  374. dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
  375. dialog.StartPosition = FormStartPosition.CenterParent;
  376. dialog.ShowDialog();
  377. }
  378. /// <summary>
  379. /// 当前操作样式
  380. /// </summary>
  381. /// <param name="sender"></param>
  382. /// <param name="e"></param>
  383. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  384. {
  385. measureAreaModel = XmlSerializeHelper.DESerializer<MeasureAreaModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  386. InitializeData();
  387. }
  388. /// <summary>
  389. /// 绑定样式下拉
  390. /// </summary>
  391. private void InitializeStyleName()
  392. {
  393. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\");
  394. files.Clear();
  395. foreach (string fileName in fileNames)
  396. {
  397. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  398. files.Add(name);
  399. }
  400. this.comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
  401. this.comboBox1.DataSource = null;
  402. this.comboBox1.DataSource = files;
  403. string nowModelName = Program.instance.configModel.Watermark.Substring(0, Program.instance.configModel.Watermark.LastIndexOf("."));
  404. this.comboBox1.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
  405. measureAreaModel = XmlSerializeHelper.DESerializer<MeasureAreaModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  406. // InitializeData();
  407. this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
  408. }
  409. /// <summary>
  410. /// 删除按钮
  411. /// </summary>
  412. /// <param name="sender"></param>
  413. /// <param name="e"></param>
  414. private void Button4_Click(object sender, EventArgs e)
  415. {
  416. if ("Default".Equals(this.comboBox1.Text))
  417. {
  418. MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  419. return;
  420. }
  421. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  422. if (dr == DialogResult.OK)
  423. {
  424. int newIndex = 0;
  425. int selectIndex = this.comboBox1.SelectedIndex;
  426. int tall = files.Count - 1;
  427. if (selectIndex < tall)
  428. {
  429. newIndex = selectIndex;
  430. }
  431. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\" + this.comboBox1.Text + ".xml";
  432. FileInfo fileInfo = new FileInfo(filePath);
  433. fileInfo.Delete();
  434. InitializeStyleName();
  435. this.comboBox1.SelectedIndex = newIndex;
  436. measureAreaModel = XmlSerializeHelper.DESerializer<MeasureAreaModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\" + this.comboBox1.SelectedItem.ToString() + ".xml", FileMode.Open));
  437. InitializeData();
  438. }
  439. else if (dr == DialogResult.Cancel)
  440. {
  441. }
  442. }
  443. /// <summary>
  444. /// 弹出另存为框点击保存效果
  445. /// </summary>
  446. /// <param name="name"></param>
  447. public override void GetCreateName(string name)
  448. {
  449. string currentcomboBox = this.comboBox1.Text;
  450. this.newName = name;
  451. if (files.Contains(this.newName))
  452. {
  453. MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  454. return;
  455. }
  456. CopyConfigAndRename();
  457. InitializeStyleName();
  458. this.comboBox1.Text = currentcomboBox;
  459. dialog.Close();
  460. }
  461. /// <summary>
  462. /// 另存配置文件
  463. /// </summary>
  464. private void CopyConfigAndRename()
  465. {
  466. //另存为
  467. string stageModelXml = XmlSerializeHelper.XmlSerialize<MeasureAreaModel>(this.measureAreaModel);
  468. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\MeasureArea\\" + this.newName + ".xml";
  469. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  470. }
  471. /// <summary>
  472. /// 应用按钮
  473. /// </summary>
  474. /// <param name="sender"></param>
  475. /// <param name="e"></param>
  476. private void ApplicationSetting()
  477. {
  478. //修改缓存中的样式数据
  479. Program.instance.measureAreaModel = this.measureAreaModel;
  480. //修改主配置文件中的值
  481. configModel.MeasurementArea = this.comboBox1.Text + ".xml";
  482. //修改主配置文件的xml
  483. string configModelXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(this.configModel);
  484. string filePath = Application.StartupPath + "\\Config\\" + Program.instance.SettingPrefix + "\\Config.xml";
  485. FileOperationHelper.WriteStringToFile(configModelXml, filePath, FileMode.Create);
  486. MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
  487. }
  488. private void lineColorPanel_Click(object sender, EventArgs e)
  489. {
  490. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.linePanel.BackColor);
  491. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
  492. this.colorsForm1.ShowDialog();
  493. }
  494. private void lineColorChanged(object sender, EventArgs e)
  495. {
  496. this.linePanel.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  497. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  498. this.colorsForm1.Close();
  499. }
  500. }
  501. }