private void b_Click(object sender, RoutedEventArgs e) { (sender as Button).IsEnabled = false; _ClickedCard = (gImages.Children[gImages.Children.Count - 2] as Image).Tag as DominionBase.Cards.Card; RaiseEvent(new RoutedEventArgs(CardStackControlClickEvent)); _ClickedCard = null; (sender as Button).IsEnabled = true; }
public void NewTurn(DominionBase.Players.Player player, DominionBase.Cards.Card grantedBy) { Utilities.Log(this.LogFile, "-------------------------------------------------------"); if (_CurrentPlayerTurn != null) { _CurrentPlayerTurn.End(); } _CurrentPlayerTurn = new ucPlayerTurn(); _CurrentPlayerTurn.LogFile = this.LogFile; if (player != null) { _CurrentPlayerTurn.New(player, this.PlayerBrushes[player.Name], grantedBy); } if (_CurrentGameTurn != null) { (_CurrentGameTurn as ucGameTurn).Add(_CurrentPlayerTurn as ucPlayerTurn); if (wMain.Settings.AutoCollapseOldTurns) { IEnumerable <ucGameTurn> gameTurns = spArea.Children.OfType <ucGameTurn>(); if (gameTurns.Count() > 1) { ucGameTurn gtOld = gameTurns.ElementAt(gameTurns.Count() - 2); foreach (ucPlayerTurn pt in gtOld.GetChildren(player)) { pt.IsExpanded = false; } if (!gtOld.IsAnyExpanded) { gtOld.IsAllExpanded = true; gtOld.IsExpanded = false; } } } } else { spArea.Children.Add(_CurrentPlayerTurn); } svArea.ScrollToBottom(); svArea.ScrollToLeftEnd(); }
private void UpdateGlowEffectAll() { if (IsCardsVisible && PileVisibility == DominionBase.Piles.Visibility.All) { Boolean anyGlowAdded = false; foreach (Image image in gImages.Children.OfType <Image>()) { DominionBase.Cards.Card card = image.Tag as DominionBase.Cards.Card; Boolean addGlow = (_PlayerPhase == DominionBase.Players.PhaseEnum.Action && _PlayerMode == DominionBase.Players.PlayerMode.Normal && ((card.Category & DominionBase.Cards.Category.Action) == DominionBase.Cards.Category.Action || (card.Category & DominionBase.Cards.Category.Treasure) == DominionBase.Cards.Category.Treasure)) || ((_PlayerPhase == DominionBase.Players.PhaseEnum.ActionTreasure || _PlayerPhase == DominionBase.Players.PhaseEnum.BuyTreasure) && _PlayerMode == DominionBase.Players.PlayerMode.Normal && (card.Category & DominionBase.Cards.Category.Treasure) == DominionBase.Cards.Category.Treasure); UpdateGlowEffect(image, addGlow, _GlowSize, Colors.Black, Colors.MediumBlue); anyGlowAdded |= addGlow; } UpdateGlowEffect(lName, anyGlowAdded, _GlowSize, Colors.Black, Colors.MediumBlue); } }
void toggleButton_Checked(object sender, RoutedEventArgs e) { bool? isChecked = false; Object tag = null; if (sender is ToggleButton) { ToggleButton tb = sender as ToggleButton; isChecked = tb.IsChecked; tag = tb.Tag; } else if (sender is ucICardButton) { ucICardButton icb = sender as ucICardButton; isChecked = icb.IsChecked; tag = icb.Tag; } bOK.IsEnabled = false; switch (Choice.ChoiceType) { case DominionBase.ChoiceType.Options: if (this.ChoiceResult == null) { this.ChoiceResult = new DominionBase.ChoiceResult(new List <String>()); } String option = ((DominionBase.Option)tag).Text; if (this.Choice.Maximum == 1) { foreach (ToggleButton chkdToggleButton in wrapPanel1.Children.OfType <ToggleButton>().Where(tb => this.ChoiceResult.Options.Contains(((DominionBase.Option)tb.Tag).Text))) { chkdToggleButton.IsChecked = false; this.ChoiceResult.Options.Remove(((DominionBase.Option)chkdToggleButton.Tag).Text); } } if (isChecked == true) { this.ChoiceResult.Options.Add(option); } else if (this.ChoiceResult.Options.Contains(option)) { this.ChoiceResult.Options.Remove(option); } if ((Choice.Minimum > 0 || this.ChoiceResult.Options.Count > 0) && this.ChoiceResult.Options.Count >= Choice.Minimum && this.ChoiceResult.Options.Count <= Choice.Maximum) { bOK.IsEnabled = true; } break; case DominionBase.ChoiceType.Cards: case DominionBase.ChoiceType.SuppliesAndCards: //case DominionBase.ChoiceType.Pile: if (this.ChoiceResult == null) { this.ChoiceResult = new DominionBase.ChoiceResult(new DominionBase.Cards.CardCollection()); } DominionBase.Cards.Card card = tag as DominionBase.Cards.Card; if (isChecked == true) { this.ChoiceResult.Cards.Add(card); } else if (this.ChoiceResult.Cards.Contains(card)) { this.ChoiceResult.Cards.Remove(card); } if ((Choice.Minimum > 0 || this.ChoiceResult.Cards.Count > 0) && this.ChoiceResult.Cards.Count >= Choice.Minimum && this.ChoiceResult.Cards.Count <= Choice.Maximum) { bOK.IsEnabled = true; } break; case DominionBase.ChoiceType.Supplies: if (isChecked == true) { this.ChoiceResult = new DominionBase.ChoiceResult(tag as DominionBase.Piles.Supply); } else { this.ChoiceResult = null; } if (this.ChoiceResult != null) { bOK.IsEnabled = true; } break; } foreach (ToggleButton control in wrapPanel1.Children.OfType <ToggleButton>()) { Panel pButtonText = (Panel)((Border)control.Content).Child; String option = ((DominionBase.Option)control.Tag).Text; if (Choice.IsOrdered) { pButtonText.Visibility = System.Windows.Visibility.Visible; String ordinal = String.Empty; switch (Choice.ChoiceType) { case DominionBase.ChoiceType.Options: if (this.ChoiceResult.Options.Contains(option)) { ordinal = Utilities.Ordinal(this.ChoiceResult.Options.IndexOf(option) + 1); } break; } if (ordinal != String.Empty) { (pButtonText.Children[0] as TextBlock).Text = String.Format("{0}: ", ordinal); } else { (pButtonText.Children[0] as TextBlock).Text = String.Empty; } } } foreach (ucICardButton control in wrapPanel1.Children.OfType <ucICardButton>()) { DominionBase.Cards.Card card = control.Tag as DominionBase.Cards.Card; if (Choice.IsOrdered) { String ordinal = String.Empty; switch (Choice.ChoiceType) { case DominionBase.ChoiceType.Cards: //case DominionBase.ChoiceType.Pile: if (this.ChoiceResult.Cards.Contains(card)) { control.Order = this.ChoiceResult.Cards.IndexOf(card) + 1; } else { control.Order = 0; } break; } } } if (bOK.IsEnabled && (this.ChoiceResult.Supply != null || (this.ChoiceResult.Cards != null && (this.ChoiceResult.Cards.Count == Choice.Maximum || this.ChoiceResult.Cards.Count == this.Choice.Cards.Count())) || (this.ChoiceResult.Options != null && (this.ChoiceResult.Options.Count == Choice.Maximum || this.ChoiceResult.Options.Count == this.Choice.Options.Count)) ) && cbAutoClick.IsChecked == true) { bOK_Click(bOK, null); } }
public override void New(DominionBase.Players.Player player, List <Brush> playerBrushes, DominionBase.Cards.Card grantedBy) { this.Player = new DominionBase.Visual.VisualPlayer(player); _CurrentInset = 0; if (playerBrushes[0] != Brushes.Transparent) { this.Background = playerBrushes[1]; this.BorderBrush = playerBrushes[2]; } Utilities.Log(this.LogFile, String.Format("{0} starting turn{1}", player, grantedBy == null ? "" : String.Format(" from {0}", grantedBy.Name))); DockPanel dp = new DockPanel(); TextBlock tbPlayerName = new TextBlock(); tbPlayerName.Text = player.Name; tbPlayerName.FontWeight = FontWeights.Bold; DockPanel.SetDock(tbPlayerName, Dock.Left); dp.Children.Add(tbPlayerName); tbPlayerName = new TextBlock(); tbPlayerName.Text = " starting turn"; DockPanel.SetDock(tbPlayerName, Dock.Left); dp.Children.Add(tbPlayerName); if (grantedBy != null) { TextBlock tbGrantedBy = new TextBlock(); tbGrantedBy.Text = " granted by "; DockPanel.SetDock(tbGrantedBy, Dock.Left); dp.Children.Add(tbGrantedBy); ucCardIcon icon = CardIconUtilities.CreateCardIcon(grantedBy); DockPanel.SetDock(icon, Dock.Left); dp.Children.Add(icon); TextBlock tbBlank = new TextBlock(); DockPanel.SetDock(tbBlank, Dock.Left); dp.Children.Add(tbBlank); } expTurn.Header = dp; }
public virtual void New(DominionBase.Players.Player player, List <Brush> playerBrushes, DominionBase.Cards.Card grantedBy) { }
private void b_Click(object sender, RoutedEventArgs e) { (sender as Button).IsEnabled = false; _ClickedCard = (gImages.Children[gImages.Children.Count - 2] as Image).Tag as DominionBase.Cards.Card; RaiseEvent(new RoutedEventArgs(CardStackControlClickEvent)); _ClickedCard = null; (sender as Button).IsEnabled = true; }