DataOut.cs
上传用户:chizxy
上传日期:2014-11-29
资源大小:407k
文件大小:16k
源码类别:

其他行业

开发平台:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace MKIms3
  7. {
  8. /// <summary>
  9. /// DataOut 的摘要说明。
  10. /// </summary>
  11. public class DataOut : System.Windows.Forms.Form
  12. {
  13. string[] dateset;
  14. /// <summary>
  15. /// 必需的设计器变量。
  16. /// </summary>
  17. /// 
  18. public SuperMapLib.soDataPump myPump;
  19. private SuperMapLib.soExportParams myExport;
  20. private System.Windows.Forms.GroupBox groupBox1;
  21. private System.Windows.Forms.GroupBox groupBox2;
  22. private System.Windows.Forms.Label label3;
  23. private System.Windows.Forms.Label label4;
  24. private System.Windows.Forms.Button btn_url;
  25. private System.Windows.Forms.Label label5;
  26. private System.Windows.Forms.PictureBox pictureBox1;
  27. private System.Windows.Forms.Button btn_ok;
  28. private System.Windows.Forms.Button btn_esc;
  29. private System.Windows.Forms.ColumnHeader 源数据集名;
  30. private System.Windows.Forms.ColumnHeader 目标数据集名;
  31. private System.Windows.Forms.ListView listView_data;
  32. private System.Windows.Forms.ComboBox comboBox_file;
  33. private System.Windows.Forms.TextBox txt_url;
  34. private System.Windows.Forms.ComboBox comboBox_unit;
  35. private System.Windows.Forms.Button btn_select_all;
  36. private System.Windows.Forms.Button btn_select_no;
  37. private System.Windows.Forms.ColumnHeader 状态;
  38. private System.Windows.Forms.PictureBox pictureBox2;
  39. private System.ComponentModel.Container components = null;
  40. public DataOut(string[] dataset)
  41. {
  42. //
  43. // Windows 窗体设计器支持所必需的
  44. //
  45. InitializeComponent();
  46. //
  47. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  48. //
  49. this.dateset = dataset;
  50. }
  51. /// <summary>
  52. /// 清理所有正在使用的资源。
  53. /// </summary>
  54. protected override void Dispose( bool disposing )
  55. {
  56. if( disposing )
  57. {
  58. if(components != null)
  59. {
  60. components.Dispose();
  61. }
  62. }
  63. base.Dispose( disposing );
  64. }
  65. #region Windows 窗体设计器生成的代码
  66. /// <summary>
  67. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  68. /// 此方法的内容。
  69. /// </summary>
  70. private void InitializeComponent()
  71. {
  72. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DataOut));
  73. this.listView_data = new System.Windows.Forms.ListView();
  74. this.目标数据集名 = new System.Windows.Forms.ColumnHeader();
  75. this.源数据集名 = new System.Windows.Forms.ColumnHeader();
  76. this.状态 = new System.Windows.Forms.ColumnHeader();
  77. this.groupBox1 = new System.Windows.Forms.GroupBox();
  78. this.btn_select_no = new System.Windows.Forms.Button();
  79. this.btn_select_all = new System.Windows.Forms.Button();
  80. this.groupBox2 = new System.Windows.Forms.GroupBox();
  81. this.comboBox_unit = new System.Windows.Forms.ComboBox();
  82. this.label5 = new System.Windows.Forms.Label();
  83. this.btn_url = new System.Windows.Forms.Button();
  84. this.txt_url = new System.Windows.Forms.TextBox();
  85. this.label4 = new System.Windows.Forms.Label();
  86. this.comboBox_file = new System.Windows.Forms.ComboBox();
  87. this.label3 = new System.Windows.Forms.Label();
  88. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  89. this.btn_ok = new System.Windows.Forms.Button();
  90. this.btn_esc = new System.Windows.Forms.Button();
  91. this.pictureBox2 = new System.Windows.Forms.PictureBox();
  92. this.groupBox1.SuspendLayout();
  93. this.groupBox2.SuspendLayout();
  94. this.SuspendLayout();
  95. // 
  96. // listView_data
  97. // 
  98. this.listView_data.CheckBoxes = true;
  99. this.listView_data.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  100. this.目标数据集名,
  101. this.源数据集名,
  102. this.状态});
  103. this.listView_data.LabelEdit = true;
  104. this.listView_data.LabelWrap = false;
  105. this.listView_data.Location = new System.Drawing.Point(8, 16);
  106. this.listView_data.Name = "listView_data";
  107. this.listView_data.Size = new System.Drawing.Size(328, 144);
  108. this.listView_data.TabIndex = 0;
  109. this.listView_data.View = System.Windows.Forms.View.Details;
  110. // 
  111. // 目标数据集名
  112. // 
  113. this.目标数据集名.Text = "目标数据集名";
  114. this.目标数据集名.Width = 123;
  115. // 
  116. // 源数据集名
  117. // 
  118. this.源数据集名.Text = "源数据集名";
  119. this.源数据集名.Width = 117;
  120. // 
  121. // 状态
  122. // 
  123. this.状态.Text = "状态";
  124. // 
  125. // groupBox1
  126. // 
  127. this.groupBox1.Controls.Add(this.btn_select_no);
  128. this.groupBox1.Controls.Add(this.btn_select_all);
  129. this.groupBox1.Controls.Add(this.listView_data);
  130. this.groupBox1.Location = new System.Drawing.Point(192, 8);
  131. this.groupBox1.Name = "groupBox1";
  132. this.groupBox1.Size = new System.Drawing.Size(368, 168);
  133. this.groupBox1.TabIndex = 2;
  134. this.groupBox1.TabStop = false;
  135. this.groupBox1.Text = "源数据集";
  136. // 
  137. // btn_select_no
  138. // 
  139. this.btn_select_no.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  140. this.btn_select_no.Location = new System.Drawing.Point(338, 72);
  141. this.btn_select_no.Name = "btn_select_no";
  142. this.btn_select_no.Size = new System.Drawing.Size(24, 40);
  143. this.btn_select_no.TabIndex = 2;
  144. this.btn_select_no.Text = "反选";
  145. this.btn_select_no.Click += new System.EventHandler(this.btn_select_no_Click);
  146. // 
  147. // btn_select_all
  148. // 
  149. this.btn_select_all.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  150. this.btn_select_all.Location = new System.Drawing.Point(338, 24);
  151. this.btn_select_all.Name = "btn_select_all";
  152. this.btn_select_all.Size = new System.Drawing.Size(24, 40);
  153. this.btn_select_all.TabIndex = 1;
  154. this.btn_select_all.Text = "全选";
  155. this.btn_select_all.Click += new System.EventHandler(this.btn_select_all_Click);
  156. // 
  157. // groupBox2
  158. // 
  159. this.groupBox2.Controls.Add(this.comboBox_unit);
  160. this.groupBox2.Controls.Add(this.label5);
  161. this.groupBox2.Controls.Add(this.btn_url);
  162. this.groupBox2.Controls.Add(this.txt_url);
  163. this.groupBox2.Controls.Add(this.label4);
  164. this.groupBox2.Controls.Add(this.comboBox_file);
  165. this.groupBox2.Controls.Add(this.label3);
  166. this.groupBox2.Location = new System.Drawing.Point(192, 184);
  167. this.groupBox2.Name = "groupBox2";
  168. this.groupBox2.Size = new System.Drawing.Size(368, 80);
  169. this.groupBox2.TabIndex = 3;
  170. this.groupBox2.TabStop = false;
  171. this.groupBox2.Text = "输出";
  172. // 
  173. // comboBox_unit
  174. // 
  175. this.comboBox_unit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  176. this.comboBox_unit.Items.AddRange(new object[] {
  177.    "度",
  178.    "毫米",
  179.    "厘米",
  180.    "英寸",
  181.    "分米",
  182.    "英尺",
  183.    "码",
  184.    "米",
  185.    "千米",
  186.    "英里"});
  187. this.comboBox_unit.Location = new System.Drawing.Point(272, 17);
  188. this.comboBox_unit.Name = "comboBox_unit";
  189. this.comboBox_unit.Size = new System.Drawing.Size(88, 20);
  190. this.comboBox_unit.TabIndex = 6;
  191. this.comboBox_unit.SelectedIndexChanged += new System.EventHandler(this.comboBox_unit_SelectedIndexChanged);
  192. // 
  193. // label5
  194. // 
  195. this.label5.Location = new System.Drawing.Point(240, 22);
  196. this.label5.Name = "label5";
  197. this.label5.Size = new System.Drawing.Size(32, 16);
  198. this.label5.TabIndex = 5;
  199. this.label5.Text = "单位";
  200. // 
  201. // btn_url
  202. // 
  203. this.btn_url.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  204. this.btn_url.Location = new System.Drawing.Point(318, 45);
  205. this.btn_url.Name = "btn_url";
  206. this.btn_url.Size = new System.Drawing.Size(40, 21);
  207. this.btn_url.TabIndex = 4;
  208. this.btn_url.Text = ">>";
  209. this.btn_url.Click += new System.EventHandler(this.btn_url_Click);
  210. // 
  211. // txt_url
  212. // 
  213. this.txt_url.Location = new System.Drawing.Point(72, 46);
  214. this.txt_url.Name = "txt_url";
  215. this.txt_url.Size = new System.Drawing.Size(240, 21);
  216. this.txt_url.TabIndex = 3;
  217. this.txt_url.Text = "";
  218. // 
  219. // label4
  220. // 
  221. this.label4.Location = new System.Drawing.Point(8, 51);
  222. this.label4.Name = "label4";
  223. this.label4.Size = new System.Drawing.Size(56, 16);
  224. this.label4.TabIndex = 2;
  225. this.label4.Text = "输出目录";
  226. // 
  227. // comboBox_file
  228. // 
  229. this.comboBox_file.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  230. this.comboBox_file.Items.AddRange(new object[] {
  231.    "MapInfo的mif文件(*.mif)",
  232.    "国标矢量文件 (*.VCT) ",
  233.    "AutoCAD的DXF(*.dxf)",
  234.    "mapgis明码交换格式文件 ",
  235.    "ArcView的shp格式(*.shp)",
  236.    "ArcInfo的Coverage||ArcInfo交换格式E00(*.e00)",
  237.    "位图文件(*.bmp)"});
  238. this.comboBox_file.Location = new System.Drawing.Point(72, 18);
  239. this.comboBox_file.Name = "comboBox_file";
  240. this.comboBox_file.Size = new System.Drawing.Size(160, 20);
  241. this.comboBox_file.TabIndex = 1;
  242. this.comboBox_file.SelectedIndexChanged += new System.EventHandler(this.comboBox_file_SelectedIndexChanged);
  243. // 
  244. // label3
  245. // 
  246. this.label3.Location = new System.Drawing.Point(8, 23);
  247. this.label3.Name = "label3";
  248. this.label3.Size = new System.Drawing.Size(56, 16);
  249. this.label3.TabIndex = 0;
  250. this.label3.Text = "文件类型";
  251. // 
  252. // pictureBox1
  253. // 
  254. this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  255. this.pictureBox1.Location = new System.Drawing.Point(14, 272);
  256. this.pictureBox1.Name = "pictureBox1";
  257. this.pictureBox1.Size = new System.Drawing.Size(538, 4);
  258. this.pictureBox1.TabIndex = 4;
  259. this.pictureBox1.TabStop = false;
  260. // 
  261. // btn_ok
  262. // 
  263. this.btn_ok.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  264. this.btn_ok.Location = new System.Drawing.Point(288, 282);
  265. this.btn_ok.Name = "btn_ok";
  266. this.btn_ok.Size = new System.Drawing.Size(75, 24);
  267. this.btn_ok.TabIndex = 5;
  268. this.btn_ok.Text = "导 出";
  269. this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
  270. // 
  271. // btn_esc
  272. // 
  273. this.btn_esc.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  274. this.btn_esc.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  275. this.btn_esc.Location = new System.Drawing.Point(408, 282);
  276. this.btn_esc.Name = "btn_esc";
  277. this.btn_esc.Size = new System.Drawing.Size(75, 24);
  278. this.btn_esc.TabIndex = 6;
  279. this.btn_esc.Text = "放 弃";
  280. this.btn_esc.Click += new System.EventHandler(this.btn_esc_Click);
  281. // 
  282. // pictureBox2
  283. // 
  284. this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  285. this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
  286. this.pictureBox2.Location = new System.Drawing.Point(16, 16);
  287. this.pictureBox2.Name = "pictureBox2";
  288. this.pictureBox2.Size = new System.Drawing.Size(160, 248);
  289. this.pictureBox2.TabIndex = 7;
  290. this.pictureBox2.TabStop = false;
  291. // 
  292. // DataOut
  293. // 
  294. this.AcceptButton = this.btn_ok;
  295. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  296. this.CancelButton = this.btn_esc;
  297. this.ClientSize = new System.Drawing.Size(568, 309);
  298. this.Controls.Add(this.pictureBox2);
  299. this.Controls.Add(this.btn_esc);
  300. this.Controls.Add(this.btn_ok);
  301. this.Controls.Add(this.pictureBox1);
  302. this.Controls.Add(this.groupBox2);
  303. this.Controls.Add(this.groupBox1);
  304. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  305. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  306. this.Name = "DataOut";
  307. this.ShowInTaskbar = false;
  308. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  309. this.Text = "数据集导出";
  310. this.Load += new System.EventHandler(this.DataOut_Load);
  311. this.groupBox1.ResumeLayout(false);
  312. this.groupBox2.ResumeLayout(false);
  313. this.ResumeLayout(false);
  314. }
  315. #endregion
  316. private void DataOut_Load(object sender, System.EventArgs e)
  317. {
  318. this.myExport = this.myPump.DataExportParams;
  319. add_list(this.dateset);
  320. }
  321. private void btn_esc_Click(object sender, System.EventArgs e)
  322. {
  323. this.Close();
  324. }
  325. #region 加载数据源列表
  326. private void add_list(string[] dataset)
  327. {
  328. foreach(string aa in dataset)
  329. {
  330. ListViewItem ite = new ListViewItem(new string[] {aa,aa,"未转"});
  331. this.listView_data.Items.Add(ite);
  332. }
  333. }
  334. #endregion
  335. private void btn_url_Click(object sender, System.EventArgs e)
  336. {
  337. FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
  338. if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) 
  339. {
  340. this.txt_url.Text = folderBrowserDialog1.SelectedPath;
  341. }
  342. }
  343. private void comboBox_file_SelectedIndexChanged(object sender, System.EventArgs e)
  344. {
  345. int a = this.comboBox_file.SelectedIndex;
  346. switch(a)
  347. {
  348. case 0:
  349. this.myExport.FileType = SuperMapLib.seFileType.scfMIF;
  350. break;
  351. case 1:
  352. this.myExport.FileType = SuperMapLib.seFileType.scfVCT;
  353. break;
  354. case 2:
  355. this.myExport.FileType = SuperMapLib.seFileType.scfDXF;
  356. break;
  357. case 3:
  358. this.myExport.FileType = SuperMapLib.seFileType.scfMapGis;
  359. break;
  360. case 4:
  361. this.myExport.FileType = SuperMapLib.seFileType.scfSHP;
  362. break;
  363. case 5:
  364. this.myExport.FileType = SuperMapLib.seFileType.scfE00;
  365. break;
  366. case 6:
  367. this.myExport.FileType = SuperMapLib.seFileType.scfBMP;
  368. break;
  369. }
  370. }
  371. private void comboBox_unit_SelectedIndexChanged(object sender, System.EventArgs e)
  372. {
  373. int a = this.comboBox_unit.SelectedIndex;
  374. switch(a)
  375. {
  376. case 0:
  377. this.myExport.DesUnits = SuperMapLib.seUnits.scuDegree;
  378. break;
  379. case 1:
  380. this.myExport.DesUnits = SuperMapLib.seUnits.scuMillimeter;
  381. break;
  382. case 2:
  383. this.myExport.DesUnits = SuperMapLib.seUnits.scuCentimeter;
  384. break;
  385. case 3:
  386. this.myExport.DesUnits = SuperMapLib.seUnits.scuInch;
  387. break;
  388. case 4:
  389. this.myExport.DesUnits = SuperMapLib.seUnits.scuDecimeter;
  390. break;
  391. case 5:
  392. this.myExport.DesUnits = SuperMapLib.seUnits.scuFoot;
  393. break;
  394. case 6:
  395. this.myExport.DesUnits = SuperMapLib.seUnits.scuYard;
  396. break;
  397. case 7:
  398. this.myExport.DesUnits = SuperMapLib.seUnits.scuMeter;
  399. break;
  400. case 8:
  401. this.myExport.DesUnits = SuperMapLib.seUnits.scuKilometer;
  402. break;
  403. case 9:
  404. this.myExport.DesUnits = SuperMapLib.seUnits.scuMile;
  405. break;
  406. }
  407. }
  408. private void btn_select_all_Click(object sender, System.EventArgs e)
  409. {
  410. int a = this.listView_data.Items.Count;
  411. for(int i = 0;i<a;i++)
  412. {
  413. this.listView_data.Items[i].Checked = true;
  414. }
  415. }
  416. private void btn_select_no_Click(object sender, System.EventArgs e)
  417. {
  418. int a = this.listView_data.Items.Count;
  419. for(int i = 0;i<a;i++)
  420. {
  421. this.listView_data.Items[i].Checked = (this.listView_data.Items[i].Checked)?false:true;
  422. }
  423. }
  424. private void btn_ok_Click(object sender, System.EventArgs e)
  425. {
  426. if(this.txt_url.Text.Length==0)
  427. {
  428. MessageBox.Show("请设定输出目录","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
  429. }
  430. else
  431. {
  432. int a = this.listView_data.Items.Count;
  433. for(int i=0;i<a;i++)
  434. {
  435. if(this.listView_data.Items[i].Checked)
  436. this.myExport.DatasetToBeExported = this.listView_data.Items[i].SubItems[1].Text.Trim();
  437. this.myExport.FileName = this.txt_url.Text+"\"+this.listView_data.Items[i].SubItems[0].Text;
  438. if(this.myPump.Export())
  439. {
  440. this.listView_data.Items[i].SubItems[2].Text="成功";
  441. }
  442. else
  443. {
  444. this.listView_data.Items[i].SubItems[2].Text="失败";
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. }