private void GLSurface_DragOver(object sender, DragEventArgs e)
 {
     try
     {
         var pos = GLSurface.AdjustMouse(GLSurface.PointToClient(new Point(e.X, e.Y)));
         MouseManager.UpdateLocation(pos);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.ToString(), "Error: Can not drag tile.",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void GLSurface_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (!e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    return;
                }
                var paths = e.Data.GetData(DataFormats.FileDrop) as string[];
                if (paths.Length != 1 || Resource.GetType(paths[0]) != ResourceType.Tile)
                {
                    return;
                }
                var path = ExtraPath.MakeDirectoryRelated(Directory.GetCurrentDirectory(), paths[0]);

                bool insert = !GLSurface.TileLoaded(path);

                if (GLSurface.LoadTile(path, path))
                {
                    if (insert)
                    {
                        TileComboBox.Items.Add(path);
                    }
                    var pos = GLSurface.AdjustMouse(GLSurface.PointToClient(new Point(e.X, e.Y)));
                    MouseManager.UpdateLocation(pos);

                    int tx = (int)Math.Round(-OffsetX + pos.X + GLSurface.FieldW / 2 - 0.5);
                    int ty = (int)Math.Round(-OffsetY + pos.Y + GLSurface.FieldH / 2 - 0.5);

                    if (GLSurface.GetTile(tx, ty) == null)
                    {
                        GLSurface.PlaceTile(path, tx, ty);
                    }
                    else
                    {
                        GLSurface.PlaceTile(null, tx, ty);
                    }

                    TileComboBox.SelectedItem = path;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error: Can not place tile.",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }