示例#1
0
 /// <summary>
 /// Constructor setting the source <see cref="Media"/> of the event
 /// and the new+previous text values
 /// </summary>
 /// <param name="src">The source <see cref="Media"/> of the event</param>
 /// <param name="newTxt">The new text value</param>
 /// <param name="prevTxt">The text value prior to the change</param>
 public TextChangedEventArgs(AbstractTextMedia src, string newTxt, string prevTxt)
     : base(src)
 {
     SourceTextMedia = src;
     NewText         = newTxt;
     PreviousText    = prevTxt;
 }
示例#2
0
        public void CopyTextMediaRenameAndCheckAgain()
        {
            TextMedia text_obj = factory.Create <TextMedia>();

            text_obj.Text = "original media object";

            AbstractTextMedia copy_obj = (AbstractTextMedia)text_obj.Copy();

            copy_obj.Text = "copied media object";

            Assert.AreNotEqual(text_obj.Text, copy_obj.Text);
        }
示例#3
0
        public void canSequenceMediaHoldOnlyOneMediaType()
        {
            SequenceMedia obj = factory.CreateSequenceMedia();

            AbstractAudioMedia audio_obj = factory.Create <ExternalAudioMedia>();
            AbstractTextMedia  text_obj  = factory.CreateTextMedia();

            obj.InsertItem(obj.ChildMedias.Count, audio_obj);

            obj.InsertItem(obj.ChildMedias.Count, text_obj);
            Assert.Fail("The previous should have thrown an MediaNotAcceptable exception");
        }
