示例#1
0
        /// <summary>
        /// Gets the close symbol which corresponds to the specified open symbol.
        /// </summary>
        private BraceSymbol GetCloseSymbol(BraceSymbol open)
        {
            Contract.Require(open, nameof(open));

            if (open.Type != BraceSymbolType.Open)
            {
                throw new ArgumentException(nameof(open));
            }

            if (open.Nesting > 0)
            {
                return(null);
            }

            var index = symbols.IndexOfKey(open.Position);

            for (int i = index + 1; i < symbols.Count; i++)
            {
                var symbol = symbols.Values[i];

                if (commentTracker.IsPositionInsideComment(symbol.Position))
                {
                    continue;
                }

                if (symbol.Type == BraceSymbolType.Close && symbol.Nesting == open.Nesting)
                {
                    return(symbol);
                }
            }

            return(null);
        }
示例#2
0
        /// <summary>
        /// Gets the open symbol which corresponds to the specified close symbol.
        /// </summary>
        private BraceSymbol GetOpenSymbol(BraceSymbol close)
        {
            Contract.Require(close, nameof(close));

            if (close.Type != BraceSymbolType.Close)
            {
                throw new ArgumentException(nameof(close));
            }

            if (close.Nesting < 0)
            {
                return(null);
            }

            var index = symbols.IndexOfKey(close.Position);

            for (int i = index - 1; i >= 0; i--)
            {
                var symbol = symbols.Values[i];

                if (commentTracker.IsPositionInsideComment(symbol.Position))
                {
                    continue;
                }

                if (symbol.Type == BraceSymbolType.Open && symbol.Nesting == close.Nesting)
                {
                    return(symbol);
                }
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// Gets the previous close symbol which occurs at the same nesting level as
        /// the specified open symbol.
        /// </summary>
        private BraceSymbol GetPreviousCloseSymbol(BraceSymbol open)
        {
            Contract.Require(open, nameof(open));

            var index = symbols.IndexOfKey(open.Position);

            for (int i = index - 1; i >= 0; i--)
            {
                var symbol = symbols.Values[i];

                if (commentTracker.IsPositionInsideComment(symbol.Position))
                {
                    continue;
                }

                if (symbol.Type == BraceSymbolType.Close && symbol.Nesting == open.Nesting)
                {
                    return(symbol);
                }
            }

            return(null);
        }
示例#4
0
        private List<BraceSymbol> CreateBraceSymbols(List<Staff> staffs)
        {
            List<BraceSymbol> symbols = new List<BraceSymbol>();
            int ypos = 0;
            BraceSymbol symbol = null;
            foreach (Staff staff in staffs)
            {
            if (staff.Track == 0)
            {
                symbol = new BraceSymbol();
                symbol.Height += staff.Height;
                symbol.Top = ypos;
                symbol.YTop = staff.YTop;
                symbols.Add(symbol);
            }
            else if (staff.Track == 1)
            {
                if (symbol != null)
                {
                    symbol.Height += staff.Height;
                    symbol.YBottom = staff.YBottom;
                }
            }
            ypos += staff.Height;
            }

            return symbols;
        }
示例#5
0
        /// <summary>
        /// Gets the previous close symbol which occurs at the same nesting level as
        /// the specified open symbol.
        /// </summary>
        private BraceSymbol GetPreviousCloseSymbol(BraceSymbol open)
        {
            Contract.Require(open, nameof(open));

            var index = symbols.IndexOfKey(open.Position);

            for (int i = index - 1; i >= 0; i--)
            {
                var symbol = symbols.Values[i];

                if (commentTracker.IsPositionInsideComment(symbol.Position))
                    continue;

                if (symbol.Type == BraceSymbolType.Close && symbol.Nesting == open.Nesting)
                    return symbol;
            }

            return null;
        }
示例#6
0
        /// <summary>
        /// Gets the open symbol which corresponds to the specified close symbol.
        /// </summary>
        private BraceSymbol GetOpenSymbol(BraceSymbol close)
        {
            Contract.Require(close, nameof(close));

            if (close.Type != BraceSymbolType.Close)
                throw new ArgumentException(nameof(close));

            if (close.Nesting < 0)
                return null;

            var index = symbols.IndexOfKey(close.Position);

            for (int i = index - 1; i >= 0; i--)
            {
                var symbol = symbols.Values[i];

                if (commentTracker.IsPositionInsideComment(symbol.Position))
                    continue;

                if (symbol.Type == BraceSymbolType.Open && symbol.Nesting == close.Nesting)
                    return symbol;
            }

            return null;
        }
示例#7
0
        /// <summary>
        /// Gets the close symbol which corresponds to the specified open symbol.
        /// </summary>
        private BraceSymbol GetCloseSymbol(BraceSymbol open)
        {
            Contract.Require(open, nameof(open));

            if (open.Type != BraceSymbolType.Open)
                throw new ArgumentException(nameof(open));

            if (open.Nesting > 0)
                return null;

            var index = symbols.IndexOfKey(open.Position);

            for (int i = index + 1; i < symbols.Count; i++)
            {
                var symbol = symbols.Values[i];

                if (commentTracker.IsPositionInsideComment(symbol.Position))
                    continue;

                if (symbol.Type == BraceSymbolType.Close && symbol.Nesting == open.Nesting)
                    return symbol;
            }

            return null;
        }