⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zoomtoresults.cs

📁 C#开发的ArcGIS Server9.2查询地物居中高亮显示控件
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.Collections;

using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS.ADF.ArcGISServer;
using ESRI.ArcGIS.ADF.Web.Geometry;
using ESRI.ArcGIS.ADF.Web;
using ESRI.ArcGIS.ADF.Web.Display.Graphics;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Design;
using ESRI.ArcGIS.ADF.Web.DataSources;

namespace CustomControls
{
    // To override ITaskResultsContainer methods implemented in TaskResults but not marked virtual, implement ITaskResultsContainer methods directly.  
    // For example, the DisplayResults and StartTaskActivityIndicator methods are implemented within this class.
    [ToolboxData("<{0}:ZoomToResults runat=\"server\" Width=\"200px\" Height=\"200px\" BackColor=\"#ffffff\" Font-Names=\"Verdana\" Font-Size=\"8pt\" ForeColor=\"#000000\"> </{0}:ZoomToResults>")]
    public class ZoomToResults : TaskResults, ITaskResultsContainer
    {
        [Category("TaskResults"),
         DefaultValue(10),
         Description("The maximum number of features in the result set to zoom to"),
         PersistenceMode(PersistenceMode.Attribute),
         NotifyParentProperty(true)]
        public int MaxResultsForMapZoom
        {
            get
            {
                object o = StateManager.GetProperty("MaxResultsForMapZoom");
                return (o == null) ? 10 : Convert.ToInt32(o);
            }
            set
            {
                if (value >= 0)
                { StateManager.SetProperty("MaxResultsForMapZoom", value); }
                else
                { throw new Exception(); }
            }
        }

        [Category("TaskResults"),
         DefaultValue(10),
         Description("The maximum number of features in the result set to automatically select"),
         PersistenceMode(PersistenceMode.Attribute),
         NotifyParentProperty(true)]
        public int MaxResultsForAutoSelect
        {
            get
            {
                object o = StateManager.GetProperty("MaxResultsForAutoSelect");
                return (o == null) ? 10 : Convert.ToInt32(o);
            }
            set
            {
                if (value >= 0)
                { StateManager.SetProperty("MaxResultsForAutoSelect", value); }
                else
                { throw new Exception(); }
            }
        }

        [Category("TaskResults"),
         DefaultValue(10.0),
         Description("Minimum width in map units that will be zoomed to"),
         PersistenceMode(PersistenceMode.Attribute),
         NotifyParentProperty(true)]
        public double MinWidthOfZoom
        {
            get
            {
                object o = StateManager.GetProperty("MinWidthOfZoom");
                return (o == null) ? 10.0 : Convert.ToDouble(o);
            }
            set
            {
                if (value >= 0)
                { StateManager.SetProperty("MinWidthOfZoom", value); }
                else
                { throw new Exception(); }

            }
        }

        [Category("TaskResults"),
        DefaultValue(10.0),
        Description("The percentage that you want the final extent to zoom out from the extent of the result set."),
        PersistenceMode(PersistenceMode.Attribute),
        NotifyParentProperty(true)]
        public double ZoomExtentExpansionPercent
        {
            get
            {
                object o = StateManager.GetProperty("ZoomExtentExpansionPercent");
                return (o == null) ? 10.0 : Convert.ToDouble(o);
            }
            set
            {
                if (value >= 0)
                { StateManager.SetProperty("ZoomExtentExpansionPercent", value); }
                else
                { throw new Exception(); }
            }
        }

        [Category("TaskResults"),
        DefaultValue(false),
        Description("Show or hide activity indicator during task execution."),
        PersistenceMode(PersistenceMode.Attribute),
        NotifyParentProperty(true)]
        public bool ShowTaskActivityIndicator
        {
            get
            {
                object o = StateManager.GetProperty("ShowTaskActivityIndicator");
                return (o == null) ? false : Convert.ToBoolean(o);
            }
            set
            {
                StateManager.SetProperty("ShowTaskActivityIndicator", value);
            }
        }

        [Category("TaskResults"),
        DefaultValue(false),
        Description("Display task results."),
        PersistenceMode(PersistenceMode.Attribute),
        NotifyParentProperty(true)]
        public bool DisplayTaskResults
        {
            get
            {
                object o = StateManager.GetProperty("DisplayTaskResults");
                return (o == null) ? false : Convert.ToBoolean(o);
            }
            set
            {
                StateManager.SetProperty("DisplayTaskResults", value);
            }
        }

        // Overriding the StartTaskActivityIndicator method in TaskResults is not possible since the method is 
        // not marked virtual.  Instead implement the method via ITaskResultsContainer and if necessary call the 
        // method in the base class (TaskResults).
        void ITaskResultsContainer.StartTaskActivityIndicator(ITask task, string taskJobID)
        {
            if (ShowTaskActivityIndicator)
            {
                base.StartTaskActivityIndicator(task, taskJobID);
            }
        }
        // Overriding the DisplayResults method in TaskResults is not possible since the method is 
        // not marked virtual.  Instead implement the method via ITaskResultsContainer only use this code
        // to prepare task results for display.
        void ITaskResultsContainer.DisplayResults(ITask task, string taskJobID, object taskInputs, object taskResults)
        {
            //Throw an exception if the Map property is not set to a valid map.
            if (MapInstance == null)
            { throw new Exception("You must set the Map property to a valid map"); }

            //Return if the auto select and map zoom capabilities are disabled 
            if (MaxResultsForMapZoom == 0 && MaxResultsForAutoSelect == 0)
            { return; }

            //Create the envlope to hold the extent that the map will be set to
            ESRI.ArcGIS.ADF.Web.Geometry.Envelope pEnv = null;

            //declare / initialize variables to use below
            int intTotalResultsCount = 0;
            bool doZoom = false;
            bool doSelect = false;
            DataSet ds = null;

            //Test to see if the results is a TaskResultsNode
            TreeViewPlusNode trNode = taskResults as TreeViewPlusNode;
            if (trNode != null)
            {
                //If it is a task results node count all the data 
                //table rows in each GraphicsLayerNode
                intTotalResultsCount = countAllResultsInNode(trNode);

                //save a bool for if we should zoom or select based 
                //on the size of the result set
                doZoom = (intTotalResultsCount <= MaxResultsForMapZoom);
                doSelect = (intTotalResultsCount <= MaxResultsForAutoSelect);
                //If we are going to zoom or select then process the results
                if (doZoom || doSelect)
                { processNode(trNode, doSelect, doZoom, ref pEnv); }
            }
            else
            {
                //Cast the results set to a DataSet
                ds = taskResults as DataSet;

                //Make sure we have a valid dataset with tables before iterating
                if (ds != null && ds.Tables.Count > 0)
                {

                    //Count the results set
                    foreach (DataTable dt in ds.Tables)
                    {
                        intTotalResultsCount += dt.Rows.Count;
                    }

                    if (intTotalResultsCount > 0)
                    {
                        //save a bool for if we should zoom or select based 
                        //on the size of the result set
                        doZoom = (intTotalResultsCount <= MaxResultsForMapZoom);
                        doSelect = (intTotalResultsCount <= MaxResultsForAutoSelect);
                        //If we are going to zoom or select then process the results
                        if (doZoom || doSelect)
                        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -