void TabLabel_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { _tempMouse = TabPanel.PointToClient(e.Location); } else { _tempMouse = null; } }
private void TabPanel_DragDrop(object sender, DragEventArgs e) { //fixme:カッコカリ 範囲外にドロップすると端に行く Point mp = TabPanel.PointToClient(new Point(e.X, e.Y)); var item = TabPanel.GetChildAtPoint(mp); int index = TabPanel.Controls.GetChildIndex(item, false); TabPanel.Controls.SetChildIndex((System.Windows.Forms.Control)e.Data.GetData(typeof(ImageLabel)), index); TabPanel.Invalidate(); }
void TabLabel_MouseMove(object sender, MouseEventArgs e) { if (_tempMouse != null) { Rectangle move = new Rectangle( _tempMouse.Value.X - SystemInformation.DragSize.Width / 2, _tempMouse.Value.Y - SystemInformation.DragSize.Height / 2, SystemInformation.DragSize.Width, SystemInformation.DragSize.Height ); if (!move.Contains(TabPanel.PointToClient(e.Location))) { TabPanel.DoDragDrop(sender, DragDropEffects.All); _tempMouse = null; } } }