Пример #1
0
        private void CreateNewGame(LeagueTrackerDb db, bool forced = false)
        {
            using (db = db ?? new LeagueTrackerDb())
            {
                var game = new Game();

                db.Games.Add(game);

                var ucGameEditor  = new ucGameEditor(game, db);
                var newGameWindow = new GenericDialogueWindow("New Game", ucGameEditor)
                {
                    Height = 200,
                    Width  = 300
                };

                if (forced)
                {
                    newGameWindow.Force();
                }

                var result = newGameWindow.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    DataContext = game;
                    Settings.Default.CurrentGameId = game.Id;
                    Settings.Default.Save();
                }
            }
        }
Пример #2
0
 public MainWindow()
 {
     InitializeComponent();
     using (var db = new LeagueTrackerDb())
     {
         if (!db.Games.Any())
         {
             CreateNewGame(db, true);
         }
         else
         {
             Refresh(db);
         }
     }
 }
Пример #3
0
 private void EditGame_OnClick(object sender, RoutedEventArgs e)
 {
     using (var db = new LeagueTrackerDb())
     {
         var game          = (Game)DataContext;
         var newGameWindow = new GenericDialogueWindow($"{game.Name}", new ucGameEditor(game, db))
         {
             Height = 200,
             Width  = 300
         };
         db.UpdateEntity(game);
         newGameWindow.ShowDialog();
         Refresh(db);
     }
 }
Пример #4
0
 private void SelectGame_OnClick(object sender, RoutedEventArgs e)
 {
     using (var db = new LeagueTrackerDb())
     {
         var selector = new ucGameSelector(db.Games.ToList());
         var window   = new GenericDialogueWindow("Select Game", selector);
         window.Height       = 200;
         window.Width        = 300;
         window.OkButtonText = "Ok";
         var results = window.ShowDialog();
         if (results.HasValue && results.Value)
         {
             Refresh(db);
         }
     }
 }
Пример #5
0
 public ucGameEditor(Game game, LeagueTrackerDb db)
 {
     _db = db;
     InitializeComponent();
     DataContext = game;
 }
Пример #6
0
 private void Refresh(LeagueTrackerDb db)
 {
     DataContext = db.GetGame(Settings.Default.CurrentGameId);
 }