void TokenPiles_TokenCollectionsChanged(object sender, TokenCollectionsChangedEventArgs e) { if (this.Dispatcher.CheckAccess()) { Token token = null; if (e.TokenCollection.Count > 0) token = e.TokenCollection[0]; else if (e.AddedTokens.Count > 0) token = e.AddedTokens[0]; else if (e.RemovedTokens.Count > 0) token = e.RemovedTokens[0]; else return; if (token.GetType() == DominionBase.Cards.Seaside.TypeClass.PirateShipToken) { Label lPirateShipTokenValue = dpStuff.Children.OfType<Label>().SingleOrDefault(l => l.Name == "lPirateShipTokenValue"); if (lPirateShipTokenValue == null) { if (dpStuff.Children.Count > 0) { Border bDiv = new Border(); bDiv.BorderThickness = new Thickness(1); bDiv.BorderBrush = Brushes.Black; Panel.SetZIndex(bDiv, 1); DockPanel.SetDock(bDiv, Dock.Left); dpStuff.Children.Add(bDiv); } Label lPirateShipToken = new Label(); lPirateShipToken.Content = "Pirate Ship Tokens:"; lPirateShipToken.FontSize = 16d; lPirateShipToken.FontWeight = FontWeights.Bold; lPirateShipToken.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; lPirateShipToken.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); DockPanel.SetDock(lPirateShipToken, Dock.Left); dpStuff.Children.Add(lPirateShipToken); lPirateShipTokenValue = new Label(); lPirateShipTokenValue.Name = "lPirateShipTokenValue"; lPirateShipTokenValue.FontWeight = FontWeights.Bold; lPirateShipTokenValue.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; lPirateShipTokenValue.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; lPirateShipTokenValue.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); lPirateShipTokenValue.Padding = new Thickness(0, 0, 5, 0); lPirateShipTokenValue.BorderThickness = new Thickness(0, 0, 1, 0); DockPanel.SetDock(lPirateShipTokenValue, Dock.Left); dpStuff.Children.Add(lPirateShipTokenValue); } lPirateShipTokenValue.Content = e.Count; } if (token.GetType() == DominionBase.Cards.Guilds.TypeClass.CoinToken) { Label lCoinTokenValue = dpStuff.Children.OfType<Label>().SingleOrDefault(l => l.Name == "lCoinTokenValue"); if (lCoinTokenValue == null) { if (dpStuff.Children.Count > 0) { Border bDiv = new Border(); bDiv.BorderThickness = new Thickness(1); bDiv.BorderBrush = Brushes.Black; Panel.SetZIndex(bDiv, 1); DockPanel.SetDock(bDiv, Dock.Left); dpStuff.Children.Add(bDiv); } Label lCoinToken = new Label(); lCoinToken.Content = "Coin Tokens:"; lCoinToken.FontSize = 16d; lCoinToken.FontWeight = FontWeights.Bold; lCoinToken.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; lCoinToken.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); DockPanel.SetDock(lCoinToken, Dock.Left); dpStuff.Children.Add(lCoinToken); lCoinTokenValue = new Label(); lCoinTokenValue.Name = "lCoinTokenValue"; lCoinTokenValue.FontWeight = FontWeights.Bold; lCoinTokenValue.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; lCoinTokenValue.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; lCoinTokenValue.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); lCoinTokenValue.Padding = new Thickness(0, 0, 5, 0); lCoinTokenValue.BorderThickness = new Thickness(0, 0, 1, 0); DockPanel.SetDock(lCoinTokenValue, Dock.Left); dpStuff.Children.Add(lCoinTokenValue); } lCoinTokenValue.Content = e.Count; } else if (token.GetType() == DominionBase.Cards.Prosperity.TypeClass.VictoryToken) { Label lVictoryTokenValue = dpStuff.Children.OfType<Label>().SingleOrDefault(l => l.Name == "lVictoryTokenValue"); if (lVictoryTokenValue == null) { if (dpStuff.Children.Count > 0) { Border bDiv = new Border(); bDiv.BorderThickness = new Thickness(1); bDiv.BorderBrush = Brushes.Black; Panel.SetZIndex(bDiv, 1); DockPanel.SetDock(bDiv, Dock.Left); dpStuff.Children.Add(bDiv); } Label lVictoryToken = new Label(); lVictoryToken.Content = "Victory Tokens:"; lVictoryToken.FontSize = 16d; lVictoryToken.FontWeight = FontWeights.Bold; lVictoryToken.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; lVictoryToken.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Victory); DockPanel.SetDock(lVictoryToken, Dock.Left); dpStuff.Children.Add(lVictoryToken); lVictoryTokenValue = new Label(); lVictoryTokenValue.Name = "lVictoryTokenValue"; lVictoryTokenValue.FontWeight = FontWeights.Bold; lVictoryTokenValue.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; lVictoryTokenValue.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; lVictoryTokenValue.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Victory); lVictoryTokenValue.Padding = new Thickness(0, 0, 5, 0); lVictoryTokenValue.BorderThickness = new Thickness(0, 0, 1, 0); DockPanel.SetDock(lVictoryTokenValue, Dock.Left); dpStuff.Children.Add(lVictoryTokenValue); } lVictoryTokenValue.Content = Utilities.RenderText(String.Format("{0}{1}", e.Count, token.DisplayString), NET_WPF.RenderSize.Tiny, false)[0]; } } else { this.Dispatcher.BeginInvoke(new EventHandler<TokenCollectionsChangedEventArgs>(TokenPiles_TokenCollectionsChanged), System.Windows.Threading.DispatcherPriority.Normal, sender, e); } }
void TokenPiles_TokenCollectionsChanged(object sender, TokenCollectionsChangedEventArgs e) { if (this.Dispatcher.CheckAccess()) { Token token = null; if (e.TokenCollection.Count > 0) { token = e.TokenCollection[0]; } else if (e.AddedTokens.Count > 0) { token = e.AddedTokens[0]; } else if (e.RemovedTokens.Count > 0) { token = e.RemovedTokens[0]; } else { return; } if (token.GetType() == DominionBase.Cards.Seaside.TypeClass.PirateShipToken) { Label lPirateShipTokenValue = dpStuff.Children.OfType <Label>().SingleOrDefault(l => l.Name == "lPirateShipTokenValue"); if (lPirateShipTokenValue == null) { if (dpStuff.Children.Count > 0) { Border bDiv = new Border(); bDiv.BorderThickness = new Thickness(1); bDiv.BorderBrush = Brushes.Black; Panel.SetZIndex(bDiv, 1); DockPanel.SetDock(bDiv, Dock.Left); dpStuff.Children.Add(bDiv); } Label lPirateShipToken = new Label(); lPirateShipToken.Content = "Pirate Ship Tokens:"; lPirateShipToken.FontSize = 16d; lPirateShipToken.FontWeight = FontWeights.Bold; lPirateShipToken.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; lPirateShipToken.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); DockPanel.SetDock(lPirateShipToken, Dock.Left); dpStuff.Children.Add(lPirateShipToken); lPirateShipTokenValue = new Label(); lPirateShipTokenValue.Name = "lPirateShipTokenValue"; lPirateShipTokenValue.FontWeight = FontWeights.Bold; lPirateShipTokenValue.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; lPirateShipTokenValue.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; lPirateShipTokenValue.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); lPirateShipTokenValue.Padding = new Thickness(0, 0, 5, 0); lPirateShipTokenValue.BorderThickness = new Thickness(0, 0, 1, 0); DockPanel.SetDock(lPirateShipTokenValue, Dock.Left); dpStuff.Children.Add(lPirateShipTokenValue); } lPirateShipTokenValue.Content = e.Count; } if (token.GetType() == DominionBase.Cards.Guilds.TypeClass.CoinToken) { Label lCoinTokenValue = dpStuff.Children.OfType <Label>().SingleOrDefault(l => l.Name == "lCoinTokenValue"); if (lCoinTokenValue == null) { if (dpStuff.Children.Count > 0) { Border bDiv = new Border(); bDiv.BorderThickness = new Thickness(1); bDiv.BorderBrush = Brushes.Black; Panel.SetZIndex(bDiv, 1); DockPanel.SetDock(bDiv, Dock.Left); dpStuff.Children.Add(bDiv); } Label lCoinToken = new Label(); lCoinToken.Content = "Coin Tokens:"; lCoinToken.FontSize = 16d; lCoinToken.FontWeight = FontWeights.Bold; lCoinToken.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; lCoinToken.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); DockPanel.SetDock(lCoinToken, Dock.Left); dpStuff.Children.Add(lCoinToken); lCoinTokenValue = new Label(); lCoinTokenValue.Name = "lCoinTokenValue"; lCoinTokenValue.FontWeight = FontWeights.Bold; lCoinTokenValue.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; lCoinTokenValue.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; lCoinTokenValue.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure); lCoinTokenValue.Padding = new Thickness(0, 0, 5, 0); lCoinTokenValue.BorderThickness = new Thickness(0, 0, 1, 0); DockPanel.SetDock(lCoinTokenValue, Dock.Left); dpStuff.Children.Add(lCoinTokenValue); } lCoinTokenValue.Content = e.Count; } else if (token.GetType() == DominionBase.Cards.Prosperity.TypeClass.VictoryToken) { Label lVictoryTokenValue = dpStuff.Children.OfType <Label>().SingleOrDefault(l => l.Name == "lVictoryTokenValue"); if (lVictoryTokenValue == null) { if (dpStuff.Children.Count > 0) { Border bDiv = new Border(); bDiv.BorderThickness = new Thickness(1); bDiv.BorderBrush = Brushes.Black; Panel.SetZIndex(bDiv, 1); DockPanel.SetDock(bDiv, Dock.Left); dpStuff.Children.Add(bDiv); } Label lVictoryToken = new Label(); lVictoryToken.Content = "Victory Tokens:"; lVictoryToken.FontSize = 16d; lVictoryToken.FontWeight = FontWeights.Bold; lVictoryToken.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; lVictoryToken.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Victory); DockPanel.SetDock(lVictoryToken, Dock.Left); dpStuff.Children.Add(lVictoryToken); lVictoryTokenValue = new Label(); lVictoryTokenValue.Name = "lVictoryTokenValue"; lVictoryTokenValue.FontWeight = FontWeights.Bold; lVictoryTokenValue.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; lVictoryTokenValue.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; lVictoryTokenValue.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Victory); lVictoryTokenValue.Padding = new Thickness(0, 0, 5, 0); lVictoryTokenValue.BorderThickness = new Thickness(0, 0, 1, 0); DockPanel.SetDock(lVictoryTokenValue, Dock.Left); dpStuff.Children.Add(lVictoryTokenValue); } lVictoryTokenValue.Content = Utilities.RenderText(String.Format("{0}{1}", e.Count, token.DisplayString), NET_WPF.RenderSize.Tiny, false)[0]; } } else { this.Dispatcher.BeginInvoke(new EventHandler <TokenCollectionsChangedEventArgs>(TokenPiles_TokenCollectionsChanged), System.Windows.Threading.DispatcherPriority.Normal, sender, e); } }