<commit_before>// ********************************************************************************************************
// Product Name: DotSpatial.Controls.dll
// Description:  The Windows Forms user interface controls like the map, legend, toolbox, ribbon and others.
// ********************************************************************************************************
// The contents of this file are subject to the MIT License (MIT)
// you may not use this file except in compliance with the License. You may obtain a copy of the License at
// http://dotspatial.codeplex.com/license
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
// ANY KIND, either expressed or implied. See the License for the specific language governing rights and
// limitations under the License.
//
// The Original Code is from MapWindow.dll version 6.0
//
// The Initial Developer of this Original Code is <NAME>. Created 7/25/2008 9:37:01 AM
//
// Contributor(s): (Open source contributors should list themselves and their modifications here).
//
// Name               |   Date             |         Comments
//--------------------|--------------------|--------------------------------------------------------
// <NAME>        |  2/18/2010         |  Added zoom out button and custom mouse cursors
// <NAME>       | 12/15/2010         |  Fixed Issue #190 (Deactivated MapFunctions still involved)
// <NAME>     | 12/28/2012         |  Resolved Issue (Unrestricted Zoom Out)
// ********************************************************************************************************

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using DotSpatial.Data;
using DotSpatial.Data.Forms;
using DotSpatial.Projections;
using DotSpatial.Serialization;
using DotSpatial.Symbology;
using DotSpatial.Topology;
using Point = System.Drawing.Point;
using SelectionMode = DotSpatial.Symbology.SelectionMode;

namespace DotSpatial.Controls
{
    /// <summary>
    /// The Map Control for 2D applications.
    /// </summary>
    public partial class Map : UserControl, IMap
    {
        #region Events

        /// <summary>
        /// Occurs after the map refreshes the image
        /// </summary>
        public event EventHandler FinishedRefresh;

        /// <summary>
        /// Occurs when the map function mode has changed
        /// </summary>
        /// <remarks>Example of changing the function mode
        /// is changing from zoom mode to select mode.</remarks>
        public event EventHandler FunctionModeChanged;

        /// <summary>
        /// Occurs after a resize event
        /// </summary>
        public event EventHandler Resized;

        /// <summary>
        /// Occurs after the selection has changed for all the layers
        /// </summary>
        public event EventHandler SelectionChanged;

        /// <summary>
        /// Occurs after a layer has been added to the mapframe, or any of the child groups of that mapframe.
        /// </summary>
        public event EventHandler<LayerEventArgs> LayerAdded;

        /// <summary>
        /// Public event advertising the mouse movement
        /// </summary>
        public event EventHandler<GeoMouseArgs> GeoMouseMove;

        /// <summary>
        /// Fires after the view extents have been altered and the map has redrawn to the new extents.
        /// This is an echo of the MapFrame.ViewExtentsChanged, so you only want one handler.
        /// </summary>
        public event EventHandler<ExtentArgs> ViewExtentsChanged;

        /// <summary>
        /// Occurs after the projection of the map has been changed
        /// </summary>
        public event EventHandler ProjectionChanged;

        #endregion

        #region Private Variables

        private Dictionary<FunctionMode, IMapFunction> _functionLookup;
        private FunctionMode _functionMode;
        private IMapFrame _geoMapFrame;
        private int _isBusyIndex;
        private ILegend _legend;
        private IProgressHandler _progressHandler;
        private bool isPanningTemporarily;
        private FunctionMode previousFunction = FunctionMode.None;
        private Size _oldSize;

        #endregion

        #region Constructors

        /// <summary>
        /// Creates a new instance of a map component that can be dropped on a form.
        /// </summary>
        public Map()
        {
            InitializeComponent();
            Configure();
        }

        /// <summary>
        /// Handles the resizing in the case where the map uses docking, and therefore
        /// needs to be updated whenever the form changes size.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            KeyUp += Map_KeyUp;
            KeyDown += Map_KeyDown;

            SizeChanged += OnSizeChanged;
            _oldSize = Size;

            if (ParentForm != null)
            {
                ParentForm.KeyDown += ParentFormKeyDown;
                ParentForm.KeyUp += ParentFormKeyUp;
            }
        }

        

