Action11012.cs 11 KB

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