コード例 #1
0
 /// <summary>
 /// Called when lines were inserted in ScrollLinesHost.
 /// </summary>
 /// <param name="insertAt">Index of the first inserted line.</param>
 /// <param name="count">The count.</param>
 protected override void OnLinesInserted(int insertAt, int count)
 {
     if (distances != null)
     {
         DistancesUtil.OnInserted(distances, ScrollLinesHost, insertAt, count);
     }
 }
コード例 #2
0
        /// <summary>
        /// Sets the nested lines.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="nestedLines">The nested lines. If parameter is null the line will be converted to a normal (not nested) line with default line size.</param>
        public void SetNestedLines(int index, IEditableLineSizeHost nestedLines)
        {
            if (nestedLines != null)
            {
                lineSizes[index]  = -2; // -1 indicates default value, -2 indicates nested.
                lineNested[index] = (LineSizeCollection)nestedLines;
            }
            else
            {
                lineSizes[index] = -1; // -1 indicates default value, -2 indicates nested.
                lineNested.Remove(index);
            }

            if (IsSuspendUpdates)
            {
                return;
            }

            if (distances != null)
            {
                DistancesUtil.DistancesLineSizeChanged(distances, this, index, index);
            }

            if (LineSizeChanged != null)
            {
                LineSizeChanged(this, new RangeChangedEventArgs(index, index));
            }
        }
コード例 #3
0
        /// <summary>
        /// Sets the line size for a range.
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="size">The size.</param>
        public void SetRange(int from, int to, double size)
        {
            /*if (lineNested.Count > 0)
             * {
             *  for (int n = from; n <= to; n++)
             *  {
             *      if (lineNested.ContainsKey(n))
             *          throw new InvalidOperationException("Cannot change size of a nested LineSizeCollection.");
             *  }
             * }*/
            int    count;
            double savevalue = GetRange(from, out count);

            lineSizes.SetRange(from, to - from + 1, size);

            if (IsSuspendUpdates)
            {
                return;
            }

            // DistancesLineHiddenChanged checks both hidden state and sizes together ...
            if (distances != null)
            {
                DistancesUtil.DistancesLineHiddenChanged(distances, this, from, to);
            }

            if (LineSizeChanged != null)
            {
                LineSizeChanged(this, new RangeChangedEventArgs(from, to, savevalue, size));
            }
        }
コード例 #4
0
        /// <summary>
        /// Inserts lines in the collection and raises the <see cref="LinesInserted"/> event.
        /// </summary>
        /// <param name="insertAtLine">The index of the first line to insert.</param>
        /// <param name="count">The count.</param>
        /// <param name="movelines">A container with saved state from a preceeding <see cref="RemoveLines"/> call when lines should be moved. When it is null empty lines with default size are inserted.</param>
        public void InsertLines(int insertAtLine, int count, IEditableLineSizeHost movelines)
        {
            var moveLines = (LineSizeCollection)movelines;

            lineSizes.Insert(insertAtLine, count, moveLines == null ? null : moveLines.lineSizes);
            lineHidden.Insert(insertAtLine, count, moveLines == null ? null : moveLines.lineHidden);

            Dictionary <int, LineSizeCollection> _lineNested = lineNested;

            lineNested = new Dictionary <int, LineSizeCollection>();

            foreach (KeyValuePair <int, LineSizeCollection> entry in _lineNested)
            {
                if (entry.Key >= insertAtLine)
                {
                    lineNested.Add(entry.Key + count, entry.Value);
                }
                else
                {
                    lineNested.Add(entry.Key, entry.Value);
                }
            }

            if (moveLines != null)
            {
                foreach (KeyValuePair <int, LineSizeCollection> entry in moveLines.lineNested)
                {
                    lineNested.Add(entry.Key + insertAtLine, entry.Value);
                }
            }

            lineCount += count;

            if (IsSuspendUpdates)
            {
                return;
            }

            if (distances != null)
            {
                DistancesUtil.OnInserted(distances, this, insertAtLine, count);
            }

            if (LinesInserted != null)
            {
                LinesInserted(this, new LinesInsertedEventArgs(insertAtLine, count));
            }
        }
コード例 #5
0
        /// <summary>
        /// Sets the hidden state for a range of lines.
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="hide">if set to <c>true</c> hide the lines.</param>
        public void SetHidden(int from, int to, bool hide)
        {
            lineHidden.SetRange(from, to - from + 1, hide);

            if (IsSuspendUpdates)
            {
                return;
            }

            // DistancesLineHiddenChanged checks both hidden state and sizes together ...
            if (distances != null)
            {
                DistancesUtil.DistancesLineHiddenChanged(distances, this, from, to);
            }

            if (LineHiddenChanged != null)
            {
                LineHiddenChanged(this, new HiddenRangeChangedEventArgs(from, to, hide));
            }
        }