private void WireGraphicsEvents()
        {
            try
            {
                if (m_naWindowEventSource == null)
                {
                    return;
                }

                if (m_graphicsEventSource != null)
                {
                    UnWireGraphicsEvents();
                }

                IMap           activeMap     = ActiveMap;
                IGraphicsLayer graphicsLayer = null;
                if (activeMap != null)
                {
                    graphicsLayer = activeMap.BasicGraphicsLayer;
                }

                if (graphicsLayer != null)
                {
                    m_graphicsEventSource = (IGraphicsContainer)graphicsLayer;
                }

                if (m_graphicsEventSource == null)
                {
                    return;
                }

                UpdateGraphicsEIDArrayParameterValues();

                //Create an instance of the delegate, add it to AllElementsDeleted event
                m_AllGraphicsDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_AllElementsDeletedEventHandler(OnAllGraphicsDeleted);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).AllElementsDeleted += m_AllGraphicsDeleted;

                //Create an instance of the delegate, add it to ElementAdded event
                m_GraphicAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementAddedEventHandler(OnGraphicAdded);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementAdded += m_GraphicAdded;

                //Create an instance of the delegate, add it to ElementDeleted event
                m_GraphicDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementDeletedEventHandler(OnGraphicDeleted);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementDeleted += m_GraphicDeleted;

                //Create an instance of the delegate, add it to ElementsAdded event
                m_GraphicsAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementsAddedEventHandler(OnGraphicsAdded);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementsAdded += m_GraphicsAdded;

                //Create an instance of the delegate, add it to ElementUpdated event
                m_GraphicUpdated = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementUpdatedEventHandler(OnGraphicUpdated);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementUpdated += m_GraphicUpdated;
            }
            catch (Exception ex)
            {
                string msg = SubsetHelperUI.GetFullExceptionMessage(ex);
                MessageBox.Show(msg, "Wire Graphics Events");
            }
        }
		private void WireGraphicsEvents()
		{
			try
			{
				if (m_naWindowEventSource == null)
					return;

				if (m_graphicsEventSource != null)
					UnWireGraphicsEvents();

				IMap activeMap = ActiveMap;
				IGraphicsLayer graphicsLayer = null;
				if (activeMap != null)
					graphicsLayer = activeMap.BasicGraphicsLayer;

				if (graphicsLayer != null)
					m_graphicsEventSource = (IGraphicsContainer)graphicsLayer;

				if (m_graphicsEventSource == null)
					return;

				UpdateGraphicsEIDArrayParameterValues();

				//Create an instance of the delegate, add it to AllElementsDeleted event
				m_AllGraphicsDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_AllElementsDeletedEventHandler(OnAllGraphicsDeleted);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).AllElementsDeleted += m_AllGraphicsDeleted;

				//Create an instance of the delegate, add it to ElementAdded event
				m_GraphicAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementAddedEventHandler(OnGraphicAdded);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementAdded += m_GraphicAdded;

				//Create an instance of the delegate, add it to ElementDeleted event
				m_GraphicDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementDeletedEventHandler(OnGraphicDeleted);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementDeleted += m_GraphicDeleted;

				//Create an instance of the delegate, add it to ElementsAdded event
				m_GraphicsAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementsAddedEventHandler(OnGraphicsAdded);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementsAdded += m_GraphicsAdded;

				//Create an instance of the delegate, add it to ElementUpdated event
				m_GraphicUpdated = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementUpdatedEventHandler(OnGraphicUpdated);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementUpdated += m_GraphicUpdated;
			}
			catch (Exception ex)
			{
				string msg = SubsetHelperUI.GetFullExceptionMessage(ex);
				MessageBox.Show(msg, "Wire Graphics Events");
			}
		}