public void AddHighlightsFile(string path)
        {
            savePaths.Add(path);

            if (!File.Exists(path))
            {
                return;
            }

            try
            {
                using (Stream stream = new FileStream(path, FileMode.OpenOrCreate))
                {
                    List <Highlights> list = (List <Highlights>)xmlSerializer.Deserialize(stream);

                    foreach (Highlights newHighlights in list)
                    {
                        Highlights simalarHighlights = allHighlights.FirstOrDefault(c => Similar(c, newHighlights));

                        if (simalarHighlights == null)
                        {
                            allHighlights.Add(newHighlights);
                        }
                        else if (simalarHighlights.LastChanged < newHighlights.LastChanged)
                        {
                            simalarHighlights.Change(newHighlights);
                        }
                    }
                }
            }
            catch { }
        }
        public HighlightCollection GetHighlightCollection(MediaFile mediaFile)
        {
            Highlights highlights = allHighlights.FirstOrDefault(c => c.DurationTicks == mediaFile.Duration.Ticks);

            if (highlights == null)
            {
                highlights = new Highlights(mediaFile);
                allHighlights.Add(highlights);
            }

            return(highlights.Collection);
        }
Esempio n. 3
0
        internal void Change(Highlights newHighlights)
        {
            DurationTicks = newHighlights.DurationTicks;
            FirstID       = newHighlights.FirstID;
            LastID        = newHighlights.LastID;
            LastChanged   = newHighlights.LastChanged;

            Collection.Clear();
            foreach (Highlight highlight in newHighlights.Collection)
            {
                Collection.Add(highlight);
            }
        }
        private bool Similar(Highlights collection1, Highlights collection2)
        {
            if (collection1.DurationTicks != collection2.DurationTicks)
            {
                return(false);
            }
            if (collection1.FirstID == collection2.FirstID)
            {
                return(true);
            }
            if (collection1.LastID == collection2.LastID)
            {
                return(true);
            }

            return(false);
        }