using PaintDotNet.Base; using PaintDotNet.Base.CommTool; using PaintDotNet.Base.Enum; using PaintDotNet.Base.Functionodel; using PaintDotNet.Data.Param; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using static PaintDotNet.Base.Functionodel.DebrisSelectionModel; namespace PaintDotNet.Data.Action { public class Action1009 : ParamObject { public Action1009() { this.MenuId = ActionType.ParticleStatistics; string filePath = Application.StartupPath + "\\Config\\" + "Default" + "\\" + "DebrisSelectionModel.xml"; DebrisSelectionModel debrisSelectionModel = new DebrisSelectionModel(); if (System.IO.File.Exists(filePath)) { debrisSelectionModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open)); } BooleanObject[] booleanObjects2 = new BooleanObject[debrisSelectionModel.debrisSelectionList.Count]; for (int k = 0; k < debrisSelectionModel.debrisSelectionList.Count; k++) { if (debrisSelectionModel.debrisSelectionList[k].conditionList == null || debrisSelectionModel.debrisSelectionList[k].conditionList.Count == 0) { booleanObjects2.SetValue(new BooleanObject(k.ToString(), debrisSelectionModel.debrisSelectionList[k].itemName, false, null), k); } else { booleanObjects2.SetValue(new BooleanObject(k.ToString(), debrisSelectionModel.debrisSelectionList[k].itemName, false, new Args[]{ getChoiseArray(debrisSelectionModel.debrisSelectionList[k].conditionList) }), k); } } //条件 ChoiseArray eleven = new ChoiseArray("parameter11", "条件", booleanObjects2, 0); lists.Add(eleven); //显示编号 BooleanObject one = new BooleanObject(); one.key = "parameter1"; one.name = "显示编号"; one.initialValue = false; one.Value = false; lists.Add(one); //颜色 ColorNumber two = new ColorNumber(); two.key = "parameter2"; two.name = "颜色"; two.Value = Color.Blue.ToArgb(); lists.Add(two); //显示参数 BooleanObject three = new BooleanObject(); three.key = "parameter3"; three.name = "显示参数"; three.initialValue = false; three.Value = false; lists.Add(three); ////参数 //ChoiseArray four = new ChoiseArray("parameter4", "参数", // new BooleanObject[] // { // new BooleanObject("0", "面积", true, null), // new BooleanObject("1", "宽度", false, null), // } //); //four.initialValue = 0; //four.value = 0; //lists.Add(four); //颜色 ColorNumber five = new ColorNumber(); five.key = "parameter5"; five.name = "颜色"; five.Value = Color.Blue.ToArgb(); lists.Add(five); System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection(); BooleanObject[] booleanObjects = new BooleanObject[fonts.Families.Length]; int i = 0; int defaultIndex = 0; foreach (FontFamily fontFamily in fonts.Families) { if (fontFamily.Name.Equals("宋体")) { defaultIndex = i; booleanObjects.SetValue(new BooleanObject(i.ToString(), fontFamily.Name, true, null), i); i++; continue; } booleanObjects.SetValue(new BooleanObject(i.ToString(), fontFamily.Name, false, null), i); i++; } //字体 ChoiseArray six = new ChoiseArray("parameter6", PdnResources.GetString("Menu.Font.text"), booleanObjects, defaultIndex); lists.Add(six); //字号 IntegerNumber seven = new IntegerNumber(1, 9999); seven.key = "parameter7"; seven.name = "字号"; seven.initialValue = 2; seven.value = 2; lists.Add(seven); //显示前数据 IntegerNumber eight = new IntegerNumber(1, 9999); eight.key = "parameter8"; eight.name = "显示前数据"; eight.initialValue = 2; eight.value = 2; lists.Add(eight); //颜色 ColorNumber nine = new ColorNumber(); nine.key = "parameter9"; nine.name = "选择颜色"; nine.Value = Color.Blue.ToArgb(); lists.Add(nine); //显示数据 BooleanObject ten = new BooleanObject(); ten.key = "parameter10"; ten.name = "显示数据"; ten.initialValue = false; ten.Value = false; lists.Add(ten); //小数 IntegerNumber CalculatorDecimalDigits = new IntegerNumber(0, 10); CalculatorDecimalDigits.key = "CalculatorDecimalDigits"; CalculatorDecimalDigits.name = "小数点位数"; CalculatorDecimalDigits.initialValue = 2; CalculatorDecimalDigits.value = 2; lists.Add(CalculatorDecimalDigits); lists.Add(new BooleanObject("OpenWhileExportReport", "生成报告时打开设置", true, null)); lists.Add(new BooleanObject("ExportResults", "导出结果", true, null)); lists.Add(new BooleanObject("ExportReports", "生成报告", true, null)); lists.Add(new BooleanObject("ExportProjects", "导出项目", true, null)); } public ChoiseArray getChoiseArray(List conditions) { BooleanObject[] booleanObjects = new BooleanObject[conditions.Count]; foreach (var item in conditions) { DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), item.conditionName); object paraName = new object(); InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName); booleanObjects.SetValue(new BooleanObject(conditions.IndexOf(item).ToString(), paraName.ToString(), true, null), conditions.IndexOf(item)); } ChoiseArray dataList = new ChoiseArray("parameter4", "参数条件", booleanObjects, 0); return dataList; } } }