public Card(CardDeck d, CardInfo i) { CurrentDeck = d; Drag = new DragHelper(Control); OpacityHelper = new TweenDataDouble( delegate { foreach (Card v in this.MovableCards) { v.Control.style.Opacity = Opacity; } } ); Info = i; Control.style.cursor = IStyle.CursorEnum.@default; Control.style.SetSize(CardInfo.Width, CardInfo.Height); Native.Document.body.appendChild(Control); MoveTo(Drag.Position); Drag.History = new System.Collections.Generic.List<Point>(); Drag.DragStop += delegate { Opacity = 1; var s = FindStack(); if (s == null) MoveTo(Drag.History.First()); else { s.AttachCards(this.MovableCards); } Drag.History.Clear(); }; Drag.DragStart += delegate { Opacity = 0.7; foreach (Card v in MovableCards) { v.BringToFront(); } }; Drag.DragMove += delegate { var s = FindStack(); if (s != null) { Opacity = 1; MoveTo(s.NextPosition); } else { Opacity = 0.7; MoveTo(Drag.Position); } }; Control.ondblclick += ( e) => Helper.Invoke(DoubleClick); Control.onclick += delegate (IEvent e) { Helper.Invoke(Click); if (CurrentStack != null) CurrentStack.RaiseClick(this); }; Opacity = 1; Enabled = false; }
public static CardInfo[] By(SuitEnum suit, params CardInfo.RankEnum[] rank) { var a = new List<CardInfo>(); foreach (var z in rank) { var c = new CardInfo(suit, z); a.Add(c); } return a.ToArray(); }
public Card(CardDeck d, CardInfo i) { CurrentDeck = d; Drag = new DragHelper(Control); OpacityHelper = new TweenDataDouble( delegate { foreach (Card v in this.MovableCards) { v.Control.style.Opacity = Opacity; } } ); Info = i; Control.style.cursor = IStyle.CursorEnum.@default; Control.style.SetSize(CardInfo.Width, CardInfo.Height); Native.Document.body.appendChild(Control); MoveTo(Drag.Position); Drag.History = new System.Collections.Generic.List <Point>(); Drag.DragStop += delegate { Opacity = 1; var s = FindStack(); if (s == null) { MoveTo(Drag.History.First()); } else { s.AttachCards(this.MovableCards); } Drag.History.Clear(); }; Drag.DragStart += delegate { Opacity = 0.7; foreach (Card v in MovableCards) { v.BringToFront(); } }; Drag.DragMove += delegate { var s = FindStack(); if (s != null) { Opacity = 1; MoveTo(s.NextPosition); } else { Opacity = 0.7; MoveTo(Drag.Position); } }; Control.ondblclick += (e) => Helper.Invoke(DoubleClick); Control.onclick += delegate(IEvent e) { Helper.Invoke(Click); if (CurrentStack != null) { CurrentStack.RaiseClick(this); } }; Opacity = 1; Enabled = false; }