예제 #1
0
        private void FMain_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.F3) && (_mapFile != null))
            {
                switch (e.Modifiers)
                {
                case Keys.Control:
                    var f = new FInputBox();
                    if (f.Demana("Entre search text:", "Search :", ucSingleEdit1.GetLastSearchText()) == DialogResult.OK)
                    {
                        ucSingleEdit1.JumpToNext(f.Value);
                        ucSingleEdit1.Focus();
                    }
                    break;

                case Keys.None:
                    ucSingleEdit1.JumpToNext();
                    break;
                }
            }
        }
예제 #2
0
        private void mnMoveTo_Click(object sender, EventArgs e)
        {
            var f = new FInputBox();

            if (f.Demana("Position", "New position :", "0") != DialogResult.OK)
            {
                return;
            }

            int newpos;

            if (!int.TryParse(f.Value, out newpos))
            {
                MessageBox.Show("Invalid number");
                return;
            }

            if (newpos <= 0)
            {
                newpos = 1;
            }

            if (newpos > listView1.Items.Count)
            {
                newpos = listView1.Items.Count;
            }

            var minIndex  = -1;
            var maxIndex  = -1;
            var dragIndex = newpos - 1;

            var sel = new ListViewItem[listView1.SelectedItems.Count];

            for (var i = 0; i <= listView1.SelectedItems.Count - 1; i++)
            {
                sel[i] = listView1.SelectedItems[i];
            }

            for (var i = 0; i < sel.GetLength(0); i++)
            {
                var dragItem  = sel[i];
                var itemIndex = dragIndex;

                if (dragItem.Index < itemIndex)
                {
                    itemIndex++;
                }
                else
                {
                    itemIndex = dragIndex + i;
                }

                var insertItem = (ListViewItem)dragItem.Clone();

                var oldidx = dragItem.Index;
                var newidx = itemIndex;

                if ((minIndex == -1) || (Math.Min(oldidx, newidx) < minIndex))
                {
                    minIndex = Math.Min(oldidx, newidx);
                }

                if ((maxIndex == -1) || (Math.Max(oldidx, newidx) > maxIndex))
                {
                    maxIndex = Math.Max(oldidx, newidx);
                }

                if (newpos >= listView1.Items.Count) // Add to end
                {
                    listView1.Items.Add(insertItem);
                }
                else
                {
                    listView1.Items.Insert(itemIndex, insertItem); // insert into position
                }
                listView1.Items.Remove(dragItem);
            }

            RenumberChannels(minIndex, maxIndex);
        }