using PaintDotNet.Base; using PaintDotNet.Base.CommTool; using PaintDotNet.Base.SettingModel; using PaintDotNet.Data.Param; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.Data.Action { public class Action11012ArbitrationLaw : ActionAnalysis { public Action11012ArbitrationLaw() { //旋转角度 IntegerNumber one = new IntegerNumber(0, 50); one.key = "rotateangle"; one.name = "旋转角度"; one.initialValue = 0; one.value = 0; lists.Add(one); lists.Add(new BooleanObject("displaygrainboundaries", "显示晶界", false, null)); lists.Add(new BooleanObject("displaygrid", "显示网格", false, null)); lists.Add(new BooleanObject("displaygridsections", "显示网点", false, null)); lists.Add(new BooleanObject("autoaddgridsections", "自动添加网点", false, null)); 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 //} GrainSizeArbitrationLawModel grainSize = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + "Default"/*Startup.instance.SettingPrefix*/ + "\\" + "GrainSizeArbitrationLawModel.xml"/*modelName*/, FileMode.Open)); selectedItem.choiseList.AddRange(getComboboxArrayList1(grainSize)); if (selectedItem.choiseList.Count == 0) selectedItem.choiseList.Add(new BooleanObject(PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text")/*"1"/*"0"*/, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"), true, null)); lists.Add(selectedItem); } public List getComboboxArrayList1(GrainSizeArbitrationLawModel grainSize) { ArrayList arrayList0 = new ArrayList(); List arrayList1 = new List(); List indexList1 = new List(); if (grainSize.GridStyleList != null) { foreach (var hGuideStyle in grainSize.GridStyleList) { //if (arrayList1.Count == 0) // arrayList1.Add(new BooleanObject("1"/*"0"*/, hGuideStyle.tag, true, null)); //else // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), hGuideStyle.tag, false, null)); arrayList0.Add(hGuideStyle.gridName/*""*/); indexList1.Add(grainSize.GridStyleList.IndexOf(hGuideStyle)); } } if (arrayList0.Count > 0) { bool sortSuccess = false; while (!sortSuccess) { sortSuccess = true; int firstIndex = 0; int secondIndex = 0; for (int i = 0; i < indexList1.Count; i++) { for (int j = i + 1; j < indexList1.Count; j++) { if (indexList1[i] > indexList1[j]) { sortSuccess = false; firstIndex = i; secondIndex = j; } } if (!sortSuccess) break; } string firstValue = arrayList0[firstIndex] + ""; arrayList0[firstIndex] = arrayList0[secondIndex] + ""; arrayList0[secondIndex] = firstValue; int firstIndexV = indexList1[firstIndex] + 0; indexList1[firstIndex] = indexList1[secondIndex] + 0; indexList1[secondIndex] = firstIndexV; } for (int i = 0; i < arrayList0.Count; i++) { if (i == 0) arrayList1.Add(new BooleanObject(arrayList0[i].ToString()/*"1"*/, arrayList0[i].ToString(), true, null)); else arrayList1.Add(new BooleanObject(arrayList0[i].ToString()/*(arrayList1.Count + 1).ToString()*/, arrayList0[i].ToString(), false, null)); } //arrayList1.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text")); } return arrayList1; } } }