MeasureListDialog.cs 195 KB

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