123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249 |
- using OpenCvSharp;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.SettingModel;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Windows.Forms;
- using Point = System.Drawing.Point;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.Base.Enum;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.CustomControl;
- using Application = System.Windows.Forms.Application;
- using GroupBox = System.Windows.Forms.GroupBox;
- using CheckBox = System.Windows.Forms.CheckBox;
- using Button = System.Windows.Forms.Button;
- using Label = System.Windows.Forms.Label;
- using PaintDotNet.DedicatedAnalysis.DuctileIron.Common;
- using System.Data;
- using Microsoft.Office.Interop.Excel;
- using Font = System.Drawing.Font;
- using DataTable = System.Data.DataTable;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Data.Param;
- using PaintDotNet.Instrument;
- using PaintDotNet;
- using OpenCvSharp.Extensions;
- using Rectangle = System.Drawing.Rectangle;
- using System.Linq;
- using Metis.ParameterSet;
- using PaintDotNet.Base;
- namespace PaintDotNet.DeterminationOfNitridingDepth.GBT11354_2005
- {
- internal class MetallographicMethodDialog : PdnBaseForm
- {
- #region 控件
- private GroupBox groupBox1;
- private Button button2;
- private CheckBox checkBox2;
- private GroupBox groupBox2;
- private ListView listView1;
- private PaintDotNet.CustomControl.BinaryControl bc;
- private GroupBox groupBox7;
- private GroupBox groupBox8;
- private DataGridView dataGridView2;
- private Button button4;
- private ListView listView2;
- private NumericUpDown numericUpDown1;
- private Button button16;
- private Label label5;
- private Button button14;
- private Button button13;
- private DataGridView dataGridView4;
- private Button button12;
- private Button button11;
- private GroupBox groupBox3;
- private Button button6;
- private Button button5;
- private Button button3;
- private RadioButton radioButton1;
- private RadioButton radioButton3;
- private RadioButton radioButton2;
- private GroupBox groupBox4;
- private Label label1;
- private Label label2;
- private NumericUpDown numericUpDown2;
- private Label label3;
- private NumericUpDown numericUpDown3;
- private Panel panel1;
- private GroupBox groupBox5;
- private DataGridView dataGridView1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
- private ImageList imageList1;
- private IContainer components;
- private Button button1;
- #endregion
- /// <summary>
- /// 主控件
- /// </summary>
- private AppWorkspace appWorkspace;
- private bool canChange = false;
- //二值化集成1
- BinaryClass binaryClass;
- private int menuId;
- private string menuName;
- /// <summary>
- /// 选中图片的mat
- /// </summary>
- private Mat imageMat;
- private DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 储存点击保存结果后的所有原图与分析图
- /// </summary>
- private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- /// <summary>
- /// 处理程序
- /// </summary>
- private ParamObject action = new Data.Action.Action1010();
- /// <summary>
- /// 调色板
- /// </summary>
- private ColorsForm colorsForm1;
- /// <summary>
- /// 全部显示
- /// </summary>
- private bool allShow = false;
- /// <summary>
- /// 标尺
- /// </summary>
- private double unitLength;
- /// <summary>
- /// 数据展示
- /// </summary>
- private DataTable dataTable;
- /// <summary>
- /// 存在视场标记
- /// </summary>
- private bool existViewFlag = false;
- /// <summary>
- /// 线条绘制点矩形集合
- /// </summary>
- private Dictionary<RectangleF[], int> rectangleFs = new Dictionary<RectangleF[], int>();
- /// <summary>
- /// 线条绘制点矩形
- /// </summary>
- private RectangleF[] rectangleFsArr = new RectangleF[2];
- /// <summary>
- /// 线条矩形
- /// </summary>
- private PointF[] pointFsLine = new PointF[4];
- /// <summary>
- /// 分析结果暂存
- /// </summary>
- private List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
- /// <summary>
- /// 保存用于生成报告的图片
- /// </summary>
- private List<Bitmap> bitList;
- /// <summary>
- /// 中间数据
- /// </summary>
- private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
- /// <summary>
- /// 鼠标状态(0:添加 1:删除 2:选择)
- /// </summary>
- private int mouseStatus = -1;
- /// <summary>
- /// 测量线类型(0:全方位 1:水平 2:垂直)
- /// </summary>
- private int lineStyle = -1;
- /// <summary>
- /// 线条矩形
- /// </summary>
- private Dictionary<PointF[], int> rectangleFsLines = new Dictionary<PointF[], int>();
- private int selectLineIndex = -1;
- private PointF movePointStart;
- bool canMove = false;
- int movePointIndex = -1;
- private ToolStrip toolStrip1;
- private Label label4;
- private NumericUpDown numericUpDown4;
- bool canAdd = false;
- private int defaultIndex = -1;
- /// <summary>
- /// 保存窗口参数
- /// </summary>
- private GrainSizeAnalysisModel analysisModel;
- private const string ParamKey_Report = "report";//报告设置
- private const string ParamKey_Whole = "whole";//全方位线
- private const string ParamKey_Waterline = "waterline";//水平线
- private const string ParamKey_Vertical = "vertical";//垂直线
- private const string ParamKey_LineLength = "lineLength";//线长
- private const string ParamKey_LineWidth = "lineWidth";//线宽
- private const string ParamKey_LineColour = "lineColour";//线色
- private const string ParamKey_FontSize = "fontSize";//字号
- private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
- /// <summary>
- /// 是否脚本运行
- /// </summary>
- private Boolean initScriptValues = false;
- public MetallographicMethodDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
- {
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
- binaryClass = new BinaryClass(menuId);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
- foreach (var item in this.analysisModel.ListParam)
- item.setValue();
- this.appWorkspace = appWorkspace;
- InitializeComponent();
- InitializeLanguageText();
- // 标尺
- //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
- //
- //初始化色板
- //
- //调色板
- this.colorsForm1 = new ColorsForm();
- this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
- this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = false;
- this.documentWorkspace.panel.MouseDown += OnMouseDown;
- this.documentWorkspace.panel.Paint += Panel_Paint;
- this.documentWorkspace.panel.MouseMove += onMouseMove;
- this.documentWorkspace.panel.MouseUp += OnMouseUp;
- this.groupBox7.Controls.Add(documentWorkspace);
- //
- //初始化操作按钮
- //
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.commonControlButtons.Visible = false;
- this.groupBox7.Controls.Add(commonControlButtons);
- //初始化头
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = "";
- header0.Width = 180;
- this.listView2.Columns.Add(header0);
- InitCommonButtonEvent();
- Init();
- InitPicList();
- SetAnalyzeModelFromXml("Template.Manager.item3.NitridingLayerGBT11354");
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") }
- , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
- binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- //如果是脚本执行,将参数带入
- if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
- {
- this.initScriptValues = true;//ScriptAutomatic
- //Boolean initScriptValues = true;
- ////在这里反射出对应功能的参数类
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- foreach (Args arg in param.Lists)
- {
- Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
- if (param1.value != null)
- arg.Value = param1.value;
- getValue(arg.key, arg.Value);
- }
- appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
- }
- else
- {//读取上次关闭窗口时保存的参数
- GetListParamModel();
- }
- for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
- {
- this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
- {
- this.dataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- for (int i = 0; i < this.dataGridView4.Columns.Count; i++)
- {
- this.dataGridView4.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- }
- /// <summary>
- /// 初始化参数
- /// </summary>
- private void Init()
- {
- this.Focus();
- this.radioButton1.Checked = true;
- this.mouseStatus = -1;
- this.numericUpDown2.Value = 50;
- this.numericUpDown3.Value = 5;
- this.button11.Visible = true;
- this.button16.Visible = false;
- }
- private void ShowImgEvent(object sender, EventArgs e)
- {
- listView1.Focus();
- if (this.defaultIndex != -1)
- {
- this.listView1.Items[defaultIndex].Focused = true;
- this.listView1.Items[defaultIndex].Selected = true;
- }
- }
- /// <summary>
- /// 初始化图片列表数据
- /// </summary>
- public void InitPicList()
- {
- //初始化图片列表
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- defaultIndex = i;
- }
- }
- this.Shown += ShowImgEvent;
- }
- /// <summary>
- /// 刷新数据展示
- /// </summary>
- private void RefrashData()
- {
- canChange = true;
- if (this.rectangleFs.Count == 0)
- return;
- this.dataGridView1.Rows.Clear();
- int count = 0;
- foreach (var item in rectangleFs)
- {
- count++;
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6,Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
- dgvr.Cells[0].Value = "L" + count;
- dgvr.Cells[1].Value = Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView1.Rows.Add(dgvr);
- }
- dataTable = new DataTable();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dataTable.Columns.Add(Column.HeaderText);
- }
- count = 0;
- foreach (var item in rectangleFs)
- {
- count++;
- DataRow dataRow = dataTable.NewRow();
- double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
- dataRow[0] = "L" + count;
- dataRow[1] = length;
- this.dataTable.Rows.Add(dataRow);
- }
- double allLength = 0;
- for (int i = 0; i < dataTable.Rows.Count; i++)
- {
- allLength += Convert.ToDouble(dataTable.Rows[i][1]);
- }
- DataGridViewRow dgvr1 = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dgvr1.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr1.Cells[0].Value = PdnResources.GetString("Menu.Image.Average.Text");
- dgvr1.Cells[1].Value = Math.Round(allLength / this.dataTable.Rows.Count, Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView1.Rows.Add(dgvr1);
-
- canChange = false;
- if (this.dataGridView1.DisplayedRowCount(false) == this.dataGridView1.RowCount)
- {
- //没有
- this.dataGridViewTextBoxColumn10.Width = 242;
- }
- else
- {
- //有
- this.dataGridViewTextBoxColumn10.Width = 227;
- }
- }
- //二值化集成3
- #region 二值化相关方法
- private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- binaryClass.saveParams();
- this.saveDialogParamValues();
- //xml保存路径
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- foreach (var analysisItem in this.analysisModel.ListParam)
- {
- bool foundItem = false;
- foreach (var item in analysisModelXml.ListParam)
- {
- if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
- {
- item.param_value = analysisItem.param_value;
- foundItem = true;
- break;
- }
- }
- if (!foundItem)
- analysisModelXml.ListParam.Add(analysisItem.cloneModel());
- }
- //按路径和名称保存xml文件
- string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
- //保存xml
- FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
- }
- private void ShownChoiseItemAndInitData(object sender, EventArgs e)
- {
- binaryClass.RefreshHistogramControl1Values();
- }
- /// <summary>
- /// 添加参数改变的监听
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void GrainSizeAnalysisMethodOfClasticRockDialog_Load(object sender, EventArgs e)
- {
- this.binaryClass.loadParams();
- }
- private bool bcBinaryChecked()
- {
- return bc != null && bc.BinaryChecked;
- }
- private bool bcOriginChecked()
- {
- return bc != null && bc.OriginChecked;
- }
- /// <summary>
- /// 参数改变时,重新处理图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bClassBinaryImplFinishAction(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 显示原图/原图+二值图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bcOriginCheckedChanged(object sender, EventArgs e)
- {
- if (!bcOriginChecked())
- {
- if (bcBinaryChecked())
- this.documentWorkspace.PhaseModels[0].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- this.documentWorkspace.PhaseModels[1].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- #region 公共控件
- private void InitCommonButtonEvent()
- {
- this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomOut();
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- #endregion
- #region 初始化
- private void InitializeLanguageText()
- {
- this.bc = new PaintDotNet.CustomControl.BinaryControl();
- //
- // bc
- //
- this.bc.BinaryBackColor = System.Drawing.Color.Red;
- this.bc.BinaryChecked = false;
- this.bc.BinaryStyle = 1;
- this.bc.Location = new System.Drawing.Point(151, 59);
- this.bc.Name = "bc";
- this.bc.OriginChecked = false;
- this.bc.scope1End = 0D;
- this.bc.scope1Start = 0D;
- this.bc.scope2End = 0D;
- this.bc.scope2Start = 0D;
- this.bc.scope3End = 0D;
- this.bc.scope3Start = 0D;
- this.bc.Size = new System.Drawing.Size(360, 292);
- this.bc.TabIndex = 21;
- this.Controls.Add(this.bc);
- this.Controls.SetChildIndex(this.bc, 0);
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.checkBox2.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Numberofnitridinglayers.text");
- this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Totaldepthofnitridinglayer.text");
- this.dataGridViewTextBoxColumn6.HeaderText = PdnResources.GetString("Menu.Averagedepthofnitridinglayer.text");
- this.button4.Text = PdnResources.GetString("Menu.Exportproject.text");
- this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
- this.button14.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.button13.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.Column2.HeaderText = PdnResources.GetString("Menu.packet.text");
- this.Column5.HeaderText = PdnResources.GetString("Menu.Depthofnitridinglayer.text");
- this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button11.Text = PdnResources.GetString("Menu.Showall.text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Measurementbaseline.text");
- this.radioButton1.Text = PdnResources.GetString("Menu.Fullline.text");
- this.radioButton3.Text = PdnResources.GetString("Menu.Verticalline.text");
- this.radioButton2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureHLine.Text");
- this.button6.Text = PdnResources.GetString("Menu.Selectmeasurementline.text");
- this.button5.Text = PdnResources.GetString("Menu.Deletemeasurementline.text");
- this.button3.Text = PdnResources.GetString("Menu.Addmeasuringline.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Basicsettingsofmeasuringline.text");
- this.label3.Text = PdnResources.GetString("Menu.color.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
- this.label1.Text = PdnResources.GetString("Menu.Linelength.text") + ":";
- this.groupBox5.Text = PdnResources.GetString("Menu.datapresentation.text");
- this.dataGridViewTextBoxColumn9.HeaderText = PdnResources.GetString("Menu.packet.text");
- this.dataGridViewTextBoxColumn10.HeaderText = PdnResources.GetString("Menu.Depthofnitridinglayer.text");
- this.Text = PdnResources.GetString("Menu.yerGBT11354_2005Metallogr.text");
- this.label4.Text = PdnResources.GetString("Menu.Font.text") + PdnResources.GetString("Menu.size.text") + ":"; ;
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.toolStrip1 = new System.Windows.Forms.ToolStrip();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.button4 = new System.Windows.Forms.Button();
- this.listView2 = new System.Windows.Forms.ListView();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.button16 = new System.Windows.Forms.Button();
- this.label5 = new System.Windows.Forms.Label();
- this.button14 = new System.Windows.Forms.Button();
- this.button13 = new System.Windows.Forms.Button();
- this.dataGridView4 = new System.Windows.Forms.DataGridView();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.button12 = new System.Windows.Forms.Button();
- this.button11 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.radioButton3 = new System.Windows.Forms.RadioButton();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.button6 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
- this.label4 = new System.Windows.Forms.Label();
- this.panel1 = new System.Windows.Forms.Panel();
- this.label3 = new System.Windows.Forms.Label();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.label2 = new System.Windows.Forms.Label();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox7.SuspendLayout();
- this.groupBox8.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).BeginInit();
- this.groupBox3.SuspendLayout();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- this.groupBox5.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.checkBox2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(14, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(1081, 50);
- this.groupBox1.TabIndex = 7;
- this.groupBox1.TabStop = false;
- //
- // button2
- //
- this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button2.BackColor = System.Drawing.SystemColors.Control;
- this.button2.Location = new System.Drawing.Point(985, 14);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(84, 30);
- this.button2.TabIndex = 3;
- this.button2.UseVisualStyleBackColor = false;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // checkBox2
- //
- this.checkBox2.AutoSize = true;
- this.checkBox2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
- this.checkBox2.Location = new System.Drawing.Point(105, 20);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(15, 14);
- this.checkBox2.TabIndex = 2;
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.BackColor = System.Drawing.SystemColors.Control;
- this.button1.Location = new System.Drawing.Point(15, 14);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(84, 30);
- this.button1.TabIndex = 0;
- this.button1.UseVisualStyleBackColor = false;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.listView1);
- this.groupBox2.Location = new System.Drawing.Point(14, 68);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(135, 574);
- this.groupBox2.TabIndex = 8;
- this.groupBox2.TabStop = false;
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.HideSelection = false;
- this.listView1.LargeImageList = this.imageList1;
- this.listView1.Location = new System.Drawing.Point(5, 17);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(124, 551);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- //
- // imageList1
- //
- this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // groupBox7
- //
- this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox7.Controls.Add(this.toolStrip1);
- this.groupBox7.Location = new System.Drawing.Point(521, 68);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(580, 574);
- this.groupBox7.TabIndex = 21;
- this.groupBox7.TabStop = false;
- //
- // toolStrip1
- //
- this.toolStrip1.Location = new System.Drawing.Point(3, 17);
- this.toolStrip1.Name = "toolStrip1";
- this.toolStrip1.Size = new System.Drawing.Size(574, 25);
- this.toolStrip1.TabIndex = 0;
- this.toolStrip1.Text = "toolStrip1";
- //
- // groupBox8
- //
- this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox8.Controls.Add(this.dataGridView2);
- this.groupBox8.Controls.Add(this.button4);
- this.groupBox8.Controls.Add(this.listView2);
- this.groupBox8.Controls.Add(this.numericUpDown1);
- this.groupBox8.Controls.Add(this.button16);
- this.groupBox8.Controls.Add(this.label5);
- this.groupBox8.Controls.Add(this.button14);
- this.groupBox8.Controls.Add(this.button13);
- this.groupBox8.Controls.Add(this.dataGridView4);
- this.groupBox8.Controls.Add(this.button12);
- this.groupBox8.Controls.Add(this.button11);
- this.groupBox8.Location = new System.Drawing.Point(14, 648);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(1087, 273);
- this.groupBox8.TabIndex = 25;
- this.groupBox8.TabStop = false;
- //
- // dataGridView2
- //
- this.dataGridView2.AllowUserToAddRows = false;
- this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
- this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.dataGridViewTextBoxColumn1,
- this.dataGridViewTextBoxColumn2,
- this.dataGridViewTextBoxColumn6});
- this.dataGridView2.Location = new System.Drawing.Point(228, 159);
- this.dataGridView2.Name = "dataGridView2";
- this.dataGridView2.ReadOnly = true;
- this.dataGridView2.RowHeadersVisible = false;
- this.dataGridView2.RowTemplate.Height = 23;
- this.dataGridView2.Size = new System.Drawing.Size(693, 108);
- this.dataGridView2.TabIndex = 24;
- //
- // dataGridViewTextBoxColumn1
- //
- dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle2;
- this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
- this.dataGridViewTextBoxColumn1.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn2
- //
- dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle3;
- this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn6
- //
- dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.dataGridViewTextBoxColumn6.DefaultCellStyle = dataGridViewCellStyle4;
- this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
- this.dataGridViewTextBoxColumn6.ReadOnly = true;
- //
- // button4
- //
- this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button4.BackColor = System.Drawing.SystemColors.Control;
- this.button4.Location = new System.Drawing.Point(941, 102);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(128, 26);
- this.button4.TabIndex = 23;
- this.button4.UseVisualStyleBackColor = false;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // listView2
- //
- this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.listView2.FullRowSelect = true;
- this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
- this.listView2.HideSelection = false;
- this.listView2.Location = new System.Drawing.Point(16, 56);
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(180, 210);
- this.listView2.TabIndex = 22;
- this.listView2.UseCompatibleStateImageBehavior = false;
- this.listView2.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView2_ItemSelectionChanged);
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
- //
- // numericUpDown1
- //
- this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.numericUpDown1.Location = new System.Drawing.Point(997, 163);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(56, 21);
- this.numericUpDown1.TabIndex = 21;
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // button16
- //
- this.button16.BackColor = System.Drawing.SystemColors.Control;
- this.button16.Location = new System.Drawing.Point(16, 20);
- this.button16.Name = "button16";
- this.button16.Size = new System.Drawing.Size(93, 26);
- this.button16.TabIndex = 20;
- this.button16.UseVisualStyleBackColor = false;
- this.button16.Click += new System.EventHandler(this.button16_Click);
- //
- // label5
- //
- this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(958, 169);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(0, 12);
- this.label5.TabIndex = 18;
- //
- // button14
- //
- this.button14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button14.BackColor = System.Drawing.SystemColors.Control;
- this.button14.Location = new System.Drawing.Point(941, 68);
- this.button14.Name = "button14";
- this.button14.Size = new System.Drawing.Size(128, 26);
- this.button14.TabIndex = 16;
- this.button14.UseVisualStyleBackColor = false;
- this.button14.Click += new System.EventHandler(this.button14_Click);
- //
- // button13
- //
- this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button13.BackColor = System.Drawing.SystemColors.Control;
- this.button13.Location = new System.Drawing.Point(941, 34);
- this.button13.Name = "button13";
- this.button13.Size = new System.Drawing.Size(128, 26);
- this.button13.TabIndex = 12;
- this.button13.UseVisualStyleBackColor = false;
- this.button13.Click += new System.EventHandler(this.button13_Click);
- //
- // dataGridView4
- //
- this.dataGridView4.AllowUserToAddRows = false;
- this.dataGridView4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView4.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView4.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView4.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
- this.dataGridView4.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView4.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2,
- this.Column5});
- this.dataGridView4.Location = new System.Drawing.Point(228, 20);
- this.dataGridView4.Name = "dataGridView4";
- this.dataGridView4.ReadOnly = true;
- this.dataGridView4.RowHeadersVisible = false;
- this.dataGridView4.RowTemplate.Height = 23;
- this.dataGridView4.Size = new System.Drawing.Size(693, 133);
- this.dataGridView4.TabIndex = 15;
- //
- // Column1
- //
- dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.Column1.DefaultCellStyle = dataGridViewCellStyle6;
- this.Column1.Name = "Column1";
- this.Column1.ReadOnly = true;
- //
- // Column2
- //
- dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.Column2.DefaultCellStyle = dataGridViewCellStyle7;
- this.Column2.Name = "Column2";
- this.Column2.ReadOnly = true;
- //
- // Column5
- //
- dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.Column5.DefaultCellStyle = dataGridViewCellStyle8;
- this.Column5.Name = "Column5";
- this.Column5.ReadOnly = true;
- //
- // button12
- //
- this.button12.BackColor = System.Drawing.SystemColors.Control;
- this.button12.Location = new System.Drawing.Point(145, 20);
- this.button12.Name = "button12";
- this.button12.Size = new System.Drawing.Size(52, 26);
- this.button12.TabIndex = 13;
- this.button12.UseVisualStyleBackColor = false;
- this.button12.Click += new System.EventHandler(this.button12_Click);
- //
- // button11
- //
- this.button11.BackColor = System.Drawing.SystemColors.Control;
- this.button11.Location = new System.Drawing.Point(15, 20);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(63, 26);
- this.button11.TabIndex = 12;
- this.button11.UseVisualStyleBackColor = false;
- this.button11.Click += new System.EventHandler(this.button11_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.radioButton1);
- this.groupBox3.Controls.Add(this.radioButton3);
- this.groupBox3.Controls.Add(this.radioButton2);
- this.groupBox3.Controls.Add(this.button6);
- this.groupBox3.Controls.Add(this.button5);
- this.groupBox3.Controls.Add(this.button3);
- this.groupBox3.Location = new System.Drawing.Point(155, 366);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(360, 69);
- this.groupBox3.TabIndex = 26;
- this.groupBox3.TabStop = false;
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Location = new System.Drawing.Point(13, 20);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(14, 13);
- this.radioButton1.TabIndex = 6;
- this.radioButton1.TabStop = true;
- this.radioButton1.UseVisualStyleBackColor = true;
- this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
- //
- // radioButton3
- //
- this.radioButton3.AutoSize = true;
- this.radioButton3.Location = new System.Drawing.Point(152, 20);
- this.radioButton3.Name = "radioButton3";
- this.radioButton3.Size = new System.Drawing.Size(14, 13);
- this.radioButton3.TabIndex = 5;
- this.radioButton3.TabStop = true;
- this.radioButton3.UseVisualStyleBackColor = true;
- this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(87, 20);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(14, 13);
- this.radioButton2.TabIndex = 4;
- this.radioButton2.TabStop = true;
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(236, 42);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(97, 23);
- this.button6.TabIndex = 3;
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(125, 42);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(97, 23);
- this.button5.TabIndex = 2;
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(14, 42);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(97, 23);
- this.button3.TabIndex = 0;
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- this.button3.LostFocus += new System.EventHandler(this.button3_LostFocus);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.numericUpDown4);
- this.groupBox4.Controls.Add(this.label4);
- this.groupBox4.Controls.Add(this.panel1);
- this.groupBox4.Controls.Add(this.label3);
- this.groupBox4.Controls.Add(this.numericUpDown3);
- this.groupBox4.Controls.Add(this.label2);
- this.groupBox4.Controls.Add(this.numericUpDown2);
- this.groupBox4.Controls.Add(this.label1);
- this.groupBox4.Location = new System.Drawing.Point(155, 441);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(360, 76);
- this.groupBox4.TabIndex = 27;
- this.groupBox4.TabStop = false;
- //
- // numericUpDown4
- //
- this.numericUpDown4.Location = new System.Drawing.Point(87, 45);
- this.numericUpDown4.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.numericUpDown4.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown4.Name = "numericUpDown4";
- this.numericUpDown4.Size = new System.Drawing.Size(55, 21);
- this.numericUpDown4.TabIndex = 7;
- this.numericUpDown4.Value = new decimal(new int[] {
- 20,
- 0,
- 0,
- 0});
- this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(19, 49);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(0, 12);
- this.label4.TabIndex = 6;
- //
- // panel1
- //
- this.panel1.BackColor = System.Drawing.Color.Lime;
- this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel1.Location = new System.Drawing.Point(265, 17);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(76, 20);
- this.panel1.TabIndex = 5;
- this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged);
- this.panel1.Click += new System.EventHandler(this.panel1_Click);
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(223, 21);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(0, 12);
- this.label3.TabIndex = 4;
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(158, 17);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.numericUpDown3.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(55, 21);
- this.numericUpDown3.TabIndex = 3;
- this.numericUpDown3.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(124, 21);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(0, 12);
- this.label2.TabIndex = 2;
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(56, 17);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.numericUpDown2.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(55, 21);
- this.numericUpDown2.TabIndex = 1;
- this.numericUpDown2.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(19, 21);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(0, 12);
- this.label1.TabIndex = 0;
- //
- // groupBox5
- //
- this.groupBox5.Controls.Add(this.dataGridView1);
- this.groupBox5.Location = new System.Drawing.Point(155, 513);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(360, 129);
- this.groupBox5.TabIndex = 28;
- this.groupBox5.TabStop = false;
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle9;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.dataGridViewTextBoxColumn9,
- this.dataGridViewTextBoxColumn10});
- this.dataGridView1.Location = new System.Drawing.Point(6, 20);
- this.dataGridView1.MultiSelect = false;
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.ReadOnly = true;
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView1.Size = new System.Drawing.Size(348, 101);
- this.dataGridView1.TabIndex = 4;
- this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
- //
- // dataGridViewTextBoxColumn9
- //
- dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle10;
- this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
- this.dataGridViewTextBoxColumn9.ReadOnly = true;
- this.dataGridViewTextBoxColumn9.Width = 103;
- //
- // dataGridViewTextBoxColumn10
- //
- dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle11;
- this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
- this.dataGridViewTextBoxColumn10.ReadOnly = true;
- this.dataGridViewTextBoxColumn10.Width = 242;
- //
- // MetallographicMethodDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1107, 933);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox8);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.KeyPreview = true;
- this.Name = "MetallographicMethodDialog";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InclusionsStandardDialog_FormClosing);
- this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
- this.Load += new System.EventHandler(this.GrainSizeAnalysisMethodOfClasticRockDialog_Load);
- this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MetallographicMethodDialog_KeyDown);
- this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MetallographicMethodDialog_KeyUp);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.Controls.SetChildIndex(this.groupBox8, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.groupBox7.ResumeLayout(false);
- this.groupBox7.PerformLayout();
- this.groupBox8.ResumeLayout(false);
- this.groupBox8.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).EndInit();
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- this.groupBox4.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- this.groupBox5.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
- {
- }
- private void panel1_Click(object sender, EventArgs e)
- {
- this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
- this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
- this.colorsForm1.ShowDialog();
- }
- private void panel1Changed(object sender, EventArgs e)
- {
- this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
- this.colorsForm1.Close();
- }
- /// <summary>
- /// ListView图片选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
- {
- this.unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- this.commonControlButtons.Visible = true;
- existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView();
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- rectangleFs.Clear();
- //二值化集成4
- binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone());
- if (bcOriginChecked())
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- this.documentWorkspace.PhaseModels[1].choise = false;
- this.documentWorkspace.Refresh();
- }
-
- rectangleFsArr = new RectangleF[] { };
- rectangleFs.Clear();
- pointFsLine = new PointF []{ };
- this.dataGridView1.Rows.Clear();
- selectLineIndex = -1;
- rectangleFsLines.Clear();
- }
- }
- /// <summary>
- /// 画布绘制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Panel_Paint(object sender, PaintEventArgs e)
- {
- if (this.documentWorkspace.CompositionSurface != null)
- {
- //
- // 以下是计算绘制图片的位置和大小并绘制图片
- //
- System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
- int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
- int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
- int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
- int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
- //
- // 以下是绘制网格、标注、测量、视场等开始
- //
- e.Graphics.TranslateTransform(x, y);
- e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
- Draw(e.Graphics);
- e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
- e.Graphics.TranslateTransform(-x, -y);
- }
- }
- private AdjustableArrowCap lineCap = new AdjustableArrowCap(6, 6, true);
- /// <summary>
- /// 绘制
- /// </summary>
- /// <param name="graphics"></param>
- private void Draw(Graphics graphics)
- {
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- Pen linePen = new Pen(this.panel1.BackColor,Convert.ToInt32(this.numericUpDown3.Value));
- Pen linePen1 = new Pen(this.panel1.BackColor, Convert.ToInt32(this.numericUpDown3.Value));
- linePen.CustomStartCap = lineCap;
- linePen.CustomEndCap = lineCap;
- int drawIndex = -1;
- foreach (var item in rectangleFs)
- {
- drawIndex++;
- if (selectLineIndex != -1 && drawIndex == this.selectLineIndex)
- {
- linePen.DashStyle = DashStyle.DashDot;
- }
- else
- linePen.DashStyle = DashStyle.Solid;
- graphics.DrawLine(linePen, new PointF(item.Key[0].X + 6, item.Key[0].Y + 6), new PointF(item.Key[1].X + 6, item.Key[1].Y + 6));
- PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6);
- PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6);
- double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(startPoint.X) + 6, Convert.ToInt32(startPoint.Y) + 6), new Point(Convert.ToInt32(endPoint.X) + 6, Convert.ToInt32(endPoint.Y) + 6), Convert.ToInt32(this.numericUpDown1.Value)) * unitLength;
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- if (item.Value == 0)
- {
- //
- // 绘制两侧竖线
- //
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- Point point3 = new Point();
- Point point4 = new Point();
- Point point5 = new Point();
- Point point6 = new Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- graphics.DrawLine(linePen1, point3, point4);
- graphics.DrawLine(linePen1, point5, point6);
- SizeF sizeF = graphics.MeasureString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
- PointF cen1 = new PointF((point3.X + point5.X) / 2, (point3.Y + point5.Y) / 2);
- PointF cen2 = new PointF((point4.X + point6.X) / 2, (point4.Y + point6.Y) / 2);
- PointF drawP1 = new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2);
- PointF drawP2 = new PointF(cen2.X - sizeF.Width / 2, cen2.Y - sizeF.Height / 2);
- PointF drawP3;
- if (angle < 90)
- drawP3 = drawP1;
- else
- drawP3 = drawP2;
- Matrix mtxSave = graphics.Transform;
- Matrix matrix = graphics.Transform;
- // 画布旋转
- if (angle < 90)
- {
- matrix.RotateAt((float)angle, new PointF(cen1.X, cen1.Y));
- graphics.Transform = matrix;
- }
- else
- {
- angle = BasicCalculationHelper.Angle(endPoint, startPoint, new PointF(endPoint.X, startPoint.Y));
- matrix.RotateAt((float)angle, new PointF(cen2.X, cen2.Y));
- graphics.Transform = matrix;
- }
- graphics.DrawString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), drawP3);
- //还原为原始旋转矩阵
- graphics.Transform = mtxSave;
- matrix.Dispose();
- }
- else if(item.Value == 1)
- {
- graphics.DrawLine(linePen1, new PointF(startPoint.X, startPoint.Y - Convert.ToInt32(this.numericUpDown2.Value / 2))
- , new PointF(startPoint.X, startPoint.Y + Convert.ToInt32(this.numericUpDown2.Value / 2)));
- graphics.DrawLine(linePen1, new PointF(endPoint.X, endPoint.Y - Convert.ToInt32(this.numericUpDown2.Value / 2))
- , new PointF(endPoint.X, endPoint.Y + Convert.ToInt32(this.numericUpDown2.Value / 2)));
- SizeF sizeF = graphics.MeasureString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
- PointF cen1 = new PointF((startPoint.X + endPoint.X) / 2, startPoint.Y - Convert.ToInt32(this.numericUpDown2.Value / 2));
- graphics.DrawString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2));
- }
- else if (item.Value == 2)
- {
- graphics.DrawLine(linePen1, new PointF(startPoint.X - Convert.ToInt32(this.numericUpDown2.Value / 2), startPoint.Y)
- , new PointF(startPoint.X + Convert.ToInt32(this.numericUpDown2.Value / 2), startPoint.Y));
- graphics.DrawLine(linePen1, new PointF(endPoint.X - Convert.ToInt32(this.numericUpDown2.Value / 2), endPoint.Y)
- , new PointF(endPoint.X + Convert.ToInt32(this.numericUpDown2.Value / 2), endPoint.Y));
- SizeF sizeF = graphics.MeasureString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
- PointF cen1 = new PointF(startPoint.X + Convert.ToInt32(this.numericUpDown2.Value / 2), (startPoint.Y + endPoint.Y) / 2);
- Matrix mtxSave = graphics.Transform;
- Matrix matrix = graphics.Transform;
- matrix.RotateAt((float)90, new PointF(cen1.X, cen1.Y));
- graphics.Transform = matrix;
- graphics.DrawString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2));
- //还原为原始旋转矩阵
- graphics.Transform = mtxSave;
- matrix.Dispose();
- }
- if (selectLineIndex != -1 && drawIndex == this.selectLineIndex)
- {
- graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[0]);
- graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[1]);
- }
- }
- System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
- Region myRegion;
- int selectIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- selectIndex++;
- myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- myRegion = new Region();
- myGraphicsPath.Reset();
- myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] });
- myRegion.MakeEmpty();
- myRegion.Union(myGraphicsPath);
- //graphics.FillRegion(new SolidBrush(Color.Black), myRegion);
- }
- linePen.Dispose();
- linePen1.Dispose();
- }
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- private void OnMouseDown(object sender, MouseEventArgs e)
- {
- if(e.Button == MouseButtons.Left)
- {
- // 换算后的点
- PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- selectLineIndex = -1;
- if (mouseStatus == 0)
- {
- canAdd = true;
- rectangleFsArr = new RectangleF[2];
- pointFsLine = new PointF[4];
- rectangleFsArr[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- Dictionary<RectangleF[], int> rectangleFs1 = new Dictionary<RectangleF[], int>();
- foreach (var item in rectangleFs)
- {
- rectangleFs1.Add(item.Key, item.Value);
- }
- rectangleFs = new Dictionary<RectangleF[], int>();
- rectangleFs = rectangleFs1;
- if (lineStyle == 0)
- rectangleFs.Add(rectangleFsArr, 0);
- else if (lineStyle == 1)
- rectangleFs.Add(rectangleFsArr, 1);
- else if (lineStyle == 2)
- rectangleFs.Add(rectangleFsArr, 2);
- if (lineStyle == 0)
- rectangleFsLines.Add(pointFsLine, 0);
- else if (lineStyle == 1)
- rectangleFsLines.Add(pointFsLine, 1);
- else if (lineStyle == 2)
- rectangleFsLines.Add(pointFsLine, 2);
- }
- if (mouseStatus == 2)
- {
- System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
- Region myRegion;
- int selectIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- selectIndex++;
- myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- myRegion = new Region();
- myGraphicsPath.Reset();
- myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] });
- myRegion.MakeEmpty();
- myRegion.Union(myGraphicsPath);
- //返回判断点是否在多边形里
- //RectangleF rectangleF = myRegion.GetBounds(rag)
- bool myPoint = myRegion.IsVisible(point1);
- if (myPoint)
- {
- selectLineIndex = selectIndex;
- break;
- }
- }
- if (selectLineIndex == -1)
- {
- selectIndex = -1;
- foreach (var item in rectangleFs)
- {
- selectIndex++;
- if (item.Key[0].Contains(point1))
- {
- selectLineIndex = selectIndex;
- break;
- }
- else if (item.Key[1].Contains(point1))
- {
- selectLineIndex = selectIndex;
- break;
- }
- }
- }
- //else
- // {
- // if(this.dataGridView1.Rows.Count > selectLineIndex)
- // this.dataGridView1.Rows[selectLineIndex].Selected = true;
- //}
- }
- if (mouseStatus == 2)
- {
- int indexRectangleFs = -1;
- foreach (var item in rectangleFs)
- {
- indexRectangleFs++;
- System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
- Region myRegion;
- int indexRectangleFsLines = -1;
- bool myPoint = false;
- foreach (var item1 in rectangleFsLines)
- {
- indexRectangleFsLines++;
- if (indexRectangleFs == indexRectangleFsLines)
- {
- myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- myRegion = new Region();
- myGraphicsPath.Reset();
- myGraphicsPath.AddPolygon(new PointF[] { item1.Key[0], item1.Key[1], item1.Key[2], item1.Key[3] });
- myRegion.MakeEmpty();
- myRegion.Union(myGraphicsPath);
- //返回判断点是否在多边形里
- myPoint = myRegion.IsVisible(point1);
- if (myPoint)
- {
- break;
- }
- }
- }
- if (item.Key[0].Contains(point1))
- {
- movePointStart = point1;
- movePointIndex = 0;
- canMove = true;
- }
- else if (item.Key[1].Contains(point1))
- {
- movePointStart = point1;
- movePointIndex = 1;
- canMove = true;
- }
- else if (myPoint)
- {
- movePointStart = point1;
- movePointIndex = 2;
- canMove = true;
- }
- }
- }
- }
- }
- PointF point1;
- /// <summary>
- /// 移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void onMouseMove(object sender, MouseEventArgs e)
- {
- // 换算后的点
- this.point1 = documentWorkspace.GetScalePoint(e.Location);
- // 全方位线
- if (lineStyle == 0)
- {
- if (mouseStatus == 0 && canAdd)
- {
- rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- PointF startPoint = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y + 6);
- PointF endPoint = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y + 6);
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- Point point3 = new Point();
- Point point4 = new Point();
- Point point5 = new Point();
- Point point6 = new Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- pointFsLine[0] = point3;
- pointFsLine[1] = point4;
- pointFsLine[2] = point6;
- pointFsLine[3] = point5;
- }
- }
- // 水平线
- else if (lineStyle == 1)
- {
- if (mouseStatus == 0 && canAdd)
- {
- rectangleFsArr[1] = new RectangleF(point1.X - 6, rectangleFsArr[0].Y, 12, 12);
- pointFsLine[0] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y + (float)(this.numericUpDown3.Value / 2) + 9);
- pointFsLine[1] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y - (float)(this.numericUpDown3.Value / 2) + 3);
- pointFsLine[3] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y + (float)(this.numericUpDown3.Value / 2) + 9);
- pointFsLine[2] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y - (float)(this.numericUpDown3.Value / 2) + 3);
- }
- }
- // 垂直线
- else if (lineStyle == 2)
- {
- if (mouseStatus == 0 && canAdd)
- {
- rectangleFsArr[1] = new RectangleF(rectangleFsArr[0].X, point1.Y - 6, 12, 12);
- pointFsLine[0] = new PointF(rectangleFsArr[0].X + (float)(this.numericUpDown3.Value / 2) + 9, rectangleFsArr[0].Y + 6);
- pointFsLine[1] = new PointF(rectangleFsArr[0].X - (float)(this.numericUpDown3.Value / 2) + 3, rectangleFsArr[0].Y + 6);
- pointFsLine[3] = new PointF(rectangleFsArr[1].X + (float)(this.numericUpDown3.Value / 2) + 9, rectangleFsArr[1].Y + 6);
- pointFsLine[2] = new PointF(rectangleFsArr[1].X - (float)(this.numericUpDown3.Value / 2) + 3, rectangleFsArr[1].Y + 6);
- }
- }
- if (this.mouseStatus == 2 && canMove)
- {
- if (this.selectLineIndex != -1)
- {
- int indexRectangleFs = -1;
- foreach (var item in rectangleFs)
- {
- indexRectangleFs++;
- if (selectLineIndex == indexRectangleFs)
- {
- // 全方位线
- if (item.Value == 0)
- {
- // 线条起始点移动
- if (movePointIndex == 0)
- {
- item.Key[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 1)
- {
- item.Key[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 2)
- {
- item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- movePointStart = point1;
- }
- PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6);
- PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6);
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- Point point3 = new Point();
- Point point4 = new Point();
- Point point5 = new Point();
- Point point6 = new Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- int indexRectangleFsLines = -1;
- foreach (var item1 in rectangleFsLines)
- {
- indexRectangleFsLines++;
- if (indexRectangleFsLines == indexRectangleFs)
- {
- item1.Key[0] = point3;
- item1.Key[1] = point4;
- item1.Key[2] = point6;
- item1.Key[3] = point5;
- }
- }
- }
- // 水平线
- else if (item.Value == 1)
- {
- // 线条起始点移动
- if (movePointIndex == 0)
- {
- item.Key[0] = new RectangleF(point1.X - 6, item.Key[1].Y, 12, 12);
- }
- else if (movePointIndex == 1)
- {
- item.Key[1] = new RectangleF(point1.X - 6, item.Key[0].Y, 12, 12);
- }
- else if (movePointIndex == 2)
- {
- item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- movePointStart = point1;
- }
- int selectIndex = -1;
- foreach (var item1 in rectangleFsLines)
- {
- selectIndex++;
- if (selectIndex == selectLineIndex)
- {
- item1.Key[0] = new PointF(item.Key[0].X + 6, item.Key[0].Y + (float)(this.numericUpDown3.Value / 2) + 9);
- item1.Key[1] = new PointF(item.Key[0].X + 6, item.Key[0].Y - (float)(this.numericUpDown3.Value / 2) + 3);
- item1.Key[3] = new PointF(item.Key[1].X + 6, item.Key[1].Y + (float)(this.numericUpDown3.Value / 2) + 9);
- item1.Key[2] = new PointF(item.Key[1].X + 6, item.Key[1].Y - (float)(this.numericUpDown3.Value / 2) + 3);
- }
- }
- }
- // 垂直线
- else if (item.Value == 2)
- {
- // 线条起始点移动
- if (movePointIndex == 0)
- {
- item.Key[0] = new RectangleF(item.Key[1].X, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 1)
- {
- item.Key[1] = new RectangleF(item.Key[0].X, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 2)
- {
- item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- movePointStart = point1;
- }
- int selectIndex = -1;
- foreach (var item1 in rectangleFsLines)
- {
- selectIndex++;
- if (selectIndex == selectLineIndex)
- {
- item1.Key[0] = new PointF(item.Key[0].X + (float)(this.numericUpDown3.Value / 2) + 9, item.Key[0].Y + 6);
- item1.Key[1] = new PointF(item.Key[0].X - (float)(this.numericUpDown3.Value / 2) + 3, item.Key[0].Y + 6);
- item1.Key[3] = new PointF(item.Key[1].X + (float)(this.numericUpDown3.Value / 2) + 9, item.Key[1].Y + 6);
- item1.Key[2] = new PointF(item.Key[1].X - (float)(this.numericUpDown3.Value / 2) + 3, item.Key[1].Y + 6);
- }
- }
- }
- }
- }
- }
- }
- this.documentWorkspace.Refresh();
- }
- private void MouseMoveRefRec()
- {
- foreach (var item in rectangleFsLines)
- {
- PointF startPoint = new PointF((item.Key[0].X + item.Key[1].X) / 2, (item.Key[0].Y + item.Key[1].Y) / 2);
- PointF endPoint = new PointF((item.Key[2].X + item.Key[3].X) / 2, (item.Key[2].Y + item.Key[3].Y) / 2);
- // 全方位线
- if (item.Value == 0)
- {
- if (item.Key.Length > 3)
- {
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- Point point3 = new Point();
- Point point4 = new Point();
- Point point5 = new Point();
- Point point6 = new Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- item.Key[0] = point3;
- item.Key[1] = point4;
- item.Key[2] = point6;
- item.Key[3] = point5;
- }
- }
- // 水平线
- else if (item.Value == 1)
- {
- if (item.Key.Length > 3)
- {
- item.Key[0] = new PointF(startPoint.X, startPoint.Y + (float)(this.numericUpDown3.Value / 2) + 3);
- item.Key[1] = new PointF(startPoint.X, startPoint.Y - (float)(this.numericUpDown3.Value / 2) - 3);
- item.Key[3] = new PointF(endPoint.X, endPoint.Y + (float)(this.numericUpDown3.Value / 2) + 3);
- item.Key[2] = new PointF(endPoint.X, endPoint.Y - (float)(this.numericUpDown3.Value / 2) - 3);
- }
- }
- // 垂直线
- else if (item.Value == 2)
- {
- if (item.Key.Length > 3)
- {
- item.Key[0] = new PointF(startPoint.X + (float)(this.numericUpDown3.Value / 2) + 3, startPoint.Y);
- item.Key[1] = new PointF(startPoint.X - (float)(this.numericUpDown3.Value / 2) - 3, startPoint.Y);
- item.Key[3] = new PointF(endPoint.X + (float)(this.numericUpDown3.Value / 2) + 3, endPoint.Y);
- item.Key[2] = new PointF(endPoint.X - (float)(this.numericUpDown3.Value / 2) - 3, endPoint.Y);
- }
- }
- }
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void OnMouseUp(object sender, MouseEventArgs e)
- {
- canAdd = false;
- canMove = false;
- movePointIndex = -1;
- RefrashData();
- if(mouseStatus == 2)
- SelectDataRow();
- }
- private void SelectDataRow()
- {
- if (this.dataGridView1.Rows.Count > selectLineIndex && selectLineIndex >= 0)
- this.dataGridView1.Rows[selectLineIndex].Selected = true;
- if (dataGridView1.SelectedRows.Count > 0)
- selectLineIndex = dataGridView1.SelectedRows[0].Index;
- }
- /// <summary>
- /// 添加测量线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- this.mouseStatus = 0;
- this.selectLineIndex = -1;
- }
- private void button3_LostFocus(object sender, EventArgs e)
- {
- this.mouseStatus = -1;
- }
- private void button5_LostFocus(object sender, EventArgs e)
- {
- this.mouseStatus = -1;
- }
- private void button6_LostFocus(object sender, EventArgs e)
- {
- this.mouseStatus = -1;
- }
- /// <summary>
- /// 删除测量线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- this.mouseStatus = 1;
- if (this.mouseStatus == 1)
- {
- if (selectLineIndex == -1)
- {
- MessageBox.Show("请先选择要删除的测量线!");
- return;
- }
- int deleteIndex = -1;
- foreach (var item in rectangleFs)
- {
- deleteIndex++;
- if (deleteIndex == selectLineIndex)
- {
- rectangleFs.Remove(item.Key);
- break;
- }
- }
- deleteIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- deleteIndex++;
- if (deleteIndex == selectLineIndex)
- {
- rectangleFsLines.Remove(item.Key);
- break;
- }
- }
- selectLineIndex--;
- if (selectLineIndex < -1)
- selectLineIndex = -1;
- if (rectangleFs.Count == 0)
- this.dataGridView1.Rows.Clear();
- RefrashData();
- if (mouseStatus == 2)
- SelectDataRow();
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 选择测量线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- this.mouseStatus = 2;
- this.selectLineIndex = -1;
- }
- /// <summary>
- /// 全方位线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- this.lineStyle = 0;
- this.mouseStatus = 0;
- this.button3.Focus();
- }
- /// <summary>
- /// 水平线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- this.lineStyle = 1;
- this.mouseStatus = 0;
- this.button3.Focus();
- }
- /// <summary>
- /// 垂直线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton3_CheckedChanged(object sender, EventArgs e)
- {
- this.lineStyle = 2;
- this.mouseStatus = 0;
- this.button3.Focus();
- }
- /// <summary>
- /// 线长
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 线宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- MouseMoveRefRec();
- }
- /// <summary>
- /// 颜色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel1_BackColorChanged(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// Ctrl键按下(平行线)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MetallographicMethodDialog_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Control)
- {
- this.radioButton2.Checked = true;
- }
- else if (e.Alt)
- {
- this.radioButton3.Checked = true;
- }
- else if (e.KeyData == Keys.Delete)
- {
- //if(this.mouseStatus == 1)
- //{
- if (selectLineIndex == -1)
- {
- MessageBox.Show("请先选择要删除的测量线!");
- return;
- }
- int deleteIndex = -1;
- foreach (var item in rectangleFs)
- {
- deleteIndex++;
- if (deleteIndex == selectLineIndex)
- {
- rectangleFs.Remove(item.Key);
- break;
- }
- }
- deleteIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- deleteIndex++;
- if (deleteIndex == selectLineIndex)
- {
- rectangleFsLines.Remove(item.Key);
- break;
- }
- }
- selectLineIndex--;
- if (selectLineIndex < -1)
- selectLineIndex = -1;
- if (rectangleFs.Count == 0)
- this.dataGridView1.Rows.Clear();
- RefrashData();
- if (mouseStatus == 2)
- SelectDataRow();
- this.documentWorkspace.Refresh();
- //}
- }
- }
- private void MetallographicMethodDialog_KeyUp(object sender, KeyEventArgs e)
- {
- if(e.KeyData == Keys.ControlKey || e.KeyData == Keys.Menu)
- {
- this.radioButton1.Checked = true;
- }
- }
- /// <summary>
- /// 小数改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- RefrashData();
- RefreshDataGridView4();
- RefreshResultStatistics();
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- return;
- }
- if (this.dataGridView1.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresultdata.text")+"!");
- return;
- }
- string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
- string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
- DataTable dataTable = new DataTable();
- bool replace = false;
- int add = 0;
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(tag))
- {
- add++;
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- this.listView2.Items.Remove(item);
- }
- break;
- }
- }
- if (replace || this.listView2.Items.Count == 0 || add == 0)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.SubItems[0].Text = imgName;
- listViewItem.Tag = "" + tag;
- if (this.listView2.Items.Count == 0)
- this.listView2.Items.Add(listViewItem);
- else
- this.listView2.Items.Insert(0, listViewItem);
- this.dataGridView4.Rows.Clear();
- for (int i = 0; i < this.dataTable.Rows.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = tag;
- foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = imgName;
- dgvr.Cells[1].Value = this.dataTable.Rows[i][0];
- dgvr.Cells[2].Value = Math.Round(Convert.ToDouble(this.dataTable.Rows[i][1]), Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView4.Rows.Add(dgvr);
- }
- dataTable.TableName = tag;
- foreach (System.Data.DataTable dataTable1 in dataTables)
- {
- if (dataTable1.TableName.Equals(dataTable.TableName))
- {
- dataTables.Remove(dataTable1);
- break;
- }
- }
- foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- {
- dataTable.Columns.Add(c.HeaderText);
- }
- for (int i = 0; i < this.dataTable.Rows.Count; i++)
- {
- DataRow dataRow = dataTable.NewRow();
- dataRow[0] = imgName;
- dataRow[1] = this.dataTable.Rows[i][0];
- dataRow[2] = this.dataTable.Rows[i][1];
- dataTable.Rows.Add(dataRow);
- }
- this.dataTables.Add(dataTable);
- if (this.allShow)
- AllShow();
- this.listView2.Items[0].Selected = true;
- if (this.documentWorkspace.PhaseModels[0].mat != null)
- {
- //保存处理后的图片
- double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- graphics.DrawImage(processedBit, new PointF(0, 0));
- Draw(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- bitDic[tag] = tempBit;
- else
- bitDic.Add(tag, tempBit);
- }
- //拼接中间数据
- List<List<string>> dataList = new List<List<string>>();
- List<string> columnName = new List<string>();
- columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
- columnName.Add(PdnResources.GetString("Menu.Linelength.text")+"(μm)");
- columnName.Add(PdnResources.GetString("Menu.Startingcoordinates.text"));
- columnName.Add(PdnResources.GetString("Menu.Endpointcoordinates.Text"));
- dataList.Add(columnName);
- int no = 0;
- foreach (var item in rectangleFs)
- {
- double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 10) * unitLength;
- no++;
- List<string> strList = new List<string>();
- strList.Add("" + no);
- strList.Add("" + length);
- strList.Add("(" + (Convert.ToInt32(item.Key[0].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[0].Y) + 6).ToString() + ")");
- strList.Add("(" + (Convert.ToInt32(item.Key[1].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[1].Y) + 6).ToString() + ")");
- dataList.Add(strList);
- }
- bool isExist = false;//是否已存在进行替换
- int modelIndex = -1;//要替换的下标
- for (int j = 0; j < tempDataModel.Count; j++)
- {
- if (tempDataModel[j].tagName.Equals(tag))
- {
- isExist = true;
- modelIndex = j;
- break;
- }
- }
- if (isExist && modelIndex > -1)
- tempDataModel[modelIndex].dataList = dataList;
- else
- {
- ExportProjectModel newModel = new ExportProjectModel();
- newModel.tagName = tag;
- newModel.picName = imgName;
- newModel.dataList = dataList;
- tempDataModel.Add(newModel);
- }
- }
- }
- /// <summary>
- /// 取消全部显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button16_Click(object sender, EventArgs e)
- {
- this.button11.Visible = true;
- this.button16.Visible = false;
- this.button11.Focus();
- this.allShow = false;
- List<System.Data.DataTable> dataTables1 = new List<System.Data.DataTable>();
- foreach (var dataTable in this.dataTables)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- if (item.Tag.Equals(dataTable.TableName))
- dataTables1.Add(dataTable);
- }
- }
- else
- {
- if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
- dataTables1.Add(dataTable);
- }
- }
- this.dataGridView4.Rows.Clear();
- foreach (System.Data.DataTable item in dataTables1)
- {
- if (dataTables.Count > 0)
- {
- for (int r = 0; r < item.Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = item.TableName;
- foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < item.Columns.Count; c++)
- {
- if (c == 2)
- dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(item.Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
- else
- dgvr.Cells[c].Value = item.Rows[r][c].ToString();
- }
- this.dataGridView4.Rows.Add(dgvr);
- }
- }
- }
- if(this.listView2.SelectedItems.Count == 0)
- {
- if (this.listView2.Items.Count > 0)
- this.listView2.Items[0].Selected = true;
- }
- RefreshResultStatistics();
- }
- /// <summary>
- /// 全部显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button11_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- this.button11.Visible = false;
- this.button16.Visible = true;
- this.button16.Focus();
- this.allShow = true;
- AllShow();
- RefreshResultStatistics();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- private void AllShow()
- {
- this.dataGridView4.Rows.Clear();
- for (int i = this.dataTables.Count - 1; i >= 0; i--)
- {
- for (int r = 0; r < this.dataTables[i].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = this.dataTables[i].TableName;
- foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
- {
- if (c == 2)
- dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
- else
- dgvr.Cells[c].Value = this.dataTables[i].Rows[r][c].ToString();
- }
- this.dataGridView4.Rows.Add(dgvr);
- }
- }
- }
- /// <summary>
- /// 切换分析结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView2_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- List<int> dataTableIndex = new List<int>();
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- if (this.dataTables[i].TableName.Equals(item.Tag))
- dataTableIndex.Add(i);
- }
- }
- if (this.dataTables.Count == 0)
- return;
- this.dataGridView4.Rows.Clear();
- foreach (int item in dataTableIndex)
- {
- if (this.dataTables[item].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[item].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = this.dataTables[item].TableName;
- foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[item].Columns.Count; c++)
- {
- if (c == 2)
- dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
- else
- dgvr.Cells[c].Value = this.dataTables[item].Rows[r][c].ToString();
- }
- this.dataGridView4.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- RefreshResultStatistics();
- }
- /// <summary>
- /// 刷新结果统计数据
- /// </summary>
- private void RefreshResultStatistics()
- {
- if(allShow)
- {
- this.dataGridView2.Rows.Clear();
- // 渗氮层总深度
- double totalDepth = 0;
- foreach (ListViewItem listViewItem in this.listView2.Items)
- {
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- if (listViewItem.Tag.Equals(dataTables[i].TableName))
- {
- for (int r = 0; r < dataTables[i].Rows.Count; r++)
- {
- totalDepth += Convert.ToDouble(dataTables[i].Rows[r][2]);
- }
- }
- }
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = this.listView2.Items.Count;
- dgvr.Cells[1].Value = Math.Round(totalDepth, Convert.ToInt32(this.numericUpDown1.Value));
- dgvr.Cells[2].Value = Math.Round(totalDepth / this.listView2.Items.Count, Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView2.Rows.Add(dgvr);
- }
- else
- {
- if (this.listView2.SelectedItems.Count == 0)
- return;
- this.dataGridView2.Rows.Clear();
- // 渗氮层总深度
- double totalDepth = 0;
- foreach (ListViewItem listViewItem in this.listView2.SelectedItems)
- {
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- if (listViewItem.Tag.Equals(dataTables[i].TableName))
- {
- for (int r = 0; r < dataTables[i].Rows.Count; r++)
- {
- totalDepth += Convert.ToDouble(dataTables[i].Rows[r][2]);
- }
- }
- }
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = this.listView2.SelectedItems.Count;
- dgvr.Cells[1].Value = Math.Round(totalDepth, Convert.ToInt32(this.numericUpDown1.Value));
- dgvr.Cells[2].Value = Math.Round(totalDepth / this.listView2.SelectedItems.Count, Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- /// <summary>
- /// 未选择分析结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count == 0)
- {
- this.dataGridView2.Rows.Clear();
- this.dataGridView4.Rows.Clear();
- }
- }
- }
- /// <summary>
- /// 分析结果删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button12_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- List<string> detaleName = new List<string>();
- int selectIndex = this.listView2.SelectedItems[0].Index;
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- detaleName.Add(item.Tag.ToString());
- this.listView2.Items.Remove(item);
- }
- foreach (string item in detaleName)
- {
- foreach (var dataTable in this.dataTables)
- {
- if (dataTable.TableName.Equals(item))
- {
- this.dataTables.Remove(dataTable);
- break;
- }
- }
- if (bitDic.ContainsKey(item))
- bitDic.Remove(item);
- }
- if (this.listView2.Items.Count == 0)
- {
- this.dataGridView2.Rows.Clear();
- this.dataGridView4.Rows.Clear();
- }
- else
- {
- if (selectIndex == 0)
- this.listView2.Items[0].Selected = true;
- else
- this.listView2.Items[selectIndex - 1].Selected = true;
- RefreshDataGridView4();
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- /// <summary>
- /// 刷新分析结果数据
- /// </summary>
- private void RefreshDataGridView4()
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- List<int> dataTableIndex = new List<int>();
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[0].Tag))
- dataTableIndex.Add(i);
- }
- }
- if (this.dataTables.Count == 0)
- return;
- this.dataGridView4.Rows.Clear();
- foreach (int item in dataTableIndex)
- {
- if (this.dataTables[item].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[item].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = this.dataTables[item].TableName;
- foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[item].Columns.Count; c++)
- {
- if (c == 2)
- dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
- else
- dgvr.Cells[c].Value = this.dataTables[item].Rows[r][c].ToString();
- }
- this.dataGridView4.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- else
- {
- this.dataGridView4.Rows.Clear();
- DataTable dataTable = new DataTable();
- for (int i = this.dataTables.Count - 1; i >= 0; i--)
- {
- dataTable = this.dataTables[i];
- for (int r = 0; r < dataTable.Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = dataTable.TableName;
- foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable.Columns.Count; c++)
- {
- if (c == 2)
- dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(dataTable.Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
- else
- dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
- }
- this.dataGridView4.Rows.Add(dgvr);
- }
- }
- }
- }
- /// <summary>
- /// 生成报告
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button13_Click(object sender, EventArgs e)
- {
- if (this.checkBox2.Checked)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.NitridingLayerGBT11354");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- for (int i = 0; i < this.dataGridView4.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView4.Columns[0].HeaderText);
- content1.Add(this.dataGridView4.Columns[1].HeaderText);
- content1.Add(this.dataGridView4.Columns[2].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString());
- analysisContent.Add(content1);
- }
- List<string> content2 = new List<string>();
- analysisContent.Add(content2);
- for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView2.Columns[0].HeaderText);
- content1.Add(this.dataGridView2.Columns[1].HeaderText);
- content1.Add(this.dataGridView2.Columns[2].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView2.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView2.Rows[i].Cells[2].Value.ToString());
- analysisContent.Add(content1);
- }
- bitList = new List<Bitmap>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- bitList.Add(kv.Value[0]);
- bitList.Add(kv.Value[1]);
- }
- }
- else
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- /// <summary>
- /// 导出结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button14_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- System.Data.DataSet ds = new DataSet();
- DataTable table1 = new DataTable();
- table1.TableName = PdnResources.GetString("Menu.breakdown.text");
- foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- {
- table1.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView4.Rows.Count; r++)
- {
- DataRow dataRow = table1.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Columns[c].HeaderText;
- }
- table1.Rows.Add(dataRow);
- }
- dataRow = table1.NewRow();
- for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Rows[r].Cells[c].Value;
- }
- table1.Rows.Add(dataRow);
- }
- DataTable table2 = new DataTable();
- table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- table2.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- DataRow dataRow = table2.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Columns[c].HeaderText;
- }
- table2.Rows.Add(dataRow);
- }
- dataRow = table2.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- table2.Rows.Add(dataRow);
- }
- if (table1.Rows.Count > 0) ds.Tables.Add(table1);
- if (table2.Rows.Count > 0) ds.Tables.Add(table2);
- if (ds.Tables.Count > 0)
- DataToExcle(ds);
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
- }
- }
- /// <summary>
- /// 导出多 Sheet 报表
- /// </summary>
- /// <param name="ds">要导出的数据</param>
- public void DataToExcle(System.Data.DataSet ds)
- {
- try
- {
- if (ds.Tables == null || ds.Tables.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text")+"!");
- return;
- }
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.DefaultExt = "xlsx";
- saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
- saveFileDialog.FileName = PdnResources.GetString("Menu.yermetallographicmethod.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
- saveFileDialog.RestoreDirectory = true;
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- List<System.Data.DataTable> list = new List<System.Data.DataTable>();
- foreach (System.Data.DataTable itemTable in ds.Tables)
- list.Add(itemTable);
- this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, true, false, true);
- }
- }
- catch (Exception e)
- {
- throw e;
- }
- }
- /// <summary>
- /// 设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.NitridingLayerGBT11354");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- /// <summary>
- /// 导出项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.analyzeSettingModel == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Settheexporteitemfirst.Text"));
- return;
- }
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.DeterminationOfNitridingDepth.Text", this.analyzeSettingModel.savePath);
- if (item != null)
- {
- //向文件夹内保存图片和报告
- if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- //分析结果
- List<List<string>> analysisContent = new List<List<string>>();
- for (int i = 0; i < this.dataGridView4.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView4.Columns[0].HeaderText);
- content1.Add(this.dataGridView4.Columns[1].HeaderText);
- content1.Add(this.dataGridView4.Columns[2].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString());
- analysisContent.Add(content1);
- }
- List<string> content2 = new List<string>();
- analysisContent.Add(content2);
- for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView2.Columns[0].HeaderText);
- content1.Add(this.dataGridView2.Columns[1].HeaderText);
- content1.Add(this.dataGridView2.Columns[2].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView2.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView2.Rows[i].Cells[2].Value.ToString());
- analysisContent.Add(content1);
- }
- bitList = new List<Bitmap>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- bitList.Add(kv.Value[0]);
- bitList.Add(kv.Value[1]);
- }
- }
- else
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- foreach (ListViewItem itemL2 in this.listView2.SelectedItems)
- {
- if (bitDic.ContainsKey(itemL2.Tag.ToString()))
- {
- bitList.Add(bitDic[itemL2.Tag.ToString()][0]);
- bitList.Add(bitDic[itemL2.Tag.ToString()][1]);
- }
- }
- }
- }
- //中间数据
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- foreach (ListViewItem rowItem in this.listView2.SelectedItems)
- {
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals(rowItem.Tag))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code);
- }
- }
- else
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code);
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- return;
- }
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
- }
- }
- catch (Exception)
- {
- }
- }
- private void dataGridView1_SelectionChanged(object sender, EventArgs e)
- {
- //if (!canChange)
- //{
- // SelectDataRow();
- //}
- }
- private void numericUpDown4_ValueChanged(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- #region 参数保存及提取
- /// <summary>
- /// 保存参数的key,value和type
- /// </summary>
- /// <param name="param_key"></param>
- /// <param name="param_value"></param>
- /// <param name="param_type"></param>
- private void saveParamValue(string param_key, string param_value, int param_type)
- {
- bool foundItem = false;
- foreach (var item in this.analysisModel.ListParam)
- {
- if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
- {
- item.param_value = param_value;
- item.setValue();
- foundItem = true;
- break;
- }
- }
- if (!foundItem)
- {
- GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
- analysisItem.menuId = this.menuId;
- analysisItem.param_key = param_key;
- analysisItem.param_type = param_type;
- analysisItem.param_value = param_value;
- analysisItem.setValue();
- this.analysisModel.ListParam.Add(analysisItem);
- }
- }
- /// <summary>
- /// 保存界面中的参数到model
- /// </summary>
- private void saveDialogParamValues()
- {
- saveParamValue(ParamKey_Report, checkBox2.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置
- saveParamValue(ParamKey_Whole, radioButton1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//全方位线
- saveParamValue(ParamKey_Waterline, radioButton2.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//水平线
- saveParamValue(ParamKey_Vertical, radioButton3.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//垂直线
- saveParamValue(ParamKey_LineLength, numericUpDown2 != null ? numericUpDown2.Value.ToString() : "50", (int)Base.Dtryt.Decimal);//线长
- saveParamValue(ParamKey_LineWidth, numericUpDown3 != null ? numericUpDown3.Value.ToString() : "5", (int)Base.Dtryt.Decimal);//线宽
- saveParamValue(ParamKey_LineColour, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//线颜色
- saveParamValue(ParamKey_FontSize, numericUpDown4 != null ? numericUpDown4.Value.ToString() : "20", (int)Base.Dtryt.Decimal);//字号
- saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "2", (int)Base.Dtryt.Decimal);//保留小数位数
- }
- /// <summary>
- /// 获取保存的参数
- /// </summary>
- private void GetListParamModel()
- {
- if (this.analysisModel != null)
- {
- for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
- {
- switch (this.analysisModel.ListParam[i].param_key)
- {
- case ParamKey_Report:
- checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_Whole:
- radioButton1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_Waterline:
- radioButton2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_Vertical:
- radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_LineLength:
- numericUpDown2.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
- break;
- case ParamKey_LineWidth:
- numericUpDown3.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
- break;
- case ParamKey_LineColour:
- panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
- break;
- case ParamKey_FontSize:
- numericUpDown4.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
- break;
- case ParamKey_DecimalPlace:
- numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
- break;
- }
- }
- }
- }
- #endregion
- #region [脚本相关]
- private void getValue(string key, object value)
- {
- switch (key)
- {
- case "parameter1":
- var val = Convert.ToInt32(value);
- switch (val) {
- case 1:
- radioButton1.Checked = true;
- break;
- case 2:
- radioButton2.Checked = true;
- break;
- case 3:
- radioButton3.Checked = true;
- break;
- }
- break;
- case "parameter2":
- numericUpDown2.Value = Convert.ToDecimal(value);
- break;
- case "parameter3":
- numericUpDown3.Value = Convert.ToDecimal(value);
- break;
- case "parameter4":
- numericUpDown4.Value = Convert.ToDecimal(value);
- break;
- case "parameter5":
- panel1.BackColor = Color.FromArgb((int)value);
- break;
- case "OpenWhileExportReport":
- checkBox2.Checked = Convert.ToBoolean(value);
- break;
- case "CalculatorDecimalDigits":
- numericUpDown1.Value = Convert.ToDecimal(value);
- break;
- }
- }
- #endregion
- #region [脚本录制]
- private void getScriptRecording()
- {
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- List<Args> args = param.Lists;
- foreach (var item in args)
- {
- item.value = setScriptRecording(item.key);
- }
- //找出二值相关参数 进行赋值
- List<Args> isNullList = args.Where(m => m.value == null).ToList();
- foreach (var item in isNullList)
- {
- item.value = binaryClass.setScriptRecording(item.key);
- }
- appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
- }
- private object setScriptRecording(string key)
- {
- object value = null;
- switch (key)
- {
- case "parameter1":
- if (radioButton1.Checked)
- {
- value = 1;
- }
- else if (radioButton2.Checked)
- {
- value = 2;
- }
- else if (radioButton3.Checked) {
- value = 3;
- }
- break;
- case "parameter2":
- value = numericUpDown2.Value;
- break;
- case "parameter3":
- value = numericUpDown3.Value;
- break;
- case "parameter4":
- value = numericUpDown4.Value;
- break;
- case "parameter5":
- value = panel1.BackColor.ToArgb();
- break;
- case "OpenWhileExportReport":
- value = checkBox2.Checked;
- break;
- case "CalculatorDecimalDigits":
- value = numericUpDown1.Value;
- break;
- case "ExportResults":
- value = false;
- break;
- case "ExportReports":
- value = false;
- break;
- case "ExportProjects":
- value = false;
- break;
- }
- return value;
- }
- #endregion
- }
- }
|