Beispiel #1
0
        protected void BackgroundWorkerCalcStats_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            stopwatchCalcStats.Stop();
            MyLog.AddElapsed(stopwatchCalcStats.Elapsed);

            VideoInfoStats videoInfoStatsResults = (VideoInfoStats)sender;

            if (videoInfoStatsResults != null)
            {
                CalcVideoInfoStats.Save();
            }

            LoadVideos_Completed(sender, e);
        }
Beispiel #2
0
 public void RunCalcStats(object sender, RunWorkerCompletedEventArgs e)
 {
     MyLog.Add("Setting Stats");
     subFormProgress.Value(0);
     subFormProgress.Text("Setting Stats..");
     if (!CalcVideoInfoStats.Load())
     {
         stopwatchCalcStats = Stopwatch.StartNew(); // stopped when background worker completed
         calcVideoInfoStats.Calc(ListVideoInfo.GetList());
     }
     else
     {
         LoadVideos_Completed(sender, e);
     }
 }
Beispiel #3
0
        public LoadVideos()
        {
            // scan file system for videos
            backgroundWorkerScanSource = new BackgroundWorkerScanSource();
            backgroundWorkerScanSource.Initialize();
            backgroundWorkerScanSource.backgroundWorkerScanSource_ProgressChanged    += new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);
            backgroundWorkerScanSource.backgroundWorkerScanSource_RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerScanSource_RunWorkerCompleted);

            // filter existing list for videos
            backgroundWorkerFilterSource = new BackgroundWorkerFilterSource();
            backgroundWorkerFilterSource.Initialize();
            backgroundWorkerFilterSource.backgroundWorkerFilterSource_ProgressChanged    += new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);
            backgroundWorkerFilterSource.backgroundWorkerFilterSource_RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilterSource_RunWorkerCompleted);

            // build gallery images for video items loaded
            buildGalleryImages = new BuildGalleryImages();
            buildGalleryImages.backgroundWorkerBuildGalleryImages_RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerBuildGalleryImages_RunWorkerCompleted);

            // calc stats for video items loaded
            calcVideoInfoStats = new CalcVideoInfoStats();
            calcVideoInfoStats.backgroundWorkerCalcStats_RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerCalcStats_RunWorkerCompleted);
        }
Beispiel #4
0
        /// <summary>
        /// add criteria manually
        /// </summary>
        /// <param name="criteriaType"></param>
        /// <param name="selectedTags"></param>
        private void AddCriteria(string criteriaType, string selectedTags)
        {
            // check if valid criteria type
            if (!criteriaTypes.ContainsKey(criteriaType))
            {
                return;
            }

            // check if criteria already exits, exit if so
            string name  = "userControlTagCloud_" + criteriaType;
            int    index = 0;

            foreach (Control control in flowLayoutPanelCriteria.Controls)
            {
                if (control.Name == name)
                {
                    return;
                }
                index++;
            }

            VideoInfoStats videoItemStats = CalcVideoInfoStats.GetStats();

            if (videoItemStats == null)
            {
                return;
            }

            flowLayoutPanelCriteria.SuspendLayout();

            MyTagCloud userControlTagCloud = new MyTagCloud();

            userControlTagCloud.Height = 100;
            userControlTagCloud.Name   = "userControlTagCloud_" + criteriaType;

            userControlTagCloud.SetTagType(criteriaTypes[criteriaType]);

            List <MyTagCloud.TagItem> tagItems = new List <MyTagCloud.TagItem> {
            };



            switch (criteriaType)
            {
            case "genre":
                tagItems = GetTagItemsString(videoItemStats.genre);
                userControlTagCloud.Height = 70;
                break;

            case "height":
                tagItems = GetTagItemsNumeric(videoItemStats.height);
                userControlTagCloud.Height = 60;
                break;

            case "imdbRating":
                tagItems = GetTagItemsNumeric(videoItemStats.imdbRating);
                userControlTagCloud.Height = 60;
                break;

            case "mpaa":
                tagItems = GetTagItemsString(videoItemStats.mpaa);
                userControlTagCloud.Height = 70;
                break;

            case "playCount":
                tagItems = GetTagItemsNumeric(videoItemStats.playCount);
                userControlTagCloud.Height = 60;
                break;

            case "rating":
                tagItems = GetTagItemsNumeric(videoItemStats.rating);
                userControlTagCloud.Height = 60;
                break;

            case "source":
                tagItems = GetTagItemsString(videoItemStats.source);
                userControlTagCloud.Height = 60;
                break;

            case "sourceAlias":
                tagItems = GetTagItemsString(videoItemStats.sourceAlias);
                userControlTagCloud.Height = 60;
                break;

            case "tag":
                tagItems = GetTagItemsString(videoItemStats.tag);
                userControlTagCloud.Height = 105;
                break;

            case "version":
                tagItems = GetTagItemsString(videoItemStats.version);
                userControlTagCloud.Height = 60;
                break;

            case "watched":
                foreach (VideoInfoStatsQty <string, int> item in videoItemStats.watched)
                {
                    string watched = VideoFileEnums.watched.GetTextByKey(item.Key);
                    tagItems.Add(new MyTagCloud.TagItem(watched, item.Value));
                }
                tagItems.Sort((x, y) => x.Name.CompareTo(y.Name) * -1);

                userControlTagCloud.Height = 35;
                break;

            case "width":
                tagItems = GetTagItemsNumeric(videoItemStats.width);
                userControlTagCloud.Height = 60;
                break;

            case "year":
                List <int> yearAdded = new List <int> {
                };
                foreach (VideoInfoStatsQty <int, int> item in videoItemStats.year)
                {
                    // MyLog.Add("add year: " + item.Key.ToString() + " " + item.Value.ToString());
                    tagItems.Add(new MyTagCloud.TagItem(item.Key.ToString(), item.Value));
                    yearAdded.Add(item.Key);
                }

                int paddingYears = 2;
                int currentYear  = System.DateTime.UtcNow.Year + paddingYears;
                int minYear      = 1920;

                for (int year = currentYear; year > minYear; year--)
                {
                    if (yearAdded.Contains(year))
                    {
                        continue;
                    }
                    tagItems.Add(new MyTagCloud.TagItem(year.ToString(), 0));
                }
                tagItems.Sort((x, y) => x.Name.CompareTo(y.Name) * -1);

                userControlTagCloud.Height = 105;
                break;

            default:
                return;
            }
            if (tagItems.Count == 0)
            {
                // TODO btr way to handle no results
                tagItems.Add(new MyTagCloud.TagItem("No results", 0));

                // return;
            }
            userControlTagCloud.AddItems(tagItems, selectedTags);

            flowLayoutPanelCriteria.Controls.Add(userControlTagCloud);

            buttonCriteria.Text = "Remove Criteria";

            NormalizeCriteriaWidth();

            flowLayoutPanelCriteria.ResumeLayout();
        }