Newer
Older
GHFX_REFACTOR / Backup / FrmFlow.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.Text;
using System.Windows.Forms;
using GeoScene.Globe;
using DevComponents.DotNetBar;
using GeoScene.Data;

namespace Cyberpipe
{
    public partial class FrmFlow : Office2007Form
    {
        private GSOGlobeControl globeControl;
        private GSOLayer layer;
        List<string> pipelineLayerNames;
        public FrmFlow(GSOGlobeControl ctl,List<string> pipeLayers)
        {
            InitializeComponent();
            globeControl = ctl;
            pipelineLayerNames = pipeLayers;
        }
        /// <summary>
        /// 窗体初始化事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmFlow_Load(object sender, EventArgs e)
        {
            cboxLayer.Items.Clear();
            for (int i = 0; i < pipelineLayerNames.Count; i++)
            {
                cboxLayer.Items.Add(pipelineLayerNames[i]);
            }
        }
        /// <summary>
        /// 设置管线显示箭头
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="pipelineNameCN"></param>
        private void Flow(object sender, string pipelineNameCN)//流向
        {
            //if (checkBox1.Checked == true)
            //{
                GSOFeatures feats = layer.GetAllFeatures();
                if (feats.Length == 0)
                    return;
                for (int i = 0; i < feats.Length; i++)
                {
                    GSOFeature feat = feats[i];
                    GSOLineStyle3D lineStyle = feat.Geometry.Style as GSOLineStyle3D;
                    if (lineStyle != null)
                    {
                        if (lineStyle.ArrowStyle == null)
                        {
                            lineStyle.ArrowStyle = new GSOArrowStyle();
                        }   
                            lineStyle.ArrowStyle.BodyWidth = 2;
                            lineStyle.ArrowStyle.BodyLen = 6;
                            lineStyle.ArrowStyle.HeadWidth = 8;
                            lineStyle.ArrowStyle.HeadLen = 10;
                            lineStyle.ArrowStyle.OutlineVisible = true;
                            lineStyle.ArrowStyle.OutlineColor = Color.Red;
                            lineStyle.ArrowStyle.Speed = 25;
                            lineStyle.ArrowStyle.Play();
                        lineStyle.ArrowVisible = true;
                        feat.Geometry.SetModified(true);
                    }
                }
            //}
            globeControl.Globe.Refresh();
        }
        /// <summary>
        /// 确定按钮事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (cboxLayer.SelectedIndex == -1)
            {
                MessageBox.Show("请选择管线图层");
                return;
            }
            Flow(sender, cboxLayer.SelectedItem.ToString());
            this.Close();
        }
        /// <summary>
        /// 下拉框选中项改变事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cboxLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboxLayer.SelectedIndex != -1)
            {
                layer = globeControl.Globe.Layers.GetLayerByCaption(cboxLayer.SelectedItem.ToString());
            }
        }
        /// <summary>
        /// 取消事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}