Пример #1
0
 // Copy constructor
 public Game(Game game)
 {
     Name = game.Name;
     Plays = game.Plays;
     Note = game.Note;
     Cost = game.Cost;
     Purchased = game.Purchased;
     LastPlayed = game.LastPlayed;
 }
Пример #2
0
 public GameEditorDialog(Game game)
     : this()
 {
     _nameTextBox.DataBindings.Add(
       "Text", game, "Name", true, DataSourceUpdateMode.OnPropertyChanged);
       _playsUpDown.DataBindings.Add(
       "Value", game, "Plays", true, DataSourceUpdateMode.OnPropertyChanged);
       _noteTextBox.DataBindings.Add(
       "Text", game, "Note", true, DataSourceUpdateMode.OnPropertyChanged);
       _costTextBox.DataBindings.Add(
       "Text", game, "Cost", true, DataSourceUpdateMode.OnPropertyChanged);
       _lastPlayedDateTimePicker.DataBindings.Add(
       "Value", game, "LastPlayed",true, DataSourceUpdateMode.OnPropertyChanged);
       _purchasedDateTimePicker.DataBindings.Add(
       "Value", game, "Purchased", true, DataSourceUpdateMode.OnPropertyChanged);
       _nameTextBox.Select();
 }
Пример #3
0
        private void _newGameButton_Click(object sender, EventArgs e)
        {
            Game game = new Game();
            using (GameEditorDialog dlg = new GameEditorDialog(game)) {
                dlg.StartPosition = FormStartPosition.CenterParent;
                if (dlg.ShowDialog(this) != DialogResult.OK) return;

                _gameRepository.Add(game);
                _bindingSource.Position = _bindingSource.IndexOf(game);
                UpdateButtons();
            }
        }
Пример #4
0
 private void _gameListBox_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     Game game = (Game)_gameListBox.SelectedItem;
     Game gameClone = new Game(game);
     GameEditorDialog edit = new GameEditorDialog(gameClone);
     if (edit.ShowDialog() == DialogResult.OK) {
         _gameListBox.SelectedItem = gameClone;
     }
 }