示例#4
0
        protected void GetXmlFragment_(XmlWriter xmlWriter, bool absoluteLinks)
        {
            if (HasXmlProperty)
            {
                string name = GetXmlElementPrefixedLocalName();
                string NSPrefix;
                string localName;
                XmlProperty.SplitLocalName(name, out NSPrefix, out localName);

                //DebugFix.Assert(string.IsNullOrEmpty(NSPrefix));

                string nsUri = GetXmlNamespaceUri(NSPrefix);

                XmlProperty xmlProp = GetXmlProperty();

                if (String.IsNullOrEmpty(NSPrefix))
                {
                    if (!String.IsNullOrEmpty(nsUri))
                    {
                        xmlWriter.WriteStartElement(name, nsUri);
                    }
                    else
                    {
#if DEBUG
                        Debugger.Break();
#endif //DEBUG
                        xmlWriter.WriteStartElement(name);
                    }
                }
                else
                {
                    //#if DEBUG
                    //                    Debugger.Break();
                    //#endif //DEBUG
                    if (!String.IsNullOrEmpty(nsUri))
                    {
                        xmlWriter.WriteStartElement(NSPrefix, localName, nsUri);
                    }
                    else
                    {
#if DEBUG
                        Debugger.Break();
#endif //DEBUG
                        xmlWriter.WriteStartElement(name);
                    }
                }

                ManagedImageMedia manImageMedia = GetImageMedia() as ManagedImageMedia;
                ManagedVideoMedia manVideoMedia = GetVideoMedia() as ManagedVideoMedia;

                foreach (XmlAttribute xmlAttr in xmlProp.Attributes.ContentsAs_Enumerable)
                {
                    string value = xmlAttr.Value;

                    string nsUriAttr = xmlAttr.GetNamespaceUri();

                    string attrNSPrefix      = xmlAttr.Prefix;
                    string nameWithoutPrefix = xmlAttr.PrefixedLocalName != null ? xmlAttr.PrefixedLocalName : xmlAttr.LocalName;

                    if (manImageMedia != null &&
                        (nameWithoutPrefix == "href" || nameWithoutPrefix == "src"))
                    {
                        DebugFix.Assert(manImageMedia.ImageMediaData.OriginalRelativePath == value);
                        if (absoluteLinks)
                        {
                            value = ((FileDataProvider)manImageMedia.ImageMediaData.DataProvider).DataFileFullPath;
                        }
                    }

                    if (manVideoMedia != null &&
                        (nameWithoutPrefix == "href" || nameWithoutPrefix == "src"))
                    {
                        DebugFix.Assert(manVideoMedia.VideoMediaData.OriginalRelativePath == value);
                        if (absoluteLinks)
                        {
                            value = ((FileDataProvider)manVideoMedia.VideoMediaData.DataProvider).DataFileFullPath;
                        }
                    }


                    if (String.IsNullOrEmpty(attrNSPrefix))
                    {
                        if (nameWithoutPrefix.Equals(XmlReaderWriterHelper.NS_PREFIX_XMLNS))
                        {
                            DebugFix.Assert(XmlReaderWriterHelper.NS_URL_XMLNS.Equals(nsUriAttr));

                            xmlWriter.WriteAttributeString(XmlReaderWriterHelper.NS_PREFIX_XMLNS, XmlReaderWriterHelper.NS_URL_XMLNS, value);
                        }
                        else if (!String.IsNullOrEmpty(nsUriAttr) && nsUriAttr != nsUri)
                        {
#if DEBUG
                            Debugger.Break();
#endif //DEBUG
                            xmlWriter.WriteAttributeString(nameWithoutPrefix, nsUriAttr, value);
                        }
                        else
                        {
                            xmlWriter.WriteAttributeString(nameWithoutPrefix, value);
                        }
                    }
                    else
                    {
                        if (attrNSPrefix.Equals(XmlReaderWriterHelper.NS_PREFIX_XMLNS))
                        {
                            DebugFix.Assert(nsUriAttr == XmlReaderWriterHelper.NS_URL_XMLNS);
                            xmlWriter.WriteAttributeString(XmlReaderWriterHelper.NS_PREFIX_XMLNS, nameWithoutPrefix, XmlReaderWriterHelper.NS_URL_XMLNS,
                                                           value);
                        }
                        else if (attrNSPrefix.Equals(XmlReaderWriterHelper.NS_PREFIX_XML))
                        {
                            DebugFix.Assert(nsUriAttr == XmlReaderWriterHelper.NS_URL_XML);
                            xmlWriter.WriteAttributeString(XmlReaderWriterHelper.NS_PREFIX_XML, nameWithoutPrefix, XmlReaderWriterHelper.NS_URL_XML,
                                                           value);
                        }
                        else if (!String.IsNullOrEmpty(nsUriAttr))
                        {
#if DEBUG
                            //DebugFix.Assert(nsUriAttr != nsUri);

                            string uriCheck = xmlProp.GetNamespaceUri(attrNSPrefix);
                            DebugFix.Assert(nsUriAttr == uriCheck);
#endif //DEBUG
                            xmlWriter.WriteAttributeString(attrNSPrefix, nameWithoutPrefix, nsUriAttr, value);
                        }
                        else if (!String.IsNullOrEmpty(nsUri))
                        {
#if DEBUG
                            Debugger.Break();
#endif //DEBUG
                            xmlWriter.WriteAttributeString(attrNSPrefix, nameWithoutPrefix, nsUri, value);
                        }
                        else
                        {
#if DEBUG
                            Debugger.Break();
#endif //DEBUG
                            xmlWriter.WriteAttributeString(nameWithoutPrefix, value);
                        }
                    }
                }
            }

            if (mChildren.Count > 0)
            {
                for (int i = 0; i < mChildren.Count; i++)
                {
                    TreeNode child = mChildren.Get(i);

                    child.GetXmlFragment_(xmlWriter, absoluteLinks);
                }
            }
            else
            {
                AbstractTextMedia txt = GetTextMedia();
                if (txt != null)
                {
                    DebugFix.Assert(!HasXmlProperty || mChildren.Count == 0);

                    bool     needsCData = false;
                    TreeNode node       = null;
                    if (HasXmlProperty)
                    {
                        node = this;
                    }
                    else if (Parent != null && Parent.HasXmlProperty)
                    {
                        node = Parent;
                    }
                    if (node != null)
                    {
                        string name = node.GetXmlElementLocalName();
                        if (name == "script" || name == "style")
                        {
                            needsCData = true;
                        }
                    }

                    if (needsCData)
                    {
                        xmlWriter.WriteCData(txt.Text);
                    }
                    else
                    {
                        xmlWriter.WriteString(txt.Text);
                    }
                }
            }

            if (HasXmlProperty)
            {
                xmlWriter.WriteEndElement();
            }
        }