Exemplo n.º 1
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(ICard), progressDelegate);

            //copy media objects
            ICard targetCard = target as ICard;

            if (targetCard != null)
            {
                foreach (IMedia media in QuestionMedia)
                {
                    targetCard.AddMedia(media, Side.Question);
                }
                foreach (IMedia media in AnswerMedia)
                {
                    targetCard.AddMedia(media, Side.Answer);
                }
                try
                {
                    if (targetCard is MLifter.DAL.XML.XmlCard)
                    {
                        (targetCard as MLifter.DAL.XML.XmlCard).Id = Id;
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("Tried to set the card id for XML but failed: " + ex.ToString());
                }
            }
        }
Exemplo n.º 2
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(ICards source, ICards target, CopyToProgress progressDelegate)
        {
            source.Parent.GetParentDictionary().Chapters.CopyTo(target.Parent.GetParentDictionary().Chapters, progressDelegate);

            CopyBase.Copy(source, target, typeof(ICards), progressDelegate);
            int counter = 0;
            int count   = source.Cards.Count - (CardIdsNotToCopy != null ? CardIdsNotToCopy.Count : 0);
            Dictionary <int, int> chapterMappings = target.Parent.GetParentDictionary().Parent.Properties[ParentProperty.ChapterMappings] as Dictionary <int, int>;

            foreach (ICard card in source.Cards)
            {
                if (CardIdsNotToCopy != null && CardIdsNotToCopy.Contains(card.Id))
                {
                    continue;
                }

                ++counter;
                if (progressDelegate != null && counter % 5 == 0)
                {
                    progressDelegate.Invoke(String.Format(Properties.Resources.CARDS_COPYTO_STATUS, counter, count), counter * 1.0 / count * 100);
                }

                ICard newCard = target.AddNew();
                card.CopyTo(newCard, progressDelegate);
                newCard.Chapter = chapterMappings[card.Chapter];
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(IDictionary), progressDelegate);

            //copy extensions
            foreach (IExtension extension in Extensions)
            {
                IExtension newExtension = ((IDictionary)target).ExtensionFactory(extension.Id);
                extension.CopyTo(newExtension, progressDelegate);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Copies this instance to the specified target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public void CopyTo(MLifter.DAL.Tools.ICopy target, CopyToProgress progressDelegate)
        {
            IChapter targetChapter = target as IChapter;

            if (targetChapter != null && targetChapter.Settings == null && this.Settings != null)
            {
                targetChapter.Settings = targetChapter.Parent.GetParentDictionary().CreateSettings();
            }

            CopyBase.Copy(this, target, typeof(IChapter), progressDelegate);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Copies to.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 /// <remarks>Documented by Dev03, 2009-01-13</remarks>
 public void CopyTo(ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(ICardStyle), progressDelegate);
     if (target is DbCardStyle)
     {
         CopyMediaTo((DbCardStyle)target);
     }
     if (target is DbCardStyle)
     {
         ((DbCardStyle)target).FlushToDB();
     }
 }
Exemplo n.º 6
0
        public static void Copy(ISettings source, ISettings target, CopyToProgress progressDelegate)
        {
            try
            {
                if (!(source is XmlAllowedSettings) && source.Style != null && target.Style == null)
                {
                    target.Style = target.Parent.GetParentDictionary().CreateCardStyle();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }

            CopyBase.Copy(source, target, typeof(ISettings), progressDelegate);

            try
            {
                if (source is XmlChapterSettings || source is XmlCardSettings || source is XmlAllowedSettings || source.Logo == null)
                {
                    target.Logo = null;
                }
                else
                {
                    target.Logo = GetNewMedia(source.Logo, target);
                }
            }
            catch { }

            try
            {
                if (!(source is XmlChapterSettings || source is XmlCardSettings || source is XmlAllowedSettings))
                {
                    Dictionary <CommentarySoundIdentifier, IMedia> cSounds = new Dictionary <CommentarySoundIdentifier, IMedia>();
                    foreach (KeyValuePair <CommentarySoundIdentifier, IMedia> pair in source.CommentarySounds)
                    {
                        cSounds.Add(pair.Key, GetNewMedia(pair.Value, target));
                    }
                    target.CommentarySounds = cSounds;
                }
            }
            catch { }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Copies to.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <remarks>Documented by Dev03, 2009-03-23</remarks>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(ICard), progressDelegate);

            //copy media objects
            ICard targetCard = target as ICard;

            if (targetCard != null)
            {
                foreach (IMedia media in QuestionMedia)
                {
                    targetCard.AddMedia(media, Side.Question);
                }
                foreach (IMedia media in AnswerMedia)
                {
                    targetCard.AddMedia(media, Side.Answer);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Copies this instance to the specified target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public void CopyTo(ICopy target, CopyToProgress progressDelegate)
        {
            CopyBase.Copy(this, target, typeof(IExtension), progressDelegate);

            //copy data stream
            using (Stream data = this.Data)
            {
                if (data != null)
                {
                    ((IExtension)target).Data = data;
                }
            }

            //copy actions
            IList <ExtensionAction> actions = ((IExtension)target).Actions;

            actions.Clear();
            foreach (ExtensionAction action in this.Actions)
            {
                actions.Add(action);
            }
        }
Exemplo n.º 9
0
 public void CopyTo(MLifter.DAL.Tools.ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(IGradeSynonyms), progressDelegate);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Copies this instance to the specified target.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 public void CopyTo(MLifter.DAL.Tools.ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(ISnoozeOptions), progressDelegate);
 }
 public void CopyTo(MLifter.DAL.Tools.ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(IQueryMultipleChoiceOptions), progressDelegate);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Copies this instance to the specified target.
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="progressDelegate">The progress delegate.</param>
 public void CopyTo(MLifter.DAL.Tools.ICopy target, CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this, target, typeof(IQueryType), progressDelegate);
 }
Exemplo n.º 13
0
 public void CopyTo(MLifter.DAL.Tools.ICopy target, MLifter.DAL.Tools.CopyToProgress progressDelegate)
 {
     CopyBase.Copy(this as ISettings, target, typeof(ISettings), progressDelegate);
 }