예제 #1
0
        private int GetArrayIndex(Char2 bracePosition, Char2[] braces)
        {
            for (var i = 0; i < braces.Length; i++)
            {
                if (braces[i].Position != bracePosition.Position)
                {
                    continue;
                }

                return(i);
            }
            throw new IndexOutOfRangeException();
        }
예제 #2
0
        private void Draw(Char2 bracePosition)
        {
            var braces = this.chars.Where(x => x.IsBrace).ToArray();

            int posStart, posEnd;

            if (bracePosition.Brace?.BraceState == BraceState.IsOpenBrace)
            {
                posStart = bracePosition.Position;
                posEnd   = GetOppositePos(bracePosition, braces);
            }
            else
            {
                posStart = GetOppositePos(bracePosition, braces);
                posEnd   = bracePosition.Position;
            }

            this.Draw(posStart, posEnd);
        }
예제 #3
0
        private int GetOppositePos(Char2 bracePosition, Char2[] braces)
        {
            int arrayIndex = GetArrayIndex(bracePosition, braces);

            return(braces[braces.Length - 1 - arrayIndex].Position);
        }