Example #1
0
 // Adds all appropriate Layer objects to the list.
 // Calls itself recursively to search through GroupLayers.
 private void AddLayersToList(LayersBase layers, ListBox listbox)
 {
     foreach (IMapLayer layer in layers)
     {
         if (layer is GroupLayer)
         {
             GroupLayer grpLyr = layer as GroupLayer;
             AddLayersToList(grpLyr, listbox);
         }
         else if (layer is FeatureLayer)
         {
             FeatureLayer featLyr = layer as FeatureLayer;
             if (featLyr != null && featLyr.IsVisible &&
                 featLyr.Type != LayerType.Raster &&
                 featLyr.Type != LayerType.Grid)
             {
                 // The specified layer should be select-able.
                 // But if we've been asked to build a list of EDIT-able layers,
                 // take some other criteria into account... Seamless layers are
                 // not editable, and some tables are simply read-only.
                 if ((FilterType == FilterType.Selectable) ||
                     LayerCanBeMadeEditable(featLyr))
                 {
                     listbox.Items.Add(featLyr);
                 }
             }
         }
     }
 }
        // Return a comma-separated list of layer names, representing the list of
        // layers that are active according to the specified filter.
        // This method calls itself recursively to search within GroupLayers.
        private string BuildLayerList(string str, LayersBase layers, IMapLayerFilter filter)
        {
            bool bAllLayers=true;

            foreach (IMapLayer layer in layers)
            {
                if (layer is GroupLayer)
                {
                    GroupLayer grpLyr = layer as GroupLayer;
                    str = BuildLayerList(str, grpLyr, filter);
                    if (str.StartsWith("<All>: ")) str=str.Remove(0,7);
                    else bAllLayers=false;
                }
                else if (layer is FeatureLayer)
                {
                    FeatureLayer featLyr = layer as FeatureLayer;
                    if (featLyr != null && featLyr.IsVisible &&
                        featLyr.Type != LayerType.Raster &&
                        featLyr.Type != LayerType.Wms &&
                        featLyr.Type != LayerType.Grid)
                    {
                        if (filter.IncludeLayer(featLyr) )
                        {
                            if (str.Length > 0)
                            {
                                str += ", ";
                            }
                            str += featLyr.Name;
                        }
                        else bAllLayers=false;
                    }
                }
            }

            if (str.Length==0) str = bAllLayers ? "<No layers available>" : "<None>";

            else if (bAllLayers==true)
            {
                if (str.Length > 16) str="<All>";
                else str="<All>: " + str;
            }

            return str;
        }
Example #3
0
        // Return a comma-separated list of layer names, representing the list of
        // layers that are active according to the specified filter.
        // This method calls itself recursively to search within GroupLayers.
        private string BuildLayerList(string str, LayersBase layers, IMapLayerFilter filter)
        {
            bool bAllLayers = true;

            foreach (IMapLayer layer in layers)
            {
                if (layer is GroupLayer)
                {
                    GroupLayer grpLyr = layer as GroupLayer;
                    str = BuildLayerList(str, grpLyr, filter);
                    if (str.StartsWith("<All>: "))
                    {
                        str = str.Remove(0, 7);
                    }
                    else
                    {
                        bAllLayers = false;
                    }
                }
                else if (layer is FeatureLayer)
                {
                    FeatureLayer featLyr = layer as FeatureLayer;
                    if (featLyr != null && featLyr.IsVisible &&
                        featLyr.Type != LayerType.Raster &&
                        featLyr.Type != LayerType.Wms &&
                        featLyr.Type != LayerType.Grid)
                    {
                        if (filter.IncludeLayer(featLyr))
                        {
                            if (str.Length > 0)
                            {
                                str += ", ";
                            }
                            str += featLyr.Name;
                        }
                        else
                        {
                            bAllLayers = false;
                        }
                    }
                }
            }

            if (str.Length == 0)
            {
                str = bAllLayers ? "<No layers available>" : "<None>";
            }

            else if (bAllLayers == true)
            {
                if (str.Length > 16)
                {
                    str = "<All>";
                }
                else
                {
                    str = "<All>: " + str;
                }
            }

            return(str);
        }
 // Adds all appropriate Layer objects to the list.
 // Calls itself recursively to search through GroupLayers.
 private void AddLayersToList(LayersBase layers, ListBox listbox)
 {
     foreach (IMapLayer layer in layers)
     {
         if (layer is GroupLayer)
         {
             GroupLayer grpLyr = layer as GroupLayer;
             AddLayersToList(grpLyr, listbox);
         }
         else if (layer is FeatureLayer)
         {
             FeatureLayer featLyr = layer as FeatureLayer;
             if (featLyr != null && featLyr.IsVisible &&
                 featLyr.Type != LayerType.Raster &&
                 featLyr.Type != LayerType.Grid)
             {
                 // The specified layer should be select-able.
                 // But if we've been asked to build a list of EDIT-able layers,
                 // take some other criteria into account... Seamless layers are
                 // not editable, and some tables are simply read-only.
                 if ( (FilterType == FilterType.Selectable) ||
                       LayerCanBeMadeEditable(featLyr) )
                 {
                     listbox.Items.Add(featLyr);
                 }
             }
         }
     }
 }