Action1102511.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using PaintDotNet.Base;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.SettingModel;
  4. using PaintDotNet.Data.Param;
  5. using System;
  6. using System.Collections;
  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. namespace PaintDotNet.Data.Action
  15. {
  16. public class Action1102511 : ActionAnalysis
  17. {
  18. public Action1102511() {
  19. this.MenuId = ActionType.MagnesiumAlloyGBT4296MethodCutOff;
  20. this.OpenImage = "current";
  21. //第一个参数
  22. lists.Add(new BooleanObject("displaygrainboundaries", "显示晶界", true, null));
  23. ////第二个参数
  24. //lists.Add(new BooleanObject("ShowGrainNumber", "显示晶粒编号", true, null));
  25. ////第三个参数
  26. //lists.Add(new BooleanObject("ShowGrainColor", "用不同颜色显示晶粒", true, null));
  27. //第四个参数
  28. lists.Add(new BooleanObject("displaygrid", "显示网格", true, null));
  29. //第五个参数
  30. lists.Add(new BooleanObject("displaysections", "显示截点", true, null));
  31. //第六个参数
  32. ChoiseArray selectedItem = new ChoiseArray("comboBox1SelectedItem", "选择辅助线", null);//new BooleanObject[] //{ // new BooleanObject("1", PdnResources.GetString("Menu.solid.text"), true, null),//fill // new BooleanObject("2", PdnResources.GetString("Menu.Sideline.text"), false, null)//solid //}
  33. GrainSizeGuideStyleModel grainSize = XmlSerializeHelper.DESerializer<GrainSizeGuideStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + "Default"/*Startup.instance.SettingPrefix*/ + "\\" + "GrainGBT32461CutOffMethodModel.xml"/*modelName*/, FileMode.Open));
  34. selectedItem.choiseList.AddRange(getComboboxArrayList1(grainSize));
  35. if (selectedItem.choiseList.Count == 0)
  36. selectedItem.choiseList.Add(new BooleanObject(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text")/*"1"/*"0"*/, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"), true, null));
  37. selectedItem.initialValue = 1;
  38. selectedItem.value = 1;
  39. selectedItem.valueType = 1;
  40. lists.Add(selectedItem);
  41. #region [晶界重现]
  42. ChoiseArray eleven = new ChoiseArray("GrainApplygrainboundaries", "是否应用",
  43. new BooleanObject[]
  44. {
  45. new BooleanObject("1", "是", true, null),
  46. new BooleanObject("0", "否", false, null),
  47. }
  48. );
  49. eleven.initialValue = 0;
  50. eleven.value = 0;
  51. lists.Add(eleven);
  52. //相颜色
  53. ColorNumber three = new ColorNumber();
  54. three.key = "lineColor";
  55. three.name = "相颜色";
  56. three.Value = Color.Red.ToArgb();
  57. lists.Add(three);
  58. BooleanObject eight = new BooleanObject();
  59. eight.key = "GrainIConnect";
  60. eight.name = "强制连接";
  61. eight.initialValue = false;
  62. eight.value = false;
  63. BooleanObject nine = new BooleanObject();
  64. nine.key = "GrainDisplaysections";
  65. nine.name = "晶界增强";
  66. nine.initialValue = true;
  67. nine.value = true;
  68. //西格玛
  69. DecimalNumber four = new DecimalNumber(0, 100000);
  70. four.key = "GrainSigma";
  71. four.name = "西格玛";
  72. four.DecimalPlaces = 1;
  73. four.initialValue = 1.0;
  74. four.value = 1.0;
  75. List<double> oneL = new List<double>();
  76. oneL.Add(0);
  77. oneL.Add(0);
  78. DecimalScope five = new DecimalScope(0, 10000);
  79. five.key = "GrainCell_size1";
  80. five.name = "晶界大小";
  81. five.value = oneL;
  82. ChoiseArray six = new ChoiseArray("GrainDark", "晶界类型",
  83. new BooleanObject[]
  84. {
  85. new BooleanObject("0", "亮晶界", true, null),
  86. new BooleanObject("1", "暗晶界", false, null),
  87. new BooleanObject("2", "梯度", false, null)
  88. }
  89. );
  90. six.initialValue = 0;
  91. six.value = 0;
  92. ChoiseArray seven = new ChoiseArray("GrainSmooth_type", "去噪类型",
  93. new BooleanObject[]
  94. {
  95. new BooleanObject("0", "高斯平滑", true, null),
  96. new BooleanObject("1", "方向平滑", false, null),
  97. }
  98. );
  99. seven.initialValue = 0;
  100. seven.value = 0;
  101. ChoiseArray two = new ChoiseArray("GrainM_iStandardImage", "标准图像",
  102. new BooleanObject[]
  103. {
  104. new BooleanObject("0", "否", false, new Args[]{
  105. nine,
  106. four,
  107. five,
  108. six,
  109. seven
  110. }),
  111. new BooleanObject("1", "是", true, new Args[]{
  112. eight
  113. }),
  114. }
  115. );
  116. two.initialValue = 0;
  117. two.value = 0;
  118. lists.Add(two);
  119. #endregion
  120. }
  121. /// <summary>
  122. ///
  123. /// </summary>
  124. /// <param name="grainSize"></param>
  125. /// <returns></returns>
  126. public List<Args> getComboboxArrayList1(GrainSizeGuideStyleModel grainSize)
  127. {
  128. ArrayList arrayList0 = new ArrayList();
  129. List<Args> arrayList1 = new List<Args>();
  130. List<int> indexList1 = new List<int>();
  131. // 垂直辅助线
  132. if (grainSize.vGuideStyles != null)
  133. {
  134. foreach (var vGuideStyle in grainSize.vGuideStyles)
  135. {
  136. //if (arrayList1.Count == 0)
  137. // arrayList1.Add(new BooleanObject("1"/*"0"*/, vGuideStyle.tag, true, null));
  138. //else
  139. // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), vGuideStyle.tag, false, null));
  140. arrayList0.Add(vGuideStyle.tag/*""*/);
  141. indexList1.Add(vGuideStyle.index);
  142. }
  143. }
  144. // 水平辅助线
  145. if (grainSize.hGuideStyles != null)
  146. {
  147. foreach (var hGuideStyle in grainSize.hGuideStyles)
  148. {
  149. //if (arrayList1.Count == 0)
  150. // arrayList1.Add(new BooleanObject("1"/*"0"*/, hGuideStyle.tag, true, null));
  151. //else
  152. // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), hGuideStyle.tag, false, null));
  153. arrayList0.Add(hGuideStyle.tag/*""*/);
  154. indexList1.Add(hGuideStyle.index);
  155. }
  156. }
  157. // 单圆辅助线
  158. if (/*this.gbtType != 1 && */grainSize.cGuideStyles != null)
  159. {
  160. foreach (var cGuideStyle in grainSize.cGuideStyles)
  161. {
  162. //if (arrayList1.Count == 0)
  163. // arrayList1.Add(new BooleanObject("1"/*"0"*/, cGuideStyle.tag, true, null));
  164. //else
  165. // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), cGuideStyle.tag, false, null));
  166. arrayList0.Add(cGuideStyle.tag/*""*/);
  167. indexList1.Add(cGuideStyle.index);
  168. }
  169. }
  170. // 三圆辅助线
  171. if (grainSize.tCGuideStyles != null)
  172. {
  173. foreach (var tCGuideStyle in grainSize.tCGuideStyles)
  174. {
  175. //if (arrayList1.Count == 0)
  176. // arrayList1.Add(new BooleanObject("1"/*"0"*/, tCGuideStyle.tag, true, null));
  177. //else
  178. // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), tCGuideStyle.tag, false, null));
  179. arrayList0.Add(tCGuideStyle.tag/*""*/);
  180. indexList1.Add(tCGuideStyle.index);
  181. }
  182. }
  183. // 复合辅助线
  184. if (/*this.gbtType != 13 && this.gbtType != 1 && */grainSize.rGuideStyles != null)
  185. {
  186. foreach (var rGuideStyle in grainSize.rGuideStyles)
  187. {
  188. //if (arrayList1.Count == 0)
  189. // arrayList1.Add(new BooleanObject("1"/*"0"*/, rGuideStyle.tag, true, null));
  190. //else
  191. // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), rGuideStyle.tag, false, null));
  192. arrayList0.Add(rGuideStyle.tag/*""*/);
  193. indexList1.Add(rGuideStyle.index);
  194. }
  195. }
  196. if (arrayList0.Count > 0)
  197. {
  198. bool sortSuccess = false;
  199. while (!sortSuccess)
  200. {
  201. sortSuccess = true;
  202. int firstIndex = 0;
  203. int secondIndex = 0;
  204. for (int i = 0; i < indexList1.Count; i++)
  205. {
  206. for (int j = i + 1; j < indexList1.Count; j++)
  207. {
  208. if (indexList1[i] > indexList1[j])
  209. {
  210. sortSuccess = false;
  211. firstIndex = i;
  212. secondIndex = j;
  213. }
  214. }
  215. if (!sortSuccess)
  216. break;
  217. }
  218. string firstValue = arrayList0[firstIndex] + "";
  219. arrayList0[firstIndex] = arrayList0[secondIndex] + "";
  220. arrayList0[secondIndex] = firstValue;
  221. int firstIndexV = indexList1[firstIndex] + 0;
  222. indexList1[firstIndex] = indexList1[secondIndex] + 0;
  223. indexList1[secondIndex] = firstIndexV;
  224. }
  225. for (int i = 0; i < arrayList0.Count; i++)
  226. {
  227. if (i == 0)
  228. arrayList1.Add(new BooleanObject(arrayList0[i].ToString()/*"1"*/, arrayList0[i].ToString(), true, null));
  229. else
  230. arrayList1.Add(new BooleanObject(arrayList0[i].ToString()/*(arrayList1.Count + 1).ToString()*/, arrayList0[i].ToString(), false, null));
  231. }
  232. //arrayList1.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  233. }
  234. return arrayList1;
  235. }
  236. }
  237. }