static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DependencyObjectDecl <T> typed = (DependencyObjectDecl <T>)d;

            if (typed.PropertyChanged != null)
            {
                typed.PropertyChanged(typed.parent, new PropertyChangedEventArgs("Value"));
            }
        }
示例#2
0
        public CardAcceptanceDescription()
        {
            this.Card                  = new DependencyObjectDecl <DominionCard>(this);
            this.Count                 = new DependencyObjectDecl <int>(this);
            this.TestCard              = new DependencyObjectDecl <DominionCard>(this);
            this.CountSource           = new DependencyObjectDecl <Dominion.Strategy.Description.CountSource>(this);
            this.Comparison            = new DependencyObjectDecl <Dominion.Strategy.Description.Comparison>(this);
            this.Threshhold            = new DependencyObjectDecl <int>(this);
            this.SecondaryMatchVisible = new DependencyObjectDecl <bool>(this);
            this.CanSimulateCard       = new DependencyObjectDecl <bool>(this);

            this.CountSource.PropertyChanged += CountSource_PropertyChanged;
            this.Card.PropertyChanged        += Card_PropertyChanged;
        }
示例#3
0
        public AppDataContext(MainPage mainPage)
        {
            this.mainPage = mainPage;

            this.allCards       = new SortableCardList();
            this.currentDeck    = new SortableCardList();
            this.commonCards    = new SortableCardList();
            this.availableCards = new System.Collections.ObjectModel.ObservableCollection <DominionCard>();
            this.expansions     = new System.Collections.ObjectModel.ObservableCollection <Expansion>();

            /*
             * this.Use3OrMoreFromExpansions = new DependencyObjectDecl<bool, DefaultTrue>(this);
             * this.RequireTrashing = new DependencyObjectDecl<bool, DefaultTrue>(this);
             * this.RequirePlusCards = new DependencyObjectDecl<bool, DefaultTrue>(this);
             * this.RequirePlusBuy = new DependencyObjectDecl<bool, DefaultTrue>(this);
             * this.RequirePlus2Actions = new DependencyObjectDecl<bool, DefaultTrue>(this);
             * this.RequireAttack = new DependencyObjectDecl<bool, DefaultTrue>(this);
             * this.AllowAttack = new DependencyObjectDecl<bool, DefaultTrue>(this);*/

            this.player1Strategy          = new StrategyDescription();
            this.player2Strategy          = new StrategyDescription();
            this.currentStrategy          = new DependencyObjectDecl <StrategyDescription, DefaultEmptyStrategyDescription>(this);
            this.currentStrategy.Value    = this.player1Strategy;
            this.IsPlayer1StrategyChecked = new DependencyObjectDecl <bool, DefaultTrue>(this);
            this.IsPlayer2StrategyChecked = new DependencyObjectDecl <bool, DefaultFalse>(this);

            this.CardVisibility           = new DependencyObjectDecl <CardVisibility, DefaultCurrent>(this);
            this.SettingsButtonVisibility = new DependencyObjectDecl <SettingsButtonVisibility, DefaultSettingsButton>(this);
            this.PageConfig = new DependencyObjectDecl <PageConfig, DefaultPageConfig>(this);

            this.StrategyResultsAvailable = new DependencyObjectDecl <bool, DefaultFalse>(this);
            this.StrategyReport           = new DependencyObjectDecl <string, DefaultEmptyString>(this);
            this.Player1Name       = new DependencyObjectDecl <string, DefaultEmptyString>(this);
            this.Player2Name       = new DependencyObjectDecl <string, DefaultEmptyString>(this);
            this.Player1WinPercent = new DependencyObjectDecl <double, DefaultDoubleZero>(this);
            this.Player2WinPercent = new DependencyObjectDecl <double, DefaultDoubleZero>(this);
            this.TiePercent        = new DependencyObjectDecl <double, DefaultDoubleZero>(this);

            this.expansions.Add(new Expansion("Alchemy", ExpansionIndex.Base));
            this.expansions.Add(new Expansion("Base", ExpansionIndex.Alchemy));
            this.expansions.Add(new Expansion("Cornucopia", ExpansionIndex.Cornucopia));
            this.expansions.Add(new Expansion("Dark Ages", ExpansionIndex.DarkAges));
            this.expansions.Add(new Expansion("Guilds", ExpansionIndex.Guilds));
            this.expansions.Add(new Expansion("Hinterlands", ExpansionIndex.Hinterlands));
            this.expansions.Add(new Expansion("Intrigue", ExpansionIndex.Intrigue));
            this.expansions.Add(new Expansion("Promo", ExpansionIndex.Promo));
            this.expansions.Add(new Expansion("Prosperity", ExpansionIndex.Prosperity));
            this.expansions.Add(new Expansion("Seaside", ExpansionIndex.Seaside));

            foreach (var expansion in expansions)
            {
                expansion.IsEnabled.PropertyChanged += ExpansionEnabledChangedEventHandler;
            }

            this.commonCards.PropertyChanged += AvailableCards_PropetyChanged;
            this.currentDeck.PropertyChanged += AvailableCards_PropetyChanged;
            this.IsPlayer1StrategyChecked.PropertyChanged += Player1RadioButtonChecked;
            this.IsPlayer2StrategyChecked.PropertyChanged += Player2RadioButtonChecked;

            //this.Use3OrMoreFromExpansions.PropertyChanged += Enable3orMoreFromExpansionsChangedEventHandler;

            this.allCards.ApplyFilter(card => card.Expansion != ExpansionIndex._Unknown && this.expansions[(int)card.Expansion].IsEnabled.Value);
            this.currentDeck.ApplyFilter(card => card.Expansion != ExpansionIndex._Unknown && this.expansions[(int)card.Expansion].IsEnabled.Value);
        }
示例#4
0
 public Expansion(string name, ExpansionIndex index)
 {
     this.Name      = name;
     this.Index     = index;
     this.isEnabled = new DependencyObjectDecl <bool, DefaultTrue>(this);
 }