/// <summary>末尾に要素を追加</summary> private void addLast(CharElement aElement) { Line tLastLine = mLines[mLines.Count - 1]; Line tAddedLine, tSemiLastLine; //幅を考慮し追加可能か確認 if (mLineWidth < tLastLine.mCurrentWidth + aElement.mWidth) { //追加不可 Line tNewLine = createNewLine(); tNewLine.add(aElement); tAddedLine = tNewLine; tSemiLastLine = tLastLine; } else { //追加可 tLastLine.add(aElement); tAddedLine = tLastLine; tSemiLastLine = mLines.Count == 1 ? null : mLines[mLines.Count - 2]; } //行の位置を調整 //横方向 switch (mHorizontalAlign) { case HorizontalAlign.left: break; case HorizontalAlign.center: tAddedLine.positionX = -tAddedLine.mCurrentWidth / 2f; break; case HorizontalAlign.right: tAddedLine.positionX = -tAddedLine.mCurrentWidth; break; } //縦方向 if (tSemiLastLine == null) { tAddedLine.positionY = -tAddedLine.mCurrentHeight; } else { tAddedLine.positionY = tSemiLastLine.positionY - mLineSpacing - tAddedLine.mCurrentHeight; } switch (mVerticalAlign) { case VerticalAlign.top: break; case VerticalAlign.middle: mWriting.positionY = -tAddedLine.positionY / 2f; break; case VerticalAlign.bottom: mWriting.positionY = -tAddedLine.positionY; break; } }
/// <summary>この行に追加</summary> public void add(CharElement aElement) { //追加 aElement.transform.SetParent(this.transform); aElement.position = new Vector3(mCurrentWidth + aElement.mWidth / 2f, aElement.mHeight / 2f, 0); mElements.Add(aElement); //現在の幅更新 mCurrentWidth += aElement.mWidth; //現在の高さ更新 if (mCurrentHeight < aElement.mHeight) { mCurrentHeight = aElement.mHeight; } }
private char GenerateChar(CharElement charElement) { var stringElement = new StringElement { Type = "String", Name = charElement.Name, MinLength = 1, MaxLength = 1, HasBigLetters = charElement.HasBigLetters, HasDigits = charElement.HasDigits, HasSmallLetters = charElement.HasSmallLetters, HasSymbols = charElement.HasSymbols }; return(GenerateString(stringElement)[0]); }
private void InsertIntoBlock(int blockId, int position, Char[] newChars) { var block = blocks[blockId]; var visiblePosition = block.VisibleElements.Search(new CharElement() { Position = position }, elementPositionComparer); for (var i = position; i < block.Elements.Length; i++) { var nc = block.Elements[i]; nc.Position += newChars.Length; nc.VisiblePosition += newChars.Length; } for (var i = blockId + 1; i < blocks.Count; i++) { var nb = blocks[i]; nb.BlockPosition += newChars.Length; nb.BlockVisiblePosition += newChars.Length; } var charItems = new CharElement[newChars.Length]; for (var i = 0; i < newChars.Length; i++) { var nc = new CharElement { Char = newChars[i], Position = position + i, VisiblePosition = visiblePosition + i, Block = block }; idToChar[nc.Char.Id] = nc; charItems[i] = nc; } block.VisibleElements = block.VisibleElements.Take(visiblePosition) .Concat(charItems) .Concat(block.VisibleElements.Skip(visiblePosition)) .FastToArray(block.VisibleElements.Length + charItems.Length); block.Elements = block.Elements.Take(position) .Concat(charItems) .Concat(block.Elements.Skip(position)) .FastToArray(block.Elements.Length + charItems.Length); }