Newer
Older
GHFX_REFACTOR / FrmThreeOracle.cs
wxn on 2 Nov 2016 3 KB 提交
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using GeoScene.Engine;
using GeoScene.Globe;
using GeoScene.Data;

namespace Cyberpipe
{
    public partial class FrmThreeOracle : Office2007Form
    {

        public static GeoScene.Engine.GSODataSource dsdes = null;
        string sourIp, sourDb, sourUser, sourPwd;
        GSOGlobeControl globeControl;
        public GSOLayer rukuLayer = null;

        public FrmThreeOracle(GSOGlobeControl _globeControl)
        {
            InitializeComponent();
            this.globeControl = _globeControl;
        }

        private void FrmThreeOracle_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("施工数据");
            comboBox1.Items.Add("规划数据");

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string db = comboBox1.Text.ToString();
            listBox1.Items.Clear();
            if (db == "施工数据")
            {
                sourIp = Utility.sgdbip;
                sourDb = Utility.sgdbname;
                sourUser = Utility.sgdbuser;
                sourPwd = Utility.sgdbpwd;
            }
            else {
                sourIp = Utility.ghdbip;
                sourDb = Utility.ghdbname;
                sourUser = Utility.ghdbuser;
                sourPwd = Utility.ghdbpwd;
            }

            dsdes = globeControl.Globe.DataManager.OpenOracleDataSource(sourIp + "/" + sourDb, "", "", sourUser, sourPwd);
            if (dsdes == null)
            {
                MessageBox.Show("数据库连接失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            for (int i = 0; i < dsdes.DatasetCount; i++)
            {
                GSODataset dataset = dsdes.GetDatasetAt(i);

                if (dataset.Name.ToLower().Contains("network"))
                {
                    continue;
                }
                //if (!dataset.Name.ToLower().EndsWith("管线") && !dataset.Name.ToLower().EndsWith("附属物") && !dataset.Name.ToLower().EndsWith("管点"))

                //if(!dataset.Name.ToString().Contains("管线"))
                if (dataset.Name.Contains("SH"))
                {
                    continue;
                }
                listBox1.Items.Add(dataset.Name);
            }

        }

        private void buttonXOK_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择要查看的数据!", "提示");
                return;
            }
            else {
                for (int i = 0; i < listBox1.SelectedItems.Count; i++)
                {

                    GSODataset dt = dsdes.GetDatasetByName(listBox1.SelectedItems[i].ToString());
                    GSOFeatureDataset ly = dt as GSOFeatureDataset;

                    //if (ly != null)
                    //{
                    //    globeControl.Globe.Layers.Remove(ly);
                    //}
                    ly.Caption = ly.Name;
                    GSOLayer layerRuku = globeControl.Globe.Layers.Add(ly);
                    rukuLayer = layerRuku;
                    //重新调整模型位置,这样可以保证新入库的管线也能通过调节透明度隐现 
                    globeControl.Globe.Layers.MoveTo(0, globeControl.Globe.Layers.Count - 1);
                    globeControl.Globe.Refresh();

                    
                }
            }

            this.DialogResult = DialogResult.OK;
        }


    }
}