예제 #1
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(IChapters source, IChapters target, CopyToProgress progressDelegate)
        {
            if (target.Parent.GetParentDictionary().Parent.Properties.ContainsKey(ParentProperty.ChapterMappings))
            {
                return;
            }

            Dictionary <int, int> chaperMappings = new Dictionary <int, int>();

            foreach (IChapter chapter in source.Chapters)
            {
                IChapter newChapter = target.AddNew();
                chapter.CopyTo(newChapter, progressDelegate);
                chaperMappings.Add(chapter.Id, newChapter.Id);

                if (source.Parent.GetParentDictionary().DefaultSettings.SelectedLearnChapters.Contains(chapter.Id))
                {
                    target.Parent.GetParentDictionary().DefaultSettings.SelectedLearnChapters.Add(newChapter.Id);
                }
                if (source.Parent.GetParentDictionary().UserSettings.SelectedLearnChapters.Contains(chapter.Id))
                {
                    target.Parent.GetParentDictionary().UserSettings.SelectedLearnChapters.Add(newChapter.Id);
                }
            }

            target.Parent.GetParentDictionary().Parent.Properties[ParentProperty.ChapterMappings] = chaperMappings;
        }
        /// <summary>
        /// Adds a chapter to the dictionary.
        /// </summary>
        /// <param name="title">Chapter title</param>
        /// <param name="Description">Chapter Description</param>
        /// <returns>ID of the newly created chapter or -1 to indicate an error</returns>
        /// <remarks>Documented by Dev05, 2007-09-03</remarks>
        public int AddChapter(string title, string description)
        {
            IChapter chapter = chapters.AddNew();

            chapter.Title       = title;
            chapter.Description = description;

            return(chapter.Id);
        }
예제 #3
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(IChapters source, IChapters target, CopyToProgress progressDelegate)
        {
            if (target.Parent.GetParentDictionary().Parent.Properties.ContainsKey(ParentProperty.ChapterMappings))
                return;

            Dictionary<int, int> chaperMappings = new Dictionary<int, int>();
            foreach (IChapter chapter in source.Chapters)
            {
                IChapter newChapter = target.AddNew();
                chapter.CopyTo(newChapter, progressDelegate);
                chaperMappings.Add(chapter.Id, newChapter.Id);

                if (source.Parent.GetParentDictionary().DefaultSettings.SelectedLearnChapters.Contains(chapter.Id))
                    target.Parent.GetParentDictionary().DefaultSettings.SelectedLearnChapters.Add(newChapter.Id);
                if (source.Parent.GetParentDictionary().UserSettings.SelectedLearnChapters.Contains(chapter.Id))
                    target.Parent.GetParentDictionary().UserSettings.SelectedLearnChapters.Add(newChapter.Id);
            }

            target.Parent.GetParentDictionary().Parent.Properties[ParentProperty.ChapterMappings] = chaperMappings;
        }