Exemple #1
0
        public Columns CalculateColumns()
        {
            Columns columns = new Columns();
            Column lastColumn = null;
            Offset lastOffset = Offset.Zero;

            int count = _members.Count;
            for (int i = 0; i < count; i++)
            {
                Offset thisOffset = this[i].TopOffset;
                if (thisOffset.IsLessThanOrEqualTo(lastOffset))
                {
                    if (lastColumn != null)
                    {
                        lastColumn.SetEnd(i);
                    }
                    Column col = new Column(this, i);
                    columns.Add(col);
                    lastColumn = col;
                }
                lastOffset = thisOffset;
            }
            lastColumn.SetEnd(count);

            return columns;
        }
Exemple #2
0
 public void Adjoin(Column column, out Column resetted)
 {
     if (_stack.Count == 0)
     {
         _stack.Push(column);
         resetted = null;
         return;
     }
     Column newColumn = column;
     Column curColumn;
     for (; ; )
     {
         // 在找到被重置的列之前,堆栈不可能被挖空
         // 最糟糕的情况,就是被重置的列正好是最底一列
         curColumn = _stack.Peek();
         if (curColumn.IsAbove(newColumn))
         {
             resetted = curColumn;
             _stack.Push(newColumn);
             return;
         }
         if (curColumn.IsParallelTo(newColumn))
         {
             resetted = curColumn;
             _stack.Pop();
             _stack.Push(newColumn);
             return;
         }
         _stack.Pop();
     }
 }
Exemple #3
0
 public bool IsParallelTo(Column o)
 {
     return this.TopOffset.IsEqualTo(o.TopOffset);
 }
Exemple #4
0
 public void PushResetter(Column resetter)
 {
     _resetters.Add(resetter);
 }
Exemple #5
0
 public bool IsAbove(Column o)
 {
     return this.TopOffset.IsLessThan(o.TopOffset);
 }