private bool IsInMemoryLayer(IDatasourceInput layer)
 {
     return layer != null && 
            layer.InputType == Enums.InputType.Layer && 
            layer.Datasource is IFeatureSet &&
            (layer.Datasource as IFeatureSet).SourceType == FeatureSourceType.InMemory;
 }
Beispiel #2
0
 public InputLayerEventArgs(IDatasourceInput input)
 {
     if (input == null)
     {
         throw new ArgumentNullException("layer");
     }
     Datasource = input;
 }
 public InputLayerGridAdapter(IDatasourceInput source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     _source = source;
 }
        /// <summary>
        /// Called when selected layer is changed.
        /// </summary>
        public void OnLayerChanged(IDatasourceInput input)
        {
            var vector = input as IVectorInput;

            if (vector != null)
            {
                RebuildFieldList(vector.Datasource);
            }
        }
        /// <summary>
        /// Assigns list of fields from particular vector datasource.
        /// </summary>
        public void OnLayerChanged(IDatasourceInput input)
        {
            // let the exception be thrown, we are supposed to have only vector datasouce at this stage
            _featureSet = (input as IVectorInput).Datasource;

            // we can try to preserve the fields that are also present in new datasource
            _fields.Clear();

            fieldOperationGrid1.DataSource = _fields;
            fieldOperationGrid1.UpdateFieldCombo(_featureSet);

            RefreshControls();
        }
        /// <summary>
        /// Called when datasource is changed.
        /// </summary>
        /// <param name="layer">The layer.</param>
        public void OnDatasourceChanged(IDatasourceInput layer)
        {
            _filename = string.Empty;

            if (IsInMemoryLayer(layer))
            {
                _inputFilename = layer.Name;
            }
            else
            {
                _inputFilename = layer != null ? layer.Filename : string.Empty;
            }

            RefreshName();
        }
Beispiel #7
0
        /// <summary>
        /// Creates instance of layer input for the specified layer.
        /// </summary>
        private static IDatasourceInput ReopenLayerInput(ILayer layer, IDatasourceInput oldInput)
        {
            if (layer == null)
            {
                return(null);
            }

            var input = new LayerInput(layer);

            var vector = oldInput as IVectorInput;

            if (vector != null)
            {
                input.SelectedOnly = vector.SelectedOnly;
            }

            return(input);
        }
Beispiel #8
0
        /// <summary>
        /// Reopens datasource which served as input for GisTool. The datasource will be searched
        /// for among open layers, including in-memory layers and if not present, reoped from the disk.
        /// </summary>
        private static IDatasourceInput ReopenDatasource(
            this DatasourcePointer ds,
            IAppContext context,
            IDatasourceInput oldInput)
        {
            int layerHandle = ds.LayerHandle;

            if (layerHandle != -1)
            {
                var layer = context.Layers.ItemByHandle(layerHandle);

                return(ReopenLayerInput(layer, oldInput));
            }

            var identity = ds.LayerIdentity;

            if (identity != null)
            {
                // maybe it opened
                var layer = context.Layers.FirstOrDefault(l => l.Identity == identity);

                if (layer != null)
                {
                    return(ReopenLayerInput(layer, oldInput));
                }

                // if not, let's try to open
                var source = GeoSource.OpenFromIdentity(identity) as ILayerSource;
                if (source != null)
                {
                    return(new DatasourceInput(source));
                }
            }

            return(null);
        }
Beispiel #9
0
 /// <summary>
 /// Gets icon index for datasource.
 /// </summary>
 private int GetImageIndex(IDatasourceInput input)
 {
     return(LayerIconHelper.GetIcon(input.Datasource));
 }
 public void OnDatasourceChanged(IDatasourceInput input)
 {
     // do nothing
 }
 public InputLayerGridAdapter(string filename)
 {
     _source = new DatasourceInput(filename);
 }
 public InputLayerGridAdapter(ILayer layer)
 {
     _source = new LayerInput(layer);
 }
Beispiel #13
0
 public void OnDatasourceChanged(IDatasourceInput input)
 {
     _inputFilename = input.Name;
     RefreshName();
 }