Beispiel #1
0
        private void LoadSelectionDetails(int scrollAt = -1)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                DrawingControl.SuspendDrawing(pMovieDetailsContainer);

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

                var opRes = DAL.LoadMTD(selectedMovieData.Id, true);

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

                var prevInstance = pMovieDetailsContainer.Controls.Find("ucMovieInfo", false);

                if (prevInstance.Any())
                {
                    ((ucMovieInfo)prevInstance[0]).RefreshControls(DAL.CurrentMTD);
                }
                else
                {
                    var ucMovieInfo = new ucMovieInfo(false)
                    {
                        Dock = DockStyle.Top
                    };
                    ucMovieInfo.RefreshControls(DAL.CurrentMTD);

                    pMovieDetailsContainer.Controls.Add(ucMovieInfo);
                    ucMovieInfo.BringToFront();
                }
            }
            finally
            {
                if (scrollAt > -1)
                {
                    pMovieDetailsContainer.VerticalScroll.Value = scrollAt;
                }

                SetSaveButtonState(false);

                DrawingControl.ResumeDrawing(pMovieDetailsContainer);
                Cursor = Cursors.Default;
            }
        }
Beispiel #2
0
        private void LoadSelectionDetails(int scrollAt = -1)
        {
            if (tvCollections.SelectedNode == null)
            {
                return;                                     //why??
            }
            try
            {
                Cursor = Cursors.WaitCursor;
                DrawingControl.SuspendDrawing(pCollectionElementDetailsContainer);

                var seShortInfo      = (SeriesEpisodesShortInfo)tvCollections.SelectedNode.Tag;
                var isElementSeleted = tvCollections.SelectedNode.Level == 2;

                btnImportElements.Enabled = !isElementSeleted;
                btnLoadPoster.Enabled     =
                    (!isElementSeleted /*&& (CollectionsSiteSectionType)seShortInfo.SectionType == CollectionsSiteSectionType.SeriesType*/) ||
                    (isElementSeleted && (CollectionsSiteSectionType)seShortInfo.SectionType == CollectionsSiteSectionType.MovieType);
                btnRefreshElementData.Enabled = isElementSeleted;
                btnDeleteElement.Enabled      = isElementSeleted; //the collection is deleted by action in the main form toolbar


                btnAddMovieToCollection.Enabled = (CollectionsSiteSectionType)seShortInfo.SectionType == CollectionsSiteSectionType.MovieType;

                if (!isElementSeleted) //collection level
                {
                    ////when moving focus from ElementDetail to CollectionDetail, the "ucCollectionElements" must be removed
                    //var prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucCollectionElements", false);
                    //if (prevInstance.Any())
                    //    pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);

                    //attempting to reuse the "ucCollectionInfo" user control
                    var prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucCollectionInfo", false);

                    if (seShortInfo.Poster == null /*&& (CollectionsSiteSectionType)seShortInfo.SectionType == CollectionsSiteSectionType.SeriesType*/)
                    {
                        seShortInfo.Poster = DAL.GetPoster(seShortInfo.Id);
                    }

                    if (prevInstance.Any())
                    {
                        ((ucCollectionInfo)prevInstance[0]).RefreshControls(seShortInfo);
                    }
                    else
                    {
                        if (pCollectionElementDetailsContainer.Controls.Count > 0)
                        {
                            pCollectionElementDetailsContainer.Controls.Clear();
                        }

                        var baseInfoControl = new ucCollectionInfo()
                        {
                            Dock = DockStyle.Top
                        };
                        baseInfoControl.ParentEl = pCollectionElementDetailsContainer;
                        baseInfoControl.RefreshControls(seShortInfo);

                        pCollectionElementDetailsContainer.Controls.Add(baseInfoControl);
                    }

                    prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucCollectionElements", false);

                    //attempting to reuse the "ucSeriesEpisodes" user control
                    if (prevInstance.Any())
                    {
                        ((ucCollectionElements)prevInstance[0]).LoadControls(seShortInfo);
                        pCollectionElementDetailsContainer.Invalidate();
                    }
                    else
                    {
                        if (!_isFiltered)
                        {
                            var ucCollectionElements = new ucCollectionElements(seShortInfo, this)
                            {
                                Dock = DockStyle.Top
                            };
                            pCollectionElementDetailsContainer.Controls.Add(ucCollectionElements);
                            ucCollectionElements.BringToFront();
                        }
                    }

                    _prevSelectedSeriesId = seShortInfo.Id;
                }
                else
                {
                    var opRes = DAL.LoadMTD(seShortInfo.Id, true);

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

                    var prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucCollectionElements", false);
                    if (prevInstance.Any())
                    {
                        pCollectionElementDetailsContainer.Controls.Clear();
                    }

                    switch ((CollectionsSiteSectionType)seShortInfo.SectionType)
                    {
                    case CollectionsSiteSectionType.MovieType:

                        prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucEpisodeDetails", false);
                        if (prevInstance.Any())
                        {
                            pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                        }

                        prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucMovieInfo", false);

                        if (prevInstance.Any())
                        {
                            ((ucMovieInfo)prevInstance[0]).RefreshControls(DAL.CurrentMTD);
                        }
                        else
                        {
                            var ucMovieInfo = new ucMovieInfo(false)
                            {
                                Dock = DockStyle.Top
                            };
                            ucMovieInfo.RefreshControls(DAL.CurrentMTD);

                            pCollectionElementDetailsContainer.Controls.Add(ucMovieInfo);
                            ucMovieInfo.BringToFront();
                        }

                        break;

                    case CollectionsSiteSectionType.SeriesType:
                        prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucMovieInfo", false);
                        if (prevInstance.Any())
                        {
                            pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                        }

                        prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucEpisodeDetails", false);

                        if (prevInstance.Any())
                        {
                            ((ucEpisodeDetails)prevInstance[0]).LoadControls(seShortInfo.Id, null, "aaaa");
                        }
                        else
                        {
                            var seriesNode = tvCollections.AllNodes.FirstOrDefault(x => ((SeriesEpisodesShortInfo)x.Tag).Id == seShortInfo.SeriesId && ((SeriesEpisodesShortInfo)x.Tag).IsSeries);
                            var seriesName = seriesNode == null
                                    ? "unknown !!!"
                                    : ((SeriesEpisodesShortInfo)seriesNode.Tag).FileName;

                            var ucEpisodeDetails = new ucEpisodeDetails(seShortInfo.Id, seShortInfo.SeriesId, seriesName)
                            {
                                Dock = DockStyle.Top
                            };

                            pCollectionElementDetailsContainer.Controls.Add(ucEpisodeDetails);
                            ucEpisodeDetails.BringToFront();
                        }

                        break;
                    }
                }

                /*
                 * var prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucCollectionInfo", false);
                 *
                 * if (!isElementSeleted)
                 * {
                 *  if (prevInstance.Any())
                 *  {
                 *      ((ucCollectionInfo)prevInstance[0]).RefreshControls(seShortInfo);
                 *  }
                 *  else
                 *  {
                 *      prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucMovieInfo", false);
                 *      if (prevInstance.Any())
                 *          pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                 *
                 *      prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucEpisodeDetails", false);
                 *      if (prevInstance.Any())
                 *          pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                 *
                 *      var ucCol = new ucCollectionInfo() { Dock = DockStyle.Top };
                 *      ucCol.RefreshControls(seShortInfo);
                 *
                 *      pCollectionElementDetailsContainer.Controls.Add(ucCol);
                 *  }
                 * }
                 * else
                 * {
                 *  if (prevInstance.Any()) //the CollectionInfo UserControl
                 *      pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                 *
                 *  var opRes = DAL.LoadMTD(seShortInfo.Id, true);
                 *
                 *  if (!opRes.Success)
                 *  {
                 *      MsgBox.Show(string.Format("The following error occurred while loading the file details:{0}{0}{1}", Environment.NewLine, opRes.CustomErrorMessage),
                 *          "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 *      return;
                 *  }
                 *
                 *
                 *  prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucCollectionInfo", false);
                 *
                 *  switch ((CollectionsSiteSectionType)seShortInfo.SectionType)
                 *  {
                 *      case CollectionsSiteSectionType.MovieType:
                 *
                 *          prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucEpisodeDetails", false);
                 *          if (prevInstance.Any())
                 *              pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                 *
                 *          prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucMovieInfo", false);
                 *
                 *          if (prevInstance.Any())
                 *              ((ucMovieInfo)prevInstance[0]).RefreshControls(DAL.CurrentMTD);
                 *          else
                 *          {
                 *              var ucMovieInfo = new ucMovieInfo(false) { Dock = DockStyle.Top };
                 *              ucMovieInfo.RefreshControls(DAL.CurrentMTD);
                 *
                 *              pCollectionElementDetailsContainer.Controls.Add(ucMovieInfo);
                 *              ucMovieInfo.BringToFront();
                 *          }
                 *
                 *          break;
                 *
                 *      case CollectionsSiteSectionType.SeriesType:
                 *          prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucMovieInfo", false);
                 *          if (prevInstance.Any())
                 *              pCollectionElementDetailsContainer.Controls.Remove(prevInstance[0]);
                 *
                 *          prevInstance = pCollectionElementDetailsContainer.Controls.Find("ucEpisodeDetails", false);
                 *
                 *          if (prevInstance.Any())
                 *              ((ucEpisodeDetails)prevInstance[0]).LoadControls(seShortInfo.Id, null, "aaaa");
                 *          else
                 *          {
                 *              var seriesNode = tvCollections.AllNodes.FirstOrDefault(x => ((SeriesEpisodesShortInfo)x.Tag).Id == seShortInfo.SeriesId && ((SeriesEpisodesShortInfo)x.Tag).IsSeries);
                 *              var seriesName = seriesNode == null
                 *                  ? "unknown !!!"
                 *                  : ((SeriesEpisodesShortInfo)seriesNode.Tag).FileName;
                 *
                 *              var ucEpisodeDetails = new ucEpisodeDetails(seShortInfo.Id, seShortInfo.SeriesId, seriesName) { Dock = DockStyle.Top };
                 *
                 *              pCollectionElementDetailsContainer.Controls.Add(ucEpisodeDetails);
                 *              ucEpisodeDetails.BringToFront();
                 *          }
                 *
                 *          break;
                 *  }
                 * }
                 */
            }
            finally
            {
                if (scrollAt > -1)
                {
                    pCollectionElementDetailsContainer.VerticalScroll.Value = scrollAt;
                }

                SetSaveButtonState(false);

                DrawingControl.ResumeDrawing(pCollectionElementDetailsContainer);
                pCollectionElementDetailsContainer.PerformLayout(); //to refresh the vertical scrollbar

                Cursor = Cursors.Default;
            }
        }