private void GumpViewer_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     _gmpMoved=null;
     _gmpResized=null;
     this.Cursor=Cursors.Default;
 }
 private void bAddResize_Click(object sender, System.EventArgs e)
 {
     if (gumpChooser==null)
         gumpChooser = new GumpChooser(pathToGumps);
     if (gumpChooser.ShowDialog(this)!=DialogResult.Cancel&&gumpChooser.SelectedIndex!=null) {
         ResizableGump rg = new ResizableGump(gumpChooser.SelectedIndex, pathToGumps);
         ((GumpViewer)tabControl1.SelectedTab.Controls[0]).addGump(rg);
     }
 }
 private void GumpViewer_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
         return;
     int oldIndex = selectedIndex;
     selectedGump = null;
     IEnumerator ie = items.GetEnumerator();
     Gump g;
     ResizableGump rg;
     int index = 0;
     selectedIndex = -1;
     while (ie.MoveNext()) {
         if (ie.Current.GetType() == typeof(ResizableGump)) {
             rg = (ResizableGump)ie.Current;
             if ((e.X >= rg.X + rg.Width - 2
                 && e.X <= rg.X + rg.Width+2)
                 && (e.Y >= rg.Y + rg.Height - 2
                 && e.Y <= rg.Y + rg.Height + 2)){
                 _gmpResized=rg;
                 selectedGump=rg;
                 selectedIndex=index;
             } else if ((e.X >= rg.X && e.X <= rg.X + rg.Width)
                 && (e.Y >= rg.Y && e.Y <= rg.Y + rg.Height)) {
                 selectedGump=rg;
                 selectedIndex=index;
                 _gmpResized=null;
             }
             index++;
         } else {
             g = (Gump)ie.Current;
             if ((e.X>=g.X&&e.X<=g.X+g.Width)&&(e.Y>=g.Y&&e.Y<=g.Y+g.Height)) {
                 selectedGump=g;
                 selectedIndex=index;
             }
             index++;
         }
     }
     if (selectedIndex != oldIndex) {
         riseOnSelectedIndexChangedEvent();
     } else if (selectedGump != null && _gmpResized == null) {
         _gmpMoved=selectedGump;
         _movedX=e.X-_gmpMoved.X;
         _movedY=e.Y-_gmpMoved.Y;
     }
 }