• 我的比较差的初级的研究成果


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    using stdole;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Controls;
    using ESRI.ArcGIS.SystemUI;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.Display;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.DataSourcesFile;
    using ESRI.ArcGIS.DataSourcesGDB;
    using ESRI.ArcGIS.Geoprocessing;
    using ESRI.ArcGIS.Geoprocessor;
    using ESRI.ArcGIS.AnalysisTools;

    namespace HotFox.UI
    {
        public partial class DOMPropertyConditionControl : UserControl, IPropertyQueryConditionControl
        {

            private string TotalSearchString = string.Empty;
            private string ScaleSearchString = string.Empty;
            private string ResolutionSearchString = string.Empty;
            private string DataCatgreySearchString = string.Empty;
            private string DateSearchString = string.Empty;

            private bool is数据集名称Checked = false;
            private bool is数据集编号Checked = false;
            private bool is整体数据Chenked = false;
            private bool is详细数据Checked = false;

            private bool is显示影像种类Checked = false;
            private bool is显示时间属性Checked = false;
            private bool is图符Checked = false;
            private bool is图符编号Checked = false;

            public event EventHandler ConditionChanged = null;
            private void fireConditionChangedEvent()
            {
                if (ConditionChanged != null)
                    ConditionChanged(this, new EventArgs());
            }

            public event EventHandler OptionChanged = null;
            private void fireOptionChangedEvent()
            {
                if (OptionChanged != null)
                    OptionChanged(this, new EventArgs());
            }

            #region 事件触发

            #region 查询条件

            #region 比例尺条件

            private void 比例尺ToolStripSplitButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                比例尺ToolStripSplitButton.Text = e.ClickedItem.Text;

                if (e.ClickedItem.Text != "任意")
                    分辨率ToolStripSplitButton.Text = "任意";

                fireConditionChangedEvent();

                return;

                #region --
                //ScaleSearchString = 比例尺ToolStripSplitButton.Text.ToString();
                //if (ScaleSearchString == "任意")
                //{
                //    ScaleSearchString = "Scale <> 0 ";

                //}
                //else
                //{
                //    ScaleSearchString = ScaleSearchString.Substring(2);
                //    ScaleSearchString = "Scale" + " = " + ScaleSearchString;
                //}
                //refreshMap();
                //elementsDeleted();
                //totalDisplay();
                #endregion
            }

            private void 自定义比例尺ToolStripTextBox_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (自定义比例尺ToolStripTextBox.Text.Trim() != string.Empty)
                        比例尺ToolStripSplitButton.Text = 自定义比例尺ToolStripTextBox.Text;
                    else
                        比例尺ToolStripSplitButton.Text = "任意";

                    自定义比例尺ToolStripTextBox.Text = "自定义";
                    比例尺ToolStripSplitButton.HideDropDown();

                    fireConditionChangedEvent();
                }
            }

            #endregion

            #region 分辨率条件

            private void 分辨率ToolStripSplitButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                分辨率ToolStripSplitButton.Text = e.ClickedItem.Text;

                if (e.ClickedItem.Text != "任意")
                    比例尺ToolStripSplitButton.Text = "任意";

                fireConditionChangedEvent();

                return;

                #region --
                //ResolutionSearchString = 分辨率ToolStripSplitButton.Text.ToString();

                // if (ResolutionSearchString == "任意")
                // {
                //     ResolutionSearchString = "Resolution NOT LIKE ''";
                // }
                // else
                // {
                //     ResolutionSearchString = ResolutionSearchString.Substring(0, ResolutionSearchString.Length - 1);
                //     ResolutionSearchString = "Resolution " + " LIKE " + " '" + ResolutionSearchString + "'";
                // }
                // refreshMap();
                // elementsDeleted();
                // totalDisplay();
                #endregion
            }

            private void 自定义分辨率ToolStripTextBox_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (自定义分辨率ToolStripTextBox.Text.Trim() != string.Empty)
                        分辨率ToolStripSplitButton.Text = 自定义分辨率ToolStripTextBox.Text;
                    else
                        分辨率ToolStripSplitButton.Text = "任意";

                    自定义分辨率ToolStripTextBox.Text = "自定义";
                    分辨率ToolStripSplitButton.HideDropDown();

                    fireConditionChangedEvent();
                }
            }

            #endregion

            #region 数据类型条件

            private void DataCategoryConditionsCheckBox_Click(object sender, EventArgs e)
            {
                fireConditionChangedEvent();

                return;

                #region --
                //generateCategoryCondition();
                //refreshMap();
                //elementsDeleted();
                //totalDisplay();
                #endregion
            }

            #endregion

            #region 时效性条件

            private void 时效性条件ToolStripSplitButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                时效性条件ToolStripSplitButton.Text = e.ClickedItem.Text;

                fireConditionChangedEvent();

                return;

                #region --
                //DateSearchString = 时效性条件ToolStripSplitButton.Text.ToString();
                //generateDateConditon();
                //refreshMap();
                //elementsDeleted();
                //totalDisplay();
                #endregion
            }

            #endregion

            #endregion

            #region 显示选项

            #region 图幅选项

            private void 图幅选项_Click(object sender, EventArgs e)
            {
                if (!显示图幅网格ToolStripCheckBox.Checked)
                {
                    显示图幅号ToolStripCheckBox.Checked = false;
                    显示图幅号ToolStripCheckBox.Enabled = false;

                    显示新图幅号ToolStripCheckBox.Checked = false;
                    显示新图幅号ToolStripCheckBox.Enabled = false;

                    显示旧图幅号ToolStripCheckBox.Checked = false;
                    显示旧图幅号ToolStripCheckBox.Enabled = false;
                }
                else
                {
                    显示图幅号ToolStripCheckBox.Enabled = true;
                    if (显示图幅号ToolStripCheckBox.Checked)
                    {
                        显示新图幅号ToolStripCheckBox.Enabled = true;
                        显示旧图幅号ToolStripCheckBox.Enabled = true;
                    }
                    else
                    {
                        显示新图幅号ToolStripCheckBox.Checked = false;
                        显示新图幅号ToolStripCheckBox.Enabled = false;
                        显示旧图幅号ToolStripCheckBox.Checked = false;
                        显示旧图幅号ToolStripCheckBox.Enabled = false;
                    }
                }

                fireOptionChangedEvent();
            }

            #region 显示图幅网格

            private void 显示图幅网格ToolStripCheckBox_Click(object sender, EventArgs e)
            {
                if (显示图幅网格ToolStripCheckBox.Checked == true)
                {
                    is图符Checked = true;
                }
                else
                {
                    is图符Checked = false;

                }
                elementsDeleted();
                totalDisplay();
            }

            #endregion

            #region 显示图幅号

            private void 显示图幅号ToolStripCheckBox_Click(object sender, EventArgs e)
            {
                if (显示图幅号ToolStripCheckBox.Checked==true)
                {
                    is图符编号Checked = true;
                }
                else
                {
                    is图符编号Checked = false;
                }
                elementsDeleted();
                totalDisplay();
            }

            #endregion

            #region 显示新图幅号

            private void 显示新图幅号ToolStripCheckBox_Click(object sender, EventArgs e)
            {

            }

            #endregion

            #region 显示旧图幅号

            private void 显示旧图幅号ToolStripCheckBox_Click(object sender, EventArgs e)
            {

            }

            #endregion

            #endregion

            #region 元数据选项

            private void metadataDisplayOption_Click(object sender, EventArgs e)
            {
                fireOptionChangedEvent();
            }

            #region --


            private void 显示影像种类ToolStripCheckBox_Click(object sender, EventArgs e)
            {
                if (显示影像种类ToolStripCheckBox.Checked == true)
                {
                    is显示影像种类Checked = true;
                }
                else
                {
                    is显示影像种类Checked = false;
                }
                elementsDeleted();
                totalDisplay();
            }

            private void 显示时间属性ToolStripCheckBox_Click(object sender, EventArgs e)
            {
                if (显示时间属性ToolStripCheckBox.Checked == true)
                {
                    is显示时间属性Checked = true;
                }
                else
                {
                    is显示时间属性Checked = false;
                }
                elementsDeleted();
                totalDisplay();
            }

            #endregion
           
            #endregion

            #endregion

            #endregion

            public IEnumerable<string> GetCondition(ConditionNameEnum name)
            {
                switch (name)
                {
                    case ConditionNameEnum.比例尺:
                        return get比例尺();
                    case ConditionNameEnum.分辨率:
                        return get分辨率();
                    case ConditionNameEnum.数据种类:
                        return get数据种类();
                    case ConditionNameEnum.时效性:
                        return get时效性();
                    default:
                        return null;
                }
            }

            public bool GetOption(OptionNameEnum name)
            {
                switch (name)
                {
                    case OptionNameEnum.图幅网格:
                        return 显示图幅网格ToolStripCheckBox.Checked;
                    case OptionNameEnum.图幅号:
                        return 显示图幅号ToolStripCheckBox.Checked;
                    case OptionNameEnum.新图幅号:
                        return 显示新图幅号ToolStripCheckBox.Checked;
                    case OptionNameEnum.旧图幅号:
                        return 显示旧图幅号ToolStripCheckBox.Checked;
                    case OptionNameEnum.数据种类:
                        return 显示影像种类ToolStripCheckBox.Checked;
                    case OptionNameEnum.时间属性:
                        return 显示时间属性ToolStripCheckBox.Checked;
                    case OptionNameEnum.数据集名称:
                        return 显示数据集名称ToolStripCheckBox.Checked;
                    case OptionNameEnum.详细数据:
                        return 显示详细数据ToolStripCheckBox.Checked;
                    default:
                        return false;
                }
            }

            public void FireConditionChangedEvent()
            {
                fireConditionChangedEvent();
            }

            #region get比例尺()
            private IEnumerable<string> get比例尺()
            {
                List<string> condition = new List<string>();
                string text = 比例尺ToolStripSplitButton.Text.Trim();
                switch (text)
                {
                    case "任意":
                        break;
                    case "1:500":
                    case "1:1000":
                    case "1:2000":
                    case "1:5000":
                    case "1:10000":
                    case "1:20000":
                    case "1:50000":
                        condition.Add(text.Replace("1:", ""));
                        break;
                    default:
                        string[] pieces = text.Split(',', ',');
                        int i;
                        foreach (string piece in pieces)
                        {
                            if (int.TryParse(piece, out i))
                                condition.Add(i.ToString());
                        }
                        break;
                }

                return condition;
            }
            #endregion

            #region get分辨率()
            private IEnumerable<string> get分辨率()
            {
                List<string> condition = new List<string>();

                string text = 分辨率ToolStripSplitButton.Text.Trim();
                switch (text)
                {
                    case "任意":
                        break;
                    case "0.1米":
                    case "0.2米":
                    case "0.5米":
                    case "1米":
                    case "2米":
                    case "4米":
                    case "10米":
                        condition.Add(text.Replace("米", ""));
                        break;
                    default:
                        string[] pieces = text.Split(',', ',');
                        double i;
                        foreach (string piece in pieces)
                        {
                            if (double.TryParse(piece, out i))
                                condition.Add(i.ToString());
                        }
                        break;
                }

                return condition;
            }
            #endregion

            #region get数据种类()
            private IEnumerable<string> get数据种类()
            {
                List<string> condition = new List<string>();

                Syncfusion.Windows.Forms.Tools.ToolStripCheckBox check = null;
                foreach (ToolStripItem item in 数据种类ToolStripEx.Items)
                {
                    if (!(item is Syncfusion.Windows.Forms.Tools.ToolStripCheckBox))
                        continue;

                    check = item as Syncfusion.Windows.Forms.Tools.ToolStripCheckBox;
                    if (check.Checked)
                        condition.Add(check.Text.Trim());
                }

                return condition;
            }
            #endregion

            #region get时效性
            private IEnumerable<string> get时效性()
            {
                List<string> condition = new List<string>();

                string text = 时效性条件ToolStripSplitButton.Text.Trim();
                switch (text)
                {
                    case "任意":
                        break;
                    case "今年":
                        condition.Add(DateTime.Now.ToString("yyyy-01-01"));
                        condition.Add(DateTime.Now.AddYears(1).ToString("yyyy-01-01"));
                        break;
                    case "去年":
                        condition.Add(DateTime.Now.AddYears(-1).ToString("yyyy-01-01"));
                        condition.Add(DateTime.Now.ToString("yyyy-01-01"));
                        break;
                    case "近两年":
                        condition.Add(DateTime.Now.AddYears(-1).ToString("yyyy-01-01"));
                        condition.Add(DateTime.Now.AddYears(1).ToString("yyyy-01-01"));
                        break;
                    case "近三年":
                        condition.Add(DateTime.Now.AddYears(-2).ToString("yyyy-01-01"));
                        condition.Add(DateTime.Now.AddYears(1).ToString("yyyy-01-01"));
                        break;
                    default:
                        break;
                }

                return condition;
            }
            #endregion


            #region --

            //检索和显示的交互
            private IQueryFilter pQueryFilter;

            //设置字体样式,最好可以通过设置参数来设置字体样式
            private ITextSymbol generateFont()
            {
                IFont pFont = new StdFontClass();
                pFont.Name = "宋体";
                pFont.Size = 30;
                IRgbColor pColor = new RgbColorClass();
                pColor.Red = 255;
                pColor.Blue = 0;
                pColor.Green = 0;
                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Color = pColor;
                pTextSymbol.Font = (IFontDisp)pFont;
                pTextSymbol.Size = 11;
                return pTextSymbol;
            }

            //生成拼接字符串:摄区名称、摄区编号、影像种类、显示时间属性
            private void  stringDisplay(IFeatureClass inputFeatureClass, ITextSymbol inputTextSymbol)
            {
                ITextElement pTextElement;
                IElement pElement;
                IArea pArea;
                IPoint pPoint = new PointClass();

                IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)mapControl._AxMapControl.Map;
                IFeatureClass pFeatureClass = inputFeatureClass;

                IFeatureCursor pFeatureCursor = pFeatureClass.Search(this.pQueryFilter, false);
                string str=string.Empty;
                int index;
                IFeature pFeature = pFeatureCursor.NextFeature();

                while (pFeature != null)
                {
                    str = string.Empty;
                    pArea = (IArea)pFeature.Shape;
                    pPoint = pArea.Centroid;
                    //if (is摄区名称Checked)
                    //{
                    //    index = pFeature.Fields.FindField("ShequName");
                    //    str += "\r\n"+ pFeature.get_Value(index).ToString();
                    //}
                    //if (is摄区编号Checked)
                    //{
                    //    index = pFeature.Fields.FindField("Shequhao");
                    //    str +=  "\r\n" + pFeature.get_Value(index).ToString();
                    //}
                    if (is显示影像种类Checked)
                    {
                        index = pFeature.Fields.FindField("ImgType");
                        str +=  "\r\n" + pFeature.get_Value(index).ToString();
                    }
                    if (is显示时间属性Checked)
                    {
                        index = pFeature.Fields.FindField("StartDate");
                        str +=  "\r\n" + pFeature.get_Value(index).ToString().Substring(0,pFeature.get_Value(index).ToString().Length-8);
                        index = pFeature.Fields.FindField("EndDate");
                        str += "\r\n" + pFeature.get_Value(index).ToString().Substring(0,pFeature.get_Value(index).ToString().Length - 8);
                    }

                    pTextElement = new TextElementClass();
                    pTextElement.Symbol = generateFont();
                    pTextElement.ScaleText = true;
                    pTextElement.Text = str;

                    pElement = (IElement)pTextElement;
                    pElement.Geometry = pPoint;
                    pGraphicsContainer.AddElement(pElement, 0);

                    pFeature = pFeatureCursor.NextFeature();
                }
                mapControl._AxMapControl.ActiveView.Refresh();
     
            }


            //显示注记控制,只用来控制网格
            private void elementsDisplay(IFeatureClass inputFeatureClass,string inputstrField,ITextSymbol inputTextSymbol)
            {
                ITextElement pTextElement;
                IElement pElement;
                IArea pArea;
                IPoint pPoint = new PointClass();

                IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)mapControl._AxMapControl.Map;

                IFeatureClass pFeatureClass = inputFeatureClass;
                IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
                IFeature pFeature = pFeatureCursor.NextFeature();

                while (pFeature != null)
                {
                    pArea = (IArea)pFeature.Shape;
                    pPoint = pArea.Centroid;
                    int index = pFeature.Fields.FindField(inputstrField);
                    pTextElement = new TextElementClass();
                    pTextElement.Symbol = generateFont();
                    pTextElement.ScaleText = true;
                    pTextElement.Text = pFeature.get_Value(index).ToString();
                  
                    pElement = (IElement)pTextElement;
                    pElement.Geometry = pPoint;
                    pGraphicsContainer.AddElement(pElement, 0);
                    pFeature = pFeatureCursor.NextFeature();
                }
                mapControl._AxMapControl.ActiveView.Refresh();
            }
          
            //删除所有注记
            private void elementsDeleted()
            {
                IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)mapControl._AxMapControl.Map;
                pGraphicsContainer.DeleteAllElements();
                mapControl._AxMapControl.ActiveView.Refresh();
            }
     
            //总显示控制
            private void totalDisplay()
            {

                if (is图符Checked)
                {
                    //GetThe图符FeatureLayer(mapControl._AxMapControl).Visible = true;
                }
                else
                {  
                    //GetThe图符FeatureLayer(mapControl._AxMapControl).Visible = false;
     
                }
                if (is图符编号Checked)
                {
                    //elementsDisplay(GetThe图符FeatureClass(mapControl._AxMapControl), "新图符", generateFont());
                }

                if (is数据集名称Checked)
                {
                    stringDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), generateFont());
                    //elementsDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), "Name",generateFont());
                }

                if (is数据集编号Checked)
                {
                    stringDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), generateFont());
                    //elementsDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), "Code",generateFont());
                }

                if (is显示影像种类Checked)
                {
                    stringDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), generateFont());   
                    //elementsDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), "ImgType",generateFont());
                }
                if (is显示时间属性Checked)
                {
                    stringDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), generateFont());
                    //elementsDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), "StartDate",generateFont());
                    //elementsDisplay(GetThe摄区FeatureClass(mapControl._AxMapControl), "EndDate",generateFont());
                }       
            }

            //总查询控制
            private void TotalSearch()
            {
                mapControl._AxMapControl.Map.ClearSelection();
                IActiveView pActiveView = (IActiveView)mapControl._AxMapControl.Map;
                IFeatureClass pFeatureClass = GetThe摄区FeatureClass(mapControl._AxMapControl);
                IFeatureLayer pFeatureLayer = GetThe摄区FeatureLayer(mapControl._AxMapControl);
        
                IFeatureLayerDefinition pFeatureLayerDef = (IFeatureLayerDefinition)pFeatureLayer;

                IFeature pFeature;
                IFeatureCursor pFeatureCursor;
                IQueryFilter pQueryFilter = new QueryFilterClass();

                string strAnd = string.Empty;
                TotalSearchString = string.Empty;
                if (DataCatgreySearchString != string.Empty)
                {
                    TotalSearchString += strAnd + DataCatgreySearchString;
                    strAnd = " And ";
                }

                if (ScaleSearchString != string.Empty)
                {
                    TotalSearchString += strAnd + ScaleSearchString;
                    strAnd = " And ";
                }

                if (ResolutionSearchString != string.Empty)
                {
                    TotalSearchString += strAnd + ResolutionSearchString;
                    strAnd = " And ";
                }
                if (DateSearchString != string.Empty)
                {
                    TotalSearchString += strAnd + DateSearchString;
                    strAnd = "And";
                }

                pQueryFilter.WhereClause = TotalSearchString;

                pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);
                this.pQueryFilter = pQueryFilter;
                pFeature = pFeatureCursor.NextFeature();
                while (pFeature != null)
                {
                    mapControl._AxMapControl.Map.SelectFeature(pFeatureLayer, pFeature);
                    pFeature = pFeatureCursor.NextFeature();
                }
                pFeatureLayerDef.DefinitionExpression = TotalSearchString;
                pActiveView.Refresh();
            }
          
            public DOMPropertyConditionControl()
            {
                InitializeComponent();
            }

            private Middle_Search_Map mapControl = null;
            public void SetMapControl(Middle_Search_Map control)
            {
                mapControl = control;
            }

            private IFeatureClass GetThe摄区FeatureClass(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass=null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.ShequFeature".ToUpper())
                    {
                        pFeatureClass = pFeatureLayer.FeatureClass;

                    }
        
                }
                return pFeatureClass;
            }
            private IFeatureLayer GetThe摄区FeatureLayer(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer = null;
                IFeatureLayer pReaturnFeatureLayer = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.ShequFeature".ToUpper())
                    {
                        pReaturnFeatureLayer = pFeatureLayer;

                    }

                }
                return pReaturnFeatureLayer;
            }

            private IFeatureClass GetThe图符FeatureClass(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "sde2.SDE.图符".ToUpper())
                    {
                        pFeatureClass = pFeatureLayer.FeatureClass;

                    }

                }
                return pFeatureClass;
            }
            private IFeatureLayer GetThe图符FeatureLayer(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer = null;
                IFeatureLayer pReaturnFeatureLayer = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "sde2.SDE.图符".ToUpper())
                    {
                        pReaturnFeatureLayer = pFeatureLayer;

                    }

                }
                return pReaturnFeatureLayer;
            }

            private IFeatureClass GetThe分区FeatureClass(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.FenquFeature".ToUpper())
                    {
                        pFeatureClass = pFeatureLayer.FeatureClass;

                    }

                }
                return pFeatureClass;
            }
            private IFeatureLayer GetThe分区FeatureLayer(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer = null;
                IFeatureLayer pReaturnFeatureLayer = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.FenquFeature".ToUpper())
                    {
                        pReaturnFeatureLayer = pFeatureLayer;

                    }

                }
                return pReaturnFeatureLayer;
            }

            private IFeatureClass GetThe像点FeatureClass(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.XiangdianFeature".ToUpper())
                    {
                        pFeatureClass = pFeatureLayer.FeatureClass;

                    }

                }
                return pFeatureClass;
            }
            private IFeatureLayer GetThe像点FeatureLayer(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer=null;
                IFeatureLayer pReaturnFeatureLayer=null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.XiangdianFeature".ToUpper())
                    {
                        pReaturnFeatureLayer = pFeatureLayer;

                    }

                }
                return pReaturnFeatureLayer;
            }
         
            private IFeatureClass GetThe航线FeatureClass(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.HangxianFeature".ToUpper())
                    {
                        pFeatureClass = pFeatureLayer.FeatureClass;

                    }

                }
                return pFeatureClass;
            }

            private IFeatureLayer GetThe航线FeatureLayer(AxMapControl axMapControl)
            {
                IMap pMap = axMapControl.Map;
                IFeatureLayer pFeatureLayer = null;
                IFeatureLayer pReaturnFeatureLayer = null;
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    pFeatureLayer = (IFeatureLayer)pMap.get_Layer(i);
                    if (pFeatureLayer.FeatureClass.AliasName.ToUpper() == "FeatureImageBase.SDE.HangxianFeature".ToUpper())
                    {
                        pReaturnFeatureLayer = pFeatureLayer;

                    }

                }
                return pReaturnFeatureLayer;
            }

            //生成日期选择字符串
            private void generateDateConditon()
            {
                DateTime Today = DateTime.Today;
                DateTime TodayOfLastYear =DateTime.Today.AddYears(-1);
                DateTime TodayOfLastTwoYear= DateTime.Today.AddYears(-2);
                DateTime TodayOfLastThreeYear =  DateTime.Today.AddYears(-3);

                string strOr=string.Empty;
                string condition =string.Empty;          
               
                if (DateSearchString == "任意")
                {
                    condition += strOr+"StartDate <> '' OR EndDate <> ''";
                    strOr="Or";
                }
                else
                {
                    if (DateSearchString == "今年")
                    {
                        condition = strOr + " StartDate <" + "'" + Today.ToString("yyyy-MM-dd") + "'" + " And " + " EndDate > " + "'" + TodayOfLastYear.ToString("yyyy-MM-dd") + "'";
                            strOr = "Or";
                    }
                    else if (DateSearchString == "去年")
                    {
                        condition = strOr + " StartDate <" + "'" + TodayOfLastYear.ToString("yyyy-MM-dd") + "'" + " And " + " EndDate > " + "'" + TodayOfLastTwoYear.ToString("yyyy-MM-dd") + "'";
                        strOr = "Or";
                    }
                    else if (DateSearchString == "近两年")
                    {
                        condition = strOr + " StartDate <" + "'" + Today.ToString("yyyy-MM-dd") + "'" + " And " + " EndDate > " + "'" + TodayOfLastTwoYear.ToString("yyyy-MM-dd") + "'";
                        strOr = "Or";
                    }
                    else if (DateSearchString == "近三年")
                    {
                        condition = strOr + " StartDate <" + "'" + Today.ToString("yyyy-MM-dd") + "'" + " And " + " EndDate > " + "'" + TodayOfLastThreeYear.ToString("yyyy-MM-dd")+"'";
                        strOr = "Or";
                    }

                }

                if (condition == string.Empty)
                {
                    DateSearchString = string.Empty;
                }
                else
                {
                    DateSearchString = "(" + condition + ")";

                }
     
            }

            //生成数据类型选择字符串
            private void generateCategoryCondition()
            {
                string condition = string.Empty;
                string strOr = string.Empty;
                if (全色ToolStripCheckBox.Checked)
                {
                    condition += strOr + "( ImgType like '%全色%' )";
                    strOr = " OR ";
                }
                if (真彩ToolStripCheckBox.Checked)
                {
                    condition += strOr + "( ImgType like '%真彩%' )";
                    strOr = " OR ";
                }
                if (彩红外ToolStripCheckBox.Checked)
                {
                    condition += strOr + "( ImgType like '%彩红外%' )";
                    strOr = " OR ";
                }
                //if (原始零级ToolStripCheckBox.Checked)
                //{
                //    condition += strOr + "( ImgType like '%0级%' )";
                //    strOr = " OR ";
                //}

                if (condition == string.Empty)
                    DataCatgreySearchString = string.Empty;
                else
                    DataCatgreySearchString = "( " + condition + " )";
            }
            //完成查询和刷新
            private void refreshMap()
            {
                mapControl._AxMapControl.Map.ClearSelection();
                TotalSearch();
                mapControl._AxMapControl.ActiveView.Refresh();
            }

            #endregion

        }
    }

  • 相关阅读:
    linux c编程操作数据库(sqlite3应用)
    Silverlight-MEF-DEMO
    微软最有价值专家分享校园招聘心得体会
    C# IOCP服务器项目(学习)
    ASIHTTPRequest类库简介和使用说明
    用Python下载美国国家气候数据中心(NCDC)的气候数据
    20个大家应该知道的大数据资源
    分布式文件系统HDFS,大数据存储实战(一)
    vmware虚拟的ubuntu18.04死机,尝试关闭时关机报“虚拟机xxx繁忙”
    ubuntu下hadoop0.20.2报错/dfs/name is in an inconsistent state
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1493584.html
Copyright © 2020-2023  润新知