コード例 #1
0
ファイル: TabHeaderControl.cs プロジェクト: Zelfrom/Mtgdb
        public void RelocateTab(int fromIndex, int toIndex, bool selectRelocated)
        {
            object selectedId = TabIds[SelectedIndex];

            if (fromIndex != toIndex && toIndex >= 0 && toIndex < Count)
            {
                lock (_syncRoot)
                {
                    Texts  = Texts.Reorder(fromIndex, toIndex);
                    TabIds = TabIds.Reorder(fromIndex, toIndex);
                    Widths = Widths.Reorder(fromIndex, toIndex);
                    Icons  = Icons.Reorder(fromIndex, toIndex);
                    Tags   = Tags.Reorder(fromIndex, toIndex);
                }
            }

            if (selectRelocated)
            {
                SelectedIndex = toIndex;
            }
            else
            {
                SelectedIndex = TabIds.IndexOf(selectedId);
            }

            TabReordered?.Invoke(this);
        }
コード例 #2
0
        public void ApplyOrderFrom(TabHeaderControl other)
        {
            lock (_syncRoot)
            {
                var indices = TabIds.Select(id => other.TabIds.IndexOf(id))
                              .ToArray();

                if (indices.Any(i => i < 0 || i >= Count))
                {
                    return;
                }

                Texts  = Enumerable.Range(0, Count).Select(i => Texts[indices[i]]).ToList();
                TabIds = Enumerable.Range(0, Count).Select(i => TabIds[indices[i]]).ToList();
                Widths = Enumerable.Range(0, Count).Select(i => Widths[indices[i]]).ToList();
                Icons  = Enumerable.Range(0, Count).Select(i => Icons[indices[i]]).ToList();
            }

            Invalidate();
            TabReordered?.Invoke(this);
        }