费拉里斯球场:XtraTabControl(DEV中选项卡)分页实现拖拽 效果 - CookBlack ...
来源:百度文库 编辑:九乡新闻网 时间:2024/05/05 12:03:55
XtraTabControl(DEV中选项卡)分页实现拖拽 效果
用到的命名空间是:view sourceprint?1
using
DevExpress.XtraTab;
2
using
DevExpress.XtraTab.ViewInfo;
用到的变量:view sourceprint? 1
private
Rectangle rectDragBoxFromMouseDown;
2
private
bool
isDragging =
false
;
3
private
Point dragOffset = Point.Empty;
创建所用到的函数:view sourceprint? 01
private
void
CalcRectDragBox(
int
x,
int
y)
02
{
03
// Remember the point where the mouse down occurred. The DragSize indicates
04
// the size that the mouse can move before a drag event should be started.
05
Size dragSize = SystemInformation.DragSize;
06
// Create a rectangle using the DragSize, with the mouse position being
07
// at the center of the rectangle.
08
rectDragBoxFromMouseDown =
new
Rectangle(
new
Point((
int
)x - (dragSize.Width / 2), (
int
)y - (dragSize.Height / 2)), dragSize);
09
}
10
private
int
FindIndex(XtraTabPage page)
11
{
12
int
i = 0;
13
while
(i < xtcMain.TabPages.Count)
14
{
15
if
(xtcMain.TabPages[i].Equals(page))
16
{
17
return
i;
18
}
19
i += 1;
20
}
21
return
-1;
22
}
在 DragOver 事件中的code:view sourceprint? 01
XtraTabHitInfo hinfo =
default
(XtraTabHitInfo);
02
XtraTabPage hoverTab =
default
(XtraTabPage);
03
XtraTabPage dragTab =
default
(XtraTabPage);
04
XtraTabPage selTab =
default
(XtraTabPage);
05
XtraTabPage repTab =
default
(XtraTabPage);
06
//
07
int
itemDragIndex = 0;
08
int
dropLocationIndex = 0;
09
//
10
// get the tab we are hovering over.
11
hinfo = xtcMain.CalcHitInfo(xtcMain.PointToClient(
new
Point(e.X, e.Y)));
12
//
13
if
((hinfo.Page !=
null
))
14
{
15
hoverTab = hinfo.Page;
16
//Make sure there is a TabPage being dragged.
17
if
(e.Data.GetDataPresent(
typeof
(XtraTabPage)))
18
{
19
e.Effect = DragDropEffects.Move;
20
dragTab = (XtraTabPage)e.Data.GetData(
typeof
(XtraTabPage));
21
// can't use the TabIndex on the control because it changes
22
// when we move the tab page.
23
itemDragIndex = FindIndex(dragTab);
24
dropLocationIndex = FindIndex(hoverTab);
25
//Don't do anything if we are hovering over ourself.
26
if
(itemDragIndex != dropLocationIndex)
27
{
28
selTab = xtcMain.TabPages[itemDragIndex];
29
repTab = xtcMain.TabPages[dropLocationIndex];
30
//
31
xtcMain.TabPages.Move(dropLocationIndex, selTab);
32
xtcMain.TabPages.Move(itemDragIndex, repTab);
33
xtcMain.SelectedTabPage = selTab;
34
}
35
}
36
}
37
else
38
{
39
e.Effect = DragDropEffects.None;
40
}
在 MouseDown 事件中的code:view sourceprint? 01
CalcRectDragBox(e.X, e.Y);
02
03
04
// Handle Mouse move only if left button is pressed.
05
if
(e.Button == MouseButtons.Left)
06
{
07
// If the mouse moves outside the rectangle, start the drag.
08
if
(!rectDragBoxFromMouseDown.Equals(Rectangle.Empty) & !rectDragBoxFromMouseDown.Contains(e.X, e.Y))
09
{
10
isDragging =
true
;
11
dragOffset =
new
Point(e.X, e.Y);
12
Invalidate();
13
// Proceed with the drag and drop.
14
DragDropEffects dropEffect = DoDragDrop(xtcMain.SelectedTabPage, DragDropEffects.Move);
15
// Reset the drag box to avoid reentry of drag.
16
CalcRectDragBox(e.X, e.Y);
17
isDragging =
false
;
18
dragOffset = Point.Empty;
19
Invalidate();
20
}
21
}
如果你有不同大小的标签,张贴的代码将导致快如闪电的标签之间切换,如果您对重叠的区域的大小不同悬停。 为了防止这种情况,我只是说在dragOver处理一个简单的标志,忽略未来DragOver事件。 在上面的DragOver里面相应的 位置加入这个标志ignoreNextDrag,具体代码如下:view sourceprint? 01
if
(itemDragIndex != dropLocationIndex && !ignoreNextDrag)
02
{
03
ignoreNextDrag =
true
;
04
selTab = tabControlClientModules.TabPages[itemDragIndex];
05
repTab = tabControlClientModules.TabPages[dropLocationIndex];
06
//
07
tabControlClientModules.TabPages.Move(dropLocationIndex, selTab);
08
tabControlClientModules.TabPages.Move(itemDragIndex, repTab);
09
tabControlClientModules.SelectedTabPage = selTab;
10
}
11
else
12
{
13
ignoreNextDrag =
false
;
14
15
}
view sourceprint? 1
XtraTabControl(DEV中选项卡)分页实现拖拽 效果 - CookBlack ...
CSS JS实现的选项卡效果(html组件)-网页陶吧-CSS-天极Yesky
让DataPager分页控件实现服务器端分页
PowerPoint 2007中实现滚动字幕效果
在C#中如何读取配置文件 - CookBlack - 博客园
如何在PS中实现暗角效果
Dreamweaver轻松实现网页中透明Flash效果
PPT课件中实现"时针"的旋转效果
Premiere中马赛克追踪效果的二种实现方法
WEB开发中Struts分页算法
ListView 实现像Android Market那样 分页加载 滚动加载
实现动态模糊效果
简洁的tab选项卡,一个页面中可重复使用多个tab。
VS中为类,函数代码自动添加版权注释信息 - CookBlack - 博客园
用jQuery和jTemplates插件实现客户端分页的表格展现
PS实现水彩效果 - Photoshop
Animation动画效果的实现
10D没有多次曝光功能,在PS中如何实现多次曝光效果? - 无忌论坛
六级单选正确选项词频(总)
用PowerPoint实现淡入淡出效果
Android 实现书籍翻页效果----完结篇
Android 实现书籍翻页效果----升级篇
实现无刷新DropDownList联动效果
/dev/random和/dev/urandom区别 ? 死灰的博客