예제 #1
0
 public void Add(TabCursor item)
 {
     if (_cursors.Any(cursor => cursor.Name.Equals(item.Name)) || _cursors.Count >= MaxCursorCount)
     {
         return;
     }
     if (0 == _cursors.Count)
     {
         _adapter.RefreshPosition();
     }
     item.Initialize(this);
     if (string.IsNullOrWhiteSpace(item.Name))
     {
         for (int i = 1; i < MaxCursorCount + 1; i++)
         {
             string cursorName = string.Format(CursorNameFormat, i);
             if (!_cursors.Any(cursor => cursor.Name.Equals(cursorName)))
             {
                 item.Name  = cursorName;
                 item.Color = _cursorPalette[(i - 1) % _cursorPalette.Length];
                 break;
             }
         }
     }
     _cursors.Add(item);
     _baseChart.Controls.Add(item.Control);
     _adapter.MoveCursorToTarget(item);
     SetCursorXBoundry(item);
     AttachOrDetachPaintEvent();
     _parentChart.OnTabCursorChanged(item, TabCursorOperation.CursorAdded, null);
 }
예제 #2
0
        // 移动和显示Marker,如果有更新则返回true,没有更新位置则返回false
        public bool MoveAndShow()
        {
            bool positionChanged  = _adapter.RefreshPosition();
            bool viewRangeChanged = InitializeMoveParameter();

            // 如果图表位置和图像范围都没有变化,则无需更新位置
            if (!positionChanged && !viewRangeChanged)
            {
                return(false);
            }
            RefreshMarkerPosition();
            return(true);
        }