Action1009.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using PaintDotNet.Base;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.Enum;
  4. using PaintDotNet.Base.Functionodel;
  5. using PaintDotNet.Data.Param;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. using static PaintDotNet.Base.Functionodel.DebrisSelectionModel;
  15. namespace PaintDotNet.Data.Action
  16. {
  17. public class Action1009 : ParamObject
  18. {
  19. public Action1009() {
  20. this.MenuId = ActionType.ParticleStatistics;
  21. string filePath = Application.StartupPath + "\\Config\\" + "Default" + "\\" + "DebrisSelectionModel.xml";
  22. DebrisSelectionModel debrisSelectionModel = new DebrisSelectionModel();
  23. if (System.IO.File.Exists(filePath))
  24. {
  25. debrisSelectionModel = XmlSerializeHelper.DESerializer<DebrisSelectionModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  26. }
  27. BooleanObject[] booleanObjects2 = new BooleanObject[debrisSelectionModel.debrisSelectionList.Count];
  28. for (int k = 0; k < debrisSelectionModel.debrisSelectionList.Count; k++)
  29. {
  30. if (debrisSelectionModel.debrisSelectionList[k].conditionList == null || debrisSelectionModel.debrisSelectionList[k].conditionList.Count == 0)
  31. {
  32. booleanObjects2.SetValue(new BooleanObject(k.ToString(), debrisSelectionModel.debrisSelectionList[k].itemName, false, null), k);
  33. }
  34. else {
  35. booleanObjects2.SetValue(new BooleanObject(k.ToString(), debrisSelectionModel.debrisSelectionList[k].itemName, false, new Args[]{ getChoiseArray(debrisSelectionModel.debrisSelectionList[k].conditionList) }), k);
  36. }
  37. }
  38. //条件
  39. ChoiseArray eleven = new ChoiseArray("parameter11", "条件", booleanObjects2, 0);
  40. lists.Add(eleven);
  41. //显示编号
  42. BooleanObject one = new BooleanObject();
  43. one.key = "parameter1";
  44. one.name = "显示编号";
  45. one.initialValue = false;
  46. one.Value = false;
  47. lists.Add(one);
  48. //颜色
  49. ColorNumber two = new ColorNumber();
  50. two.key = "parameter2";
  51. two.name = "颜色";
  52. two.Value = Color.Blue.ToArgb();
  53. lists.Add(two);
  54. //显示参数
  55. BooleanObject three = new BooleanObject();
  56. three.key = "parameter3";
  57. three.name = "显示参数";
  58. three.initialValue = false;
  59. three.Value = false;
  60. lists.Add(three);
  61. ////参数
  62. //ChoiseArray four = new ChoiseArray("parameter4", "参数",
  63. // new BooleanObject[]
  64. // {
  65. // new BooleanObject("0", "面积", true, null),
  66. // new BooleanObject("1", "宽度", false, null),
  67. // }
  68. //);
  69. //four.initialValue = 0;
  70. //four.value = 0;
  71. //lists.Add(four);
  72. //颜色
  73. ColorNumber five = new ColorNumber();
  74. five.key = "parameter5";
  75. five.name = "颜色";
  76. five.Value = Color.Blue.ToArgb();
  77. lists.Add(five);
  78. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  79. BooleanObject[] booleanObjects = new BooleanObject[fonts.Families.Length];
  80. int i = 0;
  81. int defaultIndex = 0;
  82. foreach (FontFamily fontFamily in fonts.Families)
  83. {
  84. if (fontFamily.Name.Equals("宋体"))
  85. {
  86. defaultIndex = i;
  87. booleanObjects.SetValue(new BooleanObject(i.ToString(), fontFamily.Name, true, null), i);
  88. i++;
  89. continue;
  90. }
  91. booleanObjects.SetValue(new BooleanObject(i.ToString(), fontFamily.Name, false, null), i);
  92. i++;
  93. }
  94. //字体
  95. ChoiseArray six = new ChoiseArray("parameter6", PdnResources.GetString("Menu.Font.text"), booleanObjects, defaultIndex);
  96. lists.Add(six);
  97. //字号
  98. IntegerNumber seven = new IntegerNumber(1, 9999);
  99. seven.key = "parameter7";
  100. seven.name = "字号";
  101. seven.initialValue = 2;
  102. seven.value = 2;
  103. lists.Add(seven);
  104. //显示前数据
  105. IntegerNumber eight = new IntegerNumber(1, 9999);
  106. eight.key = "parameter8";
  107. eight.name = "显示前数据";
  108. eight.initialValue = 2;
  109. eight.value = 2;
  110. lists.Add(eight);
  111. //颜色
  112. ColorNumber nine = new ColorNumber();
  113. nine.key = "parameter9";
  114. nine.name = "选择颜色";
  115. nine.Value = Color.Blue.ToArgb();
  116. lists.Add(nine);
  117. //显示数据
  118. BooleanObject ten = new BooleanObject();
  119. ten.key = "parameter10";
  120. ten.name = "显示数据";
  121. ten.initialValue = false;
  122. ten.Value = false;
  123. lists.Add(ten);
  124. //小数
  125. IntegerNumber CalculatorDecimalDigits = new IntegerNumber(0, 10);
  126. CalculatorDecimalDigits.key = "CalculatorDecimalDigits";
  127. CalculatorDecimalDigits.name = "小数点位数";
  128. CalculatorDecimalDigits.initialValue = 2;
  129. CalculatorDecimalDigits.value = 2;
  130. lists.Add(CalculatorDecimalDigits);
  131. lists.Add(new BooleanObject("OpenWhileExportReport", "生成报告时打开设置", true, null));
  132. lists.Add(new BooleanObject("ExportResults", "导出结果", true, null));
  133. lists.Add(new BooleanObject("ExportReports", "生成报告", true, null));
  134. lists.Add(new BooleanObject("ExportProjects", "导出项目", true, null));
  135. }
  136. public ChoiseArray getChoiseArray(List<Condition> conditions)
  137. {
  138. BooleanObject[] booleanObjects = new BooleanObject[conditions.Count];
  139. foreach (var item in conditions) {
  140. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), item.conditionName);
  141. object paraName = new object();
  142. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  143. booleanObjects.SetValue(new BooleanObject(conditions.IndexOf(item).ToString(), paraName.ToString(), true, null), conditions.IndexOf(item));
  144. }
  145. ChoiseArray dataList = new ChoiseArray("parameter4", "参数条件", booleanObjects, 0);
  146. return dataList;
  147. }
  148. }
  149. }