Esempio n. 1
0
        private Boolean processParagraph <T>(
            ParagraphType type,
            Int32 position,
            Paragraph <T> paragraph,
            Block block
            ) where T : struct
        {
            var words = pieceWords(type, paragraph);

            addTalkBreakAndCharacter(type, paragraph, words);

            wordsToLines(words, type);

            paragraph.DebugLines = currentLine - oldLine;

            var addPage = currentLine >= pageLines;

            var style = type == ParagraphType.Teller
                                ? paragraph.Pieces[0].Style.To <TellerStyle>()
                                : TellerStyle.Default;

            if (addPage)
            {
                addPageBreak(position, block, style);
            }

            return(addPage);
        }
        public void AddListItem(int level)
        {
            CurrentParagraphType = ParagraphType.List;

            if (m_numOpenLists == 0 || level > m_openListLevel[m_numOpenLists - 1])
            {
                m_openListLevel[m_numOpenLists] = level;
                m_numOpenLists++;
            }
            else
            {
                while (m_numOpenLists > 0 && level < m_openListLevel[m_numOpenLists - 1])
                {
                    m_numOpenLists--;
                }
            }

            string style;
            string bullet;

            switch (m_numOpenLists)
            {
            case 1: style = Styler.StyleList1; bullet = "- "; break;

            case 2: style = Styler.StyleList2; bullet = "- "; break;

            default: style = Styler.StyleList3; bullet = "* "; break;
            }
            Paragraph paragraph = m_document?.LastSection.AddParagraph(bullet, style);
        }
Esempio n. 3
0
        private List <List <Decimal> > pieceWords <T>(
            ParagraphType type,
            Paragraph <T> paragraph
            ) where T : struct
        {
            var result = new List <List <Decimal> >();

            foreach (var piece in paragraph.Pieces)
            {
                if (piece.Text == null)
                {
                    continue;
                }

                var sizes = styles[type][piece.Style];

                var text  = transformToShown(piece, piece.Text);
                var words = sizeWords(text, sizes);
                piece.DebugWords = words;

                result.Add(words);

                addTellerBreak(type, piece);
            }

            return(result);
        }
Esempio n. 4
0
        public ParagraphElement(ParagraphType type, int indentation)
        {
            Contract.Requires(indentation >= 0);

            this.type        = type;
            this.indentation = indentation;
        }
Esempio n. 5
0
 private void setBlockList(Int32 block, Int32 paragraph, ParagraphType paragraphType)
 {
     for (var p = 0; p <= paragraph; p++)
     {
         Model.Story.BlockList[block].ParagraphTypeList.Add(paragraphType);
     }
 }
Esempio n. 6
0
        private void addPieces <P, S>(
            StyleMap styleMap,
            ParagraphType type,
            IList <P> paragraphList
            )
            where P : Paragraph <S>, new()
            where S : struct
        {
            foreach (var style in styleMap)
            {
                var missingSizes = style.Value
                                   .Where(c => c.Value == 0)
                                   .ToList();

                if (missingSizes.Any())
                {
                    addParagraph(
                        type,
                        paragraphList,
                        (S)style.Key,
                        $"{type}_{style.Key}"
                        );
                }

                foreach (var @char in missingSizes)
                {
                    addParagraph(
                        type,
                        paragraphList,
                        (S)style.Key,
                        "".PadLeft(20, @char.Key)
                        );
                }
            }
        }
Esempio n. 7
0
        private void wordsToLines(List <List <Decimal> > words, ParagraphType type)
        {
            var currentLineSize = type == ParagraphType.Talk ? dashSize : 0;

            for (var s = 0; s < words.Count; s++)
            {
                for (var w = 0; w < words[s].Count; w++)
                {
                    var word = words[s][w];
                    currentLineSize += word;

                    if (currentLineSize > lineMaxSize)
                    {
                        currentLine++;
                        currentLineSize = word;
                    }

                    var lastWord     = w + 1 == words[s].Count;
                    var lastSentence = s + 1 == words.Count;
                    var isTalk       = type == ParagraphType.Talk;
                    var isLast       = lastWord && (!isTalk || lastSentence);

                    currentLineSize += isLast ? 0 : spaceSize[type];
                }

                if (type == ParagraphType.Teller)
                {
                    currentLineSize = 0;
                }
            }
        }
