Beispiel #1
0
        private void buttonCreate_Click(object sender, RoutedEventArgs e)
        {
            var window = new AddMovieWindow();

            if (window.ShowDialog().Value)
            {
                Data.Movies.Add(window.NewMovie);
                Data.UpdateMoviesData();
                Data.IsSearched       = false;
                buttonReset.IsEnabled = false;
                RefreshListBox();
                DisableButtons();
                Logger.Log($"Добавлен новый фильм: \"{window.NewMovie.Name}\"");
            }
        }
Beispiel #2
0
        private void buttonRemove_Click(object sender, RoutedEventArgs e)
        {
            if (listBox.SelectedIndex != -1)
            {
                Movie selectedMovie = (Movie)listBox.SelectedItem;
                Data.Movies.RemoveAll(movie => movie.Id == selectedMovie.Id);
                if (Data.IsSearched)
                {
                    Data.MoviesSearch.RemoveAll(movie => movie.Id == selectedMovie.Id);
                }

                textBoxSearch.Text = "";
                Data.UpdateMoviesData();
                RefreshListBox();
                Logger.Log($"Удален фильм: \"{selectedMovie.Name}\"");
            }
        }
Beispiel #3
0
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (listBox.SelectedIndex != -1)
            {
                Movie selectedMovie     = (Movie)listBox.SelectedItem;
                int   selectedListIndex = Data.Movies.FindIndex(movie => movie.Id == selectedMovie.Id);

                var window = new ChangeMovieWindow(Data.Movies[selectedListIndex]);
                if (window.ShowDialog().Value)
                {
                    Data.Movies[selectedListIndex] = window.ChangedMovie;
                    Data.UpdateMoviesData();
                    Data.IsSearched = false;
                    RefreshListBox();
                    DisableButtons();
                    Logger.Log(selectedMovie.Name == window.ChangedMovie.Name ?
                               $"Изменён фильм: \"{window.ChangedMovie.Name}\"" :
                               $"Изменён фильм: \"{selectedMovie.Name}\" -> \"{window.ChangedMovie.Name}\"");
                }
            }
        }