private void GhostCard_Click(object sender, EventArgs e) { PictureBox pb = (PictureBox)sender; var mx = pb.Parent.PointToClient(Cursor.Position).X; var my = pb.Parent.PointToClient(Cursor.Position).Y; //if GhostCard is clicked on the right component, erase it and fill it try { if (panelHandler.GetComponent(pb, mx, my) == turnPageR) { //Console.WriteLine(panelHandler.getComponent(pb, mx, my).Name); TurnPageR_Click(null, null); } else if (panelHandler.GetComponent(pb, mx, my) == turnPageL) { //Console.WriteLine(panelHandler.getComponent(pb, mx, my).Name); TurnPageL_Click(null, null); } else if (panelHandler.GetComponent(pb, mx, my) == trashIcon) { //Console.WriteLine("BOORYT;JKF;D"); if (trashIcon.Visible == true) { CardDatabaseManagement.RemoveCard(swapCard, (string)currentType.SelectedItem); DisposeGhostCard(); PopulateDisplay(); } else { DisposeGhostCard(); } } else if (panelHandler.GetComponent(pb, mx, my) == changePictureIcon) { Console.WriteLine("database\\" + swapCard.Type + "\\images\\" + swapCard.Picture); if (changePictureIcon.Visible == true) { //CardDatabaseManagement.RemoveCard(swapCard, (string)currentType.SelectedItem); Process.Start("database\\" + swapCard.Type + "\\images\\"); //CardDatabaseManagement.RemoveCard(swapCard, (string)currentType.SelectedItem); DisposeGhostCard(); PopulateDisplay(); } else { DisposeGhostCard(); } } else if (panelHandler.GetComponent(pb, mx, my).GetType() == typeof(PictureBox)) { Control c = panelHandler.GetComponent(pb, mx, my); //Console.WriteLine("Slot: " + c.Name + ", Page: " + currentPage); Card destinationCard = CardDatabaseManagement.GetCard((string)currentType.SelectedItem, c.Name, currentPage + ""); //Console.WriteLine("c1: " + swapCard.Count + ", c2: " + destinationCard.Count); //swap card CardDatabaseManagement.SwapCard(ref swapCard, ref destinationCard); PopulateDisplay(); DisposeGhostCard(); } } catch (Exception ex) { ex.ToString(); DisposeGhostCard(); } }