public void AddCard(CardView cardView, ContextMenuStrip menu) { cardView.MouseDown += new MouseEventHandler(cardView_MouseDown); cardView.MouseUp += new MouseEventHandler(cardView_MouseUp); cardView.MouseMove += new MouseEventHandler(cardView_MouseMove); cardView.Click += new EventHandler(cardView_Click); menu.Opened += new EventHandler(menu_Opened); }
public void AddCards(Dictionary<string, CardViewItem> cardViewItems) { foreach(var entry in cardViewItems) { CardView cardView = new CardView(); cardView.Visible = false; this.Controls.Add(cardView); cardView.Name = entry.Key; cardView.SetCard(entry.Value); if(entry.Value.Index > -1 && (entry.Value.Index < cardViews.Count)) { this.Controls.SetChildIndex(cardView, (entry.Value.Index)); cardViews.Insert(entry.Value.Index, cardView); } else cardViews.Add(cardView); } ShowCardCount(); }
public void AddCards(Dictionary<string, CardViewItem> cardViewItems) { foreach(var entry in cardViewItems) { CardView cardView = new CardView(); cardView.DoubleClick += new EventHandler(cardView_DoubleClick); cardView.Name = entry.Key; cardView.Visible = false; CardContainer.Controls.Add(cardView); cardView.SetCard(entry.Value); cardView.Visible = true; CardMenuContainer menu = new CardMenuContainer(); menu.CardView = cardView; menu.SectorView = this; cardView.ContextMenuStrip = menu.InnerMenu; cardViewHelper.AddCard(cardView, cardView.ContextMenuStrip); if(entry.Value.Index > -1 && entry.Value.Index < CardViews.Count) CardContainer.Controls.SetChildIndex(cardView, entry.Value.Index); } AdjustPanelExpansion(); }
public void RemoveCard(CardView cardView) { cardView.DoubleClick -= new EventHandler(cardView_DoubleClick); cardViewHelper.RemoveCard(cardView, cardView.ContextMenuStrip); CardContainer.Controls.Remove(cardView); AdjustPanelExpansion(); }
public void RemoveCard(CardView cardView) { cardViewHelper.RemoveCard(cardView, cardView.ContextMenuStrip); CardContainer.Controls.Remove(cardView); }
public DragDropData(CardView cardView) : this(Enumerable.Repeat(cardView, 1).ToList()) { }
public DragDropData(List<CardView> cardViews, Point cursorOffset, CardView draggedCardView) { this.CardViews = cardViews; this.CursorOffset = cursorOffset; this.DraggedCardView = draggedCardView; }
public void RemoveCard(CardView cardView, ContextMenuStrip menu) { cardView.MouseDown -= new MouseEventHandler(cardView_MouseDown); cardView.MouseUp -= new MouseEventHandler(cardView_MouseUp); cardView.MouseMove -= new MouseEventHandler(cardView_MouseMove); cardView.Click -= new EventHandler(cardView_Click); menu.Opened -= new EventHandler(menu_Opened); }
void SelectExclusiveCard(CardView cardView) { foreach(var c in sectorView.CardViews) { if(c.Equals(cardView)) { if(!c.Selected) c.Selected = true; } else { if(c.Selected) c.Selected = false; } } }
void HandleClick(CardView cardView, bool isStandardClick) { if(GameView.SectorActionsAbilitations[sectorView.SectorKey][SectorActions.MoveCards]) { if(Control.ModifierKeys == Keys.Control) { cardView.Selected = !cardView.Selected; } else { bool bringToFront = false; if(isStandardClick) { SelectExclusiveCard(cardView); bringToFront = true; } else { if(!cardView.Selected) { SelectExclusiveCard(cardView); bringToFront = true; } } if(bringToFront && sectorView is StaticFreeSectorView) { GameView.Controller.MoveCards(Enumerable.Repeat(cardView.Name, 1).ToList(), sectorView.SectorItem.Code, sectorView.PlayerKey, Enumerable.Repeat(new CardPosition(cardView.Position.X, cardView.Position.Y, 0), 1).ToList(), null); } } } }
void ExecuteCustomDragDrop(CardView cardView) { try { string sectorKey = sectorView.SectorKey; if(GameView.SectorActionsAbilitations[sectorKey][SectorActions.MoveCards]) { if(!cardView.Selected) SelectExclusiveCard(cardView); var selectedCards = sectorView.CardViews.Where(e => e.Selected).ToList(); if(selectedCards.Count > 0) { defaultCursor = Cursor.Current; if(!Patterns.Utils.IsMono) { int x = selectedCards.Min(e => e.Left); int w = selectedCards.Max(e => e.Right) - x; int y = selectedCards.Min(e => e.Top); int h = selectedCards.Max(e => e.Bottom) - y; using(Bitmap thisBmp = new Bitmap(w, h)) { foreach(var c in selectedCards.Reverse<CardView>()) { var rect = c.Bounds; rect.Offset(-x, -y); c.DrawToBitmap(thisBmp, rect); } using(Bitmap bmp = CursorCreator.CreateOpaqueBitmap(thisBmp, 0.8f)) { Point hotSpot = sectorView.CardContainer.PointToClient(Cursor.Position); hotSpot.Offset(-x, -y); dragCursor = CursorCreator.CreateCursor(bmp, hotSpot); } } } try { Point cursorPositionOnCard = cardView.PointToClient(Cursor.Position); DragDropData data = new DragDropData(selectedCards, cursorPositionOnCard, cardView); DragDropEffects dropEffect = sectorView.CardContainer.DoDragDrop( data, DragDropEffects.Move | DragDropEffects.Copy); } finally { if(dragCursor != null) dragCursor.Dispose(); } } } } catch(Exception ex) { GameView.HandleException(ex); } }