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.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.Data.Action { public class Action11012Area : ActionAnalysis { public Action11012Area() { this.OpenImage = "current"; //第一个参数 lists.Add(new BooleanObject("displaygrainboundaries", "显示晶界", true, null)); //第二个参数 lists.Add(new BooleanObject("ShowGrainNumber", "显示晶粒编号", true, null)); //第三个参数 lists.Add(new BooleanObject("ShowGrainColor", "用不同颜色显示晶粒", true, null)); //第四个参数 lists.Add(new BooleanObject("displaygrid", "显示网格", true, null)); ////第五个参数 //lists.Add(new BooleanObject("displaysections", "显示截点", true, null)); //第六个参数 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 //} GrainSizeGuideAreaMethodModel grainSize = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + "Default"/*Startup.instance.SettingPrefix*/ + "\\" + "GrainSizeGuideAreaMethodModel.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)); selectedItem.initialValue = 1; selectedItem.value = 1; selectedItem.valueType = 1; lists.Add(selectedItem); //1不包含边缘 2边缘只处理内部 3边缘处理内外部 ChoiseArray one = new ChoiseArray("TargetSelection", "目标选择", new BooleanObject[] { new BooleanObject("1", "不包含边缘", true, null), new BooleanObject("2", "边缘只处理内部", false, null) } ); one.initialValue = 1; one.value = 1; lists.Add(one); #region [晶界重现] ChoiseArray eleven = new ChoiseArray("GrainApplygrainboundaries", "是否应用", new BooleanObject[] { new BooleanObject("1", "是", true, null), new BooleanObject("0", "否", false, null), } ); eleven.initialValue = 0; eleven.value = 0; lists.Add(eleven); //相颜色 ColorNumber three = new ColorNumber(); three.key = "lineColor"; three.name = "相颜色"; three.Value = Color.Red.ToArgb(); lists.Add(three); BooleanObject eight = new BooleanObject(); eight.key = "GrainIConnect"; eight.name = "强制连接"; eight.initialValue = false; eight.value = false; BooleanObject nine = new BooleanObject(); nine.key = "GrainDisplaysections"; nine.name = "晶界增强"; nine.initialValue = true; nine.value = true; //西格玛 DecimalNumber four = new DecimalNumber(0, 100000); four.key = "GrainSigma"; four.name = "西格玛"; four.DecimalPlaces = 1; four.initialValue = 1.0; four.value = 1.0; List oneL = new List(); oneL.Add(0); oneL.Add(0); DecimalScope five = new DecimalScope(0, 10000); five.key = "GrainCell_size1"; five.name = "晶界大小"; five.value = oneL; ChoiseArray six = new ChoiseArray("GrainDark", "晶界类型", new BooleanObject[] { new BooleanObject("0", "亮晶界", true, null), new BooleanObject("1", "暗晶界", false, null), new BooleanObject("2", "梯度", false, null) } ); six.initialValue = 0; six.value = 0; ChoiseArray seven = new ChoiseArray("GrainSmooth_type", "去噪类型", new BooleanObject[] { new BooleanObject("0", "高斯平滑", true, null), new BooleanObject("1", "方向平滑", false, null), } ); seven.initialValue = 0; seven.value = 0; ChoiseArray two = new ChoiseArray("GrainM_iStandardImage", "标准图像", new BooleanObject[] { new BooleanObject("0", "否", false, new Args[]{ nine, four, five, six, seven }), new BooleanObject("1", "是", true, new Args[]{ eight }), } ); two.initialValue = 0; two.value = 0; lists.Add(two); #endregion } public List getComboboxArrayList1(GrainSizeGuideAreaMethodModel grainSize) { ArrayList arrayList0 = new ArrayList(); List arrayList1 = new List(); List indexList1 = new List(); // 圆样式 if (grainSize.circularGuideStyles != null) { foreach (var vGuideStyle in grainSize.circularGuideStyles) { //if (arrayList1.Count == 0) // arrayList1.Add(new BooleanObject("1"/*"0"*/, vGuideStyle.tag, true, null)); //else // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), vGuideStyle.tag, false, null)); arrayList0.Add(vGuideStyle.tag/*""*/); indexList1.Add(vGuideStyle.index); } } // 矩形样式 if (grainSize.rectangleGuideStyles != null) { foreach (var hGuideStyle in grainSize.rectangleGuideStyles) { //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.tag/*""*/); indexList1.Add(hGuideStyle.index); } } 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; } } }