Common_CustomTasks_CSharp\FindNearTask_CSharp\InputParameters.cs
// Copyright 2011 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using System; using System.Collections.Generic; using System.Text; namespace FindNearTask_CSharp { // Manages task input parameters internal class InputParameters { // Array to store input geometries. Used when the user wants to combine geometries. private ESRI.ArcGIS.ADF.Web.Geometry.Geometry[] _userInputGeometries = null; // Name of the map resource containing the layer to search public string SearchResource = null; // Name of the layer to search public string SearchLayer = null; // Search distance public float SearchDistance = 1000; // Search units public string Units = null; // Search geometry. This is the user input geometries buffered by the search distance. public ESRI.ArcGIS.ADF.Web.Geometry.Geometry BufferGeometry = null; // Whether or not to combine new input geometries with those previously defined public bool AddToInputGeometry = true; // Provides read access to the geometries to search near, as defined by the user public ESRI.ArcGIS.ADF.Web.Geometry.Geometry[] UserInputGeometries { get { return _userInputGeometries; } } // Defines the geometries to search near. If AddToInputGeometry is true, the passed-in geometries // are combined with those already defined. Otherwise, the defined input geometries are overwritten. public void SetUserInputGeometries(ESRI.ArcGIS.ADF.Web.Geometry.Geometry[] inputGeometries) { // Check whether to combine the passed-in geometries with those already defined if (this.AddToInputGeometry && _userInputGeometries != null) { // Create a new geometry array that's large enough to hold both the defined geometries and those // passed-in ESRI.ArcGIS.ADF.Web.Geometry.Geometry[] combinedGeometries = new ESRI.ArcGIS.ADF.Web.Geometry.Geometry[inputGeometries.Length + _userInputGeometries.Length]; // Copy the previously defined geometries to the new array _userInputGeometries.CopyTo(combinedGeometries, 0); // Add the passed-in geometries to the end of the new array for (int i = _userInputGeometries.Length; i < combinedGeometries.Length; i++) combinedGeometries[i] = inputGeometries[i - _userInputGeometries.Length]; // Overwrite the previous geometry array with the combined array _userInputGeometries = combinedGeometries; } else { // Overwrite the previous geometry array or initialize it with the passed-in array _userInputGeometries = inputGeometries; } } } }