Help impelmenting ILayerEffects in Graphics layer to use transparency

4507
2
05-28-2015 12:39 AM
RamiBader1
New Contributor II

I tried to get graphics in an ILayar class and implemented ILayerEffects to get semi-transparent in the layer properties but it does not help can you help me? I am attaching the class file.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;

namespace FirstAddin{
    [Guid("0428816a-083f-47a1-9385-8e85b11032f4")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("FirstAddin.MyGraphicsLayer")]
    public class MyGraphicsLayer : ESRI.ArcGIS.Carto.ILayer ,
        IPersistVariant,
        IGeoDataset,
        ILayerEffects
    {
        private IGeometry mextgom;
        private ISpatialReference mLayersSpatialReference;
        private ISpatialReference mSpatialReference;
        private IPolygon mpolygon;
        private bool mCached;
        private bool mVisible;
        private string mName;
        private bool mValid;
        private Double mMaxScale;
        private Double mMinScale;
        private short mtransp;

    public MyGraphicsLayer(ISpatialReference sp){
        CreatePolygonByPoints();
        mSpatialReference = sp;
        mValid = true;
        mtransp = 0;
        mName ="MyGraphicsLayer";
}

    #region "ILayer Implementations"
    public ESRI.ArcGIS.Geometry.IEnvelope AreaOfInterest
    {
        get
        {
            // TODO: Add MyGraphicsLayer.AreaOfInterest getter implementation
            return Extent;
        }
    }


    public bool Cached
    {
        get
        {
            // TODO: Add MyGraphicsLayer.Cached getter implementation
            return mCached;
        }
        set
        {
            mCached = value;
            // TODO: Add MyGraphicsLayer.Cached setter implementation
        }
    }


    public void Draw(ESRI.ArcGIS.esriSystem.esriDrawPhase DrawPhase, ESRI.ArcGIS.Display.IDisplay Display, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel)
    {
        // TODO: Add MyGraphicsLayer.Draw implementation


        if (Display == null)
        {
            return;
        }

        ESRI.ArcGIS.Display.IScreenDisplay screenDisplay =(ESRI.ArcGIS.Display.IScreenDisplay) Display;

        // Constant.
        ESRI.ArcGIS.Display.IRgbColor rgbColor = new
          ESRI.ArcGIS.Display.RgbColorClass();
        rgbColor.Red = 255;

        ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit cast.
        ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new
          ESRI.ArcGIS.Display.SimpleFillSymbolClass();
        simpleFillSymbol.Color.NullColor = true;
        simpleFillSymbol.Color = color;




        ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as
          ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
        //ESRI.ArcGIS.Display.IRubberBand rubberBand = new
        //  ESRI.ArcGIS.Display.RubberPolygonClass();
        //ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay,
        //  symbol);


        ESRI.ArcGIS.Geometry.IGeometry geometry = (IGeometry)mpolygon;
        Display.SetSymbol(symbol);
        Display.DrawPolygon(geometry);
    }


    public double MaximumScale
    {
        get
        {
            // TODO: Add MyGraphicsLayer.MaximumScale getter implementation
            return mMaxScale;
        }
        set
        {
            // TODO: Add MyGraphicsLayer.MaximumScale setter implementation
            mMaxScale = value;
        }
    }


    public double MinimumScale
    {
        get
        {
            // TODO: Add MyGraphicsLayer.MinimumScale getter implementation
            return mMinScale;
        }
        set
        {
            // TODO: Add MyGraphicsLayer.MinimumScale setter implementation
            mMinScale = value;
        }
    }


    public string Name
    {
        get
        {
            // TODO: Add MyGraphicsLayer.Name getter implementation
            return mName;


        }
        set
        {
            // TODO: Add MyGraphicsLayer.Name setter implementation
            mName = value;


        }
    }


    public bool ShowTips
    {
        get
        {
            // TODO: Add MyGraphicsLayer.ShowTips getter implementation
            return false;
        }
        set
        {
            // TODO: Add MyGraphicsLayer.ShowTips setter implementation
        }
    }


    public ESRI.ArcGIS.Geometry.ISpatialReference SpatialReference
    {
        set
        {
            // TODO: Add MyGraphicsLayer.SpatialReference setter implementation
            mLayersSpatialReference = value;
        }
    }


    public int SupportedDrawPhases
    {
        get
        {
            // TODO: Add MyGraphicsLayer.SupportedDrawPhases getter implementation
            return Convert.ToInt32(esriDrawPhase.esriDPGeography | esriDrawPhase.esriDPSelection);
        }
    }


    public bool Valid
    {
        get
        {
            // TODO: Add MyGraphicsLayer.Valid getter implementation
            return mValid ;
        }
    }


    public bool Visible
    {
        get
        {
            // TODO: Add MyGraphicsLayer.Visible getter implementation
            return mVisible;
        }
        set
        {
            // TODO: Add MyGraphicsLayer.Visible setter implementation
            mVisible = value;
        }
    }


    public string get_TipText(double x, double y, double Tolerance)
    {
        // TODO: Add MyGraphicsLayer.get_TipText implementation
        return default(string);
    }
    #endregion


    #region "IPersistVariant"
         public UID ID
                {
                    get {
                    UID uid = new UIDClass();
                    uid.Value = "FirstAddin.MyGraphicsLayer";
                    return uid;
                    }
                }


                public void Load(IVariantStream Stream)
                {
                     mName = (string)Stream.Read();
                    mVisible = (bool)Stream.Read();
                    mValid = (bool)Stream.Read();
                    mtransp = (short)Stream.Read();
                    mCached = (bool)Stream.Read();
                    mMaxScale = (double)Stream.Read();
                    mMinScale =  (double)Stream.Read();


                }


                public void Save(IVariantStream Stream)
                {
                    Stream.Write(mName);
                   Stream.Write( mVisible);
                   Stream.Write(mValid);
                   Stream.Write(mtransp);
                   Stream.Write(mCached);
                   Stream.Write(mMaxScale);
                   Stream.Write( mMinScale);
                }
    #endregion


    #region "IGeoDataset"
         public ESRI.ArcGIS.Geometry.IEnvelope Extent
                {
                    get { return mpolygon.Envelope; }
                }


                ESRI.ArcGIS.Geometry.ISpatialReference IGeoDataset.SpatialReference
                {
                    get { return mSpatialReference; }
                }
    #endregion


    #region "ILayerEffects"


                public short Brightness
                {
                    get
                    {
                        throw new NotImplementedException();
                    }
                    set
                    {
                        throw new NotImplementedException();
                    }
                }


                public short Contrast
                {
                    get
                    {
                        throw new NotImplementedException();
                    }
                    set
                    {
                        throw new NotImplementedException();
                    }
                }


                public bool SupportsBrightnessChange
                {
                    get { throw new NotImplementedException(); }
                }


                public bool SupportsContrastChange
                {
                    get { throw new NotImplementedException(); }
                }


                public bool SupportsInteractive
                {
                    get
                    {
                        throw new NotImplementedException();
                    }
                    set
                    {
                        throw new NotImplementedException();
                    }
                }


                public bool SupportsTransparency
                {
                    get { throw new NotImplementedException(); }
                }


                public short Transparency
                {
                    get
                    {
                        return mtransp;
                    }
                    set
                    {
                       mtransp =value ;
                    }
                }
    #endregion

    #region "Private"

                public void CreatePolygonByPoints()
                {
                    //Build polygon from a sequence of points.
                    //At ArcGIS 9.2, the recommended way to add arrays of points to a geometry is to use
                    //the IGeometryBridge2 interface on the GeometryEnvironment singleton object.
                    IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass();
                    IPointCollection4 pointCollection4 = new PolygonClass();

                    //TODO:
                    //pointCollection4.SpatialReference = 'Define the spatial reference of the new polygon
                    WKSPoint[] aWKSPointBuffer = null;
                    long cPoints = 4; //The number of points in the first part
                    aWKSPointBuffer = new WKSPoint[System.Convert.ToInt32(cPoints - 1) + 1];
                    aWKSPointBuffer[0].X= 185680.7286;
                    aWKSPointBuffer[0].Y = 6476124.6791;
                    aWKSPointBuffer[1].X = 188970.8289;
                    aWKSPointBuffer[1].Y = 6476124.6791;
                    aWKSPointBuffer[2].X = 188970.8289;
                    aWKSPointBuffer[2].Y = 6478712.3093;
                    aWKSPointBuffer[3].X = 185680.7286;
                    aWKSPointBuffer[3].Y = 6478712.3093;
                   
                    //TODO:
                    //aWKSPointBuffer = 'Read cPoints into the point buffer
                    geometryBridge2.SetWKSPoints(pointCollection4, ref aWKSPointBuffer);
                    mpolygon = (IPolygon)pointCollection4;
                    mpolygon.SpatialReference = mSpatialReference;
                    //pointCollection4 has now been defined
                }
    #endregion
}
}
Tags (1)
0 Kudos
2 Replies
ToddBlanchette
Occasional Contributor II

Hi Rami,

Could you please edit your question and reformat your code with the advanced editor?  It will make it easier for everyone to read and help troubleshoot.  See Formatting Your Code In Geonet For The Visual Learner

Thanks!

Todd

0 Kudos
RamiBader1
New Contributor II

Hope that helps.

0 Kudos