Newer
Older
GHFX_REFACTOR / Forms / FrmAddLayerFromDB.cs
wxn on 2 Nov 2016 2 KB 提交
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GeoScene.Engine;
using GeoScene.Globe;
using DevComponents.DotNetBar;
namespace PipeLine.Forms
{
    public partial class FrmAddLayerFromDB :Office2007Form
    {
        private GeoScene.Engine.GSODataSource ds;
        private GSOGlobeControl ctl;
        public List<GSOLayer> listLayer = new List<GSOLayer>();
        public FrmAddLayerFromDB(GSODataSource _ds, GSOGlobeControl _ctl)
        {
            ds = _ds;
            ctl = _ctl;
            InitializeComponent();
        }

        private void FrmAddLayerFromDB_Load(object sender, EventArgs e)
        {
            try
            {
                listBox1.Items.Clear();
                for (int i = 0; i < ds.DatasetCount; i++)
                {
                    GSODataset dataset = ds.GetDatasetAt(i);
                    listBox1.Items.Add(dataset.Name);
                }
            }
            catch (Exception ex)
            {
                LogError.PublishError(ex);
            }
            //listBox1.SelectionMode = SelectionMode.MultiSimple;
        }


        private void button1_Click(object sender, EventArgs e)
        {

            for (int i = 0; i < listBox1.SelectedItems.Count; i++)
            {
                GSODataset dataset = ds.GetDatasetByName(listBox1.SelectedItems[i].ToString());
                dataset.Caption = dataset.Name;
                GSOLayer layer = ctl.Globe.Layers.Add(dataset);
                listLayer.Add(layer);
                this.DialogResult = DialogResult.OK;
            }
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //if (MessageBox.Show("确定要删除 "+listBox1.SelectedItem.ToString()+" ?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            //{
            //    ds.DeleteDatasetByName(listBox1.SelectedItem.ToString());
            //    listBox1.Items.Remove(listBox1.SelectedItem);
            //}
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}