protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            var bottomRight = new Point();
            IList <Tuple <string, string, long> > tripleTuplePoints =
                new List <Tuple <string, string, long> >();
            var hasSelection = await QueuedTask.Run(() =>
            {
                // geometry is a point
                var clickedPnt = geometry as MapPoint;
                if (clickedPnt == null)
                {
                    return(false);
                }
                // pixel tolerance
                var tolerance = 3;
                //Get the client point edges
                var topLeft = new Point(clickedPnt.X - tolerance, clickedPnt.Y + tolerance);
                bottomRight = new Point(clickedPnt.X + tolerance, clickedPnt.Y - tolerance);
                //convert the client points to Map points
                var mapTopLeft     = MapView.Active.ClientToMap(topLeft);
                var mapBottomRight = MapView.Active.ClientToMap(bottomRight);
                //create a geometry using these points
                Geometry envelopeGeometry = EnvelopeBuilder.CreateEnvelope(mapTopLeft, mapBottomRight);
                if (envelopeGeometry == null)
                {
                    return(false);
                }
                //Get the features that intersect the sketch geometry.
                var result = ActiveMapView.GetFeatures(geometry);

                ProWindowConfig objCfg = new ProWindowConfig();
                objCfg = IdentityConfigWindow.promdl;


                //string[] feat_lyrnames = { };
                var feat_lyrnames = new List <string>()
                {
                };
                //string[] mosic_lyrnames = { };
                var mosic_lyrnames = new List <string>()
                {
                };
                string filtername          = "LiquidsHCAFilter";
                string strOSPointlayername = "NHD_Intersections";

                //Assign defaul layernames if the object is empty
                if (objCfg is null)
                {
                    feat_lyrnames = new List <string> {
                        "HydrographicTransportPaths", "WaterbodySpreadPolygons"
                    };
                    mosic_lyrnames = new List <string> {
                        "MultiDimRasterMosaic"
                    };
                }
                //Assign layer names from the config object
                else
                {
                    //Check the values are null or not
                    if (!string.IsNullOrEmpty(objCfg.OSPointName))
                    {
                        strOSPointlayername = objCfg.OSPointName;
                    }
                    if (!string.IsNullOrEmpty(objCfg.LSName))
                    {
                        mosic_lyrnames.Add(objCfg.LSName);
                    }
                    if (!string.IsNullOrEmpty(objCfg.NHDIntName))
                    {
                        feat_lyrnames.Add(objCfg.NHDIntName);
                    }
                    if (!string.IsNullOrEmpty(objCfg.HTPathName))
                    {
                        feat_lyrnames.Add(objCfg.HTPathName);
                    }
                    if (!string.IsNullOrEmpty(objCfg.HTSpreadName))
                    {
                        feat_lyrnames.Add(objCfg.HTSpreadName);
                    }
                }
                var ospointlyr = ActiveMapView.Map.FindLayers(strOSPointlayername).First() as FeatureLayer;

                foreach (var kvp in result)
                {
                    var bfl = kvp.Key;
                    // only look at points
                    if (kvp.Key.ShapeType != esriGeometryType.esriGeometryPoint)
                    {
                        continue;
                    }
                    var layerName = bfl.Name;
                    var oidName   = bfl.GetTable().GetDefinition().GetObjectIDField();
                    foreach (var oid in kvp.Value)
                    {
                        //Select a single state polygon
                        FeatureLayer fl1        = ActiveMapView.Map.FindLayers(strOSPointlayername).First() as FeatureLayer;
                        QueryFilter queryFilter = new QueryFilter();
                        string whereClause      = String.Format("{0} = {1}", oidName, oid);
                        queryFilter.WhereClause = whereClause;

                        //Use a cursor to get to a feature's geometry
                        using (ArcGIS.Core.Data.RowCursor rowCursor = fl1.Search(queryFilter))
                        {
                            //Grab the first record (and hopefully only record)
                            while (rowCursor.MoveNext())
                            {
                                //Grab the features geometry
                                Feature feature = rowCursor.Current as Feature;
                                //Geometry geo = feature.GetShape();
                                string pintid_field = "POINT_ID";
                                var pointidval      = feature[pintid_field];

                                foreach (string lyrname in feat_lyrnames)
                                {
                                    FeatureLayer fl = ActiveMapView.Map.FindLayers(lyrname).First() as FeatureLayer;

                                    var lyrfilter  = new CIMDefinitionFilter();
                                    lyrfilter.Name = filtername;
                                    lyrfilter.DefinitionExpression = String.Format("{0} = '{1}'", pintid_field, pointidval);

                                    fl.SetDefinitionFilter(lyrfilter);
                                }

                                foreach (string lyrname in mosic_lyrnames)
                                {
                                    MosaicLayer fl = ActiveMapView.Map.FindLayers(lyrname).First() as MosaicLayer;
                                    //RasterLayer rl = ActiveMapView.Map.FindLayers(lyrname).First() as RasterLayer;
                                    //rl.SetDefinition();

                                    var lyrfilter  = new CIMDefinitionFilter();
                                    lyrfilter.Name = filtername;
                                    lyrfilter.DefinitionExpression = String.Format("Name LIKE '{0}%'", pointidval);

                                    fl.SetDefinitionFilter(lyrfilter);
                                }
                                ActiveMapView.RedrawAsync(true);
                            }
                        }
                    }
                }
                return(true);
            });

            return(true);
        }
        protected override Task OnToolActivateAsync(bool active)
        {
            var hasSelection = QueuedTask.Run(() =>
            {
                ProWindowConfig objCfg = new ProWindowConfig();
                objCfg = IdentityConfigWindow.promdl;

                var feat_lyrnames = new List <string>()
                {
                };
                var mosic_lyrnames = new List <string>()
                {
                };
                string filtername = "LiquidsHCAFilter";

                //Assign defaul layernames if the object is empty
                if (objCfg is null)
                {
                    feat_lyrnames = new List <string> {
                        "HydrographicTransportPaths", "WaterbodySpreadPolygons"
                    };
                    mosic_lyrnames = new List <string> {
                        "MultiDimRasterMosaic"
                    };
                }
                //Assign layer names from the config object
                else
                {
                    if (!string.IsNullOrEmpty(objCfg.LSName))
                    {
                        mosic_lyrnames.Add(objCfg.LSName);
                    }

                    if (!string.IsNullOrEmpty(objCfg.NHDIntName))
                    {
                        feat_lyrnames.Add(objCfg.NHDIntName);
                    }
                    if (!string.IsNullOrEmpty(objCfg.HTPathName))
                    {
                        feat_lyrnames.Add(objCfg.HTPathName);
                    }
                    if (!string.IsNullOrEmpty(objCfg.HTSpreadName))
                    {
                        feat_lyrnames.Add(objCfg.HTSpreadName);
                    }
                }

                //Remove the Defination query for the feature layers
                foreach (string lyrname in feat_lyrnames)
                {
                    FeatureLayer fl = ActiveMapView.Map.FindLayers(lyrname).First() as FeatureLayer;

                    fl.RemoveDefinitionFilter(filtername);
                }

                // Remove the defination query for hte Mosic dataset
                foreach (string lyrname in mosic_lyrnames)
                {
                    MosaicLayer fl = ActiveMapView.Map.FindLayers(lyrname).First() as MosaicLayer;

                    fl.RemoveDefinitionFilter(filtername);
                }

                ActiveMapView.RedrawAsync(true);

                return(true);
            });

            return(base.OnToolActivateAsync(active));
        }