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