Esempio n. 1
0
        private void AddMovie(object sender, EventArgs e)
        {
            if (!Utils.Helpers.ConfirmDiscardChanges())
            {
                return;
            }

            var frmAddMovie = new FrmAddMovie {
                Owner = _parent
            };

            if (frmAddMovie.ShowDialog() != DialogResult.OK)
            {
                Helpers.UnsavedChanges = false;
                return;
            }

            var msi = new MovieShortInfo
            {
                Id       = DAL.CurrentMTD.Id,
                FileName = DAL.CurrentMTD.FileName,
                //Cover = DAL.CurrentMTD.Poster,
                HasPoster   = DAL.CurrentMTD.Poster != null,
                HasSynopsis = !string.IsNullOrEmpty(DAL.CurrentMTD.Synopsis)
            };

            DAL.MoviesData.Add(msi);
            DAL.MoviesData = new BindingList <MovieShortInfo>(DAL.MoviesData.OrderBy(o => o.FileName).ToList());
            RefreshGrid();

            FocusCurrentMovieInGrid(msi);
        }
Esempio n. 2
0
        private void FocusCurrentMovieInGrid(MovieShortInfo msi)
        {
            var index = DAL.MoviesData.IndexOf(msi);

            if (index >= 0)
            {
                RefreshGrid();
                dgvMoviesList.Rows[index].Selected            = true;
                dgvMoviesList.FirstDisplayedScrollingRowIndex = index;
            }
        }
Esempio n. 3
0
        public void ReloadData(bool resetCachedstills = false)
        {
            DAL.MoviesData = DAL.GetMoviesGridData(_currentSortField, _advancedFilter);

            if (resetCachedstills)
            {
                DAL.CachedMoviesStills = new List <CachedMovieStills>();
            }

            RefreshGrid();

            _previousSelectedMsi = DAL.MoviesData.FirstOrDefault();
        }
Esempio n. 4
0
        private void LoadData(string m, ref string f, ref string t)
        {
            int movieId = Convert.ToInt32(m);

            movieID.Value = m;
            MovieShortInfo movieData = (from it in mc.movies
                                        where it.id == movieId
                                        select it).FirstOrDefault <MovieShortInfo>();

            if (movieData != null)
            {
                movieName.Text = movieData.name;

                FillMovieTheaterList(m, ref t);
                FillMovieFormatList(m, ref f);
            }
        }
Esempio n. 5
0
        private void DeleteMovie(object sender, EventArgs e)
        {
            if (DAL.MoviesData.Count == 0)
            {
                return;
            }

            if (MsgBox.Show(
                    string.Format("Are you sure you want to remove{0}{0}{1}{0}{0}from your collection?",
                                  Environment.NewLine, _previousSelectedMsi.FileName),
                    "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            var opRes = DAL.RemoveMovieOrEpisode(_previousSelectedMsi.Id);

            if (!opRes.Success)
            {
                MsgBox.Show(
                    string.Format("The following error occurred while removing the selection:{0}{0}{1}", Environment.NewLine, opRes.CustomErrorMessage),
                    "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Helpers.UnsavedChanges = false; //this setter takes care of the buttons states!

                var index    = DAL.MoviesData.IndexOf(_previousSelectedMsi);
                var newIndex = index == DAL.MoviesData.Count - 1
                    ? index - 1
                    : index;

                DAL.MoviesData.Remove(_previousSelectedMsi);

                RefreshGrid();

                if (DAL.MoviesData.Count > 0)
                {
                    _previousSelectedMsi = DAL.MoviesData[newIndex];
                    FocusCurrentMovieInGrid(_previousSelectedMsi);
                }
            }
        }
Esempio n. 6
0
        private void dgvMoviesList_SelectionChanged(object sender, EventArgs e)
        {
            //((DataGridView)sender).Invalidate();
            if (_preventEvent || dgvMoviesList.SelectedRows.Count == 0)
            {
                return;
            }

            if (!Utils.Helpers.ConfirmDiscardChanges())
            {
                _preventEvent = true;
                FocusCurrentMovieInGrid(_previousSelectedMsi);
                _preventEvent = false;

                return;
            }

            LoadSelectionDetails();

            _previousSelectedMsi = (MovieShortInfo)dgvMoviesList.SelectedRows[0].DataBoundItem;

            btnLoadPoster.Enabled       = true;
            btnRefreshMovieData.Enabled = true;
        }
Esempio n. 7
0
        private void btnRefreshMovieData_Click(object sender, EventArgs e)
        {
            if (Helpers.UnsavedChanges && !SaveChanges())
            {
                return;
            }

            using (var rParam = new FrmMTDFromFile(false, false)
            {
                Owner = _parent
            })
            {
                if (rParam.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (rParam.mtd == null)
                {
                    MsgBox.Show("An error occurred while determining the file (movie) details. No additional data available!", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                    return;
                }

                OperationResult opRes   = null;
                CSMScrapeResult csmData = null;

                if (DAL.CurrentMTD.HasRecommendedDataSaved)
                {
                    opRes = DAL.LoadCSMData(DAL.CurrentMTD.Id);
                    if (opRes.Success)
                    {
                        csmData = (CSMScrapeResult)opRes.AdditionalDataReturn;
                    }
                }

                opRes = DAL.RemoveMovieOrEpisode(_previousSelectedMsi.Id);

                if (!opRes.Success)
                {
                    MsgBox.Show(
                        string.Format("The following error occurred while removing the previous movie details:{0}{0}{1}{0}{0}The current operation cannot continue!", Environment.NewLine, opRes.CustomErrorMessage),
                        "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                //not using UpdateMTD in order to avoud additional check regarding the number of streams
                opRes = DAL.InsertMTD(rParam.mtd, null);

                if (!opRes.Success)
                {
                    MsgBox.Show(
                        string.Format("The following error occurred while inserting the new movie details into the database:{0}{0}{1}{0}{0}", Environment.NewLine, opRes.CustomErrorMessage),
                        "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                rParam.mtd.Id = (int)opRes.AdditionalDataReturn;
                if (csmData != null)
                {
                    DAL.SaveCommonSenseMediaData(rParam.mtd.Id, csmData);
                }

                try
                {
                    _preventEvent = true;

                    DAL.CurrentMTD = rParam.mtd;
                    var movieObj = DAL.MoviesData.FirstOrDefault(m => m.Id == _previousSelectedMsi.Id);
                    DAL.MoviesData.Remove(movieObj);

                    var msi = new MovieShortInfo
                    {
                        Id       = DAL.CurrentMTD.Id,
                        FileName = DAL.CurrentMTD.FileName,
                        //Cover = DAL.CurrentMTD.Poster,
                        HasPoster   = DAL.CurrentMTD.Poster != null,
                        HasSynopsis = !string.IsNullOrEmpty(DAL.CurrentMTD.Synopsis)
                    };

                    DAL.MoviesData.Add(msi);
                    DAL.MoviesData = new BindingList <MovieShortInfo>(DAL.MoviesData.OrderBy(o => o.FileName).ToList());
                    RefreshGrid();

                    _previousSelectedMsi = msi; //not needed?
                }
                finally
                {
                    _preventEvent = false;
                    FocusCurrentMovieInGrid(_previousSelectedMsi);
                }
            }
        }