/// <summary>
 /// Check if the form is applicable to the given set of objects. In this case
 /// only the Raster Function object is used to check compatibility.
 /// </summary>
 /// <param name="objects">Set of object to check against.</param>
 /// <returns>Flag to specify whether the form is applicable.</returns>
 public bool Applies(ESRI.ArcGIS.esriSystem.ISet objects)
 {
     objects.Reset();
     for (int i = 0; i < objects.Count; i++)
     {
         object currObject = objects.Next();
         if (currObject is IRasterFunction)
         {
             IRasterFunction rasterFunction = (IRasterFunction)currObject;
             if (rasterFunction is IPersistVariant)
             {
                 IPersistVariant myVariantObject = (IPersistVariant)rasterFunction;
                 // Compare the ID from the function object with the ID's supported by this UI page.
                 if (myVariantObject.ID.Compare(mySupportedID))
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        public static ILayer Clone(this ILayer layer)
        {
            if (layer is IPersistStream)
            {
                IObjectCopy objectCopy = new ObjectCopyClass();
                object      clone      = objectCopy.Copy(layer);
                ILayer      layerClone = clone as ILayer;
                return(layerClone);
            }
            if (layer is IPersistVariant)
            {
                // Create an XML Stream
                IXMLStream       xmlStream       = new XMLStreamClass();
                IVariantStreamIO variantStreamIO = new VariantStreamIOClass()
                {
                    Stream = (IStream)xmlStream
                };

                // Save Layer to Stream
                IVariantStream  variantStream = (IVariantStream)variantStreamIO;
                IPersistVariant save          = (IPersistVariant)layer;
                save.Save(variantStream);

                // Move Seek Pointer to beginning of Stream
                xmlStream.Reset();

                // Create New Layer
                ILayer newlayer = null;
                if (layer is IImageServerLayer)
                {
                    newlayer = new ImageServerLayerClass();
                }
                if (newlayer == null)
                {
                    return(null);
                }

                // Create new Layer
                IPersistVariant load = (IPersistVariant)newlayer;
                load.Load(variantStream);

                // Return Cloned Layer
                return(newlayer);
            }
            return(null);
        }