Ejemplo n.º 1
0
 public abstract bool MergeWith(ContentBlock contentBlock);
Ejemplo n.º 2
0
        public override bool MergeWith(ContentBlock contentBlock)
        {
            String newText = null;
            if (contentBlock is TextContentBlock)
            {
                newText = (contentBlock as TextContentBlock).Text;

                if (newText == "")
                {
                    return true;
                }
            }

            if (!NoMerge && !contentBlock.NoMerge)
            {
                if (!Text.EndsWith("\n\n") && (contentBlock is TextContentBlock) && !(contentBlock is QuoteBlock))
                {
                    if ((Text.Length + newText.Length) <= _maxTextBlockSize)
                    {
                        if ((newText != "\n") && (newText != ""))
                        {
                            if ((Text.Length > 1) && Text.EndsWith("\n") && !Text.EndsWith("\n\n"))
                            {
                                Text = Text.Substring(0, Text.Length - 1);
                                Text = Text + " ";
                            }
                        }

                        //if (!Text.EndsWith("\n") || (newText != "\n"))
                        {
                            Text = Text + newText;
                            return true;
                        }
                    }
                }

                if (contentBlock is TextContentBlock)
                {
                    if (Text.EndsWith("\n") && (newText == "\n"))
                    {
                        return true;
                    }
                }
            }

            if (contentBlock is TextContentBlock)
            {
                if ((NoMerge || contentBlock.NoMerge) && (newText == "\n"))
                {
                    return true;
                }
            }

            while (Text.EndsWith("\n\n") && Text.Length > 1)
            {
                Text = Text.Substring(0, Text.Length - 1);
            }

            return false;
        }
Ejemplo n.º 3
0
 public override bool MergeWith(ContentBlock contentBlock)
 {
     return false;
 }
Ejemplo n.º 4
0
        public override bool MergeWith(ContentBlock contentBlock)
        {
            if (NoMerge || contentBlock.NoMerge)
            {
                return false;
            }

            if (contentBlock is TextContentBlock)
            {
                String newText = (contentBlock as TextContentBlock).Text;
                bool merge = false;

                if (contentBlock is QuoteBlock)
                {
                    merge = true;
                    _lineBreakCount = 0;
                }
                else
                {

                    if (_lineBreakCount <= 1)
                    {
                        merge = true;
                    }

                    if (newText == "\n")
                    {
                        _lineBreakCount++;
                    }
                    else if (newText.Trim('\n').Trim() != "")
                    {
                        _lineBreakCount = 0;
                    }
                }

                if (merge)
                {
                    if (!App.Settings.HideFullQuote || _mergeCounter < 4)
                    {
                        Text = Text + (contentBlock as TextContentBlock).Text;
                        while (Text.EndsWith("\n\n"))
                        {
                            Text = Text.Substring(0, Text.Length - 1);
                        }

                        _mergeCounter++;
                    }

                    return true;
                }
                else
                {
                    if (newText.Trim('\n').Trim() == "")
                    {
                        return true;
                    }
                }
            }

            return false;
        }