コード例 #1
0
        public void Move(PathRename p1, PathRename p2)
        {
            if (p1 == p2)
            {
                return;
            }

            var i1 = p1.Index;
            var i2 = p2.Index;

            dataGridView.CurrentCell       = dataGridView[0, i2];
            dataGridView.Rows[i2].Selected = true;
            if (i1 > i2)
            {
                var tmp = p1;
                p1 = p2;
                p2 = tmp;
                var itmp = i1;
                i1 = i2;
                i2 = itmp;
            }
            collection.Remove(p2);
            collection.Insert(i1, p2);
            collection.Remove(p1);
            collection.Insert(i2, p1);
            Refresh();
        }
コード例 #2
0
        private void Add(int index, PathRename path)
        {
            if (collection.Exists(i => i.OriginalPath == path.OriginalPath))
            {
                return;
            }

            if (index > -1)
            {
                collection.Insert(index, path);
            }
            else
            {
                collection.Add(path);
            }
            index = path.Index;
            Refresh();
            dataGridView.Rows[index].Selected = true;
        }
コード例 #3
0
        public void Remove(PathRename path)
        {
            if (path == null)
            {
                return;
            }

            var index = path.Index;

            collection.Remove(path);
            Refresh();
            if (collection.Count == 0)
            {
                return;
            }
            if (collection.Count == index)
            {
                index--;
            }
            dataGridView.CurrentCell          = dataGridView[0, index];
            dataGridView.Rows[index].Selected = true;
        }