DataOut.cs
上传用户:chizxy
上传日期:2014-11-29
资源大小:407k
文件大小:16k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace MKIms3
- {
- /// <summary>
- /// DataOut 的摘要说明。
- /// </summary>
- public class DataOut : System.Windows.Forms.Form
- {
- string[] dateset;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- ///
- public SuperMapLib.soDataPump myPump;
- private SuperMapLib.soExportParams myExport;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Button btn_url;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.Button btn_ok;
- private System.Windows.Forms.Button btn_esc;
- private System.Windows.Forms.ColumnHeader 源数据集名;
- private System.Windows.Forms.ColumnHeader 目标数据集名;
- private System.Windows.Forms.ListView listView_data;
- private System.Windows.Forms.ComboBox comboBox_file;
- private System.Windows.Forms.TextBox txt_url;
- private System.Windows.Forms.ComboBox comboBox_unit;
- private System.Windows.Forms.Button btn_select_all;
- private System.Windows.Forms.Button btn_select_no;
- private System.Windows.Forms.ColumnHeader 状态;
- private System.Windows.Forms.PictureBox pictureBox2;
- private System.ComponentModel.Container components = null;
- public DataOut(string[] dataset)
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- this.dateset = dataset;
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DataOut));
- this.listView_data = new System.Windows.Forms.ListView();
- this.目标数据集名 = new System.Windows.Forms.ColumnHeader();
- this.源数据集名 = new System.Windows.Forms.ColumnHeader();
- this.状态 = new System.Windows.Forms.ColumnHeader();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btn_select_no = new System.Windows.Forms.Button();
- this.btn_select_all = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.comboBox_unit = new System.Windows.Forms.ComboBox();
- this.label5 = new System.Windows.Forms.Label();
- this.btn_url = new System.Windows.Forms.Button();
- this.txt_url = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.comboBox_file = new System.Windows.Forms.ComboBox();
- this.label3 = new System.Windows.Forms.Label();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.btn_ok = new System.Windows.Forms.Button();
- this.btn_esc = new System.Windows.Forms.Button();
- this.pictureBox2 = new System.Windows.Forms.PictureBox();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // listView_data
- //
- this.listView_data.CheckBoxes = true;
- this.listView_data.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.目标数据集名,
- this.源数据集名,
- this.状态});
- this.listView_data.LabelEdit = true;
- this.listView_data.LabelWrap = false;
- this.listView_data.Location = new System.Drawing.Point(8, 16);
- this.listView_data.Name = "listView_data";
- this.listView_data.Size = new System.Drawing.Size(328, 144);
- this.listView_data.TabIndex = 0;
- this.listView_data.View = System.Windows.Forms.View.Details;
- //
- // 目标数据集名
- //
- this.目标数据集名.Text = "目标数据集名";
- this.目标数据集名.Width = 123;
- //
- // 源数据集名
- //
- this.源数据集名.Text = "源数据集名";
- this.源数据集名.Width = 117;
- //
- // 状态
- //
- this.状态.Text = "状态";
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.btn_select_no);
- this.groupBox1.Controls.Add(this.btn_select_all);
- this.groupBox1.Controls.Add(this.listView_data);
- this.groupBox1.Location = new System.Drawing.Point(192, 8);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(368, 168);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "源数据集";
- //
- // btn_select_no
- //
- this.btn_select_no.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_select_no.Location = new System.Drawing.Point(338, 72);
- this.btn_select_no.Name = "btn_select_no";
- this.btn_select_no.Size = new System.Drawing.Size(24, 40);
- this.btn_select_no.TabIndex = 2;
- this.btn_select_no.Text = "反选";
- this.btn_select_no.Click += new System.EventHandler(this.btn_select_no_Click);
- //
- // btn_select_all
- //
- this.btn_select_all.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_select_all.Location = new System.Drawing.Point(338, 24);
- this.btn_select_all.Name = "btn_select_all";
- this.btn_select_all.Size = new System.Drawing.Size(24, 40);
- this.btn_select_all.TabIndex = 1;
- this.btn_select_all.Text = "全选";
- this.btn_select_all.Click += new System.EventHandler(this.btn_select_all_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.comboBox_unit);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.btn_url);
- this.groupBox2.Controls.Add(this.txt_url);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.comboBox_file);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Location = new System.Drawing.Point(192, 184);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(368, 80);
- this.groupBox2.TabIndex = 3;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "输出";
- //
- // comboBox_unit
- //
- this.comboBox_unit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox_unit.Items.AddRange(new object[] {
- "度",
- "毫米",
- "厘米",
- "英寸",
- "分米",
- "英尺",
- "码",
- "米",
- "千米",
- "英里"});
- this.comboBox_unit.Location = new System.Drawing.Point(272, 17);
- this.comboBox_unit.Name = "comboBox_unit";
- this.comboBox_unit.Size = new System.Drawing.Size(88, 20);
- this.comboBox_unit.TabIndex = 6;
- this.comboBox_unit.SelectedIndexChanged += new System.EventHandler(this.comboBox_unit_SelectedIndexChanged);
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(240, 22);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(32, 16);
- this.label5.TabIndex = 5;
- this.label5.Text = "单位";
- //
- // btn_url
- //
- this.btn_url.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_url.Location = new System.Drawing.Point(318, 45);
- this.btn_url.Name = "btn_url";
- this.btn_url.Size = new System.Drawing.Size(40, 21);
- this.btn_url.TabIndex = 4;
- this.btn_url.Text = ">>";
- this.btn_url.Click += new System.EventHandler(this.btn_url_Click);
- //
- // txt_url
- //
- this.txt_url.Location = new System.Drawing.Point(72, 46);
- this.txt_url.Name = "txt_url";
- this.txt_url.Size = new System.Drawing.Size(240, 21);
- this.txt_url.TabIndex = 3;
- this.txt_url.Text = "";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(8, 51);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(56, 16);
- this.label4.TabIndex = 2;
- this.label4.Text = "输出目录";
- //
- // comboBox_file
- //
- this.comboBox_file.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox_file.Items.AddRange(new object[] {
- "MapInfo的mif文件(*.mif)",
- "国标矢量文件 (*.VCT) ",
- "AutoCAD的DXF(*.dxf)",
- "mapgis明码交换格式文件 ",
- "ArcView的shp格式(*.shp)",
- "ArcInfo的Coverage||ArcInfo交换格式E00(*.e00)",
- "位图文件(*.bmp)"});
- this.comboBox_file.Location = new System.Drawing.Point(72, 18);
- this.comboBox_file.Name = "comboBox_file";
- this.comboBox_file.Size = new System.Drawing.Size(160, 20);
- this.comboBox_file.TabIndex = 1;
- this.comboBox_file.SelectedIndexChanged += new System.EventHandler(this.comboBox_file_SelectedIndexChanged);
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(8, 23);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(56, 16);
- this.label3.TabIndex = 0;
- this.label3.Text = "文件类型";
- //
- // pictureBox1
- //
- this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.pictureBox1.Location = new System.Drawing.Point(14, 272);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(538, 4);
- this.pictureBox1.TabIndex = 4;
- this.pictureBox1.TabStop = false;
- //
- // btn_ok
- //
- this.btn_ok.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_ok.Location = new System.Drawing.Point(288, 282);
- this.btn_ok.Name = "btn_ok";
- this.btn_ok.Size = new System.Drawing.Size(75, 24);
- this.btn_ok.TabIndex = 5;
- this.btn_ok.Text = "导 出";
- this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
- //
- // btn_esc
- //
- this.btn_esc.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btn_esc.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btn_esc.Location = new System.Drawing.Point(408, 282);
- this.btn_esc.Name = "btn_esc";
- this.btn_esc.Size = new System.Drawing.Size(75, 24);
- this.btn_esc.TabIndex = 6;
- this.btn_esc.Text = "放 弃";
- this.btn_esc.Click += new System.EventHandler(this.btn_esc_Click);
- //
- // pictureBox2
- //
- this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
- this.pictureBox2.Location = new System.Drawing.Point(16, 16);
- this.pictureBox2.Name = "pictureBox2";
- this.pictureBox2.Size = new System.Drawing.Size(160, 248);
- this.pictureBox2.TabIndex = 7;
- this.pictureBox2.TabStop = false;
- //
- // DataOut
- //
- this.AcceptButton = this.btn_ok;
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.CancelButton = this.btn_esc;
- this.ClientSize = new System.Drawing.Size(568, 309);
- this.Controls.Add(this.pictureBox2);
- this.Controls.Add(this.btn_esc);
- this.Controls.Add(this.btn_ok);
- this.Controls.Add(this.pictureBox1);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "DataOut";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "数据集导出";
- this.Load += new System.EventHandler(this.DataOut_Load);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- private void DataOut_Load(object sender, System.EventArgs e)
- {
- this.myExport = this.myPump.DataExportParams;
- add_list(this.dateset);
- }
- private void btn_esc_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- #region 加载数据源列表
-
- private void add_list(string[] dataset)
- {
-
- foreach(string aa in dataset)
- {
- ListViewItem ite = new ListViewItem(new string[] {aa,aa,"未转"});
- this.listView_data.Items.Add(ite);
- }
- }
- #endregion
- private void btn_url_Click(object sender, System.EventArgs e)
- {
- FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
- {
- this.txt_url.Text = folderBrowserDialog1.SelectedPath;
- }
- }
-
- private void comboBox_file_SelectedIndexChanged(object sender, System.EventArgs e)
- {
-
- int a = this.comboBox_file.SelectedIndex;
- switch(a)
- {
- case 0:
- this.myExport.FileType = SuperMapLib.seFileType.scfMIF;
- break;
- case 1:
- this.myExport.FileType = SuperMapLib.seFileType.scfVCT;
- break;
- case 2:
- this.myExport.FileType = SuperMapLib.seFileType.scfDXF;
- break;
- case 3:
- this.myExport.FileType = SuperMapLib.seFileType.scfMapGis;
- break;
- case 4:
- this.myExport.FileType = SuperMapLib.seFileType.scfSHP;
- break;
- case 5:
- this.myExport.FileType = SuperMapLib.seFileType.scfE00;
- break;
- case 6:
- this.myExport.FileType = SuperMapLib.seFileType.scfBMP;
- break;
- }
-
- }
- private void comboBox_unit_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- int a = this.comboBox_unit.SelectedIndex;
- switch(a)
- {
- case 0:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuDegree;
- break;
- case 1:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuMillimeter;
- break;
- case 2:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuCentimeter;
- break;
- case 3:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuInch;
- break;
- case 4:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuDecimeter;
- break;
- case 5:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuFoot;
- break;
- case 6:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuYard;
- break;
- case 7:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuMeter;
- break;
- case 8:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuKilometer;
- break;
- case 9:
- this.myExport.DesUnits = SuperMapLib.seUnits.scuMile;
- break;
-
- }
- }
- private void btn_select_all_Click(object sender, System.EventArgs e)
- {
- int a = this.listView_data.Items.Count;
- for(int i = 0;i<a;i++)
- {
- this.listView_data.Items[i].Checked = true;
- }
- }
- private void btn_select_no_Click(object sender, System.EventArgs e)
- {
- int a = this.listView_data.Items.Count;
- for(int i = 0;i<a;i++)
- {
- this.listView_data.Items[i].Checked = (this.listView_data.Items[i].Checked)?false:true;
- }
- }
- private void btn_ok_Click(object sender, System.EventArgs e)
- {
- if(this.txt_url.Text.Length==0)
- {
- MessageBox.Show("请设定输出目录","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
- else
- {
-
- int a = this.listView_data.Items.Count;
- for(int i=0;i<a;i++)
- {
- if(this.listView_data.Items[i].Checked)
- {
-
- this.myExport.DatasetToBeExported = this.listView_data.Items[i].SubItems[1].Text.Trim();
- this.myExport.FileName = this.txt_url.Text+"\"+this.listView_data.Items[i].SubItems[0].Text;
- if(this.myPump.Export())
- {
- this.listView_data.Items[i].SubItems[2].Text="成功";
- }
- else
- {
- this.listView_data.Items[i].SubItems[2].Text="失败";
- }
- }
- }
- }
- }
- }
- }