-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortingSequenceSelector.cs
68 lines (56 loc) · 1.91 KB
/
sortingSequenceSelector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class sortingSequenceSelector : UserControl
{
public sortingSequenceSelector()
{
InitializeComponent();
}
private void textBox_MouseDown(object sender, MouseEventArgs e)
{
((TextBox)sender).DoDragDrop(((TextBox)sender), DragDropEffects.Copy | DragDropEffects.Move);
}
private void textBox_DragEnter(object sender, DragEventArgs e)
{
int len = e.Data.GetFormats().Length - 1;
int i;
for (i = 0; i <= len; i++)
{
if (e.Data.GetFormats()[i].Equals("System.Windows.Forms.TextBox"))
{
e.Effect = DragDropEffects.Move;
}
}
}
private void textBox_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(TextBox)))
{
TextBox draggedTextBox = (TextBox)e.Data.GetData(typeof(TextBox));
int orgLeft = draggedTextBox.Left;
draggedTextBox.Left = ((TextBox)sender).Left;
((TextBox)sender).Left = orgLeft;
int accumulatedLeft = 0;
foreach (Control control in this.Controls.Cast<Control>().OrderBy(o => o.Location.X))
{
TextBox currTextBox = (TextBox)control;
currTextBox.Left = accumulatedLeft;
accumulatedLeft = accumulatedLeft + currTextBox.Width;
}
}
}
private void textBox_Enter(object sender, EventArgs e)
{
this.ActiveControl = this;
}
}
}