- bin.zip
- bin
- CanvasControl.dll
- gdal12.dll
- GDalGIS.dll
- GdalImage.dll
- Geometry.dll
- GisControl.dll
- proj.dll
- TerraService.dll
- VisiData.dll
- VisiDataWs.exe
- WorkSpace.dll
- visiworks.zip
- VisiWorks
|
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using CanvasControl;
using GDalGIS;
using System.IO;
using GeomModel;
using WorkSpace;
namespace GisControl
{
/// <summary>
/// Summary description for UserControl1.
/// </summary>
public class GisSelector : System.Windows.Forms.UserControl
{
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ListView listViewGIS;
private System.Windows.Forms.DataGrid dataGridGIS;
private GDalGIS.DataSource m_gdal_ds;
private Canvas canvas1;
private string m_curr_item;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Splitter splitter2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.PropertyGrid propertyGrid1;
private System.Windows.Forms.Panel panel4;
private ArrayList m_gis_files = new ArrayList();
public GDalGIS.DataSource GisDataSource
{
get
{
return m_gdal_ds;
}
}
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public void Clear()
{
listViewGIS.Items.Clear();
m_gdal_ds.Clear();
//canvas1.getGeomModel().Clear();
}
public GisSelector()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
m_gdal_ds = new GDalGIS.DataSource();
dataGridGIS.CurrentCellChanged += new
System.EventHandler(this.dataGridGIS_CurrentCellChanged);
}
private void listViewGIS_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (listViewGIS.SelectedItems.Count == 0)
return;
string lay_name = listViewGIS.SelectedItems[0].Text;
selectCurrentLayer(lay_name);
}
private bool selectCurrentLayer(string lay_name)
{
m_curr_item = lay_name;
dataGridGIS.SetDataBinding(m_gdal_ds.getDS(),m_curr_item);
ArrayList fl = m_gdal_ds.getFields(m_curr_item);
this.comboBox1.Items.Clear();
foreach(string it in fl)
{
this.comboBox1.Items.Add(it);
}
CanvasLayer lay = canvas1.getGeomModel().layerByName(lay_name);
this.propertyGrid1.SelectedObject = lay;
return true;
}
public void setCanvas(Canvas canv)
{
canvas1 = canv;
m_gdal_ds.setCanvasModel(canvas1.getGeomModel());
canvas1.ItemFindEvent += new CanvasControl.Canvas.ItemEventHandler(this.OnFindCanvasItem);
}
public void OnFindCanvasItem(object sender, GeomModel.ItemEventArgs e)
{
// statusBar1.Panels[1].Text = e.indx.ToString()+"!!!";
GeomModel.CanvasItem item = canvas1.GetItem(e.indx);
if(item == null)
return;
GeomModel.CanvasLayer lay = item.layer;
if(lay == null)
return;
selectCurrentLayer(lay.Name);
int r = m_gdal_ds.getRowOfShape(lay.Name,e.indx);
if(r == -1)
{
return;
}
dataGridGIS.CurrentCell = new DataGridCell(r,0);
}
private void dataGridGIS_CurrentCellChanged(object sender,
System.EventArgs e)
{
int id = m_gdal_ds.getShapeID(m_curr_item,dataGridGIS.CurrentCell.RowNumber);
GeomModel.CanvasItem item = canvas1.GetItem(id);
RectangleF rect = item.boundingBox();
canvas1.recenter(new PointF(rect.X+rect.Width/2,
rect.Y+rect.Height/2));
}
public ArrayList openGisFile(string fname)
{
int bar1 = WsProgressBar.Instance.Create("load file "+fname);
ArrayList l_list = new ArrayList();
//OpenFileDialog openFileDialog = new OpenFileDialog();
//openFileDialog.ShowDialog();
//string fname = openFileDialog.FileName;
m_gdal_ds.open(fname);
FileInfo f = new FileInfo(fname);
ArrayList names_list = m_gdal_ds.getLayers();
foreach(string it_name in names_list)
{
bool found = false;
foreach (ListViewItem item in listViewGIS.Items)
{
if(item.Text == it_name)
{
found = true;
break;
}
}
if(!found)
{
listViewGIS.Items.Add(it_name);
l_list.Add(it_name);
}
}
WsProgressBar.Instance.Delete(bar1);
//DataSet ds = m_gdal_ds.getDS();
// dataGridGIS.SetDataBinding(ds,gis_lay_name);
//canvas2.fitToWidget();
return l_list;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listViewGIS = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.dataGridGIS = new System.Windows.Forms.DataGrid();
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.splitter1 = new System.Windows.Forms.Splitter();
this.splitter2 = new System.Windows.Forms.Splitter();
this.panel3 = new System.Windows.Forms.Panel();
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.panel4 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.dataGridGIS)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.SuspendLayout();
//
// listViewGIS
//
this.listViewGIS.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.listViewGIS.Dock = System.Windows.Forms.DockStyle.Left;
this.listViewGIS.Location = new System.Drawing.Point(0, 0);
this.listViewGIS.Name = "listViewGIS";
this.listViewGIS.Size = new System.Drawing.Size(104, 136);
this.listViewGIS.TabIndex = 0;
this.listViewGIS.View = System.Windows.Forms.View.Details;
this.listViewGIS.SelectedIndexChanged += new System.EventHandler(this.listViewGIS_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "Layer";
this.columnHeader1.Width = 92;
//
// dataGridGIS
//
this.dataGridGIS.DataMember = "";
this.dataGridGIS.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridGIS.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridGIS.Location = new System.Drawing.Point(0, 0);
this.dataGridGIS.Name = "dataGridGIS";
this.dataGridGIS.Size = new System.Drawing.Size(360, 101);
this.dataGridGIS.TabIndex = 1;
this.dataGridGIS.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dataGridGIS_Navigate);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 16);
this.label1.TabIndex = 1;
this.label1.Text = "label";
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(40, 0);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(72, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.Text = "None";
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// panel1
//
this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.splitter1);
this.panel1.Controls.Add(this.listViewGIS);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(360, 136);
this.panel1.TabIndex = 5;
//
// panel2
//
this.panel2.Controls.Add(this.panel4);
this.panel2.Controls.Add(this.propertyGrid1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(107, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(253, 136);
this.panel2.TabIndex = 2;
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(104, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 136);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// splitter2
//
this.splitter2.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter2.Location = new System.Drawing.Point(0, 136);
this.splitter2.Name = "splitter2";
this.splitter2.Size = new System.Drawing.Size(360, 3);
this.splitter2.TabIndex = 6;
this.splitter2.TabStop = false;
//
// panel3
//
this.panel3.Controls.Add(this.dataGridGIS);
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(0, 139);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(360, 101);
this.panel3.TabIndex = 7;
//
// propertyGrid1
//
this.propertyGrid1.CommandsVisibleIfAvailable = true;
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid1.LargeButtons = false;
this.propertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar;
this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.Size = new System.Drawing.Size(253, 136);
this.propertyGrid1.TabIndex = 2;
this.propertyGrid1.Text = "propertyGrid1";
this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;
this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;
//
// panel4
//
this.panel4.Controls.Add(this.label1);
this.panel4.Controls.Add(this.comboBox1);
this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
this.panel4.Location = new System.Drawing.Point(0, 0);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(253, 24);
this.panel4.TabIndex = 3;
//
// GisSelector
//
this.Controls.Add(this.panel3);
this.Controls.Add(this.splitter2);
this.Controls.Add(this.panel1);
this.Name = "GisSelector";
this.Size = new System.Drawing.Size(360, 240);
((System.ComponentModel.ISupportInitialize)(this.dataGridGIS)).EndInit();
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void dataGridGIS_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
public string GetLabel(string lay_name)
{
if(m_layers_labels.ContainsKey(lay_name))
return (string)m_layers_labels[lay_name];
return "None";
}
SortedList m_layers_labels = new SortedList();
public bool SetLabel(string layer_name,string label)
{
int bar1 = WsProgressBar.Instance.Create("load label "+layer_name+":"+label);
m_gdal_ds.setLabel(layer_name,label);
WsProgressBar.Instance.Delete(bar1);
if(!m_layers_labels.ContainsKey(layer_name))
m_layers_labels.Add(layer_name,label);
else
m_layers_labels[layer_name] = label;
return true;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
SetLabel(this.m_curr_item,comboBox1.SelectedItem.ToString());
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Baranovsky Eduard has been a software developer for more then 10 years. He has an experence in image processing, computer graphics and distributed systems design.