This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
69 lines (63 loc) · 1.96 KB
/
Form1.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
69
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraTab;
using DevExpress.XtraTab.ViewInfo;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
XtraTabPage dragPage;
DragWindow dragWindow;
private void xtraTabControl1_MouseDown(object sender, MouseEventArgs e)
{
dragPage = (sender as XtraTabControl).CalcHitInfo(e.Location).Page;
}
private void xtraTabControl1_MouseMove(object sender, MouseEventArgs e)
{
if (dragPage != null & dragWindow == null)
CreateDragWindow();
if (dragWindow != null)
dragWindow.Location = Control.MousePosition;
}
private void xtraTabControl1_MouseUp(object sender, MouseEventArgs e)
{
XtraTabHitInfo hitInfo = (sender as XtraTabControl).CalcHitInfo(e.Location);
if (hitInfo.HitTest == XtraTabHitTest.PageHeader)
{
if (dragWindow != null)
{
dragPage.Controls.Add(dragWindow.ClonedPage.Controls[0]);
dragWindow.Close();
}
}
else
{
FinalizeDragWindow();
}
dragPage = null;
dragWindow = null;
}
private void CreateDragWindow()
{
if (dragWindow == null)
dragWindow = new DragWindow(dragPage);
}
private void FinalizeDragWindow()
{
if (dragWindow == null) return;
xtraTabControl1.TabPages.Remove(dragPage);
dragWindow.FormBorderStyle = FormBorderStyle;
dragWindow.Opacity = 100;
dragWindow.WindowState = FormWindowState.Maximized;
}
}
}