/// <summary>
        /// Opens a new Map window in Mapinfo using the tables supplied as the layers for that map.
        /// </summary>
        /// <param name="wrapper">An instance of Mapinfo.</param>
        /// <param name="tablelist">A collection of tables which will be used in the new map window.</param>
        /// <returns>A map containing a referance to the newly opened map window.</returns>
        public static MapWindow MapTables(IEnumerable <ITable> tablelist)
        {
            var mappable = tablelist.ToList().FindAll(table => table.IsMappable);

            if (mappable == null)
            {
                throw new ArgumentNullException("mappable", "No tables are mappable");
            }

            StringBuilder commandbuilder = new StringBuilder("Map From ");

            foreach (var table in tablelist)
            {
                commandbuilder.AppendFormat("{0},".FormatWith(table.Name));
            }
            string command = commandbuilder.ToString().TrimEnd(',');

            wrapper.RunCommand(command);
            int frontwindowid = MapWindow.GetFrontWindowID();

            return(new MapWindow(frontwindowid));
        }
        /// <summary>
        /// Gets the front window from Mapinfo.
        /// </summary>
        /// <param name="wrapper">An instance of Mapinfo.</param>
        /// <returns>An instance of <see cref="T:MapWindow"/> containing the front window.</returns>
        public static MapWindow GetFrontWindow()
        {
            int windowid = MapWindow.GetFrontWindowID();

            return(new MapWindow(windowid));
        }