Пример #1
0
        public void ReplaceSpan(Span existingSpan, Span replacementSpan)
        {
            if (_span != existingSpan) throw new ArgumentException("The existing span is not the child of this paragraph.", "existingSpan");

            if (_span != null) _span.Parent = null;

            _span = replacementSpan;

            if (_span != null) _span.Parent = this;
        }
Пример #2
0
        public void ReplaceSpan(Span existingSpan, Span replacementSpan)
        {
            int index = _spans.IndexOf(existingSpan);

            if (index == -1) throw new ArgumentException("The existing span is not contained in this container.", "existingSpan");

            if (replacementSpan != null)
            {
                _spans[index] = replacementSpan;
            }
            else
            {
                _spans.RemoveAt(index);
            }
        }
Пример #3
0
        void RenderSpanInto(Span span, XmlElement container)
        {
            if (span is TextSpan)
            {
                container.AppendChild(container.OwnerDocument.CreateTextNode(StripAllWhitespace((span as TextSpan).Text)));
            }
            else if (span is SequenceSpan)
            {
                foreach (Span childSpan in (span as SequenceSpan).Spans)
                {
                    RenderSpanInto(childSpan, container);
                }
            }
            else if (span is FormattedSpan)
            {
                FormattedSpan formattedSpan = span as FormattedSpan;

                string containerName;

                switch (formattedSpan.Kind)
                {
                    case FormattedSpanKind.Code:
                        containerName = "span-code";
                        break;

                    case FormattedSpanKind.Bold:
                        containerName = "span-bold";
                        break;

                    case FormattedSpanKind.Italic:
                        containerName = "span-italic";
                        break;

                    case FormattedSpanKind.Underline:
                        containerName = "span-underline";
                        break;

                    default:
                        containerName = "span-unknown";
                        break;
                }

                XmlElement formattedContainer = container.OwnerDocument.CreateElement(containerName);
                container.AppendChild(formattedContainer);

                RenderSpanInto(formattedSpan.ChildSpan, formattedContainer);
            }
            else if (span is ReferenceSpan)
            {
                RenderReference(span as ReferenceSpan, container);
            }
        }
Пример #4
0
 public Paragraph(Span span)
 {
     _span = span;
     _span.Parent = this;
 }
Пример #5
0
 // Span visitors, also placed in the base class earliest partial ordering:
 public virtual void VisitSpan(Span span)
 {
 }
Пример #6
0
 public ReferenceSpan(string kindTag, string reference, Span childSpan)
     : base(childSpan)
 {
     _kindTag = kindTag;
     _reference = reference;
 }
Пример #7
0
        public void ReplaceSpan(Span existingSpan, Span replacementSpan)
        {
            if (_childSpan != existingSpan) throw new ArgumentException("The existing span is not the child of this span.", "existingSpan");

            ChildSpan = replacementSpan;
        }
Пример #8
0
        public WrapperSpan(Span childSpan)
        {
            _childSpan = childSpan;

            if (_childSpan != null) _childSpan.Parent = this;
        }
Пример #9
0
        void RenderSpanInto(Span span, XmlElement container)
        {
            if (span is TextSpan)
            {
                container.AppendChild(container.OwnerDocument.CreateTextNode((span as TextSpan).Text));
            }
            else if (span is SequenceSpan)
            {
                foreach (Span childSpan in (span as SequenceSpan).Spans)
                {
                    RenderSpanInto(childSpan, container);
                }
            }
            else if (span is FormattedSpan)
            {
                FormattedSpan formattedSpan = span as FormattedSpan;

                XmlElement formattedContainer = container.OwnerDocument.CreateElement("span");
                container.AppendChild(formattedContainer);

                switch (formattedSpan.Kind)
                {
                    case FormattedSpanKind.Code:
                        formattedContainer.SetAttribute("kind", "code");
                        break;

                    case FormattedSpanKind.Bold:
                        formattedContainer.SetAttribute("kind", "bold");
                        break;

                    case FormattedSpanKind.Italic:
                        formattedContainer.SetAttribute("kind", "italic");
                        break;

                    case FormattedSpanKind.Underline:
                        formattedContainer.SetAttribute("kind", "underline");
                        break;
                }

                RenderSpanInto(formattedSpan.ChildSpan, formattedContainer);
            }
            else if (span is ReferenceSpan)
            {
                RenderReference(span as ReferenceSpan, container);
            }
        }