Beispiel #1
0
        public Movie AttachMovieInternal(Movie movie, string attachName,
                                         int attachDepth = -1, bool reorder = false)
        {
            if (m_attachedMovies == null)
            {
                m_attachedMovies              = new AttachedMovies();
                m_detachedMovies              = new DetachDict();
                m_attachedMovieList           = new AttachedMovieList();
                m_attachedMovieDescendingList =
                    new AttachedMovieDescendingList(new DescendingComparer <int>());
            }

            Movie attachedMovie;

            if (m_attachedMovies.TryGetValue(attachName, out attachedMovie))
            {
                DeleteAttachedMovie(this, attachedMovie);
            }

            if (!reorder && attachDepth >= 0)
            {
                if (m_attachedMovieList.TryGetValue(attachDepth, out attachedMovie))
                {
                    DeleteAttachedMovie(this, attachedMovie);
                }
            }

            movie.m_attachName = attachName;
            if (attachDepth >= 0)
            {
                movie.depth = attachDepth;
            }
            else
            {
                AttachedMovieDescendingList.KeyCollection.Enumerator e =
                    m_attachedMovieDescendingList.Keys.GetEnumerator();
                if (e.MoveNext())
                {
                    movie.depth = e.Current + 1;
                }
                else
                {
                    movie.depth = 0;
                }
            }
            movie.m_name = attachName;
            m_attachedMovies[attachName] = movie;
            ReorderAttachedMovieList(reorder, movie.depth, movie);

            return(movie);
        }
Beispiel #2
0
 private void ReorderAttachedMovieList(bool reorder, int index, Movie movie)
 {
     m_attachedMovieList[index] = movie;
     if (reorder)
     {
         AttachedMovieList list = m_attachedMovieList;
         m_attachedMovieList           = new AttachedMovieList();
         m_attachedMovieDescendingList =
             new AttachedMovieDescendingList(new DescendingComparer <int>());
         int i = 0;
         foreach (Movie m in list.Values)
         {
             m.depth = i;
             m_attachedMovieList[i]           = m;
             m_attachedMovieDescendingList[i] = i;
             ++i;
         }
     }
 }