}   // end of HandleMouseInput();

        public override void Render(Camera camera)
        {
            if (active && !hidden)
            {
                // Render reticule around selected material.
                CameraSpaceQuad    quad     = CameraSpaceQuad.GetInstance();
                UIGridWaterElement e        = (UIGridWaterElement)grid.SelectionElement;
                Vector2            position = new Vector2(e.Position.X, e.Position.Y);
                position.X += grid.WorldMatrix.Translation.X;
                position.Y += grid.WorldMatrix.Translation.Y;
                Vector2 size = 2.0f * new Vector2(e.Size.X, e.Size.Y);
                quad.Render(camera, reticuleTexture, position, size, @"AdditiveBlend");

                // Trigger icons?
                double curTime = Time.WallClockTotalSeconds;
                double dTime   = curTime - lastChangedTime;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad && dTime > kPreFadeTime)
                {
                    dTime -= kPreFadeTime;

                    float   alpha  = Math.Min((float)(dTime / kFadeTime), 1.0f);
                    Vector2 offset = size * 0.4f;
                    size *= 0.4f;
                    // Note the 12/64 in the positioning accounts for the fact that the
                    // button textures only use the upper 40x40 out of the 64x64 space they allocate.
                    // The 12 is actually (64-40)/2.
                    quad.Render(camera, ButtonTextures.RightTrigger, alpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                    offset.X = -offset.X;
                    quad.Render(camera, ButtonTextures.LeftTrigger, alpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha");
                }
            }

            BokuGame.bokuGame.GraphicsDevice.DepthStencilState = DepthStencilState.None;
            base.Render(camera);

            /*
             * // Debug code to show spherical bounding hits.
             * Vector4 red = new Vector4(1, 0, 0, 0.5f);
             * if (active && !hidden)
             * {
             *  for (int i = 0; i < grid.ActualDimensions.X; i++)
             *  {
             *      UIGridWaterElement e = grid.Get(i, 0) as UIGridWaterElement;
             *
             *      // Don't bother if offscreen.
             *      Vector3 position = e.WorldMatrix.Translation;
             *      float radius = 2.0f;
             *      Frustum.CullResult cullResult = camera.Frustum.CullTest(position, radius);
             *      if (cullResult == Frustum.CullResult.TotallyOutside)
             *          continue;
             *
             *      Utils.DrawSolidSphere(camera, e.HitWorldMatrix.Translation, 1.25f * e.HitWorldMatrix.M33, red);
             *  }
             * }
             */
        } // end of WaterPicker Render()
        // c'tor
        public WaterPicker(OnSetMaterial onSet, OnGetMaterial onGet)
            : base(onSet, onGet)
        {
            helpOverlay = @"WaterPicker";

            // Create material elements for the grid.
            // Start with a blob of common parameters.
            UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob();
            blob.width         = 1.0f;
            blob.height        = 1.0f;
            blob.edgeSize      = 0.1f;
            blob.selectedColor = Color.White;
            Vector4 transparentWhite = new Vector4(1.0f, 1.0f, 1.0f, 0.5f);

            blob.unselectedColor = new Color(transparentWhite);
            blob.normalMapName   = @"QuarterRound4NormalMap";

            // Create and populate grid.
            int maxMaterials = Water.Types.Count;

            grid = new UIGrid(OnSelect, OnCancel, new Point(maxMaterials, 1), "TerrainEdit.WaterPicker");

            numMaterials = 0;

            UIGridWaterElement e = null;

            for (int i = 0; i < maxMaterials; i++)
            {
                e = new UIGridWaterElement(i);
                e.SelectedScale   = 0.8f;
                e.UnselectedScale = 0.5f;
                grid.Add(e, numMaterials++, 0);
            }

            // Set grid properties.
            grid.IgnoreInput = true;    // We'll control the grid selection from here instead of internally.
            grid.Spacing     = new Vector2(0.25f, 0.0f);
            grid.Scrolling   = true;
            grid.Wrap        = false;
            grid.LocalMatrix = Matrix.CreateTranslation(0.0f, -2.5f, 0.0f);

            OnSampleType = SampleType;
        }   // end of WaterPicker c'tor