        private void Map_KeyUp(object sender, KeyEventArgs e)
        {
            // Allow panning if the space is pressed.
            if (e.KeyCode == Keys.Space && isPanningTemporarily)
            {
                this.FunctionMode = previousFunction;
                isPanningTemporarily = false;
            }
<commit_msg>Changed the keyboad input for the map so that HydroDesktop can get KeyUp and KeyDown updates.<commit_after>// ********************************************************************************************************
// Product Name: DotSpatial.Controls.dll
// Description:  The Windows Forms user interface controls like the map, legend, toolbox, ribbon and others.
// ********************************************************************************************************
// The contents of this file are subject to the MIT License (MIT)
// you may not use this file except in compliance with the License. You may obtain a copy of the License at
// http://dotspatial.codeplex.com/license
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
// ANY KIND, either expressed or implied. See the License for the specific language governing rights and
// limitations under the License.
//
// The Original Code is from MapWindow.dll version 6.0
//
// The Initial Developer of this Original Code is <NAME>. Created 7/25/2008 9:37:01 AM
//
// Contributor(s): (Open source contributors should list themselves and their modifications here).
//
// Name               |   Date             |         Comments
//--------------------|--------------------|--------------------------------------------------------
// <NAME>        |  2/18/2010         |  Added zoom out button and custom mouse cursors
// <NAME>       | 12/15/2010         |  Fixed Issue #190 (Deactivated MapFunctions still involved)
// <NAME>     | 12/28/2012         |  Resolved Issue (Unrestricted Zoom Out)
// ********************************************************************************************************

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using DotSpatial.Data;
using DotSpatial.Data.Forms;
using DotSpatial.Projections;
using DotSpatial.Serialization;
using DotSpatial.Symbology;
using DotSpatial.Topology;
using Point = System.Drawing.Point;
using SelectionMode = DotSpatial.Symbology.SelectionMode;

namespace DotSpatial.Controls
{
    /// <summary>
    /// The Map Control for 2D applications.
    /// </summary>
    public partial class Map : UserControl, IMap, IMessageFilter
    {
        #region Events

        /// <summary>
        /// Occurs after the map refreshes the image
        /// </summary>
        public event EventHandler FinishedRefresh;

        /// <summary>
        /// Occurs when the map function mode has changed
        /// </summary>
        /// <remarks>Example of changing the function mode
        /// is changing from zoom mode to select mode.</remarks>
        public event EventHandler FunctionModeChanged;

        /// <summary>
        /// Occurs after a resize event
        /// </summary>
        public event EventHandler Resized;

        /// <summary>
        /// Occurs after the selection has changed for all the layers
        /// </summary>
        public event EventHandler SelectionChanged;

        /// <summary>
        /// Occurs after a layer has been added to the mapframe, or any of the child groups of that mapframe.
        /// </summary>
        public event EventHandler<LayerEventArgs> LayerAdded;

        /// <summary>
        /// Public event advertising the mouse movement
        /// </summary>
        public event EventHandler<GeoMouseArgs> GeoMouseMove;

        /// <summary>
        /// Fires after the view extents have been altered and the map has redrawn to the new extents.
        /// This is an echo of the MapFrame.ViewExtentsChanged, so you only want one handler.
        /// </summary>
        public event EventHandler<ExtentArgs> ViewExtentsChanged;

        /// <summary>
        /// Occurs after the projection of the map has been changed
        /// </summary>
        public event EventHandler ProjectionChanged;

        #endregion

        #region Private Variables

        private Dictionary<FunctionMode, IMapFunction> _functionLookup;
        private FunctionMode _functionMode;
        private IMapFrame _geoMapFrame;
        private int _isBusyIndex;
        private ILegend _legend;
        private IProgressHandler _progressHandler;
        private bool isPanningTemporarily;
        private FunctionMode previousFunction = FunctionMode.None;
        private Size _oldSize;

        #endregion

        #region Constructors

        /// <summary>
        /// Creates a new instance of a map component that can be dropped on a form.
        /// </summary>
        public Map()
        {
            InitializeComponent();
            Configure();
            Application.AddMessageFilter(this);
        }

        /// <summary>
        /// Handles the resizing in the case where the map uses docking, and therefore
        /// needs to be updated whenever the form changes size.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            KeyUp += Map_KeyUp;
            KeyDown += Map_KeyDown;

            SizeChanged += OnSizeChanged;
            _oldSize = Size;
        }

        public bool PreFilterMessage(ref Message m) 
        {
            if (m.Msg == (int)0x0100)
            {
                if(this.ContainsFocus)
                    OnKeyDown(new KeyEventArgs((Keys)m.WParam.ToInt32()));
            }
            else if (m.Msg == (int)0x0101)
            {
                if (this.ContainsFocus)
                    OnKeyUp(new KeyEventArgs((Keys)m.WParam.ToInt32()));
            }
            return false;
        }

        private void Map_KeyUp(object sender, KeyEventArgs e)
        {
            // Allow panning if the space is pressed.
            if (e.KeyCode == Keys.Space && isPanningTemporarily)
            {
                this.FunctionMode = previousFunction;
                isPanningTemporarily = false;
            }

{'fraction_non_alphanumeric': 0.15072240745490298, 'fraction_numerical': 0.008378216636744464, 'mean_word_length': 2.1244658119658117, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598820', 'n_tokens_mistral': 2910, 'n_tokens_neox': 2733, 'n_words': 1003}