Пример #1
0
 public LabelLayer(String name, ILayerProvider dataSource)
 {
     this.Visible     = true;
     this._DataSource = dataSource;
     this.LayerName   = name;
     this.Style       = new GravurGIS.Styles.LabelStyle();
 }
Пример #2
0
 public LabelLayer(String name, ILayerProvider dataSource)
 {
     this.Visible = true;
     this._DataSource = dataSource;
     this.LayerName = name;
     this.Style = new GravurGIS.Styles.LabelStyle();
 }
Пример #3
0
        /// <summary>
        /// This should be called once all the permitted directories have been set in the code.
        /// This will not affect the PreferredProviders or the general list of Providers.
        /// These automatically have the lowest priority and will only be used if nothing
        /// else works. Use the PreferredProviders to force preferential loading of a plugin LayerProvider.
        /// </summary>
        /// <returns>A list of just the newly added LayerProviders from this method.</returns>
        public virtual List <ILayerProvider> LoadProvidersFromDirectories()
        {
            List <ILayerProvider> result = new List <ILayerProvider>();

            foreach (string directory in _layerProviderDirectories)
            {
                foreach (string file in Directory.GetFiles(directory, "*.dll", SearchOption.AllDirectories))
                {
                    if (file.Contains("Interop"))
                    {
                        continue;
                    }
                    if (Path.GetFileName(file) == "DotSpatial.dll")
                    {
                        continue;                                             // If they forget to turn "copy local" to false.
                    }
                    var asm = Assembly.LoadFrom(file);
                    try
                    {
                        Type[] coClassList = asm.GetTypes();
                        foreach (Type coClass in coClassList)
                        {
                            Type[] infcList = coClass.GetInterfaces();
                            foreach (Type infc in infcList)
                            {
                                if (infc == typeof(ILayerProvider))
                                {
                                    try
                                    {
                                        object         obj = asm.CreateInstance(coClass.FullName);
                                        ILayerProvider dp  = obj as ILayerProvider;
                                        if (dp != null)
                                        {
                                            _layerProviders.Add(dp);
                                            result.Add(dp);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Debug.WriteLine(ex);

                                        // this object didn't work, but keep looking
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);

                        // We will fail frequently.
                    }
                }
            }

            OnProvidersLoaded(result);
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Given a string fileName for the "*.dll" file, this will attempt to load any classes that implement the
        /// ILayerProvder interface.
        /// </summary>
        /// <param name="fileName">The string path of the assembly to load from.</param>
        /// <returns>A list that contains only the providers that were just loaded. This may be a list of count 0, but shouldn't return null.</returns>
        public virtual List <ILayerProvider> LoadProvidersFromAssembly(string fileName)
        {
            List <ILayerProvider> result = new List <ILayerProvider>();

            if (Path.GetExtension(fileName) != ".dll")
            {
                return(result);
            }
            if (fileName.Contains("Interop"))
            {
                return(result);
            }

            Assembly asm = Assembly.LoadFrom(fileName);

            try
            {
                Type[] coClassList = asm.GetTypes();
                foreach (Type coClass in coClassList)
                {
                    Type[] infcList = coClass.GetInterfaces();

                    foreach (Type infc in infcList)
                    {
                        if (infc != typeof(ILayerProvider))
                        {
                            continue;
                        }

                        try
                        {
                            object         obj = asm.CreateInstance(coClass.FullName);
                            ILayerProvider dp  = obj as ILayerProvider;
                            if (dp != null)
                            {
                                _layerProviders.Add(dp);
                                result.Add(dp);
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex);

                            // this object didn't work, but keep looking
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);

                // We will fail frequently.
            }

            OnProvidersLoaded(result);
            return(result);
        }
Пример #5
0
 public DirectoryLayer(string id, ILayerProvider provider, Mod mod, Link link, uint priority, bool writable = false)
 {
     Id                = id;
     Provider          = provider;
     this.mod          = mod;
     this.Link         = link;
     this.priority     = priority;
     this.writable     = writable;
     pathMapper        = new PathMapper(Path.Combine(mod.ModPath, link.ModPath), Path.Combine(mod.RootPath, link.TargetPath));
     rootDirectoryInfo = new DirectoryInfo(pathMapper.SourcePath);
 }
Пример #6
0
		public RasterLayer(ILayerProvider dataSource)
			: base(dataSource)
		{
		}
Пример #7
0
 /// <summary>
 /// Creates a new Layer instance identified by the given name, with
 /// symbology described by <paramref name="style"/> and
 /// with the given data source.
 /// </summary>
 /// <param name="layerName">
 /// The name to uniquely identify the layer by.
 /// </param>
 /// <param name="style">
 /// The symbology used to style the layer.
 /// </param>
 /// <param name="dataSource">
 /// The <see cref="ILayerProvider"/> which provides the data 
 /// for the layer.
 /// </param>
 protected Layer(string layerName, IStyle style, ILayerProvider dataSource)
 {
     LayerName = layerName;
     _dataSource = dataSource;
     Style = style;
 }
Пример #8
0
 /// <summary>
 /// Creates a new Layer instance identified by the given name and
 /// with the given data source.
 /// </summary>
 /// <param name="layerName">
 /// The name to uniquely identify the layer by.
 /// </param>
 /// <param name="dataSource">
 /// The <see cref="ILayerProvider"/> which provides the data 
 /// for the layer.
 /// </param>
 protected Layer(string layerName, ILayerProvider dataSource) :
     this(layerName, null, dataSource)
 {
 }
Пример #9
0
 /// <summary>
 /// Creates a new Layer instance with the given data source.
 /// </summary>
 /// <param name="dataSource">
 /// The <see cref="ILayerProvider"/> which provides the data 
 /// for the layer.
 /// </param>
 protected Layer(ILayerProvider dataSource) :
     this(String.Empty, null, dataSource)
 {
 }