Action11012ArbitrationLaw.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace PaintDotNet.Data.Action
  14. {
  15. public class Action11012ArbitrationLaw : ActionAnalysis
  16. {
  17. public Action11012ArbitrationLaw() {
  18. //旋转角度
  19. IntegerNumber one = new IntegerNumber(0, 50);
  20. one.key = "rotateangle";
  21. one.name = "旋转角度";
  22. one.initialValue = 0;
  23. one.value = 0;
  24. lists.Add(one);
  25. lists.Add(new BooleanObject("displaygrainboundaries", "显示晶界", false, null));
  26. lists.Add(new BooleanObject("displaygrid", "显示网格", false, null));
  27. lists.Add(new BooleanObject("displaygridsections", "显示网点", false, null));
  28. lists.Add(new BooleanObject("autoaddgridsections", "自动添加网点", false, null));
  29. ChoiseArray selectedItem = new ChoiseArray("selectgrid", "选择辅助线", 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 //}
  30. GrainSizeArbitrationLawModel grainSize = XmlSerializeHelper.DESerializer<GrainSizeArbitrationLawModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + "Default"/*Startup.instance.SettingPrefix*/ + "\\" + "GrainSizeArbitrationLawModel.xml"/*modelName*/, FileMode.Open));
  31. selectedItem.choiseList.AddRange(getComboboxArrayList1(grainSize));
  32. if (selectedItem.choiseList.Count == 0)
  33. selectedItem.choiseList.Add(new BooleanObject(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text")/*"1"/*"0"*/, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"), true, null));
  34. lists.Add(selectedItem);
  35. }
  36. public List<Args> getComboboxArrayList1(GrainSizeArbitrationLawModel grainSize)
  37. {
  38. ArrayList arrayList0 = new ArrayList();
  39. List<Args> arrayList1 = new List<Args>();
  40. List<int> indexList1 = new List<int>();
  41. if (grainSize.GridStyleList != null)
  42. {
  43. foreach (var hGuideStyle in grainSize.GridStyleList)
  44. {
  45. //if (arrayList1.Count == 0)
  46. // arrayList1.Add(new BooleanObject("1"/*"0"*/, hGuideStyle.tag, true, null));
  47. //else
  48. // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), hGuideStyle.tag, false, null));
  49. arrayList0.Add(hGuideStyle.gridName/*""*/);
  50. indexList1.Add(grainSize.GridStyleList.IndexOf(hGuideStyle));
  51. }
  52. }
  53. if (arrayList0.Count > 0)
  54. {
  55. bool sortSuccess = false;
  56. while (!sortSuccess)
  57. {
  58. sortSuccess = true;
  59. int firstIndex = 0;
  60. int secondIndex = 0;
  61. for (int i = 0; i < indexList1.Count; i++)
  62. {
  63. for (int j = i + 1; j < indexList1.Count; j++)
  64. {
  65. if (indexList1[i] > indexList1[j])
  66. {
  67. sortSuccess = false;
  68. firstIndex = i;
  69. secondIndex = j;
  70. }
  71. }
  72. if (!sortSuccess)
  73. break;
  74. }
  75. string firstValue = arrayList0[firstIndex] + "";
  76. arrayList0[firstIndex] = arrayList0[secondIndex] + "";
  77. arrayList0[secondIndex] = firstValue;
  78. int firstIndexV = indexList1[firstIndex] + 0;
  79. indexList1[firstIndex] = indexList1[secondIndex] + 0;
  80. indexList1[secondIndex] = firstIndexV;
  81. }
  82. for (int i = 0; i < arrayList0.Count; i++)
  83. {
  84. if (i == 0)
  85. arrayList1.Add(new BooleanObject(arrayList0[i].ToString()/*"1"*/, arrayList0[i].ToString(), true, null));
  86. else
  87. arrayList1.Add(new BooleanObject(arrayList0[i].ToString()/*(arrayList1.Count + 1).ToString()*/, arrayList0[i].ToString(), false, null));
  88. }
  89. //arrayList1.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  90. }
  91. return arrayList1;
  92. }
  93. }
  94. }