Example #1
0
 public SearchControl(DataNew.Entities.Game game)
 {
     Game = game;
     InitializeComponent();
     filtersList.ItemsSource =
         Enumerable.Repeat<object>("First", 1).Union(
             Enumerable.Repeat<object>(new SetPropertyDef(Game.Sets()), 1).Union(
                 game.AllProperties().Where(p => !p.Hidden)));
     GenerateColumns(game);
     //resultsGrid.ItemsSource = game.SelectCards(null).DefaultView;
     UpdateDataGrid(game.AllCards().ToDataTable(Game).DefaultView);
 }
Example #2
0
 public SearchControl(DataNew.Entities.Game game, DeckBuilderWindow deckWindow)
 {
     _deckWindow = deckWindow;
     NumMod = "";
     Game = game;
     InitializeComponent();
     filtersList.ItemsSource =
         Enumerable.Repeat<object>("First", 1).Union(
             Enumerable.Repeat<object>(new SetPropertyDef(Game.Sets()), 1).Union(
                 game.AllProperties().Where(p => !p.Hidden)));
     GenerateColumns(game);
     //resultsGrid.ItemsSource = game.SelectCards(null).DefaultView;
     UpdateDataGrid(game.AllCards().ToDataTable(Game).DefaultView);
     FileName = "";
     UpdateCount();
 }//Why are we populating the list on load? I'd rather wait until the search is run with no parameters (V)_V
Example #3
0
        // Why are we poluting the code with snide comments instead of fixing the problem or making a generic TODO (V)_V
        // Actually, the more that I think about it, the more I think that the first comment is actually a bad idea. (V)_V
        public SearchControl(DataNew.Entities.Game loadedGame, SearchSave save)
        {
            NumMod = "";
            var game = GameManager.Get().GetById(save.GameId);
            if (game == null)
            {
                TopMostMessageBox.Show("You don't have the game for this search installed", "Oh No", MessageBoxButton.OK, MessageBoxImage.Error);
                save = null;
            }
            else if (loadedGame.Id != save.GameId)
            {
                TopMostMessageBox.Show(
                    "This search is for the game " + game.Name + ". You currently have the game " + loadedGame.Name
                    + " loaded so you can not load this search.", "Oh No", MessageBoxButton.OK, MessageBoxImage.Error);
                save = null;
            }
            Game = loadedGame;
            InitializeComponent();
            filtersList.ItemsSource =
                Enumerable.Repeat<object>("First", 1).Union(
                    Enumerable.Repeat<object>(new SetPropertyDef(Game.Sets()), 1).Union(
                        game.AllProperties().Where(p => !p.Hidden)));
            this.GenerateColumns(game);
            FileName = "";
            if (save != null)
            {

                this.SearchName = save.Name;
                this.FileName = save.FileName;
                // Load filters
                foreach (var filter in save.Filters)
                {
                    DataNew.Entities.PropertyDef prop;
                    if (filter.IsSetProperty)
                    {
                        prop = filtersList.Items.OfType<SetPropertyDef>().First();
                    }
                    else
                    {
                        prop =
                            loadedGame.CustomProperties.FirstOrDefault(
                                x => x.Name.Equals(filter.PropertyName, StringComparison.InvariantCultureIgnoreCase));
                    }
                    if (prop == null) continue;

                    filterList.Items.Add(prop);
                }
                this.Loaded += (sender, args) =>
                    {
                        var generator = filterList.ItemContainerGenerator;
                        for (int i = 0; i < filterList.Items.Count; i++)
                        {
                            DependencyObject container = generator.ContainerFromIndex(i);
                            var filterCtrl = (FilterControl)VisualTreeHelper.GetChild(container, 0);
                            var filter = save.Filters[i];
                            filterCtrl.SetFromSave(Game, filter);
                        }
                        this.RefreshSearch(SearchButton, null);
                    };
            }
            this.UpdateDataGrid(game.AllCards().ToDataTable(Game).DefaultView);
            UpdateCount();
        }
Example #4
0
 public SearchControl(DataNew.Entities.Game game, DeckBuilderWindow deckWindow)
 {
     _deckWindow = deckWindow;
     NumMod = "";
     Game = game;
     InitializeComponent();
     filtersList.ItemsSource =
         Enumerable.Repeat<object>("First", 1).Union(
             Enumerable.Repeat<object>(new SetPropertyDef(Game.Sets().Where(x => x.Hidden == false)), 1).Union(
                 game.AllProperties().Where(p => !p.Hidden)));
     GenerateColumns(game);
     //resultsGrid.ItemsSource = game.SelectCards(null).DefaultView;
     UpdateDataGrid(game.AllCards(true).ToDataTable(Game).DefaultView);
     FileName = "";
     UpdateCount();
 }