示例#1
0
        /// <summary>
        /// Handles pressing the delete key to remove features from the specified layer.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool changed = false;

            if (e.KeyCode == Keys.Delete)
            {
                bool selectable = false;
                foreach (ILayer layer in Map.MapFrame.GetAllLayers())
                {
                    IFeatureLayer fl = layer as IFeatureLayer;
                    if (fl == null)
                    {
                        continue;
                    }

                    if (fl.IsWithinLegendSelection())
                    {
                        selectable = true;
                        fl.RemoveSelectedFeatures();
                        changed = true;
                        break;
                    }
                }
                if (selectable == false)
                {
                    MessageBox.Show(MessageStrings.MapFunctionSelect_OnKeyDown_No_Deletable_Layers);
                }
            }
            base.OnKeyDown(e);
            if (changed && Map != null)
            {
                Map.MapFrame.Invalidate();
            }
        }