Пример #1
0
        private void FocusNextItem(LinkItem linkItem, bool upNotDown)
        {
            if (upNotDown == false)
            {
                int index = _items.IndexOf(linkItem);
                if (index < _items.Count - 1)
                {
                    _items[index + 1].Controls[1].Focus();
                }
                else
                {
                    _items[0].Controls[1].Focus();
                }
            }
            else
            {
                int index = _items.IndexOf(linkItem);
                if (index > 0)
                {
                    _items[index - 1].Controls[0].Focus();
                }
                else
                {
                    _items[_items.Count - 1].Controls[0].Focus();
                }
            }

            scrollbarList.ThumbPosition = panelList.VerticalScroll.Value;
        }
Пример #2
0
        private void RepositionItems(LinkItem linkItem, int difference)
        {
            int index = _items.IndexOf(linkItem);

            for (int i = index + 1; i < _items.Count; i++)
            {
                _items[i].Location = new System.Drawing.Point(_items[i].Location.X, _items[i].Location.Y + difference);
            }

            UpdateScrollBar();
        }
Пример #3
0
 public void SetLinkItemInfo(LinkItem linkItem, System.Drawing.Point location)
 {
     linkItem.Location                     = location;
     linkItem.Width                        = this.Width - SystemInformation.VerticalScrollBarWidth;
     linkItem.MouseWheel                  += scrollbarList.AdvancedScrollbar_MouseWheel;
     linkItem.Controls[0].MouseWheel      += scrollbarList.AdvancedScrollbar_MouseWheel;
     linkItem.Controls[1].MouseWheel      += scrollbarList.AdvancedScrollbar_MouseWheel;
     linkItem.OnLinkItemResizedVertically += RepositionItems;
     linkItem.OnLinkItemSelected          += SetLastSelectedLinkItem;
     linkItem.OnTabPressed                += FocusNextItem;
     linkItem.OnDeleteKeyDown             += Remove;
 }
Пример #4
0
        internal void Populate(List <LinkData> list)
        {
            LinkItem linkItem;

            for (int i = list.Count - 1; i >= 0; i--)
            {
                linkItem = new LinkItem();
                linkItem.Controls[0].Text = list[i].Description;
                linkItem.Controls[1].Text = list[i].Address;
                Add(linkItem);
            }
        }
Пример #5
0
        private void SwapWithNextFromIndex(int index)
        {
            LinkItem item = _items[index];

            panelList.Controls.Remove(item);
            _items.RemoveAt(index);

            _items[index].Location = new System.Drawing.Point(_items[index].Location.X, item.Location.Y);
            item.Location          = new System.Drawing.Point(item.Location.X, item.Location.Y + _items[index].Height);

            _items.Insert(index + 1, item);
            panelList.Controls.Add(item);
        }
Пример #6
0
        public void Add(LinkItem linkItem)
        {
            scrollbarList.ThumbPosition = 0;

            if (_items.Count == 0)
            {
                SetLinkItemInfo(linkItem, new System.Drawing.Point(0, 0));
            }
            else
            {
                SetLinkItemInfo(linkItem, new System.Drawing.Point(0, _items[0].Location.Y));
            }

            foreach (LinkItem item in _items)
            {
                item.Location = new System.Drawing.Point(item.Location.X, item.Location.Y + linkItem.Height);
            }

            _items.Insert(0, linkItem);
            if (_undo == false)
            {
                _undoHistory.Insert(0, new Tuple <string, int, LinkItem>("insert", 0, linkItem));
                if (_redo == false)
                {
                    if (_redoHistory.Count != 0)
                    {
                        _redoHistory.Clear();
                        OnDisableRedo?.Invoke();
                    }
                }
            }

            panelList.Controls.Add(_items[0]);

            if (_items.Count == 0)
            {
                OnDisableUndo?.Invoke();
            }
            else
            {
                OnEnableUndo?.Invoke();
            }

            UpdateScrollBar();
        }
Пример #7
0
        public void Remove(LinkItem linkItem)
        {
            LastSelectedLinkItem = null;

            if (linkItem != null)
            {
                int index = -1;
                for (int i = 0; i < _items.Count; i++)
                {
                    if (_items[i] == linkItem)
                    {
                        index = i;
                        break;
                    }
                }

                if (index != -1)
                {
                    RemoveAt(index);
                }
            }
        }
Пример #8
0
 public void MoveUp(LinkItem linkItem)
 {
     if (linkItem != null)
     {
         int index = _items.IndexOf(linkItem);
         if (index > 0)
         {
             SwapWithNextFromIndex(index - 1);
             if (_undo == false)
             {
                 _undoHistory.Add(new Tuple <string, int, LinkItem>("moveUp", index, linkItem));
                 if (_redo == false)
                 {
                     if (_redoHistory.Count != 0)
                     {
                         _redoHistory.Clear();
                         OnDisableRedo?.Invoke();
                     }
                 }
             }
         }
         linkItem.Controls[0].Focus();
     }
 }
Пример #9
0
        public void Insert(int index, LinkItem linkItem)
        {
            scrollbarList.ThumbPosition = 0;
            if (_items.Count == 0)
            {
                SetLinkItemInfo(linkItem, new System.Drawing.Point(0, 0));
            }
            else
            {
                if (_items.Count == index)
                {
                    SetLinkItemInfo(linkItem, new System.Drawing.Point(0, _items[index - 1].Location.Y + _items[index - 1].Height));
                }
                else
                {
                    SetLinkItemInfo(linkItem, new System.Drawing.Point(0, _items[index].Location.Y));
                }
            }

            for (int i = index; i < _items.Count; i++)
            {
                _items[i].Location = new System.Drawing.Point(_items[i].Location.X, _items[i].Location.Y + linkItem.Height);
            }

            panelList.Controls.Add(linkItem);
            if (_items.Count == 0)
            {
                _items.Add(linkItem);
            }
            else
            {
                if (_items.Count == index)
                {
                    _items.Add(linkItem);
                }
                else
                {
                    _items.Insert(index, linkItem);
                }
            }

            if (_undo == false)
            {
                _undoHistory.Add(new Tuple <string, int, LinkItem>("insert", index, linkItem));
                if (_redo == false)
                {
                    if (_redoHistory.Count != 0)
                    {
                        _redoHistory.Clear();
                        OnDisableRedo?.Invoke();
                    }
                }
            }

            if (_items.Count == 0)
            {
                OnDisableUndo?.Invoke();
            }
            else
            {
                OnEnableUndo?.Invoke();
            }

            UpdateScrollBar();
        }
Пример #10
0
 private void SetLastSelectedLinkItem(LinkItem linkItem)
 {
     LastSelectedLinkItem = linkItem;
 }