123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Windows.Forms;
- using PaintDotNet.Base;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.Data.Param;
- namespace PaintDotNet.Data.Action
- {
- /// <summary>
- /// 晶粒度
- /// </summary>
- public class Action11012 : ActionAnalysis
- {
- ////专用分析的设置
- //lists.AddRange(createDedicatedLists());
- public Action11012()
- {
- this.MenuId = ActionType.GrainSize;
- 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 //}
- GrainSizeGuideStyleModel grainSize = XmlSerializeHelper.DESerializer<GrainSizeGuideStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + "Default"/*Startup.instance.SettingPrefix*/ + "\\" + "GrainSizeGuideStyleModel.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);
- #region [晶界重现]
- ChoiseArray one = new ChoiseArray("GrainApplygrainboundaries", "是否应用",
- new BooleanObject[]
- {
- new BooleanObject("1", "是", true, null),
- new BooleanObject("0", "否", false, null),
- }
- );
- one.initialValue = 0;
- one.value = 0;
- lists.Add(one);
- //相颜色
- 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<double> oneL = new List<double>();
- 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<Args> getComboboxArrayList1(GrainSizeGuideStyleModel grainSize)
- {
- ArrayList arrayList0 = new ArrayList();
- List<Args> arrayList1 = new List<Args>();
- List<int> indexList1 = new List<int>();
- // 垂直辅助线
- if (grainSize.vGuideStyles != null)
- {
- foreach (var vGuideStyle in grainSize.vGuideStyles)
- {
- //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.hGuideStyles != null)
- {
- foreach (var hGuideStyle in grainSize.hGuideStyles)
- {
- //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 (/*this.gbtType != 1 && */grainSize.cGuideStyles != null)
- {
- foreach (var cGuideStyle in grainSize.cGuideStyles)
- {
- //if (arrayList1.Count == 0)
- // arrayList1.Add(new BooleanObject("1"/*"0"*/, cGuideStyle.tag, true, null));
- //else
- // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), cGuideStyle.tag, false, null));
- arrayList0.Add(cGuideStyle.tag/*""*/);
- indexList1.Add(cGuideStyle.index);
- }
- }
- // 三圆辅助线
- if (grainSize.tCGuideStyles != null)
- {
- foreach (var tCGuideStyle in grainSize.tCGuideStyles)
- {
- //if (arrayList1.Count == 0)
- // arrayList1.Add(new BooleanObject("1"/*"0"*/, tCGuideStyle.tag, true, null));
- //else
- // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), tCGuideStyle.tag, false, null));
- arrayList0.Add(tCGuideStyle.tag/*""*/);
- indexList1.Add(tCGuideStyle.index);
- }
- }
- // 复合辅助线
- if (/*this.gbtType != 13 && this.gbtType != 1 && */grainSize.rGuideStyles != null)
- {
- foreach (var rGuideStyle in grainSize.rGuideStyles)
- {
- //if (arrayList1.Count == 0)
- // arrayList1.Add(new BooleanObject("1"/*"0"*/, rGuideStyle.tag, true, null));
- //else
- // arrayList1.Add(new BooleanObject((arrayList1.Count + 1).ToString(), rGuideStyle.tag, false, null));
- arrayList0.Add(rGuideStyle.tag/*""*/);
- indexList1.Add(rGuideStyle.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;
- }
- }
- }
|