public void HandleDragAndDrop()
 {
     if (DragAndDrop.objectReferences.Length != 0 && this.guiRect.Contains(Event.current.mousePosition))
     {
         EventType type = Event.current.type;
         if (type != EventType.DragUpdated)
         {
             if (type != EventType.DragPerform)
             {
                 if (type != EventType.Repaint)
                 {
                 }
             }
             else
             {
                 if (this.m_HoverData == null || this.m_HoverData.Count == 0)
                 {
                     return;
                 }
                 this.RegisterUndo();
                 bool       flag = GridPaintPaletteClipboard.TilemapIsEmpty(this.tilemap);
                 Vector2Int mouseGridPosition = base.mouseGridPosition;
                 DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                 Dictionary <Vector2Int, TileBase> dictionary = TileDragAndDrop.ConvertToTileSheet(this.m_HoverData);
                 foreach (KeyValuePair <Vector2Int, TileBase> current in dictionary)
                 {
                     this.SetTile(this.tilemap, mouseGridPosition + current.Key, current.Value, Color.white, Matrix4x4.identity);
                 }
                 this.OnPaletteChanged();
                 this.m_PaletteNeedsSave = true;
                 this.FlushHoverData();
                 GUI.changed = true;
                 this.SavePaletteIfNecessary();
                 if (flag)
                 {
                     this.ResetPreviewInstance();
                     this.FrameEntirePalette();
                 }
                 Event.current.Use();
                 GUIUtility.ExitGUI();
             }
         }
         else
         {
             List <Texture2D> validSpritesheets  = TileDragAndDrop.GetValidSpritesheets(DragAndDrop.objectReferences);
             List <Sprite>    validSingleSprites = TileDragAndDrop.GetValidSingleSprites(DragAndDrop.objectReferences);
             List <TileBase>  validTiles         = TileDragAndDrop.GetValidTiles(DragAndDrop.objectReferences);
             this.m_HoverData = TileDragAndDrop.CreateHoverData(validSpritesheets, validSingleSprites, validTiles);
             if (this.m_HoverData != null && this.m_HoverData.Count > 0)
             {
                 DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                 Event.current.Use();
                 GUI.changed = true;
             }
         }
         if (this.m_HoverData != null && (Event.current.type == EventType.DragExited || (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)))
         {
             DragAndDrop.visualMode = DragAndDropVisualMode.None;
             this.FlushHoverData();
             Event.current.Use();
         }
     }
 }
        private void HandlePanAndZoom()
        {
            switch (Event.current.type)
            {
            case EventType.MouseDown:
                if (GridPaintPaletteClipboard.MousePanningEvent() && this.guiRect.Contains(Event.current.mousePosition) && GUIUtility.hotControl == 0)
                {
                    GUIUtility.hotControl = this.m_MousePanningID;
                    Event.current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == this.m_MousePanningID)
                {
                    this.ClampZoomAndPan();
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }
                break;

            case EventType.MouseMove:
                if (GUIUtility.hotControl == this.m_MousePanningID && !GridPaintPaletteClipboard.MousePanningEvent())
                {
                    GUIUtility.hotControl = 0;
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == this.m_MousePanningID)
                {
                    Vector3 translation = new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f) / this.LocalToScreenRatio();
                    this.previewUtility.camera.transform.Translate(translation);
                    this.ClampZoomAndPan();
                    Event.current.Use();
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.hotControl == 0)
                {
                    switch (Event.current.keyCode)
                    {
                    case KeyCode.UpArrow:
                        this.m_KeyboardPanning = new Vector3(0f, this.k_KeyboardPanningSpeed) / this.LocalToScreenRatio();
                        GUIUtility.hotControl  = this.m_KeyboardPanningID;
                        Event.current.Use();
                        break;

                    case KeyCode.DownArrow:
                        this.m_KeyboardPanning = new Vector3(0f, -this.k_KeyboardPanningSpeed) / this.LocalToScreenRatio();
                        GUIUtility.hotControl  = this.m_KeyboardPanningID;
                        Event.current.Use();
                        break;

                    case KeyCode.RightArrow:
                        this.m_KeyboardPanning = new Vector3(this.k_KeyboardPanningSpeed, 0f) / this.LocalToScreenRatio();
                        GUIUtility.hotControl  = this.m_KeyboardPanningID;
                        Event.current.Use();
                        break;

                    case KeyCode.LeftArrow:
                        this.m_KeyboardPanning = new Vector3(-this.k_KeyboardPanningSpeed, 0f) / this.LocalToScreenRatio();
                        GUIUtility.hotControl  = this.m_KeyboardPanningID;
                        Event.current.Use();
                        break;
                    }
                }
                break;

            case EventType.KeyUp:
                if (GUIUtility.hotControl == this.m_KeyboardPanningID)
                {
                    this.m_KeyboardPanning = Vector3.zero;
                    GUIUtility.hotControl  = 0;
                    Event.current.Use();
                }
                break;

            case EventType.ScrollWheel:
                if (this.guiRect.Contains(Event.current.mousePosition))
                {
                    float   num    = HandleUtility.niceMouseDeltaZoom * (float)((!Event.current.shift) ? -3 : -9) * 7f;
                    Camera  camera = this.previewUtility.camera;
                    Vector3 b      = this.ScreenToLocal(Event.current.mousePosition);
                    camera.orthographicSize = Mathf.Max(0.0001f, camera.orthographicSize * (1f + num * 0.001f));
                    this.ClampZoomAndPan();
                    Vector3 a  = this.ScreenToLocal(Event.current.mousePosition);
                    Vector3 b2 = a - b;
                    camera.transform.position = camera.transform.position - b2;
                    this.ClampZoomAndPan();
                    Event.current.Use();
                }
                break;

            case EventType.Repaint:
                if (GUIUtility.hotControl == this.m_KeyboardPanningID)
                {
                    this.previewUtility.camera.transform.Translate(this.m_KeyboardPanning);
                    this.ClampZoomAndPan();
                    this.Repaint();
                }
                if (GUIUtility.hotControl == this.m_MousePanningID)
                {
                    EditorGUIUtility.AddCursorRect(this.guiRect, MouseCursor.Pan);
                }
                break;

            case EventType.ValidateCommand:
                if (Event.current.commandName == "FrameSelected")
                {
                    Event.current.Use();
                }
                break;

            case EventType.ExecuteCommand:
                if (Event.current.commandName == "FrameSelected")
                {
                    if (this.m_ActivePick.HasValue)
                    {
                        this.Frame(this.m_ActivePick.Value);
                    }
                    else
                    {
                        this.FrameEntirePalette();
                    }
                    Event.current.Use();
                }
                break;
            }
        }