private void AccountsView_MouseUp(object sender, MouseEventArgs e) { if ((DateTime.Now - DragTime).TotalMilliseconds < 120) { DraggingItem = null; } Cursor = Cursors.Default; if (DraggingItem == null) { return; } ListViewItem HoveringItem = AccountsView.GetItemAt(0, e.Y); if (HoveringItem == null) { return; } Rectangle rc = HoveringItem.GetBounds(ItemBoundsPortion.Entire); bool InsertBefore = (e.Y < rc.Top + (rc.Height / 2)); if (DraggingItem != HoveringItem) { string Item = DraggingItem.SubItems[3].Text; Account account = AccountsList.FirstOrDefault(x => Item.Length >= x.Username.Length && x.Username == Item.Substring(0, x.Username.Length)); if (account == null) { MessageBox.Show("Something went wrong!", "Roblox Account Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (InsertBefore) { AccountsView.Items.Remove(DraggingItem); AccountsView.Items.Insert(HoveringItem.Index, DraggingItem); AccountsList.Remove(account); AccountsList.Insert(HoveringItem.Index - 1, account); } else { AccountsView.Items.Remove(DraggingItem); AccountsView.Items.Insert(HoveringItem.Index + 1, DraggingItem); AccountsList.Remove(account); AccountsList.Insert(HoveringItem.Index, account); } DraggingItem = null; SaveAccounts(); } }
private void AccountsView_MouseDown(object sender, MouseEventArgs e) { if (AccountsView.Groups.Count > 0) { return; } DraggingItem = AccountsView.GetItemAt(e.X, e.Y); DragTime = DateTime.Now; }
private void AccountsView_MouseDown(object sender, MouseEventArgs e) { DraggingItem = AccountsView.GetItemAt(e.X, e.Y); DragTime = DateTime.Now; }