MeasureListDialog.cs 190 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691
  1. using PaintDotNet.Annotation;
  2. using PaintDotNet.Annotation.Enum;
  3. using PaintDotNet.Annotation.Measure;
  4. using PaintDotNet.Annotation.relationModel;
  5. using PaintDotNet.Base.SettingModel;
  6. using PaintDotNet.Base.CommTool;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text.RegularExpressions;
  14. using System.Windows.Forms;
  15. using Microsoft.Office.Interop.Excel;
  16. using Button = System.Windows.Forms.Button;
  17. using Label = System.Windows.Forms.Label;
  18. using DataTable = System.Data.DataTable;
  19. using Metis.Measuring;
  20. using Metis.ParameterSet;
  21. using PaintDotNet.Preview2;
  22. using PaintDotNet.Menus;
  23. namespace PaintDotNet.Measuring
  24. {
  25. /// <summary>
  26. /// 测量列表
  27. /// </summary>
  28. internal class MeasureListDialog : FloatingToolForm
  29. {
  30. #region 控件
  31. private TabControl tabControl1;
  32. private TabPage tabPage1;
  33. private TabPage tabPage2;
  34. private Panel panel1;
  35. private Button button1;
  36. private Button button2;
  37. private Button button3;
  38. private Button button4;
  39. private Button button5;
  40. private Button button6;
  41. private ListView listView1;
  42. private ListView listView2;
  43. public NumericUpDown numericUpDown1;
  44. private Label label2;
  45. private ComboBox comboBox2;
  46. private ComboBox comboBox4;
  47. private ComboBox comboBox3;
  48. private Panel panel2;
  49. private ComboBox comboBox5;
  50. private ToolTip toolTip1;
  51. #endregion
  52. /// <summary>
  53. /// 主控件
  54. /// </summary>
  55. private AppWorkspace appWorkspace;
  56. public Preview2Dialog _p2Form => Preview2Dialog.Instance;
  57. /// <summary>
  58. /// 关系数据
  59. /// </summary>
  60. private static List<MeasureRelationModel> list;
  61. private MeasureRelationModel model;
  62. private Dictionary<Enum, string> valuePairs;
  63. /// <summary>
  64. /// 设置画面属性(绘制属性)
  65. /// </summary>
  66. public static TreeView drawNodes;
  67. /// <summary>
  68. /// 设置画面属性(数据属性)
  69. /// </summary>
  70. public static TreeView dataNodes;
  71. /// <summary>
  72. /// 设置画面属性(绘制元素属性)
  73. /// </summary>
  74. public static TreeView allDrawNodes;
  75. private Button button7;
  76. /// <summary>
  77. /// 设置画面属性(数据元素属性)
  78. /// </summary>
  79. public static TreeView allDataNodes;
  80. private MeasureModel measureModel = new MeasureModel();
  81. /// <param name="appWorkspace"></param>
  82. public MeasureListDialog(AppWorkspace appWorkspace)
  83. {
  84. if (list == null)
  85. {
  86. list = InvariantData.GetMeasureRelations();
  87. list.RemoveAt(list.Count - 1);
  88. }
  89. this.appWorkspace = appWorkspace;
  90. InitializeComponent();
  91. InitializeLanguageText();
  92. InitializeButtonBackgroudImage();
  93. //InitializeUnitComboBox();
  94. InitializeClassComboBox();
  95. InitializeItemizedComboBox();
  96. InitializeItemizedHeader();
  97. InitializeTotalData();
  98. GetAttributeFromConfigurationFile();
  99. appWorkspace.ActiveDocumentWorkspaceChanged += new EventHandler(RefreshListView);//切换窗口
  100. appWorkspace.ActiveDocumentWorkspaceChanged += new EventHandler(SetDrawNodes);//切换窗口
  101. this.toolTip1 = new ToolTip();
  102. this.toolTip1.SetToolTip(this.button1, PdnResources.GetString("Menu.Setting.Text"));
  103. this.toolTip1.SetToolTip(this.button2, PdnResources.GetString("Menu.Exporttotemplate.Text"));
  104. this.toolTip1.SetToolTip(this.button3, PdnResources.GetString("Menu.Statistics.Text"));
  105. this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Edit.Delete.Text"));
  106. this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Empty.text"));
  107. this.toolTip1.SetToolTip(this.button6, PdnResources.GetString("Menu.Exporttoexcel.Text"));
  108. this.toolTip1.SetToolTip(this.button7, PdnResources.GetString("Menu.Exportall.text"));
  109. this.toolTip1.ShowAlways = true;
  110. getLastData();
  111. }
  112. private DocumentView _document => _p2Form == null ? appWorkspace.ActiveDocumentWorkspace : (DocumentView)_p2Form._document;
  113. private void InitializeButtonBackgroudImage()
  114. {
  115. this.button7.FlatStyle = FlatStyle.Flat;
  116. this.button7.FlatAppearance.BorderSize = 0;
  117. this.button7.BackgroundImageLayout = ImageLayout.Center;
  118. this.button7.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListALLIcon.png").Reference;
  119. this.button1.FlatStyle = FlatStyle.Flat;
  120. this.button1.FlatAppearance.BorderSize = 0;
  121. this.button1.BackgroundImageLayout = ImageLayout.Center;
  122. this.button1.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListSettingIcon.png").Reference;
  123. this.button2.FlatStyle = FlatStyle.Flat;
  124. this.button2.FlatAppearance.BorderSize = 0;
  125. this.button2.BackgroundImageLayout = ImageLayout.Center;
  126. this.button2.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListTemplateIcon.png").Reference;
  127. this.button3.FlatStyle = FlatStyle.Flat;
  128. this.button3.FlatAppearance.BorderSize = 0;
  129. this.button3.BackgroundImageLayout = ImageLayout.Center;
  130. this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListStatisticsIcon.png").Reference;
  131. this.button4.FlatStyle = FlatStyle.Flat;
  132. this.button4.FlatAppearance.BorderSize = 0;
  133. this.button4.BackgroundImageLayout = ImageLayout.Center;
  134. this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListChoiseIcon.png").Reference;
  135. this.button5.FlatStyle = FlatStyle.Flat;
  136. this.button5.FlatAppearance.BorderSize = 0;
  137. this.button5.BackgroundImageLayout = ImageLayout.Center;
  138. this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListClearIcon.png").Reference;
  139. this.button6.FlatStyle = FlatStyle.Flat;
  140. this.button6.FlatAppearance.BorderSize = 0;
  141. this.button6.BackgroundImageLayout = ImageLayout.Center;
  142. this.button6.BackgroundImage = PdnResources.GetImageResource("Icons.MenuMeasureListExportIcon.png").Reference;
  143. }
  144. /// <summary>
  145. /// 刷新列表数据
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. public void RefreshListView(object sender, EventArgs e)
  150. {
  151. this.InitializeItemizedComboBox();
  152. this.listView1.Items.Clear();
  153. this.InitializeItemizedHeader();
  154. this.InitializeItemizedData();
  155. this.listView2.Clear();
  156. this.InitializeTotalData();
  157. this.InitialMasterDataSheetData();
  158. //if (_document != null)
  159. //{
  160. //_document.UpdateMeasureUnit((MeasurementUnit)(this.comboBox1.SelectedIndex + 1));
  161. //}
  162. if (_p2Form != null)
  163. {
  164. }
  165. else
  166. if (_document != null
  167. && _document.GraphicsList != null
  168. && _document.GraphicsList.Count > 0)
  169. {
  170. int count = _document.GraphicsList.Count;
  171. for (int i = 0; i < count; i++)
  172. {
  173. if (_document.GraphicsList[i].objectType == DrawClass.Measure)
  174. {
  175. DrawObject dd = (DrawObject)_document.GraphicsList[i];
  176. if (dd != null)
  177. {
  178. if (dd.Selected)
  179. {
  180. this.comboBox5.SelectedValue = dd.drawToolType;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. this.listView1.SelectedIndexChanged -= new System.EventHandler(this.ListView1_SelectedIndexChanged);
  187. if (listView1.Items.Count > 0)
  188. {
  189. this.listView1.SelectedItems.Clear();
  190. for (int k = 0; k < this.listView1.Items.Count; k++)
  191. {
  192. DrawObject dd = (DrawObject)this.listView1.Items[k].Tag;
  193. if (dd != null)
  194. {
  195. if (dd.Selected)
  196. {
  197. this.listView1.Items[k].Selected = true;
  198. }
  199. }
  200. }
  201. }
  202. if (listView2.Items.Count > 1)
  203. {
  204. this.listView2.SelectedItems.Clear();
  205. for (int i = 0; i < this.listView2.Items.Count; i++)
  206. {
  207. DrawObject dd = (DrawObject)this.listView2.Items[i].Tag;
  208. if (dd != null)
  209. {
  210. if (dd.Selected)
  211. {
  212. this.listView2.Items[i].Selected = true;
  213. }
  214. }
  215. }
  216. }
  217. this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListView1_SelectedIndexChanged);
  218. }
  219. /// <summary>
  220. /// 设置绘制属性
  221. /// </summary>
  222. public void SetDrawNodes(object sender, EventArgs e)
  223. {
  224. if (drawNodes != null && _document != null)
  225. {
  226. this.SetDrawNodes(drawNodes);
  227. }
  228. }
  229. private void SetDrawNodes(TreeView drawTreeView)
  230. {
  231. for (int i = 0; i < _document.GraphicsList.Count; i++)
  232. {
  233. if (_document.GraphicsList[i].objectType == DrawClass.Measure)
  234. {
  235. int count1 = drawTreeView.Nodes.Count;
  236. ((MeasureDrawObject)(_document.GraphicsList[i])).drawingProperties.Clear();
  237. ((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Clear();
  238. for (int k = 0; k < count1; k++)
  239. {
  240. int count2 = drawTreeView.Nodes[k].Nodes.Count;
  241. for (int j = 0; j < count2; j++)
  242. {
  243. if (_document.GraphicsList[i].drawToolType == (DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name))
  244. {
  245. bool drawb = false;
  246. if (drawTreeView.Nodes[k].Nodes[j].Nodes.Count == 0)
  247. {
  248. ((MeasureDrawObject)(_document.GraphicsList[i])).drawingProperties.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), new string[] { "nothing" });
  249. if (_document.oldDrawTreeView != null)
  250. {
  251. if (_document.oldDrawTreeView.Nodes[k].Nodes[j].Nodes.Count != 0)
  252. ((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
  253. }
  254. else
  255. {
  256. ((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
  257. }
  258. }
  259. else
  260. {
  261. int a = 0;
  262. string[] arr = new string[drawTreeView.Nodes[k].Nodes[j].Nodes.Count];
  263. foreach (TreeNode node2 in drawTreeView.Nodes[k].Nodes[j].Nodes)
  264. {
  265. arr[a] = node2.Name;
  266. a++;
  267. }
  268. ((MeasureDrawObject)(_document.GraphicsList[i])).drawingProperties.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), arr);
  269. if (_document.oldDrawTreeView != null)
  270. {
  271. if (drawTreeView.Nodes[k].Nodes[j].Nodes.Count != _document.oldDrawTreeView.Nodes[k].Nodes[j].Nodes.Count)
  272. {
  273. ((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
  274. }
  275. else
  276. {
  277. foreach (TreeNode oldNode in _document.oldDrawTreeView.Nodes[k].Nodes[j].Nodes)
  278. {
  279. if (!arr.Contains(oldNode.Name))
  280. {
  281. drawb = true;
  282. }
  283. }
  284. if (drawb)
  285. ((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), drawb);
  286. }
  287. }
  288. else
  289. {
  290. ((MeasureDrawObject)(_document.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true);
  291. }
  292. }
  293. this.Refresh();
  294. }
  295. }
  296. }
  297. }
  298. }
  299. _document.oldDrawTreeView = drawTreeView;
  300. }
  301. /// <summary>
  302. /// 从配置文件中读取设置信息
  303. /// </summary>
  304. private void GetAttributeFromConfigurationFile()
  305. {
  306. MeasureListSetModel measureListSetModel = XmlSerializeHelper.DESerializer<MeasureListSetModel>(FileOperationHelper.ReadStringFromFile(System.Windows.Forms.Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\MeasureListSetModel.xml", FileMode.Open));
  307. drawNodes = new TreeView();
  308. dataNodes = new TreeView();
  309. allDrawNodes = new TreeView();
  310. allDataNodes = new TreeView();
  311. if (measureListSetModel != null && measureListSetModel.AttributeMapDrawNodes != null)
  312. {
  313. for (int i = 0; i < measureListSetModel.AttributeMapDrawNodes.Count; i++)
  314. {
  315. TreeNode firstNode = new TreeNode();
  316. firstNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Name;
  317. for (int j = 0; j < measureListSetModel.AttributeMapDrawNodes[i].Attribute.Count; j++)
  318. {
  319. TreeNode scondNode = new TreeNode();
  320. scondNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Text;
  321. scondNode.Name = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Name;
  322. for (int k = 0; k < measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute.Count; k++)
  323. {
  324. if (measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute.Count > 0)
  325. {
  326. TreeNode thirdNode = new TreeNode();
  327. thirdNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute[k].Text;
  328. thirdNode.Name = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute[k].Name;
  329. scondNode.Nodes.Add(thirdNode);
  330. }
  331. }
  332. firstNode.Nodes.Add(scondNode);
  333. }
  334. drawNodes.Nodes.Add(firstNode);
  335. }
  336. }
  337. if (measureListSetModel != null && measureListSetModel.AttributeMapDataNodes != null)
  338. {
  339. for (int i = 0; i < measureListSetModel.AttributeMapDataNodes.Count; i++)
  340. {
  341. TreeNode firstNode = new TreeNode();
  342. firstNode.Text = measureListSetModel.AttributeMapDataNodes[i].Name;
  343. for (int j = 0; j < measureListSetModel.AttributeMapDataNodes[i].Attribute.Count; j++)
  344. {
  345. TreeNode scondNode = new TreeNode();
  346. scondNode.Text = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Text;
  347. scondNode.Name = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Name;
  348. for (int k = 0; k < measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute.Count; k++)
  349. {
  350. if (measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute.Count > 0)
  351. {
  352. TreeNode thirdNode = new TreeNode();
  353. thirdNode.Text = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute[k].Text;
  354. thirdNode.Name = measureListSetModel.AttributeMapDataNodes[i].Attribute[j].Attribute[k].Name;
  355. scondNode.Nodes.Add(thirdNode);
  356. }
  357. }
  358. firstNode.Nodes.Add(scondNode);
  359. }
  360. dataNodes.Nodes.Add(firstNode);
  361. }
  362. }
  363. if (measureListSetModel != null && measureListSetModel.AttributeMapAllDrawNodes != null)
  364. {
  365. for (int i = 0; i < measureListSetModel.AttributeMapAllDrawNodes.Count; i++)
  366. {
  367. TreeNode firstNode = new TreeNode();
  368. firstNode.Text = measureListSetModel.AttributeMapAllDrawNodes[i].Name;
  369. for (int j = 0; j < measureListSetModel.AttributeMapAllDrawNodes[i].Attribute.Count; j++)
  370. {
  371. TreeNode scondNode = new TreeNode();
  372. scondNode.Text = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Text;
  373. scondNode.Name = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Name;
  374. for (int k = 0; k < measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute.Count; k++)
  375. {
  376. if (measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute.Count > 0)
  377. {
  378. TreeNode thirdNode = new TreeNode();
  379. thirdNode.Text = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute[k].Text;
  380. thirdNode.Name = measureListSetModel.AttributeMapAllDrawNodes[i].Attribute[j].Attribute[k].Name;
  381. scondNode.Nodes.Add(thirdNode);
  382. }
  383. }
  384. firstNode.Nodes.Add(scondNode);
  385. }
  386. allDrawNodes.Nodes.Add(firstNode);
  387. }
  388. }
  389. if (measureListSetModel != null && measureListSetModel.AttributeMapAllDataNodes != null)
  390. {
  391. for (int i = 0; i < measureListSetModel.AttributeMapAllDataNodes.Count; i++)
  392. {
  393. TreeNode firstNode = new TreeNode();
  394. firstNode.Text = measureListSetModel.AttributeMapAllDataNodes[i].Name;
  395. for (int j = 0; j < measureListSetModel.AttributeMapAllDataNodes[i].Attribute.Count; j++)
  396. {
  397. TreeNode scondNode = new TreeNode();
  398. scondNode.Text = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Text;
  399. scondNode.Name = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Name;
  400. for (int k = 0; k < measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute.Count; k++)
  401. {
  402. if (measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute.Count > 0)
  403. {
  404. TreeNode thirdNode = new TreeNode();
  405. thirdNode.Text = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute[k].Text;
  406. thirdNode.Name = measureListSetModel.AttributeMapAllDataNodes[i].Attribute[j].Attribute[k].Name;
  407. scondNode.Nodes.Add(thirdNode);
  408. }
  409. }
  410. firstNode.Nodes.Add(scondNode);
  411. }
  412. allDataNodes.Nodes.Add(firstNode);
  413. }
  414. }
  415. }
  416. /// <summary>
  417. /// 初始化分项数据下拉
  418. /// </summary>
  419. private void InitializeItemizedComboBox()
  420. {
  421. valuePairs = new Dictionary<Enum, string>();
  422. if (_document != null
  423. && _document.GraphicsList != null
  424. && _document.GraphicsList.Count > 0)
  425. {
  426. int count = _document.GraphicsList.Count;
  427. for (int i = 0; i < count; i++)
  428. {
  429. if (_document.GraphicsList[i].objectType == DrawClass.Measure)
  430. {
  431. if (!valuePairs.ContainsKey(_document.GraphicsList[i].drawToolType))
  432. {
  433. valuePairs.Add(_document.GraphicsList[i].drawToolType,
  434. PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  435. }
  436. }
  437. }
  438. if (valuePairs.Count != 0)
  439. {
  440. this.comboBox5.DataSource = new BindingSource(valuePairs, null);
  441. this.comboBox5.DisplayMember = "Value";
  442. this.comboBox5.ValueMember = "Key";
  443. }
  444. }
  445. else
  446. {
  447. this.comboBox5.DataSource = null;
  448. }
  449. }
  450. /// <summary>
  451. /// 初始化分项数据的头
  452. /// </summary>
  453. private void InitializeItemizedHeader()
  454. {
  455. if (_document != null
  456. && _document.GraphicsList != null
  457. && _document.GraphicsList.Count > 0)
  458. {
  459. if (this.comboBox5.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.comboBox5.Text))
  460. {
  461. if (valuePairs.Count == 0)
  462. return;
  463. DrawToolType type = (DrawToolType)valuePairs.ElementAt(this.comboBox5.SelectedIndex).Key;
  464. //初始化头
  465. this.listView1.Clear();
  466. this.listView1.View = View.Details;
  467. ColumnHeader header0 = new ColumnHeader();
  468. header0.Text = "";
  469. header0.Width = 0;
  470. this.listView1.Columns.Add(header0);
  471. ColumnHeader header = new ColumnHeader();
  472. header.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text");
  473. header.Width = 40;
  474. this.listView1.Columns.Add(header);
  475. if (dataNodes != null)
  476. {
  477. int count3 = dataNodes.Nodes.Count;
  478. for (int i = 0; i < count3; i++)
  479. {
  480. int count4 = dataNodes.Nodes[i].Nodes.Count;
  481. for (int j = 0; j < count4; j++)
  482. {
  483. if (this.comboBox5.Text == dataNodes.Nodes[i].Nodes[j].Text)
  484. {
  485. foreach (TreeNode node2 in dataNodes.Nodes[i].Nodes[j].Nodes)
  486. {
  487. ColumnHeader header1 = new ColumnHeader();
  488. header1.Text = node2.Text;
  489. header1.Width = 100;
  490. this.listView1.Columns.Add(header1);
  491. }
  492. }
  493. }
  494. }
  495. }
  496. else
  497. {
  498. int[] arr;
  499. InvariantData.measureRelationAttributes.TryGetValue(type, out arr);
  500. foreach (int v in arr)
  501. {
  502. if (v > 0)
  503. {
  504. ColumnHeader header1 = new ColumnHeader();
  505. object value;
  506. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)v, out value);
  507. header1.Text = value.ToString();
  508. header1.Width = 100;
  509. this.listView1.Columns.Add(header1);
  510. }
  511. }
  512. }
  513. }
  514. }
  515. }
  516. /// <summary>
  517. /// 初始化分项数据
  518. /// </summary>
  519. private void InitializeItemizedData()
  520. {
  521. if (this.comboBox5.SelectedIndex >= 0)
  522. {
  523. if (_document != null)
  524. {
  525. if (_document.GraphicsList != null
  526. && _document.GraphicsList.Count > 0)
  527. {
  528. int count = _document.GraphicsList.Count;
  529. int no = 0;
  530. for (int i = 0; i < count; i++)
  531. {
  532. if (_document.GraphicsList[i].objectType == DrawClass.Measure)
  533. {
  534. if (_document.GraphicsList[i].drawToolType == (DrawToolType)valuePairs.ElementAt(this.comboBox5.SelectedIndex).Key)
  535. {
  536. Dictionary<System.Enum, object> data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
  537. no++;
  538. ListViewItem item = new ListViewItem();
  539. item.SubItems.Add("" + (no));
  540. if (dataNodes != null)
  541. {
  542. int count3 = dataNodes.Nodes.Count;
  543. for (int a = 0; a < count3; a++)
  544. {
  545. int count4 = dataNodes.Nodes[a].Nodes.Count;
  546. for (int j = 0; j < count4; j++)
  547. {
  548. if (this.comboBox5.Text == dataNodes.Nodes[a].Nodes[j].Text)
  549. {
  550. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  551. {
  552. foreach (var keys in data)
  553. {
  554. object v;
  555. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)keys.Key, out v);
  556. if (v.ToString() == node2.Text)
  557. {
  558. item.SubItems.Add(keys.Value.ToString());
  559. }
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. else
  567. {
  568. foreach (var keys in data)
  569. {
  570. item.SubItems.Add(keys.Value.ToString());
  571. }
  572. }
  573. this.listView1.Items.Add(item);
  574. this.listView1.Items[no - 1].Tag = _document.GraphicsList[i];
  575. }
  576. }
  577. }
  578. this.ReSizeListViewColumns();
  579. }
  580. }
  581. }
  582. }
  583. private void ReSizeListViewColumns()
  584. {
  585. int width = (this.listView1.Columns.Count - 2) * 110;
  586. //使列自使用宽度
  587. //对于DataGridView的每一个列都调整
  588. /*for (int i = 0; i < this.listView1.Columns.Count; i++)
  589. {
  590. //将每一列都调整为自动适应模式
  591. this.listView1.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize);
  592. //记录整个DataGridView的宽度
  593. width += this.listView1.Columns[i].Width;
  594. }*/
  595. //判断调整后的宽度与原来设定的宽度的关系,如果是调整后的宽度大于原来设定的宽度,
  596. //则将DataGridView的列自动调整模式设置为显示的列即可,
  597. //如果是小于原来设定的宽度,将模式改为填充。
  598. if (width > this.listView1.Size.Width)
  599. {
  600. for (int i = 2; i < this.listView1.Columns.Count; i++)
  601. {
  602. this.listView1.Columns[i].Width = 110;
  603. }
  604. }
  605. else
  606. {
  607. for (int i = 2; i < this.listView1.Columns.Count; i++)
  608. {
  609. this.listView1.Columns[i].Width = (int)((this.listView1.Size.Width - this.listView1.Columns[1].Width) / (this.listView1.Columns.Count - 2));
  610. }
  611. }
  612. }
  613. /// <summary>
  614. /// 初始化总数据表
  615. /// </summary>
  616. private void InitializeTotalData()
  617. {
  618. //初始化头
  619. this.listView2.View = View.Details;
  620. ColumnHeader header0 = new ColumnHeader();
  621. header0.Text = "";
  622. header0.Width = 0;
  623. this.listView2.Columns.Add(header0);
  624. ColumnHeader header = new ColumnHeader();
  625. header.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text");
  626. header.Width = 39;
  627. this.listView2.Columns.Add(header);
  628. ColumnHeader header1 = new ColumnHeader();
  629. header1.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.classification.text");
  630. header1.Width = 154;
  631. this.listView2.Columns.Add(header1);
  632. ColumnHeader header2 = new ColumnHeader();
  633. header2.Text = PdnResources.GetString("Menu.name.text");
  634. header2.Width = 154;
  635. this.listView2.Columns.Add(header2);
  636. ColumnHeader header3 = new ColumnHeader();
  637. header3.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Attributes.text");
  638. header3.Width = 154;
  639. this.listView2.Columns.Add(header3);
  640. ColumnHeader header4 = new ColumnHeader();
  641. header4.Text = PdnResources.GetString("Menu.unit.text");
  642. header4.Width = 154;
  643. this.listView2.Columns.Add(header4);
  644. ColumnHeader header5 = new ColumnHeader();
  645. header5.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.value.text");
  646. header5.Width = 150;
  647. this.listView2.Columns.Add(header5);
  648. }
  649. /// <summary>
  650. /// 初始化总数据表数据
  651. /// </summary>
  652. private void InitialMasterDataSheetData()
  653. {
  654. //初始化数据
  655. if (_document != null
  656. && _document.GraphicsList != null
  657. && _document.GraphicsList.Count > 0)
  658. {
  659. int count = _document.GraphicsList.Count;
  660. int no = 0;
  661. for (int i = 0; i < count; i++)
  662. {
  663. if (_document.GraphicsList[i].objectType == DrawClass.Measure)
  664. {
  665. Dictionary<System.Enum, object> data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
  666. object MeasureMethod;
  667. data.TryGetValue(MeasureAttributes.MeasureMethod, out MeasureMethod);
  668. if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex <= 0 && this.comboBox4.SelectedIndex <= 0)
  669. {
  670. if (this.comboBox2.Text.Equals(MeasureMethod))
  671. {
  672. int[] arr;
  673. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  674. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  675. if (arr != null)
  676. {
  677. foreach (int t in arr)
  678. {
  679. if (t != 0)
  680. {
  681. object v;
  682. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  683. models.Add((MeasureAttributes)t, v);
  684. }
  685. }
  686. }
  687. if (dataNodes != null)
  688. {
  689. int count3 = dataNodes.Nodes.Count;
  690. for (int a = 0; a < count3; a++)
  691. {
  692. if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
  693. {
  694. int count4 = dataNodes.Nodes[a].Nodes.Count;
  695. for (int j = 0; j < count4; j++)
  696. {
  697. if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
  698. {
  699. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  700. {
  701. foreach (var keys in models)
  702. {
  703. if (keys.Value.ToString() == node2.Text)
  704. {
  705. no++;
  706. ListViewItem item1 = new ListViewItem();
  707. item1.SubItems.Add("" + (no));
  708. item1.SubItems.Add(MeasureMethod.ToString());
  709. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  710. item1.SubItems.Add(keys.Value.ToString());
  711. object unit;
  712. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  713. item1.SubItems.Add(unit.ToString());
  714. object values;
  715. data.TryGetValue(keys.Key, out values);
  716. item1.SubItems.Add(values.ToString());
  717. this.listView2.Items.Add(item1);
  718. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  719. }
  720. }
  721. }
  722. }
  723. }
  724. }
  725. }
  726. }
  727. else
  728. {
  729. foreach (var keys in models)
  730. {
  731. no++;
  732. ListViewItem item1 = new ListViewItem();
  733. item1.SubItems.Add("" + (no));
  734. item1.SubItems.Add(MeasureMethod.ToString());
  735. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  736. item1.SubItems.Add(keys.Value.ToString());
  737. object unit;
  738. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  739. item1.SubItems.Add(unit.ToString());
  740. object values;
  741. data.TryGetValue(keys.Key, out values);
  742. item1.SubItems.Add(values.ToString());
  743. this.listView2.Items.Add(item1);
  744. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  745. }
  746. }
  747. }
  748. }
  749. else if (this.comboBox2.SelectedIndex <= 0 && this.comboBox3.SelectedIndex <= 0 && this.comboBox4.SelectedIndex > 0)
  750. {
  751. int[] arr;
  752. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  753. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  754. if (arr != null)
  755. {
  756. foreach (int t in arr)
  757. {
  758. if (t != 0)
  759. {
  760. object v;
  761. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  762. models.Add((MeasureAttributes)t, v);
  763. }
  764. }
  765. }
  766. if (dataNodes != null)
  767. {
  768. int count3 = dataNodes.Nodes.Count;
  769. for (int a = 0; a < count3; a++)
  770. {
  771. if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
  772. {
  773. int count4 = dataNodes.Nodes[a].Nodes.Count;
  774. for (int j = 0; j < count4; j++)
  775. {
  776. if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
  777. {
  778. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  779. {
  780. foreach (var keys in models)
  781. {
  782. if (this.comboBox4.Text.Equals(keys.Value))
  783. {
  784. if (keys.Value.ToString() == node2.Text)
  785. {
  786. no++;
  787. ListViewItem item1 = new ListViewItem();
  788. item1.SubItems.Add("" + (no));
  789. item1.SubItems.Add(MeasureMethod.ToString());
  790. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  791. item1.SubItems.Add(keys.Value.ToString());
  792. object unit;
  793. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  794. item1.SubItems.Add(unit.ToString());
  795. object values;
  796. data.TryGetValue(keys.Key, out values);
  797. item1.SubItems.Add(values.ToString());
  798. this.listView2.Items.Add(item1);
  799. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  800. }
  801. }
  802. }
  803. }
  804. }
  805. }
  806. }
  807. }
  808. }
  809. else
  810. {
  811. foreach (var keys in models)
  812. {
  813. if (this.comboBox4.Text.Equals(keys.Value))
  814. {
  815. no++;
  816. ListViewItem item1 = new ListViewItem();
  817. item1.SubItems.Add("" + (no));
  818. item1.SubItems.Add(MeasureMethod.ToString());
  819. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  820. item1.SubItems.Add(keys.Value.ToString());
  821. object unit;
  822. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  823. item1.SubItems.Add(unit.ToString());
  824. object values;
  825. data.TryGetValue(keys.Key, out values);
  826. item1.SubItems.Add(values.ToString());
  827. this.listView2.Items.Add(item1);
  828. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  829. }
  830. }
  831. }
  832. }
  833. else if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex > 0 && this.comboBox4.SelectedIndex <= 0)
  834. {
  835. if (this.comboBox2.Text.Equals(MeasureMethod) && this.comboBox3.Text.Equals(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text")))
  836. {
  837. int[] arr;
  838. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  839. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  840. if (arr != null)
  841. {
  842. foreach (int t in arr)
  843. {
  844. if (t != 0)
  845. {
  846. object v;
  847. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  848. models.Add((MeasureAttributes)t, v);
  849. }
  850. }
  851. }
  852. if (dataNodes != null)
  853. {
  854. int count3 = dataNodes.Nodes.Count;
  855. for (int a = 0; a < count3; a++)
  856. {
  857. if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
  858. {
  859. int count4 = dataNodes.Nodes[a].Nodes.Count;
  860. for (int j = 0; j < count4; j++)
  861. {
  862. if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
  863. {
  864. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  865. {
  866. foreach (var keys in models)
  867. {
  868. if (keys.Value.ToString() == node2.Text)
  869. {
  870. no++;
  871. ListViewItem item1 = new ListViewItem();
  872. item1.SubItems.Add("" + (no));
  873. item1.SubItems.Add(MeasureMethod.ToString());
  874. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  875. item1.SubItems.Add(keys.Value.ToString());
  876. object unit;
  877. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  878. item1.SubItems.Add(unit.ToString());
  879. object values;
  880. data.TryGetValue(keys.Key, out values);
  881. item1.SubItems.Add(values.ToString());
  882. this.listView2.Items.Add(item1);
  883. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  884. }
  885. }
  886. }
  887. }
  888. }
  889. }
  890. }
  891. }
  892. else
  893. {
  894. foreach (var keys in models)
  895. {
  896. no++;
  897. ListViewItem item1 = new ListViewItem();
  898. item1.SubItems.Add("" + (no));
  899. item1.SubItems.Add(MeasureMethod.ToString());
  900. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  901. item1.SubItems.Add(keys.Value.ToString());
  902. object unit;
  903. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  904. item1.SubItems.Add(unit.ToString());
  905. object values;
  906. data.TryGetValue(keys.Key, out values);
  907. item1.SubItems.Add(values.ToString());
  908. this.listView2.Items.Add(item1);
  909. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  910. }
  911. }
  912. }
  913. }
  914. else if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex <= 0 && this.comboBox4.SelectedIndex > 0)
  915. {
  916. if (this.comboBox2.Text.Equals(MeasureMethod))
  917. {
  918. int[] arr;
  919. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  920. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  921. if (arr != null)
  922. {
  923. foreach (int t in arr)
  924. {
  925. if (t != 0)
  926. {
  927. object v;
  928. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  929. models.Add((MeasureAttributes)t, v);
  930. }
  931. }
  932. }
  933. if (dataNodes != null)
  934. {
  935. int count3 = dataNodes.Nodes.Count;
  936. for (int a = 0; a < count3; a++)
  937. {
  938. if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
  939. {
  940. int count4 = dataNodes.Nodes[a].Nodes.Count;
  941. for (int j = 0; j < count4; j++)
  942. {
  943. if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
  944. {
  945. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  946. {
  947. foreach (var keys in models)
  948. {
  949. if (this.comboBox4.Text.Equals(keys.Value))
  950. {
  951. if (keys.Value.ToString() == node2.Text)
  952. {
  953. no++;
  954. ListViewItem item1 = new ListViewItem();
  955. item1.SubItems.Add("" + (no));
  956. item1.SubItems.Add(MeasureMethod.ToString());
  957. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  958. item1.SubItems.Add(keys.Value.ToString());
  959. object unit;
  960. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  961. item1.SubItems.Add(unit.ToString());
  962. object values;
  963. data.TryGetValue(keys.Key, out values);
  964. item1.SubItems.Add(values.ToString());
  965. this.listView2.Items.Add(item1);
  966. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  967. }
  968. }
  969. }
  970. }
  971. }
  972. }
  973. }
  974. }
  975. }
  976. else
  977. {
  978. foreach (var keys in models)
  979. {
  980. if (this.comboBox4.Text.Equals(keys.Value))
  981. {
  982. no++;
  983. ListViewItem item1 = new ListViewItem();
  984. item1.SubItems.Add("" + (no));
  985. item1.SubItems.Add(MeasureMethod.ToString());
  986. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  987. item1.SubItems.Add(keys.Value.ToString());
  988. object unit;
  989. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  990. item1.SubItems.Add(unit.ToString());
  991. object values;
  992. data.TryGetValue(keys.Key, out values);
  993. item1.SubItems.Add(values.ToString());
  994. this.listView2.Items.Add(item1);
  995. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  996. }
  997. }
  998. }
  999. }
  1000. }
  1001. else if (this.comboBox2.SelectedIndex > 0 && this.comboBox3.SelectedIndex > 0 && this.comboBox4.SelectedIndex > 0)
  1002. {
  1003. if (this.comboBox2.Text.Equals(MeasureMethod) && this.comboBox3.Text.Equals(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text")))
  1004. {
  1005. int[] arr;
  1006. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  1007. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  1008. if (arr != null)
  1009. {
  1010. foreach (int t in arr)
  1011. {
  1012. if (t != 0)
  1013. {
  1014. object v;
  1015. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  1016. models.Add((MeasureAttributes)t, v);
  1017. }
  1018. }
  1019. }
  1020. if (dataNodes != null)
  1021. {
  1022. int count3 = dataNodes.Nodes.Count;
  1023. for (int a = 0; a < count3; a++)
  1024. {
  1025. if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
  1026. {
  1027. int count4 = dataNodes.Nodes[a].Nodes.Count;
  1028. for (int j = 0; j < count4; j++)
  1029. {
  1030. if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
  1031. {
  1032. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  1033. {
  1034. foreach (var keys in models)
  1035. {
  1036. if (this.comboBox4.Text.Equals(keys.Value))
  1037. {
  1038. if (keys.Value.ToString() == node2.Text)
  1039. {
  1040. no++;
  1041. ListViewItem item1 = new ListViewItem();
  1042. item1.SubItems.Add("" + (no));
  1043. item1.SubItems.Add(MeasureMethod.ToString());
  1044. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  1045. item1.SubItems.Add(keys.Value.ToString());
  1046. object unit;
  1047. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  1048. item1.SubItems.Add(unit.ToString());
  1049. object values;
  1050. data.TryGetValue(keys.Key, out values);
  1051. item1.SubItems.Add(values.ToString());
  1052. this.listView2.Items.Add(item1);
  1053. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  1054. }
  1055. }
  1056. }
  1057. }
  1058. }
  1059. }
  1060. }
  1061. }
  1062. }
  1063. else
  1064. {
  1065. foreach (var keys in models)
  1066. {
  1067. if (this.comboBox4.Text.Equals(keys.Value))
  1068. {
  1069. no++;
  1070. ListViewItem item1 = new ListViewItem();
  1071. item1.SubItems.Add("" + (no));
  1072. item1.SubItems.Add(MeasureMethod.ToString());
  1073. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  1074. item1.SubItems.Add(keys.Value.ToString());
  1075. object unit;
  1076. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  1077. item1.SubItems.Add(unit.ToString());
  1078. object values;
  1079. data.TryGetValue(keys.Key, out values);
  1080. item1.SubItems.Add(values.ToString());
  1081. this.listView2.Items.Add(item1);
  1082. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  1083. }
  1084. }
  1085. }
  1086. }
  1087. }
  1088. else
  1089. {
  1090. int[] arr;
  1091. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  1092. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  1093. if (arr != null)
  1094. {
  1095. foreach (int t in arr)
  1096. {
  1097. if (t != 0)
  1098. {
  1099. object v;
  1100. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  1101. models.Add((MeasureAttributes)t, v);
  1102. }
  1103. }
  1104. }
  1105. if (dataNodes != null)
  1106. {
  1107. int count3 = dataNodes.Nodes.Count;
  1108. for (int a = 0; a < count3; a++)
  1109. {
  1110. if (dataNodes.Nodes[a].Text == MeasureMethod.ToString())
  1111. {
  1112. int count4 = dataNodes.Nodes[a].Nodes.Count;
  1113. for (int j = 0; j < count4; j++)
  1114. {
  1115. if (dataNodes.Nodes[a].Nodes[j].Text == PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"))
  1116. {
  1117. foreach (TreeNode node2 in dataNodes.Nodes[a].Nodes[j].Nodes)
  1118. {
  1119. foreach (var keys in models)
  1120. {
  1121. if (keys.Value.ToString() == node2.Text)
  1122. {
  1123. no++;
  1124. ListViewItem item1 = new ListViewItem();
  1125. item1.SubItems.Add("" + (no));
  1126. item1.SubItems.Add(MeasureMethod.ToString());
  1127. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  1128. item1.SubItems.Add(keys.Value.ToString());
  1129. object unit;
  1130. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  1131. item1.SubItems.Add(unit.ToString());
  1132. object values;
  1133. data.TryGetValue(keys.Key, out values);
  1134. item1.SubItems.Add(values.ToString());
  1135. this.listView2.Items.Add(item1);
  1136. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  1137. }
  1138. }
  1139. }
  1140. }
  1141. }
  1142. }
  1143. }
  1144. }
  1145. else
  1146. {
  1147. foreach (var keys in models)
  1148. {
  1149. no++;
  1150. ListViewItem item1 = new ListViewItem();
  1151. item1.SubItems.Add("" + (no));
  1152. item1.SubItems.Add(MeasureMethod.ToString());
  1153. item1.SubItems.Add(PdnResources.GetString("Menu.MeasureAction." + _document.GraphicsList[i].drawToolType.ToString() + ".Text"));
  1154. item1.SubItems.Add(keys.Value.ToString());
  1155. object unit;
  1156. data.TryGetValue(MeasureAttributes.MeasureUnitCN, out unit);
  1157. item1.SubItems.Add(unit.ToString());
  1158. object values;
  1159. data.TryGetValue(keys.Key, out values);
  1160. item1.SubItems.Add(values.ToString());
  1161. this.listView2.Items.Add(item1);
  1162. this.listView2.Items[no - 1].Tag = _document.GraphicsList[i];
  1163. }
  1164. }
  1165. }
  1166. }
  1167. }
  1168. }
  1169. }
  1170. /// <summary>
  1171. /// 初始化总数据表的三级下拉
  1172. /// </summary>
  1173. private void InitializeClassComboBox()
  1174. {
  1175. this.comboBox2.DataSource = list;
  1176. this.comboBox2.DisplayMember = "name";
  1177. this.comboBox2.ValueMember = "id";
  1178. //初始化第三级菜单
  1179. this.comboBox4.DataSource = new BindingSource(InvariantData.measureAttributes, null);
  1180. this.comboBox4.DisplayMember = "Value";
  1181. this.comboBox4.ValueMember = "Key";
  1182. }
  1183. /// <summary>
  1184. /// 初始数据Excel
  1185. /// </summary>
  1186. private void InitialDataExcel()
  1187. {
  1188. var selectedItems1 = this.listView1.SelectedItems;
  1189. var selectedItems2 = this.listView2.SelectedItems;
  1190. if ((this.listView1.Visible && selectedItems1.Count == 0) || (this.listView2.Visible && selectedItems2.Count == 0))
  1191. {
  1192. int count = _document.GraphicsList.Count;
  1193. System.Data.DataSet ds = new DataSet();
  1194. DataTable MeasureLine = new DataTable();
  1195. MeasureLine.TableName = PdnResources.GetString("Menu.LabelAction.DrawLine.Text");
  1196. for (int c = 0; c < 18; c++)
  1197. {
  1198. MeasureLine.Columns.Add(c.ToString());
  1199. }
  1200. DataTable MeasureLength = new DataTable();
  1201. MeasureLength.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");
  1202. for (int c = 0; c < 18; c++)
  1203. {
  1204. MeasureLength.Columns.Add(c.ToString());
  1205. }
  1206. DataTable MeasureHLine = new DataTable();
  1207. MeasureHLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureHLine.Text");
  1208. for (int c = 0; c < 18; c++)
  1209. {
  1210. MeasureHLine.Columns.Add(c.ToString());
  1211. }
  1212. DataTable MeasureVLine = new DataTable();
  1213. MeasureVLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureVLine.Text");
  1214. for (int c = 0; c < 18; c++)
  1215. {
  1216. MeasureVLine.Columns.Add(c.ToString());
  1217. }
  1218. DataTable MeasureMulLine = new DataTable();
  1219. MeasureMulLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulLine.Text");
  1220. for (int c = 0; c < 18; c++)
  1221. {
  1222. MeasureMulLine.Columns.Add(c.ToString());
  1223. }
  1224. DataTable MeasureMulHVLine = new DataTable();
  1225. MeasureMulHVLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulHVLine.Text");
  1226. for (int c = 0; c < 18; c++)
  1227. {
  1228. MeasureMulHVLine.Columns.Add(c.ToString());
  1229. }
  1230. DataTable MeasureMulSegment = new DataTable();
  1231. MeasureMulSegment.TableName = PdnResources.GetString("Menu.MeasureAction.MultiPointLineSegment.Text");
  1232. for (int c = 0; c < 18; c++)
  1233. {
  1234. MeasureMulSegment.Columns.Add(c.ToString());
  1235. }
  1236. DataTable MeasureMulVLine = new DataTable();
  1237. MeasureMulVLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulPLine.Text");
  1238. for (int c = 0; c < 18; c++)
  1239. {
  1240. MeasureMulVLine.Columns.Add(c.ToString());
  1241. }
  1242. DataTable MeasureBrokenLine = new DataTable();
  1243. MeasureBrokenLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureBrokenLine.Text");
  1244. for (int c = 0; c < 18; c++)
  1245. {
  1246. MeasureBrokenLine.Columns.Add(c.ToString());
  1247. }
  1248. DataTable MeasureTraceCurve = new DataTable();
  1249. MeasureTraceCurve.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureTraceCurve.Text");
  1250. for (int c = 0; c < 18; c++)
  1251. {
  1252. MeasureTraceCurve.Columns.Add(c.ToString());
  1253. }
  1254. DataTable MeasureCurveLine = new DataTable();
  1255. MeasureCurveLine.TableName = PdnResources.GetString("Menu.LabelAction.DrawCurve.Text");
  1256. for (int c = 0; c < 18; c++)
  1257. {
  1258. MeasureCurveLine.Columns.Add(c.ToString());
  1259. }
  1260. DataTable MeasurePLine = new DataTable();
  1261. MeasurePLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasurePLine.Text");
  1262. for (int c = 0; c < 18; c++)
  1263. {
  1264. MeasurePLine.Columns.Add(c.ToString());
  1265. }
  1266. DataTable MeasureMulPLine = new DataTable();
  1267. MeasureMulPLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulPLine.Text");
  1268. for (int c = 0; c < 18; c++)
  1269. {
  1270. MeasureMulPLine.Columns.Add(c.ToString());
  1271. }
  1272. DataTable MeasureHMulPLine = new DataTable();
  1273. MeasureHMulPLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureHMulPLine.Text");
  1274. for (int c = 0; c < 18; c++)
  1275. {
  1276. MeasureHMulPLine.Columns.Add(c.ToString());
  1277. }
  1278. DataTable MeasureVMulPLine = new DataTable();
  1279. MeasureVMulPLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureVMulPLine.Text");
  1280. for (int c = 0; c < 18; c++)
  1281. {
  1282. MeasureVMulPLine.Columns.Add(c.ToString());
  1283. }
  1284. DataTable MeasureParallelLine = new DataTable();
  1285. MeasureParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureParallelLine.Text");
  1286. for (int c = 0; c < 18; c++)
  1287. {
  1288. MeasureParallelLine.Columns.Add(c.ToString());
  1289. }
  1290. DataTable MeasureMulParallelLine = new DataTable();
  1291. MeasureMulParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureMulParallelLine.Text");
  1292. for (int c = 0; c < 18; c++)
  1293. {
  1294. MeasureMulParallelLine.Columns.Add(c.ToString());
  1295. }
  1296. DataTable MeasureVMulParallelLine = new DataTable();
  1297. MeasureVMulParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureVMulParallelLine.Text");
  1298. for (int c = 0; c < 18; c++)
  1299. {
  1300. MeasureVMulParallelLine.Columns.Add(c.ToString());
  1301. }
  1302. DataTable MeasureHMulParallelLine = new DataTable();
  1303. MeasureHMulParallelLine.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureHMulParallelLine.Text");
  1304. for (int c = 0; c < 18; c++)
  1305. {
  1306. MeasureHMulParallelLine.Columns.Add(c.ToString());
  1307. }
  1308. DataTable MeasureClosedCurve = new DataTable();
  1309. MeasureClosedCurve.TableName = PdnResources.GetString("Menu.LabelAction.DrawClosedCurve.Text");
  1310. for (int c = 0; c < 18; c++)
  1311. {
  1312. MeasureClosedCurve.Columns.Add(c.ToString());
  1313. }
  1314. DataTable MeasurePolygon = new DataTable();
  1315. MeasurePolygon.TableName = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
  1316. for (int c = 0; c < 18; c++)
  1317. {
  1318. MeasurePolygon.Columns.Add(c.ToString());
  1319. }
  1320. DataTable MeasureRectangle = new DataTable();
  1321. MeasureRectangle.TableName = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
  1322. for (int c = 0; c < 18; c++)
  1323. {
  1324. MeasureRectangle.Columns.Add(c.ToString());
  1325. }
  1326. DataTable MeasureRandRectangle = new DataTable();
  1327. MeasureRandRectangle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureRandRectangle.Text");
  1328. for (int c = 0; c < 18; c++)
  1329. {
  1330. MeasureRandRectangle.Columns.Add(c.ToString());
  1331. }
  1332. DataTable MeasureSquare = new DataTable();
  1333. MeasureSquare.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureSquare.Text");
  1334. for (int c = 0; c < 18; c++)
  1335. {
  1336. MeasureSquare.Columns.Add(c.ToString());
  1337. }
  1338. DataTable MeasureRandSquare = new DataTable();
  1339. MeasureRandSquare.TableName = PdnResources.GetString("Menu.Anypositivedirection.Text");
  1340. for (int c = 0; c < 18; c++)
  1341. {
  1342. MeasureRandSquare.Columns.Add(c.ToString());
  1343. }
  1344. DataTable MeasureTracePolygon = new DataTable();
  1345. MeasureTracePolygon.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureTracePolygon.Text");
  1346. for (int c = 0; c < 18; c++)
  1347. {
  1348. MeasureTracePolygon.Columns.Add(c.ToString());
  1349. }
  1350. DataTable MeasureCircle = new DataTable();
  1351. MeasureCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureCircle.Text");
  1352. for (int c = 0; c < 18; c++)
  1353. {
  1354. MeasureCircle.Columns.Add(c.ToString());
  1355. }
  1356. DataTable MeasureInnerCircle = new DataTable();
  1357. MeasureInnerCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureInnerCircle.Text");
  1358. for (int c = 0; c < 18; c++)
  1359. {
  1360. MeasureInnerCircle.Columns.Add(c.ToString());
  1361. }
  1362. DataTable MeasureOuterCircle = new DataTable();
  1363. MeasureOuterCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureOuterCircle.Text");
  1364. for (int c = 0; c < 18; c++)
  1365. {
  1366. MeasureOuterCircle.Columns.Add(c.ToString());
  1367. }
  1368. DataTable MeasureDiameterCircle = new DataTable();
  1369. MeasureDiameterCircle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureDiameterCircle.Text");
  1370. for (int c = 0; c < 18; c++)
  1371. {
  1372. MeasureDiameterCircle.Columns.Add(c.ToString());
  1373. }
  1374. DataTable MeasurePointEdgeSize = new DataTable();
  1375. MeasurePointEdgeSize.TableName = PdnResources.GetString("Menu.MeasureAction.MeasurePointEdgeSize.Text");
  1376. for (int c = 0; c < 18; c++)
  1377. {
  1378. MeasurePointEdgeSize.Columns.Add(c.ToString());
  1379. }
  1380. DataTable MeasurePointCenterSize = new DataTable();
  1381. MeasurePointCenterSize.TableName = PdnResources.GetString("Menu.MeasureAction.MeasurePointCenterSize.Text");
  1382. for (int c = 0; c < 18; c++)
  1383. {
  1384. MeasurePointCenterSize.Columns.Add(c.ToString());
  1385. }
  1386. DataTable MeasureThreePointAngle = new DataTable();
  1387. MeasureThreePointAngle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureThreePointAngle.Text");
  1388. for (int c = 0; c < 18; c++)
  1389. {
  1390. MeasureThreePointAngle.Columns.Add(c.ToString());
  1391. }
  1392. DataTable MeasureFourPointAngle = new DataTable();
  1393. MeasureFourPointAngle.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureFourPointAngle.Text");
  1394. for (int c = 0; c < 18; c++)
  1395. {
  1396. MeasureFourPointAngle.Columns.Add(c.ToString());
  1397. }
  1398. DataTable MeasureThreePointArc = new DataTable();
  1399. MeasureThreePointArc.TableName = PdnResources.GetString("Menu.MeasureAction.MeasureThreePointArc.Text");
  1400. for (int c = 0; c < 18; c++)
  1401. {
  1402. MeasureThreePointArc.Columns.Add(c.ToString());
  1403. }
  1404. for (int i = 0; i < count; i++)
  1405. {
  1406. if (_document.GraphicsList[i].objectType == DrawClass.Measure)
  1407. {
  1408. Dictionary<System.Enum, object> data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
  1409. int[] arr;
  1410. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  1411. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  1412. if (arr != null)
  1413. {
  1414. foreach (int t in arr)
  1415. {
  1416. if (t != 0)
  1417. {
  1418. object v;
  1419. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  1420. models.Add((MeasureAttributes)t, v);
  1421. }
  1422. }
  1423. }
  1424. if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureLine)
  1425. {
  1426. DataRow row = MeasureLine.NewRow();
  1427. int a = 0;
  1428. if (MeasureLine.Rows.Count == 0)
  1429. {
  1430. foreach (var item in models)
  1431. {
  1432. row[a.ToString()] = item.Value;
  1433. a++;
  1434. }
  1435. MeasureLine.Rows.Add(row);
  1436. }
  1437. row = MeasureLine.NewRow();
  1438. a = 0;
  1439. foreach (var item in data)
  1440. {
  1441. object cnvalue;
  1442. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1443. row[a.ToString()] = item.Value;
  1444. a++;
  1445. }
  1446. MeasureLine.Rows.Add(row);
  1447. }
  1448. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureLength)
  1449. {
  1450. DataRow row = MeasureLength.NewRow();
  1451. int a = 0;
  1452. if (MeasureLength.Rows.Count == 0)
  1453. {
  1454. foreach (var item in models)
  1455. {
  1456. row[a.ToString()] = item.Value;
  1457. a++;
  1458. }
  1459. MeasureLength.Rows.Add(row);
  1460. }
  1461. row = MeasureLength.NewRow();
  1462. a = 0;
  1463. foreach (var item in data)
  1464. {
  1465. object cnvalue;
  1466. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1467. row[a.ToString()] = item.Value;
  1468. a++;
  1469. }
  1470. MeasureLength.Rows.Add(row);
  1471. }
  1472. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureHLine)
  1473. {
  1474. DataRow row = MeasureHLine.NewRow();
  1475. int a = 0;
  1476. if (MeasureHLine.Rows.Count == 0)
  1477. {
  1478. foreach (var item in models)
  1479. {
  1480. row[a.ToString()] = item.Value;
  1481. a++;
  1482. }
  1483. MeasureHLine.Rows.Add(row);
  1484. }
  1485. row = MeasureHLine.NewRow();
  1486. a = 0;
  1487. foreach (var item in data)
  1488. {
  1489. object cnvalue;
  1490. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1491. row[a.ToString()] = item.Value;
  1492. a++;
  1493. }
  1494. MeasureHLine.Rows.Add(row);
  1495. }
  1496. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureVLine)
  1497. {
  1498. DataRow row = MeasureVLine.NewRow();
  1499. int a = 0;
  1500. if (MeasureVLine.Rows.Count == 0)
  1501. {
  1502. foreach (var item in models)
  1503. {
  1504. row[a.ToString()] = item.Value;
  1505. a++;
  1506. }
  1507. MeasureVLine.Rows.Add(row);
  1508. }
  1509. row = MeasureVLine.NewRow();
  1510. a = 0;
  1511. foreach (var item in data)
  1512. {
  1513. object cnvalue;
  1514. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1515. row[a.ToString()] = item.Value;
  1516. a++;
  1517. }
  1518. MeasureVLine.Rows.Add(row);
  1519. }
  1520. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulLine)
  1521. {
  1522. DataRow row = MeasureMulLine.NewRow();
  1523. int a = 0;
  1524. if (MeasureMulLine.Rows.Count == 0)
  1525. {
  1526. foreach (var item in models)
  1527. {
  1528. row[a.ToString()] = item.Value;
  1529. a++;
  1530. }
  1531. MeasureMulLine.Rows.Add(row);
  1532. }
  1533. row = MeasureMulLine.NewRow();
  1534. a = 0;
  1535. foreach (var item in data)
  1536. {
  1537. object cnvalue;
  1538. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1539. row[a.ToString()] = item.Value;
  1540. a++;
  1541. }
  1542. MeasureMulLine.Rows.Add(row);
  1543. }
  1544. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulHVLine)
  1545. {
  1546. DataRow row = MeasureMulHVLine.NewRow();
  1547. int a = 0;
  1548. if (MeasureMulHVLine.Rows.Count == 0)
  1549. {
  1550. foreach (var item in models)
  1551. {
  1552. row[a.ToString()] = item.Value;
  1553. a++;
  1554. }
  1555. MeasureMulHVLine.Rows.Add(row);
  1556. }
  1557. row = MeasureMulHVLine.NewRow();
  1558. a = 0;
  1559. foreach (var item in data)
  1560. {
  1561. object cnvalue;
  1562. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1563. row[a.ToString()] = item.Value;
  1564. a++;
  1565. }
  1566. MeasureMulHVLine.Rows.Add(row);
  1567. }
  1568. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulSegment)
  1569. {
  1570. DataRow row = MeasureMulSegment.NewRow();
  1571. int a = 0;
  1572. if (MeasureMulSegment.Rows.Count == 0)
  1573. {
  1574. foreach (var item in models)
  1575. {
  1576. row[a.ToString()] = item.Value;
  1577. a++;
  1578. }
  1579. MeasureMulSegment.Rows.Add(row);
  1580. }
  1581. row = MeasureMulSegment.NewRow();
  1582. a = 0;
  1583. foreach (var item in data)
  1584. {
  1585. object cnvalue;
  1586. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1587. row[a.ToString()] = item.Value;
  1588. a++;
  1589. }
  1590. MeasureMulSegment.Rows.Add(row);
  1591. }
  1592. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulVLine)
  1593. {
  1594. DataRow row = MeasureMulVLine.NewRow();
  1595. int a = 0;
  1596. if (MeasureMulVLine.Rows.Count == 0)
  1597. {
  1598. foreach (var item in models)
  1599. {
  1600. row[a.ToString()] = item.Value;
  1601. a++;
  1602. }
  1603. MeasureMulVLine.Rows.Add(row);
  1604. }
  1605. row = MeasureMulVLine.NewRow();
  1606. a = 0;
  1607. foreach (var item in data)
  1608. {
  1609. object cnvalue;
  1610. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1611. row[a.ToString()] = item.Value;
  1612. a++;
  1613. }
  1614. MeasureMulVLine.Rows.Add(row);
  1615. }
  1616. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureBrokenLine)
  1617. {
  1618. DataRow row = MeasureBrokenLine.NewRow();
  1619. int a = 0;
  1620. if (MeasureBrokenLine.Rows.Count == 0)
  1621. {
  1622. foreach (var item in models)
  1623. {
  1624. row[a.ToString()] = item.Value;
  1625. a++;
  1626. }
  1627. MeasureBrokenLine.Rows.Add(row);
  1628. }
  1629. row = MeasureBrokenLine.NewRow();
  1630. a = 0;
  1631. foreach (var item in data)
  1632. {
  1633. object cnvalue;
  1634. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1635. row[a.ToString()] = item.Value;
  1636. a++;
  1637. }
  1638. MeasureBrokenLine.Rows.Add(row);
  1639. }
  1640. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureTraceCurve)
  1641. {
  1642. DataRow row = MeasureTraceCurve.NewRow();
  1643. int a = 0;
  1644. if (MeasureTraceCurve.Rows.Count == 0)
  1645. {
  1646. foreach (var item in models)
  1647. {
  1648. row[a.ToString()] = item.Value;
  1649. a++;
  1650. }
  1651. MeasureTraceCurve.Rows.Add(row);
  1652. }
  1653. row = MeasureTraceCurve.NewRow();
  1654. a = 0;
  1655. foreach (var item in data)
  1656. {
  1657. object cnvalue;
  1658. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1659. row[a.ToString()] = item.Value;
  1660. a++;
  1661. }
  1662. MeasureTraceCurve.Rows.Add(row);
  1663. }
  1664. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureCurveLine)
  1665. {
  1666. DataRow row = MeasureCurveLine.NewRow();
  1667. int a = 0;
  1668. if (MeasureCurveLine.Rows.Count == 0)
  1669. {
  1670. foreach (var item in models)
  1671. {
  1672. row[a.ToString()] = item.Value;
  1673. a++;
  1674. }
  1675. MeasureCurveLine.Rows.Add(row);
  1676. }
  1677. row = MeasureCurveLine.NewRow();
  1678. a = 0;
  1679. foreach (var item in data)
  1680. {
  1681. object cnvalue;
  1682. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1683. row[a.ToString()] = item.Value;
  1684. a++;
  1685. }
  1686. MeasureCurveLine.Rows.Add(row);
  1687. }
  1688. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePLine)
  1689. {
  1690. DataRow row = MeasurePLine.NewRow();
  1691. int a = 0;
  1692. if (MeasurePLine.Rows.Count == 0)
  1693. {
  1694. foreach (var item in models)
  1695. {
  1696. row[a.ToString()] = item.Value;
  1697. a++;
  1698. }
  1699. MeasurePLine.Rows.Add(row);
  1700. }
  1701. row = MeasurePLine.NewRow();
  1702. a = 0;
  1703. foreach (var item in data)
  1704. {
  1705. object cnvalue;
  1706. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1707. row[a.ToString()] = item.Value;
  1708. a++;
  1709. }
  1710. MeasurePLine.Rows.Add(row);
  1711. }
  1712. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulPLine)
  1713. {
  1714. DataRow row = MeasureMulPLine.NewRow();
  1715. int a = 0;
  1716. if (MeasureMulPLine.Rows.Count == 0)
  1717. {
  1718. foreach (var item in models)
  1719. {
  1720. row[a.ToString()] = item.Value;
  1721. a++;
  1722. }
  1723. MeasureMulPLine.Rows.Add(row);
  1724. }
  1725. row = MeasureMulPLine.NewRow();
  1726. a = 0;
  1727. foreach (var item in data)
  1728. {
  1729. object cnvalue;
  1730. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1731. row[a.ToString()] = item.Value;
  1732. a++;
  1733. }
  1734. MeasureMulPLine.Rows.Add(row);
  1735. }
  1736. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureHMulPLine)
  1737. {
  1738. DataRow row = MeasureHMulPLine.NewRow();
  1739. int a = 0;
  1740. if (MeasureHMulPLine.Rows.Count == 0)
  1741. {
  1742. foreach (var item in models)
  1743. {
  1744. row[a.ToString()] = item.Value;
  1745. a++;
  1746. }
  1747. MeasureHMulPLine.Rows.Add(row);
  1748. }
  1749. row = MeasureHMulPLine.NewRow();
  1750. a = 0;
  1751. foreach (var item in data)
  1752. {
  1753. object cnvalue;
  1754. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1755. row[a.ToString()] = item.Value;
  1756. a++;
  1757. }
  1758. MeasureHMulPLine.Rows.Add(row);
  1759. }
  1760. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureVMulPLine)
  1761. {
  1762. DataRow row = MeasureVMulPLine.NewRow();
  1763. int a = 0;
  1764. if (MeasureVMulPLine.Rows.Count == 0)
  1765. {
  1766. foreach (var item in models)
  1767. {
  1768. row[a.ToString()] = item.Value;
  1769. a++;
  1770. }
  1771. MeasureVMulPLine.Rows.Add(row);
  1772. }
  1773. row = MeasureVMulPLine.NewRow();
  1774. a = 0;
  1775. foreach (var item in data)
  1776. {
  1777. object cnvalue;
  1778. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1779. row[a.ToString()] = item.Value;
  1780. a++;
  1781. }
  1782. MeasureVMulPLine.Rows.Add(row);
  1783. }
  1784. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureParallelLine)
  1785. {
  1786. DataRow row = MeasureParallelLine.NewRow();
  1787. int a = 0;
  1788. if (MeasureParallelLine.Rows.Count == 0)
  1789. {
  1790. foreach (var item in models)
  1791. {
  1792. row[a.ToString()] = item.Value;
  1793. a++;
  1794. }
  1795. MeasureParallelLine.Rows.Add(row);
  1796. }
  1797. row = MeasureParallelLine.NewRow();
  1798. a = 0;
  1799. foreach (var item in data)
  1800. {
  1801. object cnvalue;
  1802. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1803. row[a.ToString()] = item.Value;
  1804. a++;
  1805. }
  1806. MeasureParallelLine.Rows.Add(row);
  1807. }
  1808. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureMulParallelLine)
  1809. {
  1810. DataRow row = MeasureMulParallelLine.NewRow();
  1811. int a = 0;
  1812. if (MeasureMulParallelLine.Rows.Count == 0)
  1813. {
  1814. foreach (var item in models)
  1815. {
  1816. row[a.ToString()] = item.Value;
  1817. a++;
  1818. }
  1819. MeasureMulParallelLine.Rows.Add(row);
  1820. }
  1821. row = MeasureMulParallelLine.NewRow();
  1822. a = 0;
  1823. foreach (var item in data)
  1824. {
  1825. object cnvalue;
  1826. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1827. row[a.ToString()] = item.Value;
  1828. a++;
  1829. }
  1830. MeasureMulParallelLine.Rows.Add(row);
  1831. }
  1832. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureVMulParallelLine)
  1833. {
  1834. DataRow row = MeasureVMulParallelLine.NewRow();
  1835. int a = 0;
  1836. if (MeasureVMulParallelLine.Rows.Count == 0)
  1837. {
  1838. foreach (var item in models)
  1839. {
  1840. row[a.ToString()] = item.Value;
  1841. a++;
  1842. }
  1843. MeasureVMulParallelLine.Rows.Add(row);
  1844. }
  1845. row = MeasureVMulParallelLine.NewRow();
  1846. a = 0;
  1847. foreach (var item in data)
  1848. {
  1849. object cnvalue;
  1850. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1851. row[a.ToString()] = item.Value;
  1852. a++;
  1853. }
  1854. MeasureVMulParallelLine.Rows.Add(row);
  1855. }
  1856. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureHMulParallelLine)
  1857. {
  1858. DataRow row = MeasureHMulParallelLine.NewRow();
  1859. int a = 0;
  1860. if (MeasureHMulParallelLine.Rows.Count == 0)
  1861. {
  1862. foreach (var item in models)
  1863. {
  1864. row[a.ToString()] = item.Value;
  1865. a++;
  1866. }
  1867. MeasureHMulParallelLine.Rows.Add(row);
  1868. }
  1869. row = MeasureHMulParallelLine.NewRow();
  1870. a = 0;
  1871. foreach (var item in data)
  1872. {
  1873. object cnvalue;
  1874. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1875. row[a.ToString()] = item.Value;
  1876. a++;
  1877. }
  1878. MeasureHMulParallelLine.Rows.Add(row);
  1879. }
  1880. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureClosedCurve)
  1881. {
  1882. DataRow row = MeasureClosedCurve.NewRow();
  1883. int a = 0;
  1884. if (MeasureClosedCurve.Rows.Count == 0)
  1885. {
  1886. foreach (var item in models)
  1887. {
  1888. row[a.ToString()] = item.Value;
  1889. a++;
  1890. }
  1891. MeasureClosedCurve.Rows.Add(row);
  1892. }
  1893. row = MeasureClosedCurve.NewRow();
  1894. a = 0;
  1895. foreach (var item in data)
  1896. {
  1897. object cnvalue;
  1898. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1899. row[a.ToString()] = item.Value;
  1900. a++;
  1901. }
  1902. MeasureClosedCurve.Rows.Add(row);
  1903. }
  1904. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePolygon)
  1905. {
  1906. DataRow row = MeasurePolygon.NewRow();
  1907. int a = 0;
  1908. if (MeasurePolygon.Rows.Count == 0)
  1909. {
  1910. foreach (var item in models)
  1911. {
  1912. row[a.ToString()] = item.Value;
  1913. a++;
  1914. }
  1915. MeasurePolygon.Rows.Add(row);
  1916. }
  1917. row = MeasurePolygon.NewRow();
  1918. a = 0;
  1919. foreach (var item in data)
  1920. {
  1921. object cnvalue;
  1922. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1923. row[a.ToString()] = item.Value;
  1924. a++;
  1925. }
  1926. MeasurePolygon.Rows.Add(row);
  1927. }
  1928. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureRectangle)
  1929. {
  1930. DataRow row = MeasureRectangle.NewRow();
  1931. int a = 0;
  1932. if (MeasureRectangle.Rows.Count == 0)
  1933. {
  1934. foreach (var item in models)
  1935. {
  1936. row[a.ToString()] = item.Value;
  1937. a++;
  1938. }
  1939. MeasureRectangle.Rows.Add(row);
  1940. }
  1941. row = MeasureRectangle.NewRow();
  1942. a = 0;
  1943. foreach (var item in data)
  1944. {
  1945. object cnvalue;
  1946. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1947. row[a.ToString()] = item.Value;
  1948. a++;
  1949. }
  1950. MeasureRectangle.Rows.Add(row);
  1951. }
  1952. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureRandRectangle)
  1953. {
  1954. DataRow row = MeasureRandRectangle.NewRow();
  1955. int a = 0;
  1956. if (MeasureRandRectangle.Rows.Count == 0)
  1957. {
  1958. foreach (var item in models)
  1959. {
  1960. row[a.ToString()] = item.Value;
  1961. a++;
  1962. }
  1963. MeasureRandRectangle.Rows.Add(row);
  1964. }
  1965. row = MeasureRandRectangle.NewRow();
  1966. a = 0;
  1967. foreach (var item in data)
  1968. {
  1969. object cnvalue;
  1970. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1971. row[a.ToString()] = item.Value;
  1972. a++;
  1973. }
  1974. MeasureRandRectangle.Rows.Add(row);
  1975. }
  1976. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureSquare)
  1977. {
  1978. DataRow row = MeasureSquare.NewRow();
  1979. int a = 0;
  1980. if (MeasureSquare.Rows.Count == 0)
  1981. {
  1982. foreach (var item in models)
  1983. {
  1984. row[a.ToString()] = item.Value;
  1985. a++;
  1986. }
  1987. MeasureSquare.Rows.Add(row);
  1988. }
  1989. row = MeasureSquare.NewRow();
  1990. a = 0;
  1991. foreach (var item in data)
  1992. {
  1993. object cnvalue;
  1994. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  1995. row[a.ToString()] = item.Value;
  1996. a++;
  1997. }
  1998. MeasureSquare.Rows.Add(row);
  1999. }
  2000. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureRandSquare)
  2001. {
  2002. DataRow row = MeasureRandSquare.NewRow();
  2003. int a = 0;
  2004. if (MeasureRandSquare.Rows.Count == 0)
  2005. {
  2006. foreach (var item in models)
  2007. {
  2008. row[a.ToString()] = item.Value;
  2009. a++;
  2010. }
  2011. MeasureRandSquare.Rows.Add(row);
  2012. }
  2013. row = MeasureRandSquare.NewRow();
  2014. a = 0;
  2015. foreach (var item in data)
  2016. {
  2017. object cnvalue;
  2018. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2019. row[a.ToString()] = item.Value;
  2020. a++;
  2021. }
  2022. MeasureRandSquare.Rows.Add(row);
  2023. }
  2024. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureTracePolygon)
  2025. {
  2026. DataRow row = MeasureTracePolygon.NewRow();
  2027. int a = 0;
  2028. if (MeasureTracePolygon.Rows.Count == 0)
  2029. {
  2030. foreach (var item in models)
  2031. {
  2032. row[a.ToString()] = item.Value;
  2033. a++;
  2034. }
  2035. MeasureTracePolygon.Rows.Add(row);
  2036. }
  2037. row = MeasureTracePolygon.NewRow();
  2038. a = 0;
  2039. foreach (var item in data)
  2040. {
  2041. object cnvalue;
  2042. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2043. row[a.ToString()] = item.Value;
  2044. a++;
  2045. }
  2046. MeasureTracePolygon.Rows.Add(row);
  2047. }
  2048. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureCircle)
  2049. {
  2050. DataRow row = MeasureCircle.NewRow();
  2051. int a = 0;
  2052. if (MeasureCircle.Rows.Count == 0)
  2053. {
  2054. foreach (var item in models)
  2055. {
  2056. row[a.ToString()] = item.Value;
  2057. a++;
  2058. }
  2059. MeasureCircle.Rows.Add(row);
  2060. }
  2061. row = MeasureCircle.NewRow();
  2062. a = 0;
  2063. foreach (var item in data)
  2064. {
  2065. object cnvalue;
  2066. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2067. row[a.ToString()] = item.Value;
  2068. a++;
  2069. }
  2070. MeasureCircle.Rows.Add(row);
  2071. }
  2072. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureInnerCircle)
  2073. {
  2074. DataRow row = MeasureInnerCircle.NewRow();
  2075. int a = 0;
  2076. if (MeasureInnerCircle.Rows.Count == 0)
  2077. {
  2078. foreach (var item in models)
  2079. {
  2080. row[a.ToString()] = item.Value;
  2081. a++;
  2082. }
  2083. MeasureInnerCircle.Rows.Add(row);
  2084. }
  2085. row = MeasureInnerCircle.NewRow();
  2086. a = 0;
  2087. foreach (var item in data)
  2088. {
  2089. object cnvalue;
  2090. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2091. row[a.ToString()] = item.Value;
  2092. a++;
  2093. }
  2094. MeasureInnerCircle.Rows.Add(row);
  2095. }
  2096. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureOuterCircle)
  2097. {
  2098. DataRow row = MeasureOuterCircle.NewRow();
  2099. int a = 0;
  2100. if (MeasureOuterCircle.Rows.Count == 0)
  2101. {
  2102. foreach (var item in models)
  2103. {
  2104. row[a.ToString()] = item.Value;
  2105. a++;
  2106. }
  2107. MeasureOuterCircle.Rows.Add(row);
  2108. }
  2109. row = MeasureOuterCircle.NewRow();
  2110. a = 0;
  2111. foreach (var item in data)
  2112. {
  2113. object cnvalue;
  2114. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2115. row[a.ToString()] = item.Value;
  2116. a++;
  2117. }
  2118. MeasureOuterCircle.Rows.Add(row);
  2119. }
  2120. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureDiameterCircle)
  2121. {
  2122. DataRow row = MeasureDiameterCircle.NewRow();
  2123. int a = 0;
  2124. if (MeasureDiameterCircle.Rows.Count == 0)
  2125. {
  2126. foreach (var item in models)
  2127. {
  2128. row[a.ToString()] = item.Value;
  2129. a++;
  2130. }
  2131. MeasureDiameterCircle.Rows.Add(row);
  2132. }
  2133. row = MeasureDiameterCircle.NewRow();
  2134. a = 0;
  2135. foreach (var item in data)
  2136. {
  2137. object cnvalue;
  2138. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2139. row[a.ToString()] = item.Value;
  2140. a++;
  2141. }
  2142. MeasureDiameterCircle.Rows.Add(row);
  2143. }
  2144. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePointEdgeSize)
  2145. {
  2146. DataRow row = MeasurePointEdgeSize.NewRow();
  2147. int a = 0;
  2148. if (MeasurePointEdgeSize.Rows.Count == 0)
  2149. {
  2150. foreach (var item in models)
  2151. {
  2152. row[a.ToString()] = item.Value;
  2153. a++;
  2154. }
  2155. MeasurePointEdgeSize.Rows.Add(row);
  2156. }
  2157. row = MeasurePointEdgeSize.NewRow();
  2158. a = 0;
  2159. foreach (var item in data)
  2160. {
  2161. object cnvalue;
  2162. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2163. row[a.ToString()] = item.Value;
  2164. a++;
  2165. }
  2166. MeasurePointEdgeSize.Rows.Add(row);
  2167. }
  2168. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasurePointCenterSize)
  2169. {
  2170. DataRow row = MeasurePointCenterSize.NewRow();
  2171. int a = 0;
  2172. if (MeasurePointCenterSize.Rows.Count == 0)
  2173. {
  2174. foreach (var item in models)
  2175. {
  2176. row[a.ToString()] = item.Value;
  2177. a++;
  2178. }
  2179. MeasurePointCenterSize.Rows.Add(row);
  2180. }
  2181. row = MeasurePointCenterSize.NewRow();
  2182. a = 0;
  2183. foreach (var item in data)
  2184. {
  2185. object cnvalue;
  2186. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2187. row[a.ToString()] = item.Value;
  2188. a++;
  2189. }
  2190. MeasurePointCenterSize.Rows.Add(row);
  2191. }
  2192. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureThreePointAngle)
  2193. {
  2194. DataRow row = MeasureThreePointAngle.NewRow();
  2195. int a = 0;
  2196. if (MeasureThreePointAngle.Rows.Count == 0)
  2197. {
  2198. foreach (var item in models)
  2199. {
  2200. row[a.ToString()] = item.Value;
  2201. a++;
  2202. }
  2203. MeasureThreePointAngle.Rows.Add(row);
  2204. }
  2205. row = MeasureThreePointAngle.NewRow();
  2206. a = 0;
  2207. foreach (var item in data)
  2208. {
  2209. object cnvalue;
  2210. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2211. row[a.ToString()] = item.Value;
  2212. a++;
  2213. }
  2214. MeasureThreePointAngle.Rows.Add(row);
  2215. }
  2216. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureFourPointAngle)
  2217. {
  2218. DataRow row = MeasureFourPointAngle.NewRow();
  2219. int a = 0;
  2220. if (MeasureFourPointAngle.Rows.Count == 0)
  2221. {
  2222. foreach (var item in models)
  2223. {
  2224. row[a.ToString()] = item.Value;
  2225. a++;
  2226. }
  2227. MeasureFourPointAngle.Rows.Add(row);
  2228. }
  2229. row = MeasureFourPointAngle.NewRow();
  2230. a = 0;
  2231. foreach (var item in data)
  2232. {
  2233. object cnvalue;
  2234. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2235. row[a.ToString()] = item.Value;
  2236. a++;
  2237. }
  2238. MeasureFourPointAngle.Rows.Add(row);
  2239. }
  2240. else if (_document.GraphicsList[i].drawToolType == DrawToolType.MeasureThreePointArc)
  2241. {
  2242. DataRow row = MeasureThreePointArc.NewRow();
  2243. int a = 0;
  2244. if (MeasureThreePointArc.Rows.Count == 0)
  2245. {
  2246. foreach (var item in models)
  2247. {
  2248. row[a.ToString()] = item.Value;
  2249. a++;
  2250. }
  2251. MeasureThreePointArc.Rows.Add(row);
  2252. }
  2253. row = MeasureThreePointArc.NewRow();
  2254. a = 0;
  2255. foreach (var item in data)
  2256. {
  2257. object cnvalue;
  2258. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2259. row[a.ToString()] = item.Value;
  2260. a++;
  2261. }
  2262. MeasureThreePointArc.Rows.Add(row);
  2263. }
  2264. }
  2265. }
  2266. if (MeasureLine.Rows.Count > 0) ds.Tables.Add(MeasureLine);
  2267. if (MeasureLength.Rows.Count > 0) ds.Tables.Add(MeasureLength);
  2268. if (MeasureHLine.Rows.Count > 0) ds.Tables.Add(MeasureHLine);
  2269. if (MeasureVLine.Rows.Count > 0) ds.Tables.Add(MeasureVLine);
  2270. if (MeasureMulLine.Rows.Count > 0) ds.Tables.Add(MeasureMulLine);
  2271. if (MeasureMulHVLine.Rows.Count > 0) ds.Tables.Add(MeasureMulHVLine);
  2272. if (MeasureMulSegment.Rows.Count > 0) ds.Tables.Add(MeasureMulSegment);
  2273. if (MeasureMulVLine.Rows.Count > 0) ds.Tables.Add(MeasureMulVLine);
  2274. if (MeasureBrokenLine.Rows.Count > 0) ds.Tables.Add(MeasureBrokenLine);
  2275. if (MeasureTraceCurve.Rows.Count > 0) ds.Tables.Add(MeasureTraceCurve);
  2276. if (MeasureCurveLine.Rows.Count > 0) ds.Tables.Add(MeasureCurveLine);
  2277. if (MeasurePLine.Rows.Count > 0) ds.Tables.Add(MeasurePLine);
  2278. if (MeasureMulPLine.Rows.Count > 0) ds.Tables.Add(MeasureMulPLine);
  2279. if (MeasureHMulPLine.Rows.Count > 0) ds.Tables.Add(MeasureHMulPLine);
  2280. if (MeasureVMulPLine.Rows.Count > 0) ds.Tables.Add(MeasureVMulPLine);
  2281. if (MeasureParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureParallelLine);
  2282. if (MeasureMulParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureMulParallelLine);
  2283. if (MeasureVMulParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureVMulParallelLine);
  2284. if (MeasureHMulParallelLine.Rows.Count > 0) ds.Tables.Add(MeasureHMulParallelLine);
  2285. if (MeasureClosedCurve.Rows.Count > 0) ds.Tables.Add(MeasureClosedCurve);
  2286. if (MeasurePolygon.Rows.Count > 0) ds.Tables.Add(MeasurePolygon);
  2287. if (MeasureRectangle.Rows.Count > 0) ds.Tables.Add(MeasureRectangle);
  2288. if (MeasureRandRectangle.Rows.Count > 0) ds.Tables.Add(MeasureRandRectangle);
  2289. if (MeasureSquare.Rows.Count > 0) ds.Tables.Add(MeasureSquare);
  2290. if (MeasureRandSquare.Rows.Count > 0) ds.Tables.Add(MeasureRandSquare);
  2291. if (MeasureTracePolygon.Rows.Count > 0) ds.Tables.Add(MeasureTracePolygon);
  2292. if (MeasureCircle.Rows.Count > 0) ds.Tables.Add(MeasureCircle);
  2293. if (MeasureInnerCircle.Rows.Count > 0) ds.Tables.Add(MeasureInnerCircle);
  2294. if (MeasureOuterCircle.Rows.Count > 0) ds.Tables.Add(MeasureOuterCircle);
  2295. if (MeasureDiameterCircle.Rows.Count > 0) ds.Tables.Add(MeasureDiameterCircle);
  2296. if (MeasurePointEdgeSize.Rows.Count > 0) ds.Tables.Add(MeasurePointEdgeSize);
  2297. if (MeasurePointCenterSize.Rows.Count > 0) ds.Tables.Add(MeasurePointCenterSize);
  2298. if (MeasureThreePointAngle.Rows.Count > 0) ds.Tables.Add(MeasureThreePointAngle);
  2299. if (MeasureFourPointAngle.Rows.Count > 0) ds.Tables.Add(MeasureFourPointAngle);
  2300. if (MeasureThreePointArc.Rows.Count > 0) ds.Tables.Add(MeasureThreePointArc);
  2301. DataToExcle(ds);
  2302. }
  2303. else
  2304. {
  2305. SaveFileDialog exe = new SaveFileDialog();
  2306. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  2307. exe.FilterIndex = 0;
  2308. exe.RestoreDirectory = true;
  2309. //exe.CreatePrompt = true;
  2310. exe.Title = "Export Excel File";
  2311. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  2312. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Measurementdatasheet.Text");
  2313. DialogResult dr = exe.ShowDialog();
  2314. if (dr != DialogResult.OK)
  2315. {
  2316. return;
  2317. }
  2318. DataTable dtb = new DataTable();
  2319. for (int i = 0; i < 18; i++)
  2320. {
  2321. dtb.Columns.Add(i.ToString());
  2322. }
  2323. if (selectedItems1.Count > 0 && this.listView1.Visible)
  2324. {
  2325. for (int j = 0; j < selectedItems1.Count; j++)
  2326. {
  2327. int count = _document.GraphicsList.Count;
  2328. for (int i = 0; i < count; i++)
  2329. {
  2330. if (_document.GraphicsList[i].objectType == DrawClass.Measure && _document.GraphicsList[i] == selectedItems1[j].Tag)
  2331. {
  2332. Dictionary<System.Enum, object> data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
  2333. int[] arr;
  2334. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  2335. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  2336. if (arr != null)
  2337. {
  2338. foreach (int t in arr)
  2339. {
  2340. if (t != 0)
  2341. {
  2342. object v;
  2343. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  2344. models.Add((MeasureAttributes)t, v);
  2345. }
  2346. }
  2347. }
  2348. DataRow row = dtb.NewRow();
  2349. int a = 0;
  2350. foreach (var item in models)
  2351. {
  2352. row[a.ToString()] = item.Value;
  2353. a++;
  2354. }
  2355. dtb.Rows.Add(row);
  2356. row = dtb.NewRow();
  2357. a = 0;
  2358. foreach (var item in data)
  2359. {
  2360. object cnvalue;
  2361. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2362. row[a.ToString()] = item.Value;
  2363. a++;
  2364. }
  2365. dtb.Rows.Add(row);
  2366. row = dtb.NewRow();
  2367. dtb.Rows.Add(row);
  2368. }
  2369. }
  2370. }
  2371. }
  2372. else if (selectedItems2.Count > 0 && this.listView2.Visible)
  2373. {
  2374. ArrayList arrayList = new ArrayList();
  2375. object tag = string.Empty;
  2376. for (int j = 0; j < selectedItems2.Count; j++)
  2377. {
  2378. if (tag != selectedItems2[j].Tag)
  2379. {
  2380. arrayList.Add(selectedItems2[j].Tag);
  2381. }
  2382. tag = selectedItems2[j].Tag;
  2383. }
  2384. foreach (var tags in arrayList)
  2385. {
  2386. int count = _document.GraphicsList.Count;
  2387. for (int i = 0; i < count; i++)
  2388. {
  2389. if (_document.GraphicsList[i].objectType == DrawClass.Measure && _document.GraphicsList[i] == tags)
  2390. {
  2391. Dictionary<System.Enum, object> data = ((MeasureDrawObject)_document.GraphicsList[i]).GetData();
  2392. int[] arr;
  2393. InvariantData.measureRelationAttributes.TryGetValue(_document.GraphicsList[i].drawToolType, out arr);
  2394. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  2395. if (arr != null)
  2396. {
  2397. foreach (int t in arr)
  2398. {
  2399. if (t != 0)
  2400. {
  2401. object v;
  2402. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  2403. models.Add((MeasureAttributes)t, v);
  2404. }
  2405. }
  2406. }
  2407. DataRow row = dtb.NewRow();
  2408. int a = 0;
  2409. foreach (var item in models)
  2410. {
  2411. row[a.ToString()] = item.Value;
  2412. a++;
  2413. }
  2414. dtb.Rows.Add(row);
  2415. row = dtb.NewRow();
  2416. a = 0;
  2417. foreach (var item in data)
  2418. {
  2419. object cnvalue;
  2420. InvariantData.measureAttributes.TryGetValue(item.Key, out cnvalue);
  2421. row[a.ToString()] = item.Value;
  2422. a++;
  2423. }
  2424. dtb.Rows.Add(row);
  2425. row = dtb.NewRow();
  2426. dtb.Rows.Add(row);
  2427. }
  2428. }
  2429. }
  2430. }
  2431. List<DataTable> list = new List<DataTable>();
  2432. list.Add(dtb);
  2433. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false, false, true);
  2434. }
  2435. }
  2436. /// <summary>
  2437. /// 测量统计数据Excel
  2438. /// </summary>
  2439. private void StatisticalDataExcel()
  2440. {
  2441. SaveFileDialog exe = new SaveFileDialog();
  2442. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  2443. exe.FilterIndex = 0;
  2444. exe.RestoreDirectory = true;
  2445. exe.Title = "Export Excel File";
  2446. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  2447. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Statisticaldattable.Text");
  2448. DialogResult dr = exe.ShowDialog();
  2449. if (dr != DialogResult.OK)
  2450. {
  2451. return;
  2452. }
  2453. DataTable dtb = new DataTable();
  2454. for (int c = 0; c < this.listView1.Columns.Count; c++)
  2455. {
  2456. if (c == 1)
  2457. dtb.Columns.Add(PdnResources.GetString("Menu.compute.text"));
  2458. if (c > 1)
  2459. dtb.Columns.Add(listView1.Columns[c].Text);
  2460. }
  2461. ArrayList arrayList1 = new ArrayList();
  2462. ArrayList arrayList2 = new ArrayList();
  2463. ArrayList arrayList3 = new ArrayList();
  2464. ArrayList arrayList4 = new ArrayList();
  2465. ArrayList arrayList5 = new ArrayList();
  2466. Regex r1 = new Regex(@"^[0-9]+$");
  2467. Regex r = new Regex(@"^([0-9]{1,}[.][0-9]*)$");
  2468. for (int j = 2; j < this.listView1.Columns.Count; j++)
  2469. {
  2470. string maxValue = "0";
  2471. string minValue = "0";
  2472. string sumValue = "0";
  2473. string averageValue = "0";
  2474. for (int i = 0; i < this.listView1.Items.Count; i++)
  2475. {
  2476. if (j > 1)
  2477. {
  2478. if ((r.Match(this.listView1.Items[i].SubItems[j].Text).Success
  2479. || r1.Match(this.listView1.Items[i].SubItems[j].Text).Success) && i != 0)
  2480. {
  2481. // 最大值
  2482. if (Convert.ToDouble(this.listView1.Items[i].SubItems[j].Text) > Convert.ToDouble(maxValue))
  2483. maxValue = this.listView1.Items[i].SubItems[j].Text;
  2484. // 最小值
  2485. if (Convert.ToDouble(this.listView1.Items[i].SubItems[j].Text) < Convert.ToDouble(minValue))
  2486. minValue = this.listView1.Items[i].SubItems[j].Text;
  2487. // 和
  2488. sumValue = Math.Round((Convert.ToDouble(sumValue) + Convert.ToDouble(this.listView1.Items[i].SubItems[j].Text)), (int)this.numericUpDown1.Value).ToString();
  2489. // 平均值
  2490. averageValue = Math.Round((Convert.ToDouble(sumValue) / this.listView1.Items.Count), (int)this.numericUpDown1.Value).ToString();
  2491. }
  2492. else
  2493. {
  2494. maxValue = this.listView1.Items[i].SubItems[j].Text;
  2495. minValue = this.listView1.Items[i].SubItems[j].Text;
  2496. sumValue = this.listView1.Items[i].SubItems[j].Text;
  2497. averageValue = this.listView1.Items[i].SubItems[j].Text;
  2498. }
  2499. }
  2500. }
  2501. arrayList1.Add(maxValue);
  2502. arrayList2.Add(minValue);
  2503. arrayList3.Add(averageValue);
  2504. arrayList4.Add(sumValue);
  2505. arrayList5.Add(this.listView1.Items.Count);
  2506. }
  2507. for (int i = 0; i < 5; i++)
  2508. {
  2509. DataRow dataRow = dtb.NewRow();
  2510. string rowHeader = string.Empty;
  2511. ArrayList arrayList = new ArrayList();
  2512. if (i == 0)
  2513. {
  2514. rowHeader = PdnResources.GetString("Menu.Image.Max.Text");
  2515. arrayList = arrayList1;
  2516. }
  2517. else if (i == 1)
  2518. {
  2519. rowHeader = PdnResources.GetString("Menu.Image.Min.Text");
  2520. arrayList = arrayList2;
  2521. }
  2522. else if (i == 2)
  2523. {
  2524. rowHeader = PdnResources.GetString("Menu.averagevalue.text");
  2525. arrayList = arrayList3;
  2526. }
  2527. else if (i == 3)
  2528. {
  2529. rowHeader = PdnResources.GetString("Menu.and.Text");
  2530. arrayList = arrayList4;
  2531. }
  2532. else
  2533. {
  2534. rowHeader = PdnResources.GetString("Menu.count.Text");
  2535. arrayList = arrayList5;
  2536. }
  2537. for (int c = 0; c < this.listView1.Columns.Count; c++)
  2538. {
  2539. if (c == 1)
  2540. dataRow[PdnResources.GetString("Menu.count.Text")] = rowHeader;
  2541. if (c > 1)
  2542. {
  2543. dataRow[listView1.Columns[c].Text] = arrayList[c - 2];
  2544. }
  2545. }
  2546. dtb.Rows.Add(dataRow);
  2547. }
  2548. List<DataTable> list = new List<DataTable>();
  2549. list.Add(dtb);
  2550. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false, false, true);
  2551. }
  2552. /// <summary>
  2553. /// 模板数据Excel
  2554. /// </summary>
  2555. private void TemplateDataExcel()
  2556. {
  2557. DataTable dtb = new DataTable();
  2558. if (this.listView1.Visible)
  2559. {
  2560. for (int c = 1; c < this.listView1.Columns.Count; c++)
  2561. {
  2562. dtb.Columns.Add(listView1.Columns[c].Text);
  2563. }
  2564. for (int i = 0; i < this.listView1.Items.Count; i++)
  2565. {
  2566. DataRow dataRow = dtb.NewRow();
  2567. if (i == 0)
  2568. {
  2569. for (int j = 1; j < this.listView1.Columns.Count; j++)
  2570. {
  2571. dataRow[this.listView1.Columns[j].Text] = this.listView1.Columns[j].Text;
  2572. }
  2573. dtb.Rows.Add(dataRow);
  2574. dataRow = dtb.NewRow();
  2575. }
  2576. for (int j = 1; j < this.listView1.Columns.Count; j++)
  2577. {
  2578. if (this.listView1.Items.Count > i && this.listView1.Items[i].SubItems.Count > j)
  2579. dataRow[this.listView1.Columns[j].Text] = this.listView1.Items[i].SubItems[j].Text;//#20103
  2580. else
  2581. dataRow[this.listView1.Columns[j].Text] = "";
  2582. }
  2583. dtb.Rows.Add(dataRow);
  2584. }
  2585. }
  2586. else
  2587. {
  2588. for (int c = 1; c < this.listView2.Columns.Count; c++)
  2589. {
  2590. dtb.Columns.Add(listView2.Columns[c].Text);
  2591. }
  2592. for (int i = 0; i < this.listView2.Items.Count; i++)
  2593. {
  2594. DataRow dataRow = dtb.NewRow();
  2595. if (i == 0)
  2596. {
  2597. for (int j = 1; j < this.listView2.Columns.Count; j++)
  2598. {
  2599. dataRow[this.listView2.Columns[j].Text] = this.listView2.Columns[j].Text;
  2600. }
  2601. dtb.Rows.Add(dataRow);
  2602. dataRow = dtb.NewRow();
  2603. }
  2604. for (int j = 1; j < this.listView2.Columns.Count; j++)
  2605. {
  2606. if (this.listView2.Items.Count > i && this.listView2.Items[i].SubItems.Count > j)
  2607. dataRow[this.listView2.Columns[j].Text] = this.listView2.Items[i].SubItems[j].Text;
  2608. else
  2609. dataRow[this.listView2.Columns[j].Text] = "";
  2610. }
  2611. dtb.Rows.Add(dataRow);
  2612. }
  2613. }
  2614. datatable = dtb;
  2615. //List<DataTable> list = new List<DataTable>();
  2616. //list.Add(dtb);
  2617. //this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName);
  2618. }
  2619. private DataTable datatable;
  2620. private void InitializeLanguageText()
  2621. {
  2622. this.tabPage1.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Itemizeddatasheet.text");
  2623. this.tabPage2.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Generaldatasheet.text");
  2624. this.comboBox4.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
  2625. this.comboBox3.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
  2626. this.comboBox2.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
  2627. this.label2.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Decimalpoint.text") + ":";
  2628. this.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Listofmeasuringelements.text");
  2629. }
  2630. private void InitializeComponent()
  2631. {
  2632. this.tabControl1 = new System.Windows.Forms.TabControl();
  2633. this.tabPage1 = new System.Windows.Forms.TabPage();
  2634. this.listView1 = new System.Windows.Forms.ListView();
  2635. this.tabPage2 = new System.Windows.Forms.TabPage();
  2636. this.listView2 = new System.Windows.Forms.ListView();
  2637. this.panel1 = new System.Windows.Forms.Panel();
  2638. this.comboBox4 = new System.Windows.Forms.ComboBox();
  2639. this.comboBox3 = new System.Windows.Forms.ComboBox();
  2640. this.comboBox2 = new System.Windows.Forms.ComboBox();
  2641. this.panel2 = new System.Windows.Forms.Panel();
  2642. this.comboBox5 = new System.Windows.Forms.ComboBox();
  2643. this.button1 = new System.Windows.Forms.Button();
  2644. this.button2 = new System.Windows.Forms.Button();
  2645. this.button3 = new System.Windows.Forms.Button();
  2646. this.button4 = new System.Windows.Forms.Button();
  2647. this.button5 = new System.Windows.Forms.Button();
  2648. this.button6 = new System.Windows.Forms.Button();
  2649. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  2650. this.label2 = new System.Windows.Forms.Label();
  2651. this.button7 = new System.Windows.Forms.Button();
  2652. this.tabControl1.SuspendLayout();
  2653. this.tabPage1.SuspendLayout();
  2654. this.tabPage2.SuspendLayout();
  2655. this.panel1.SuspendLayout();
  2656. this.panel2.SuspendLayout();
  2657. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  2658. this.SuspendLayout();
  2659. //
  2660. // tabControl1
  2661. //
  2662. this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  2663. | System.Windows.Forms.AnchorStyles.Left)
  2664. | System.Windows.Forms.AnchorStyles.Right)));
  2665. this.tabControl1.Controls.Add(this.tabPage1);
  2666. this.tabControl1.Controls.Add(this.tabPage2);
  2667. this.tabControl1.Location = new System.Drawing.Point(12, 12);
  2668. this.tabControl1.Name = "tabControl1";
  2669. this.tabControl1.SelectedIndex = 0;
  2670. this.tabControl1.Size = new System.Drawing.Size(898, 369);
  2671. this.tabControl1.TabIndex = 0;
  2672. this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
  2673. //
  2674. // tabPage1
  2675. //
  2676. this.tabPage1.Controls.Add(this.listView1);
  2677. this.tabPage1.Location = new System.Drawing.Point(4, 22);
  2678. this.tabPage1.Name = "tabPage1";
  2679. this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
  2680. this.tabPage1.Size = new System.Drawing.Size(890, 343);
  2681. this.tabPage1.TabIndex = 0;
  2682. this.tabPage1.UseVisualStyleBackColor = true;
  2683. //
  2684. // listView1
  2685. //
  2686. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  2687. | System.Windows.Forms.AnchorStyles.Left)
  2688. | System.Windows.Forms.AnchorStyles.Right)));
  2689. this.listView1.FullRowSelect = true;
  2690. this.listView1.GridLines = true;
  2691. this.listView1.HideSelection = false;
  2692. this.listView1.Location = new System.Drawing.Point(6, 6);
  2693. this.listView1.Margin = new System.Windows.Forms.Padding(0);
  2694. this.listView1.Name = "listView1";
  2695. this.listView1.Size = new System.Drawing.Size(877, 330);
  2696. this.listView1.TabIndex = 0;
  2697. this.listView1.UseCompatibleStateImageBehavior = false;
  2698. this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListView1_SelectedIndexChanged);
  2699. //
  2700. // tabPage2
  2701. //
  2702. this.tabPage2.Controls.Add(this.listView2);
  2703. this.tabPage2.Location = new System.Drawing.Point(4, 22);
  2704. this.tabPage2.Name = "tabPage2";
  2705. this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
  2706. this.tabPage2.Size = new System.Drawing.Size(890, 343);
  2707. this.tabPage2.TabIndex = 1;
  2708. this.tabPage2.UseVisualStyleBackColor = true;
  2709. //
  2710. // listView2
  2711. //
  2712. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  2713. | System.Windows.Forms.AnchorStyles.Left)
  2714. | System.Windows.Forms.AnchorStyles.Right)));
  2715. this.listView2.FullRowSelect = true;
  2716. this.listView2.GridLines = true;
  2717. this.listView2.HideSelection = false;
  2718. this.listView2.Location = new System.Drawing.Point(6, 6);
  2719. this.listView2.Margin = new System.Windows.Forms.Padding(0);
  2720. this.listView2.Name = "listView2";
  2721. this.listView2.Size = new System.Drawing.Size(805, 330);
  2722. this.listView2.TabIndex = 0;
  2723. this.listView2.UseCompatibleStateImageBehavior = false;
  2724. this.listView2.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView2_ItemSelectionChanged);
  2725. //
  2726. // panel1
  2727. //
  2728. this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  2729. this.panel1.Controls.Add(this.comboBox4);
  2730. this.panel1.Controls.Add(this.comboBox3);
  2731. this.panel1.Controls.Add(this.comboBox2);
  2732. this.panel1.Location = new System.Drawing.Point(12, 388);
  2733. this.panel1.Name = "panel1";
  2734. this.panel1.Size = new System.Drawing.Size(618, 45);
  2735. this.panel1.TabIndex = 1;
  2736. //
  2737. // comboBox4
  2738. //
  2739. this.comboBox4.FormattingEnabled = true;
  2740. this.comboBox4.Location = new System.Drawing.Point(382, 11);
  2741. this.comboBox4.Name = "comboBox4";
  2742. this.comboBox4.Size = new System.Drawing.Size(230, 20);
  2743. this.comboBox4.TabIndex = 2;
  2744. this.comboBox4.SelectedIndexChanged += new System.EventHandler(this.comboBox4_SelectedIndexChanged);
  2745. //
  2746. // comboBox3
  2747. //
  2748. this.comboBox3.FormattingEnabled = true;
  2749. this.comboBox3.Location = new System.Drawing.Point(196, 11);
  2750. this.comboBox3.Name = "comboBox3";
  2751. this.comboBox3.Size = new System.Drawing.Size(180, 20);
  2752. this.comboBox3.TabIndex = 1;
  2753. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  2754. //
  2755. // comboBox2
  2756. //
  2757. this.comboBox2.FormattingEnabled = true;
  2758. this.comboBox2.Location = new System.Drawing.Point(10, 11);
  2759. this.comboBox2.Name = "comboBox2";
  2760. this.comboBox2.Size = new System.Drawing.Size(180, 20);
  2761. this.comboBox2.TabIndex = 0;
  2762. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  2763. //
  2764. // panel2
  2765. //
  2766. this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  2767. this.panel2.Controls.Add(this.comboBox5);
  2768. this.panel2.Location = new System.Drawing.Point(12, 388);
  2769. this.panel2.Name = "panel2";
  2770. this.panel2.Size = new System.Drawing.Size(618, 45);
  2771. this.panel2.TabIndex = 3;
  2772. //
  2773. // comboBox5
  2774. //
  2775. this.comboBox5.FormattingEnabled = true;
  2776. this.comboBox5.Location = new System.Drawing.Point(10, 11);
  2777. this.comboBox5.Name = "comboBox5";
  2778. this.comboBox5.Size = new System.Drawing.Size(180, 20);
  2779. this.comboBox5.TabIndex = 0;
  2780. this.comboBox5.SelectedIndexChanged += new System.EventHandler(this.comboBox5_SelectedIndexChanged);
  2781. //
  2782. // button1
  2783. //
  2784. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2785. this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
  2786. this.button1.Location = new System.Drawing.Point(686, 5);
  2787. this.button1.Name = "button1";
  2788. this.button1.Size = new System.Drawing.Size(29, 23);
  2789. this.button1.TabIndex = 2;
  2790. this.button1.UseVisualStyleBackColor = true;
  2791. this.button1.Click += new System.EventHandler(this.button1_Click);
  2792. //
  2793. // button2
  2794. //
  2795. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2796. this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
  2797. this.button2.Location = new System.Drawing.Point(721, 5);
  2798. this.button2.Name = "button2";
  2799. this.button2.Size = new System.Drawing.Size(33, 23);
  2800. this.button2.TabIndex = 3;
  2801. this.button2.UseVisualStyleBackColor = true;
  2802. this.button2.Click += new System.EventHandler(this.button2_Click);
  2803. //
  2804. // button3
  2805. //
  2806. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2807. this.button3.Cursor = System.Windows.Forms.Cursors.Hand;
  2808. this.button3.Location = new System.Drawing.Point(760, 5);
  2809. this.button3.Name = "button3";
  2810. this.button3.Size = new System.Drawing.Size(33, 23);
  2811. this.button3.TabIndex = 4;
  2812. this.button3.UseVisualStyleBackColor = true;
  2813. this.button3.Click += new System.EventHandler(this.button3_Click);
  2814. //
  2815. // button4
  2816. //
  2817. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2818. this.button4.Cursor = System.Windows.Forms.Cursors.Hand;
  2819. this.button4.Location = new System.Drawing.Point(799, 5);
  2820. this.button4.Name = "button4";
  2821. this.button4.Size = new System.Drawing.Size(33, 23);
  2822. this.button4.TabIndex = 5;
  2823. this.button4.UseVisualStyleBackColor = true;
  2824. this.button4.Click += new System.EventHandler(this.button4_Click);
  2825. //
  2826. // button5
  2827. //
  2828. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2829. this.button5.Cursor = System.Windows.Forms.Cursors.Hand;
  2830. this.button5.Location = new System.Drawing.Point(838, 5);
  2831. this.button5.Name = "button5";
  2832. this.button5.Size = new System.Drawing.Size(33, 23);
  2833. this.button5.TabIndex = 6;
  2834. this.button5.UseVisualStyleBackColor = true;
  2835. this.button5.Click += new System.EventHandler(this.button5_Click);
  2836. //
  2837. // button6
  2838. //
  2839. this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2840. this.button6.Cursor = System.Windows.Forms.Cursors.Hand;
  2841. this.button6.Location = new System.Drawing.Point(877, 5);
  2842. this.button6.Name = "button6";
  2843. this.button6.Size = new System.Drawing.Size(33, 23);
  2844. this.button6.TabIndex = 7;
  2845. this.button6.UseVisualStyleBackColor = true;
  2846. this.button6.Click += new System.EventHandler(this.button6_Click);
  2847. //
  2848. // numericUpDown1
  2849. //
  2850. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  2851. this.numericUpDown1.Location = new System.Drawing.Point(831, 399);
  2852. this.numericUpDown1.Maximum = new decimal(new int[] {
  2853. 10,
  2854. 0,
  2855. 0,
  2856. 0});
  2857. this.numericUpDown1.Minimum = new decimal(new int[] {
  2858. 2,
  2859. 0,
  2860. 0,
  2861. 0});
  2862. this.numericUpDown1.Name = "numericUpDown1";
  2863. this.numericUpDown1.Size = new System.Drawing.Size(75, 21);
  2864. this.numericUpDown1.TabIndex = 11;
  2865. this.numericUpDown1.Value = new decimal(new int[] {
  2866. 2,
  2867. 0,
  2868. 0,
  2869. 0});
  2870. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  2871. //
  2872. // label2
  2873. //
  2874. this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  2875. this.label2.AutoSize = true;
  2876. this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
  2877. this.label2.Location = new System.Drawing.Point(771, 403);
  2878. this.label2.Name = "label2";
  2879. this.label2.Size = new System.Drawing.Size(53, 12);
  2880. this.label2.TabIndex = 10;
  2881. this.label2.Text = "小数点:";
  2882. //
  2883. // button7
  2884. //
  2885. this.button7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  2886. this.button7.Cursor = System.Windows.Forms.Cursors.Hand;
  2887. this.button7.Location = new System.Drawing.Point(651, 5);
  2888. this.button7.Name = "button7";
  2889. this.button7.Size = new System.Drawing.Size(29, 23);
  2890. this.button7.TabIndex = 12;
  2891. this.button7.UseVisualStyleBackColor = true;
  2892. this.button7.Click += new System.EventHandler(this.button7_Click);
  2893. //
  2894. // MeasureListDialog
  2895. //
  2896. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  2897. this.BackColor = System.Drawing.SystemColors.Control;
  2898. this.ClientSize = new System.Drawing.Size(922, 442);
  2899. this.Controls.Add(this.button7);
  2900. this.Controls.Add(this.panel2);
  2901. this.Controls.Add(this.numericUpDown1);
  2902. this.Controls.Add(this.label2);
  2903. this.Controls.Add(this.button6);
  2904. this.Controls.Add(this.button5);
  2905. this.Controls.Add(this.button4);
  2906. this.Controls.Add(this.button3);
  2907. this.Controls.Add(this.button2);
  2908. this.Controls.Add(this.button1);
  2909. this.Controls.Add(this.panel1);
  2910. this.Controls.Add(this.tabControl1);
  2911. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
  2912. this.Name = "MeasureListDialog";
  2913. this.Text = "测量元素列表";
  2914. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MeasureListDialog_FormClosing);
  2915. this.Load += new System.EventHandler(this.MeasureListDialog_Load);
  2916. this.Controls.SetChildIndex(this.tabControl1, 0);
  2917. this.Controls.SetChildIndex(this.panel1, 0);
  2918. this.Controls.SetChildIndex(this.button1, 0);
  2919. this.Controls.SetChildIndex(this.button2, 0);
  2920. this.Controls.SetChildIndex(this.button3, 0);
  2921. this.Controls.SetChildIndex(this.button4, 0);
  2922. this.Controls.SetChildIndex(this.button5, 0);
  2923. this.Controls.SetChildIndex(this.button6, 0);
  2924. this.Controls.SetChildIndex(this.label2, 0);
  2925. this.Controls.SetChildIndex(this.numericUpDown1, 0);
  2926. this.Controls.SetChildIndex(this.panel2, 0);
  2927. this.Controls.SetChildIndex(this.button7, 0);
  2928. this.tabControl1.ResumeLayout(false);
  2929. this.tabPage1.ResumeLayout(false);
  2930. this.tabPage2.ResumeLayout(false);
  2931. this.panel1.ResumeLayout(false);
  2932. this.panel2.ResumeLayout(false);
  2933. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  2934. this.ResumeLayout(false);
  2935. this.PerformLayout();
  2936. }
  2937. /// <summary>
  2938. /// 总数据表,一级下拉改变事件
  2939. /// </summary>
  2940. /// <param name="sender"></param>
  2941. /// <param name="e"></param>
  2942. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  2943. {
  2944. if (this.comboBox2.SelectedIndex == 0)
  2945. {
  2946. if (this.comboBox3.Items.Count > 0)
  2947. {
  2948. this.comboBox3.DataSource = null;
  2949. this.comboBox3.Text = PdnResources.GetString("Menu.Pleaseselect.Text");
  2950. this.comboBox3.Items.Clear();
  2951. }
  2952. }
  2953. else
  2954. {
  2955. model = list.Find(a => a.id == this.comboBox2.SelectedIndex);
  2956. this.comboBox3.DataSource = model.childLabel;
  2957. this.comboBox3.DisplayMember = "name";
  2958. this.comboBox3.ValueMember = "drawToolType";
  2959. }
  2960. this.listView2.Items.Clear();
  2961. this.InitialMasterDataSheetData();
  2962. }
  2963. /// <summary>
  2964. /// 总数据表,二级下拉改变事件
  2965. /// </summary>
  2966. /// <param name="sender"></param>
  2967. /// <param name="e"></param>
  2968. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  2969. {
  2970. if (this.comboBox3.SelectedIndex <= 0)
  2971. {
  2972. this.comboBox4.DataSource = new BindingSource(InvariantData.measureAttributes, null);
  2973. this.comboBox4.DisplayMember = "Value";
  2974. this.comboBox4.ValueMember = "Key";
  2975. }
  2976. else
  2977. {
  2978. int[] arr;
  2979. InvariantData.measureRelationAttributes.TryGetValue(model.childLabel[this.comboBox3.SelectedIndex].drawToolType, out arr);
  2980. if (arr != null)
  2981. {
  2982. Dictionary<Enum, Object> models = new Dictionary<Enum, object>();
  2983. foreach (int t in arr)
  2984. {
  2985. object v;
  2986. InvariantData.measureAttributes.TryGetValue((MeasureAttributes)t, out v);
  2987. models.Add((DrawToolType)t, v);
  2988. }
  2989. //Dictionary<Enum, Object> models = (Dictionary<Enum, Object>)InvariantData.measureAttributes.Keys.(a=> arr.Contains((int)((DrawToolType)a)));
  2990. this.comboBox4.DataSource = new BindingSource(models, null);
  2991. this.comboBox4.DisplayMember = "Value";
  2992. this.comboBox4.ValueMember = "Key";
  2993. }
  2994. else
  2995. {
  2996. this.comboBox4.DataSource = new BindingSource(InvariantData.measureAttributes, null);
  2997. this.comboBox4.DisplayMember = "Value";
  2998. this.comboBox4.ValueMember = "Key";
  2999. }
  3000. }
  3001. this.listView2.Items.Clear();
  3002. this.InitialMasterDataSheetData();
  3003. }
  3004. /// <summary>
  3005. /// 总数据表,三级下拉改变事件
  3006. /// </summary>
  3007. /// <param name="sender"></param>
  3008. /// <param name="e"></param>
  3009. private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
  3010. {
  3011. this.listView2.Items.Clear();
  3012. this.InitialMasterDataSheetData();
  3013. }
  3014. private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
  3015. {
  3016. if (this.tabControl1.SelectedIndex == 0)
  3017. {
  3018. this.panel1.Visible = false;
  3019. this.panel2.Visible = true;
  3020. }
  3021. else if (this.tabControl1.SelectedIndex == 1)
  3022. {
  3023. this.panel1.Visible = true;
  3024. this.panel2.Visible = false;
  3025. }
  3026. }
  3027. /// <summary>
  3028. /// listView1 ItemSelectionChanged事件
  3029. /// </summary>
  3030. /// <param name="sender"></param>
  3031. /// <param name="e"></param>
  3032. private void ListView1_SelectedIndexChanged(object sender, EventArgs e)
  3033. {
  3034. if (this.listView1.SelectedItems.Count > 0)
  3035. {
  3036. var senderGrid = (ListView)sender;
  3037. var selectedItems = senderGrid.SelectedItems;
  3038. if (selectedItems.Count > 0)
  3039. {
  3040. DrawObject dObject;
  3041. _document.GraphicsList.UnselectAll();
  3042. for (int i = 0; i < selectedItems.Count; i++)
  3043. {
  3044. dObject = (DrawObject)senderGrid.SelectedItems[i].Tag;
  3045. dObject.Selected = true;
  3046. }
  3047. _document.Refresh();
  3048. }
  3049. this.listView1.EndUpdate();
  3050. }
  3051. }
  3052. /// <summary>
  3053. /// listView2 ItemSelectionChanged事件
  3054. /// </summary>
  3055. /// <param name="sender"></param>
  3056. /// <param name="e"></param>
  3057. private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
  3058. {
  3059. if (this.listView2.SelectedItems.Count > 0)
  3060. {
  3061. var senderGrid = (ListView)sender;
  3062. var selectedItems = senderGrid.SelectedItems;
  3063. if (selectedItems.Count > 0)
  3064. {
  3065. DrawObject dObject;
  3066. _document.GraphicsList.UnselectAll();
  3067. for (int i = 0; i < selectedItems.Count; i++)
  3068. {
  3069. dObject = (DrawObject)senderGrid.SelectedItems[i].Tag;
  3070. dObject.Selected = true;
  3071. }
  3072. _document.Refresh();
  3073. }
  3074. this.listView2.EndUpdate();
  3075. }
  3076. }
  3077. /// <summary>
  3078. /// 分项数据表 测量方式下拉改变事件
  3079. /// </summary>
  3080. /// <param name="sender"></param>
  3081. /// <param name="e"></param>
  3082. private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
  3083. {
  3084. this.listView1.Clear();
  3085. this.InitializeItemizedHeader();
  3086. this.InitializeItemizedData();
  3087. }
  3088. /// <summary>
  3089. /// 单位下拉改变事件
  3090. /// </summary>
  3091. /// <param name="sender"></param>
  3092. /// <param name="e"></param>
  3093. //private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  3094. //{
  3095. // if (this.comboBox1.SelectedIndex > -1 && _document != null)
  3096. // {
  3097. // _document.UpdateMeasureUnit((MeasurementUnit)(this.comboBox1.SelectedIndex + 1));// + 1
  3098. // this.listView1.Items.Clear();
  3099. // this.InitializeItemizedData();
  3100. // this.listView2.Items.Clear();
  3101. // this.InitialMasterDataSheetData();
  3102. // }
  3103. //}
  3104. /// <summary>
  3105. /// 小数点位数更改事件
  3106. /// </summary>
  3107. /// <param name="sender"></param>
  3108. /// <param name="e"></param>
  3109. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  3110. {
  3111. if (!string.IsNullOrEmpty(numericUpDown1.Value.ToString()))
  3112. {
  3113. this.UpdateMeasureDecimalPlaces((int)numericUpDown1.Value);
  3114. if (this.appWorkspace.Widgets != null)
  3115. this.appWorkspace.Widgets.GeometryMeasureDialog.numericUpDown5.Value = numericUpDown1.Value;
  3116. //_document.UpdateMeasureDecimalPlaces((int)numericUpDown1.Value);
  3117. this.listView1.Items.Clear();
  3118. this.InitializeItemizedData();
  3119. this.listView2.Items.Clear();
  3120. this.InitialMasterDataSheetData();
  3121. }
  3122. }
  3123. /// <summary>
  3124. /// 更新小数位数
  3125. /// </summary>
  3126. /// <param name="decimalPlaces"></param>
  3127. public void UpdateMeasureDecimalPlaces(int praDecimalPlaces)
  3128. {
  3129. MeasureDrawObject.decimalPlaces = praDecimalPlaces;
  3130. if (_document != null)
  3131. {
  3132. for (int i = 0; i < _document.GraphicsList.Count; i++)
  3133. {
  3134. if (!"Measure".Equals(_document.GraphicsList[i].objectType.ToString()))
  3135. continue;
  3136. ((MeasureDrawObject)_document.GraphicsList[i]).mouseUpAttribute = true;
  3137. }
  3138. _document.Refresh();
  3139. }
  3140. }
  3141. /// <summary>
  3142. /// 设置按钮按下
  3143. /// </summary>
  3144. /// <param name="sender"></param>
  3145. /// <param name="e"></param>
  3146. private void button1_Click(object sender, EventArgs e)
  3147. {
  3148. using (MeasureListSetDialog dialog = new MeasureListSetDialog(this.appWorkspace, drawNodes, dataNodes, allDrawNodes, allDataNodes))
  3149. {
  3150. dialog.StartPosition = FormStartPosition.CenterParent;
  3151. dialog.ShowDialog();
  3152. }
  3153. }
  3154. /// <summary>
  3155. /// 导出到模板
  3156. /// </summary>
  3157. /// <param name="sender"></param>
  3158. /// <param name="e"></param>
  3159. private void button2_Click(object sender, EventArgs e)
  3160. {
  3161. //if(this.listView2.Items.Count > 0)
  3162. this.TemplateDataExcel();
  3163. //else
  3164. // MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text")+"!", PdnResources.GetString("Menu.hint.text"));
  3165. MeasureListSettingDialog measureListSettingDialog = new MeasureListSettingDialog(this, "Template.Manager.item1.MeasureList", this.appWorkspace, datatable);
  3166. if (measureListSettingDialog.hasModule)
  3167. {
  3168. measureListSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  3169. measureListSettingDialog.ShowDialog();
  3170. }
  3171. else
  3172. {
  3173. measureListSettingDialog = null;
  3174. }
  3175. }
  3176. /// <summary>
  3177. /// 数据统计导出到Excel
  3178. /// </summary>
  3179. /// <param name="sender"></param>
  3180. /// <param name="e"></param>
  3181. private void button3_Click(object sender, EventArgs e)
  3182. {
  3183. if (this.listView1.Items.Count == 0)
  3184. {
  3185. MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
  3186. return;
  3187. }
  3188. if (!this.listView1.Visible)
  3189. {
  3190. MessageBox.Show(PdnResources.GetString("Menu.Thetotaldatatableisnotstatistical.Text") + "!", PdnResources.GetString("Menu.hint.text"));
  3191. return;
  3192. }
  3193. MeasureListStatisticalDataDialog measureListStatisticalDataDialog = new MeasureListStatisticalDataDialog(this.appWorkspace, this.listView1, this.comboBox5.SelectedIndex);
  3194. measureListStatisticalDataDialog.StartPosition = FormStartPosition.CenterParent;
  3195. measureListStatisticalDataDialog.ShowDialog();
  3196. //if (this.listView1.Items.Count > 0)
  3197. //{
  3198. // if(this.listView1.Visible)
  3199. // this.StatisticalDataExcel();
  3200. // else
  3201. // MessageBox.Show(PdnResources.GetString("Menu.Thetotaldatatableisnotstatistical.Text")+"!", PdnResources.GetString("Menu.hint.text"));
  3202. //}
  3203. //else
  3204. // MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text")+"!", PdnResources.GetString("Menu.hint.text"));
  3205. //if (this.listView1.Items.Count > 0)
  3206. //{
  3207. // if(this.listView1.Visible)
  3208. // this.StatisticalDataExcel();
  3209. // else
  3210. // MessageBox.Show(PdnResources.GetString("Menu.Thetotaldatatableisnotstatistical.Text")+"!", PdnResources.GetString("Menu.hint.text"));
  3211. //}
  3212. //else
  3213. // MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text")+"!", PdnResources.GetString("Menu.hint.text"));
  3214. }
  3215. /// <summary>
  3216. /// 选择清除按钮按下事件
  3217. /// </summary>
  3218. /// <param name="sender"></param>
  3219. /// <param name="e"></param>
  3220. private void button4_Click(object sender, EventArgs e)
  3221. {
  3222. if (this.listView2.Items.Count == 0)
  3223. {
  3224. MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
  3225. }
  3226. else
  3227. {
  3228. var selectedItems1 = this.listView1.SelectedItems;
  3229. var selectedItems2 = this.listView2.SelectedItems;
  3230. if (selectedItems1.Count == 0 && selectedItems2.Count == 0)
  3231. {
  3232. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text") + "!", PdnResources.GetString("Menu.hint.text"));
  3233. }
  3234. else
  3235. {
  3236. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Aresuredeletemeasurementdata.Text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3237. if (dr == DialogResult.OK)
  3238. {
  3239. // 分项数据表
  3240. if (selectedItems1.Count > 0 && this.listView1.Visible)
  3241. {
  3242. int index1 = this.listView1.SelectedIndices[0];
  3243. if (_document != null)
  3244. {
  3245. for (int i = _document.GraphicsList.Count - 1; i >= 0; i--)
  3246. {
  3247. if (_document.GraphicsList[i] == this.listView1.Items[index1].Tag)
  3248. {
  3249. _document.GraphicsList.RemoveAt(i);
  3250. break;
  3251. }
  3252. }
  3253. if (_document.GraphicsList.Count > 0)
  3254. {
  3255. this.InitializeItemizedComboBox();
  3256. this.InitializeItemizedHeader();
  3257. this.listView1.Items.Clear();
  3258. this.InitializeItemizedData();
  3259. this.listView2.Items.Clear();
  3260. this.InitialMasterDataSheetData();
  3261. }
  3262. else
  3263. {
  3264. this.listView2.Clear();
  3265. this.listView1.Clear();
  3266. this.comboBox5.DataSource = null;
  3267. }
  3268. _document.Refresh();
  3269. }
  3270. }
  3271. // 总数据表
  3272. if (selectedItems2.Count > 0 && this.listView2.Visible)
  3273. {
  3274. int index2 = this.listView2.SelectedIndices[0];
  3275. if (_document != null)
  3276. {
  3277. for (int i = _document.GraphicsList.Count - 1; i >= 0; i--)
  3278. {
  3279. if (_document.GraphicsList[i] == this.listView2.Items[index2].Tag)
  3280. {
  3281. _document.GraphicsList.RemoveAt(i);
  3282. break;
  3283. }
  3284. }
  3285. if (_document.GraphicsList.Count > 0)
  3286. {
  3287. this.InitializeItemizedComboBox();
  3288. this.InitializeItemizedHeader();
  3289. this.listView1.Items.Clear();
  3290. this.InitializeItemizedData();
  3291. this.listView2.Items.Clear();
  3292. this.InitialMasterDataSheetData();
  3293. }
  3294. else
  3295. {
  3296. this.listView2.Clear();
  3297. this.listView1.Clear();
  3298. this.comboBox5.DataSource = null;
  3299. }
  3300. _document.Refresh();
  3301. }
  3302. }
  3303. }
  3304. }
  3305. }
  3306. }
  3307. /// <summary>
  3308. /// /// 清除按钮按下事件
  3309. /// /// </summary>
  3310. /// /// <param name="sender"></param>
  3311. /// /// <param name="e"></param>
  3312. private void button5_Click(object sender, EventArgs e)
  3313. {
  3314. if (this.listView2.Items.Count == 0)
  3315. {
  3316. MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
  3317. }
  3318. else
  3319. {
  3320. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Aresuredeletemeasurementdata.Text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3321. if (dr == DialogResult.OK)
  3322. {
  3323. // 分项数据表
  3324. if (this.listView1.Visible)
  3325. {
  3326. if (this.comboBox5.SelectedIndex >= 0)
  3327. {
  3328. if (_document != null)
  3329. {
  3330. for (int i = _document.GraphicsList.Count - 1; i >= 0; i--)
  3331. {
  3332. if (_document.GraphicsList[i].drawToolType == (DrawToolType)this.comboBox5.SelectedValue)
  3333. {
  3334. _document.GraphicsList.RemoveAt(i);
  3335. }
  3336. }
  3337. if (_document.GraphicsList.Count > 0)
  3338. {
  3339. this.InitializeItemizedComboBox();
  3340. this.InitializeItemizedHeader();
  3341. this.InitializeItemizedData();
  3342. this.listView2.Items.Clear();
  3343. this.InitialMasterDataSheetData();
  3344. }
  3345. else
  3346. {
  3347. this.listView2.Clear();
  3348. this.listView1.Clear();
  3349. this.comboBox5.DataSource = null;
  3350. }
  3351. _document.Refresh();
  3352. }
  3353. }
  3354. }
  3355. // 总数据表
  3356. if (this.listView2.Visible)
  3357. {
  3358. if (_document != null)
  3359. {
  3360. _document.GraphicsList.Clear();
  3361. _document.Refresh();
  3362. this.listView2.Items.Clear();
  3363. this.listView1.Clear();
  3364. this.comboBox5.DataSource = null;
  3365. this.comboBox2.SelectedIndex = 0;
  3366. }
  3367. }
  3368. }
  3369. }
  3370. }
  3371. /// <summary>
  3372. /// 导出数据到Excel按钮按下
  3373. /// </summary>
  3374. /// <param name="sender"></param>
  3375. /// <param name="e"></param>
  3376. private void button6_Click(object sender, EventArgs e)
  3377. {
  3378. if (this.listView2.Items.Count > 0)
  3379. this.InitialDataExcel();
  3380. else
  3381. MessageBox.Show(PdnResources.GetString("Menu.Thereisnomeasurementdata.Text") + "!", PdnResources.GetString("Menu.hint.text"));
  3382. }
  3383. /// <summary>
  3384. /// 导出多 Sheet 报表
  3385. /// </summary>
  3386. /// <param name="ds">要导出的数据</param>
  3387. public void DataToExcle(System.Data.DataSet ds)
  3388. {
  3389. try
  3390. {
  3391. if (ds.Tables == null || ds.Tables.Count == 0)
  3392. {
  3393. MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text") + "!");
  3394. return;
  3395. }
  3396. SaveFileDialog saveFileDialog = new SaveFileDialog();
  3397. saveFileDialog.DefaultExt = "xlsx";
  3398. saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
  3399. saveFileDialog.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Measurementdatasheet.Text");
  3400. saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
  3401. saveFileDialog.RestoreDirectory = true;
  3402. if (saveFileDialog.ShowDialog() == DialogResult.OK)
  3403. {
  3404. System.Reflection.Missing miss = System.Reflection.Missing.Value;
  3405. Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();
  3406. Workbooks workbooks = xlapp.Workbooks;
  3407. Workbook workbook = workbooks.Add(true);
  3408. if (ds.Tables.Count > 1)
  3409. {
  3410. workbook.Sheets.Add(miss, workbook.Sheets[1], ds.Tables.Count - 1, miss);
  3411. }
  3412. for (int d = 0; d < ds.Tables.Count; d++)
  3413. {
  3414. Worksheet ws = workbook.Worksheets[d + 1] as Worksheet;
  3415. ws.Name = ds.Tables[d].TableName;
  3416. int totalCellsCount = ds.Tables[d].Columns.Count;
  3417. Range range = ws.Range[ws.Cells[1, 1], ws.Cells[1, ds.Tables[d].Columns.Count]];
  3418. //生成列
  3419. for (int i = 0; i < ds.Tables[d].Columns.Count; i++)
  3420. {
  3421. range.EntireColumn.AutoFit();
  3422. range.EntireRow.AutoFit();
  3423. }
  3424. //插入数据
  3425. for (int r = 0; r < ds.Tables[d].Rows.Count; r++)
  3426. {
  3427. for (int i = 0; i < ds.Tables[d].Columns.Count; i++)
  3428. {
  3429. ws.Cells[r + 1, i + 1] = "'" + ds.Tables[d].Rows[r][i].ToString();
  3430. }
  3431. }
  3432. System.Runtime.InteropServices.Marshal.ReleaseComObject(range);
  3433. range = null;
  3434. System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
  3435. ws = null;
  3436. }
  3437. ((Worksheet)workbook.Sheets[1]).Select(true);//选中第一个worksheet
  3438. workbook.SaveAs(saveFileDialog.FileName, miss, miss, miss, miss, miss, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, miss, miss, miss);
  3439. System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook);
  3440. workbook = null;
  3441. xlapp.Quit();
  3442. System.Runtime.InteropServices.Marshal.ReleaseComObject(xlapp);
  3443. xlapp = null;
  3444. GC.Collect();
  3445. GC.WaitForPendingFinalizers();
  3446. }
  3447. }
  3448. catch (Exception e)
  3449. {
  3450. throw e;
  3451. }
  3452. }
  3453. private void MeasureListDialog_Load(object sender, EventArgs e)
  3454. {
  3455. if (this.appWorkspace != null)
  3456. {
  3457. this.appWorkspace.RefreshListView();
  3458. }
  3459. }
  3460. private void MeasureListDialog_FormClosing(object sender, FormClosingEventArgs e)
  3461. {
  3462. appWorkspace.Widgets.MeasureListDialog.Visible = false;
  3463. this.appWorkspace.toolBar.RefreshBtnSelect(false, "MeasureList");
  3464. this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "MeasureList");
  3465. saveLastData();
  3466. }
  3467. /// <summary>
  3468. /// 总数据导出
  3469. /// </summary>
  3470. /// <param name="sender"></param>
  3471. /// <param name="e"></param>
  3472. private void button7_Click(object sender, EventArgs e)
  3473. {
  3474. DataTable dtb = new DataTable();
  3475. for (int c = 0; c < 5; c++)
  3476. {
  3477. dtb.Columns.Add(c.ToString());
  3478. }
  3479. // 单位
  3480. DataRow dataRow = dtb.NewRow();
  3481. dataRow[0] = "单位";
  3482. dataRow[1] = this.appWorkspace.GetPxPerUnit()[2];
  3483. dtb.Rows.Add(dataRow);
  3484. // 标题
  3485. dataRow = dtb.NewRow();
  3486. dataRow[0] = "图片名称";
  3487. dataRow[1] = "分组";
  3488. dataRow[2] = "测量工具名称";
  3489. dataRow[3] = "测量属性名称";
  3490. dataRow[4] = "值";
  3491. dtb.Rows.Add(dataRow);
  3492. // 所有图片
  3493. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  3494. {
  3495. // 图片名称
  3496. string imgName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  3497. List<string> measures = new List<string>();
  3498. // 所有测量工具
  3499. for (int g = this.appWorkspace.DocumentWorkspaces[i].GraphicsList.Count - 1; g >= 0; g--)
  3500. {
  3501. if (this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].objectType == DrawClass.Measure)
  3502. {
  3503. measures.Add(this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType.ToString());
  3504. // 测量数据
  3505. Dictionary<System.Enum, object> data = ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).GetData();
  3506. // 测量工具名称
  3507. string drawName = PdnResources.GetString("Menu.MeasureAction." + this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType.ToString() + ".Text");
  3508. string[] drawingPropertiesList;
  3509. ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).drawingProperties.TryGetValue(this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType, out drawingPropertiesList);
  3510. int addCount = 0;
  3511. foreach (var measure in measures)
  3512. {
  3513. if (measure.Equals(this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g].drawToolType.ToString()))
  3514. addCount++;
  3515. }
  3516. // 所有可见的属性
  3517. foreach (var item in drawingPropertiesList)
  3518. {
  3519. dataRow = dtb.NewRow();
  3520. string itemFirst = item.Substring(0, 1);
  3521. string itemToLower = item.Substring(1, item.Length - 1).ToLower();
  3522. string itemAll = itemFirst + itemToLower;
  3523. // 测量属性名称
  3524. string attributeName = PdnResources.GetString("Menu." + itemAll + ".text");
  3525. // 属性值
  3526. object value;
  3527. MeasureAttributes type = (MeasureAttributes)System.Enum.Parse(typeof(MeasureAttributes), item);
  3528. data.TryGetValue(type, out value);
  3529. dataRow[0] = imgName;
  3530. dataRow[1] = addCount;
  3531. dataRow[2] = drawName;
  3532. dataRow[3] = attributeName;
  3533. dataRow[4] = value;
  3534. dtb.Rows.Add(dataRow);
  3535. }
  3536. if (((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).lengthParagraphs != null
  3537. && ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).lengthParagraphs.Count > 0)
  3538. {
  3539. int length = 0;
  3540. foreach (var lengthParagraph in ((MeasureDrawObject)this.appWorkspace.DocumentWorkspaces[i].GraphicsList[g]).lengthParagraphs)
  3541. {
  3542. length++;
  3543. dataRow = dtb.NewRow();
  3544. dataRow[0] = imgName;
  3545. dataRow[1] = addCount;
  3546. dataRow[2] = drawName;
  3547. dataRow[3] = "物理长度(段" + length + ")";
  3548. dataRow[4] = lengthParagraph;
  3549. dtb.Rows.Add(dataRow);
  3550. }
  3551. }
  3552. }
  3553. }
  3554. }
  3555. MeasureListSettingDialog measureListSettingDialog = new MeasureListSettingDialog(this, "Template.Manager.item1.MeasureListAll", this.appWorkspace, dtb);
  3556. if (measureListSettingDialog.hasModule)
  3557. {
  3558. measureListSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  3559. measureListSettingDialog.ShowDialog();
  3560. }
  3561. else
  3562. {
  3563. measureListSettingDialog = null;
  3564. }
  3565. }
  3566. /// <summary>
  3567. /// 获取上次操作参数
  3568. /// </summary>
  3569. private void getLastData()
  3570. {
  3571. string filePath = System.Windows.Forms.Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterMeasureModel.xml";
  3572. if (!System.IO.File.Exists(filePath))
  3573. {
  3574. measureModel = new MeasureModel();
  3575. measureModel.MeasureListModels = new MeasureModel.MeasureListModel();
  3576. measureModel.MeasureListModels.hasUsed = false;
  3577. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<MeasureModel>(measureModel);
  3578. Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  3579. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  3580. }
  3581. else
  3582. {
  3583. measureModel = XmlSerializeHelper.DESerializer<MeasureModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  3584. if (measureModel.MeasureListModels == null)
  3585. {
  3586. measureModel.MeasureListModels = new MeasureModel.MeasureListModel();
  3587. }
  3588. if (measureModel.MeasureListModels.hasUsed)
  3589. {
  3590. numericUpDown1.Value = measureModel.MeasureListModels.parameter1;
  3591. }
  3592. }
  3593. }
  3594. /// <summary>
  3595. /// 保存上次操作参数
  3596. /// </summary>
  3597. private void saveLastData()
  3598. {
  3599. if (measureModel.MeasureListModels == null)
  3600. {
  3601. measureModel.MeasureListModels = new MeasureModel.MeasureListModel();
  3602. }
  3603. measureModel.MeasureListModels.hasUsed = true;
  3604. measureModel.MeasureListModels.parameter1 = Convert.ToInt32(numericUpDown1.Value);
  3605. string filePath = System.Windows.Forms.Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterMeasureModel.xml";
  3606. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<MeasureModel>(measureModel);
  3607. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  3608. }
  3609. }
  3610. }