Esempio n. 8
0
        public static StyleMap New <T>(ParagraphType type)
        {
            var map = new StyleMap();

            map.fill <T>(type);
            return(map);
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes the instance.
 /// </summary>
 internal Paragraph(string text, ParagraphType type, int quoteLevel, string quotePrefix, bool outlookQuote)
 {
     _text         = text;
     _type         = type;
     _quoteLevel   = quoteLevel;
     _quotePrefix  = quotePrefix;
     _outlookQuote = outlookQuote;
 }
        public Paragraph(XmlNode node)
        {
            this.Regions = new List<Region>();
            this.paragraphNode = node;
            this.paragraphType = ParagraphType.Standard;

            this.parse();
        }
Esempio n. 11
0
 private void fill <T>(ParagraphType type)
 {
     foreach (var style in EnumX.All <T>())
     {
         var name    = style.ToString().ToLower();
         var charMap = new CharMap(type, name);
         Add(style, charMap);
     }
 }
Esempio n. 12
0
 public static Piece <TS> GetPiece(Piece genericPiece, ParagraphType type)
 {
     return(new Piece <TS>
     {
         Text = genericPiece.Text,
         Style = getStyle(genericPiece, type),
         Audio = genericPiece.Audio,
     });
 }
Esempio n. 13
0
 public CommissionType()
 {
     this._tPA_Extensions          = new TPA_ExtensionsType();
     this._comment                 = new ParagraphType();
     this._commissionPayableAmount = new CommissionTypeCommissionPayableAmount();
     this._flatCommission          = new CommissionTypeFlatCommission();
     this._prepaidAmount           = new CommissionTypePrepaidAmount();
     this._commissionableAmount    = new CommissionTypeCommissionableAmount();
     this._uniqueID                = new UniqueID_Type();
 }
        public void StartNote(int level)
        {
            //Do nothing if within a code block
            if (IsCodeBlockOpen())
            {
                return;
            }

            CurrentParagraphType = ParagraphType.Note;
            m_document?.LastSection.AddParagraph("", Styler.StyleNote);
        }
        protected override void DisplayChildProperty(
            Rect position, SerializedProperty parentProperty, SerializedProperty childProperty, GUIContent label
            )
        {
            ParagraphType type = (ParagraphType)parentProperty.FindPropertyRelative(k_TypePath).intValue;

            switch (childProperty.name)
            {
            case k_TextPath:
                if (type == ParagraphType.SwitchTutorial || type == ParagraphType.Image || type == ParagraphType.Video)
                {
                    return;
                }
                break;

            case k_TutorialButtonTextPath:
            case k_TutorialPath:
                if (type != ParagraphType.SwitchTutorial)
                {
                    return;
                }
                break;

            case k_CriteriaPath:
            case k_CompletionPath:
                if (type != ParagraphType.Instruction)
                {
                    return;
                }
                break;

            case k_SummaryPath:
                if ((type != ParagraphType.Instruction) && (type != ParagraphType.Narrative))
                {
                    return;
                }
                break;

            case k_ImagePath:
                if (type != ParagraphType.Image)
                {
                    return;
                }
                break;

            case k_VideoPath:
                if (type != ParagraphType.Video)
                {
                    return;
                }
                break;
            }
            base.DisplayChildProperty(position, parentProperty, childProperty, label);
        }
 public void ToggleCodeBlock(int level)
 {
     if (CurrentParagraphType != ParagraphType.Code)
     {
         CurrentParagraphType = ParagraphType.Code;
         m_document?.LastSection.AddParagraph("", Styler.StyleCode);
     }
     else
     {
         CurrentParagraphType = ParagraphType.Normal;
     }
 }
 public void AddImage(string filename)
 {
     CurrentParagraphType = ParagraphType.Image;
     MigraDoc.DocumentObjectModel.Shapes.Image image;
     if (!filename.EndsWith(".svg"))
     {
         image = m_document.LastSection.AddParagraph("", Styler.StyleImage).AddImage(filename);
         Unit maxWidth = Unit.FromCentimeter(14);
         Unit width    = Unit.FromPoint(GetImageWidthInPoints(filename));
         image.LockAspectRatio = true;
         image.Width           = Unit.FromCentimeter(Math.Min(width.Centimeter, maxWidth.Centimeter));
     }
 }
Esempio n. 18
0
 private static TS getStyle(Piece genericPiece, ParagraphType type)
 {
     try
     {
         return(genericPiece.Type.To <TS>());
     }
     catch
     {
         throw new Exception(
                   $"Style {genericPiece.Type} not found in " +
                   $"{type} (text: '{genericPiece.Text}')."
                   );
     }
 }
Esempio n. 19
0
        private void addParagraph <P, S>(ParagraphType type, IList <P> paragraphList, S style, String text)
            where P : Paragraph <S>, new() where S : struct
        {
            var paragraph = new P();
            var piece     = new Piece <S>
            {
                Style = style,
                Text  = text,
            };

            paragraph.Pieces.Add(piece);
            paragraphList.Add(paragraph);
            block.ParagraphTypeList.Add(type);
        }
        protected override float GetChildPropertyHeight(SerializedProperty parentProperty, SerializedProperty childProperty)
        {
            ParagraphType type = (ParagraphType)parentProperty.FindPropertyRelative(k_TypePath).intValue;

            switch (childProperty.name)
            {
            case k_TextPath:
                if (type == ParagraphType.Icons || type == ParagraphType.Image || type == ParagraphType.Video)
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
                break;

            case k_IconsPath:
                if (type != ParagraphType.Icons)
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
                break;

            case k_CriteriaPath:
                if (type != ParagraphType.Instruction)
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
                break;

            case k_SummaryPath:
                if (type != ParagraphType.Instruction)
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
                break;

            case k_ImagePath:
                if (type != ParagraphType.Image)
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
                break;

            case k_VideoPath:
                if (type != ParagraphType.Video)
                {
                    return(-EditorGUIUtility.standardVerticalSpacing);
                }
                break;
            }
            return(base.GetChildPropertyHeight(parentProperty, childProperty));
        }
Esempio n. 21
0
        private void addTellerBreak <T>(
            ParagraphType type,
            Piece <T> piece
            ) where T : struct
        {
            if (type != ParagraphType.Teller)
            {
                return;
            }

            currentLine++;

            var style = piece.Style.To <TellerStyle>();

            currentLine += linesToAdd(style);
        }
        private bool detectedFormatting(XmlNode node)
        {
            if (node.LocalName != "pPr")
                return false;

            // determine the type of paragraph
            foreach (XmlNode styleNode in node.ChildNodes) {
                if (styleNode.LocalName == "pStyle") {
                    XmlAttribute style = (XmlAttribute)styleNode.Attributes.GetNamedItem("w:val");

                    if (style == null)
                        continue;

                    paragraphType = (ParagraphType)Enum.Parse(typeof(ParagraphType), style.Value);
                }
            }
            return true;
        }
Esempio n. 23
0
        private void addTalkBreakAndCharacter <T>(
            ParagraphType type,
            Paragraph <T> paragraph,
            List <List <Decimal> > words
            ) where T : struct
        {
            if (!(paragraph is Talk talk))
            {
                return;
            }

            var character = $"({talk.Character})";
            var @default  = styles[type][TalkStyle.Default];

            var name = sizeWords(character, @default);

            words.Add(name);

            talk.DebugCharacter = name;

            currentLine++;
        }
Esempio n. 24
0
        protected override void DisplayChildProperty(
            Rect position, SerializedProperty parentProperty, SerializedProperty childProperty, GUIContent label
            )
        {
            ParagraphType type = (ParagraphType)parentProperty.FindPropertyRelative(k_TypePath).intValue;

            switch (childProperty.name)
            {
            case k_TextPath:
                if (type == ParagraphType.Icons)
                {
                    return;
                }
                break;

            case k_IconsPath:
                if (type != ParagraphType.Icons)
                {
                    return;
                }
                break;

            case k_CriteriaPath:
                if (type != ParagraphType.Instruction)
                {
                    return;
                }
                break;

            case k_SummaryPath:
                if (type != ParagraphType.Instruction)
                {
                    return;
                }
                break;
            }
            base.DisplayChildProperty(position, parentProperty, childProperty, label);
        }
Esempio n. 25
0
 public CharMap(ParagraphType type, String style)
 {
     map($"{type}-{style}".ToLower());
 }
Esempio n. 26
0
 public DiscountType()
 {
     this._discountReason = new ParagraphType();
 }
Esempio n. 27
0
        /**
         * Adds the paragraph with the specified type and text to the paragraph list.
         */

        private void AddPara(string body, ParagraphType type)
        {
            _paragraphs.Add(new Paragraph(body, type, 0, "", false));
        }
Esempio n. 28
0
 public ServiceTypeServiceDetails()
 {
     this._serviceDescription = new ParagraphType();
 }
 public CruisePackageTypeLocation()
 {
     this._information = new ParagraphType();
 }
Esempio n. 30
0
 public Paragraph(ParagraphType type, IEnumerable <XmlDoc> content)
 {
     Type    = type;
     Content = new ReadOnlyCollection <XmlDoc>(content?.Where(n => n != null).ToList() ?? new List <XmlDoc>());
 }
Esempio n. 31
0
 public PoliciesTypePolicyPolicyInfo()
 {
     this._description = new ParagraphType();
 }
Esempio n. 32
0
 private Int32 getIndex(Block block, Int32 until, ParagraphType type)
 {
     return(block.ParagraphTypeList
            .Take(until + 1)
            .Count(p => p == type) - 1);
 }