本文整理汇总了C#中Gwen.DragDrop.Package类的典型用法代码示例。如果您正苦于以下问题:C# Package类的具体用法?C# Package怎么用?C# Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Package类属于Gwen.DragDrop命名空间,在下文中一共展示了Package类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DragAndDrop_HandleDrop
public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
{
Point LocalPos = CanvasPosToLocal(new Point(x, y));
TabButton button = DragAndDrop.SourceControl as TabButton;
TabControl tabControl = Parent as TabControl;
if (tabControl != null && button != null)
{
if (button.TabControl != tabControl)
{
// We've moved tab controls!
tabControl.AddPage(button);
}
}
Base droppedOn = GetControlAt(LocalPos.X, LocalPos.Y);
if (droppedOn != null)
{
Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y));
DragAndDrop.SourceControl.BringNextToControl(droppedOn, dropPos.X > droppedOn.Width/2);
}
else
{
DragAndDrop.SourceControl.BringToFront();
}
return true;
}
示例2: DragAndDrop_CanAcceptPackage
public override bool DragAndDrop_CanAcceptPackage(Package p)
{
if (!m_AllowReorder)
return false;
if (p.Name == "TabButtonMove")
return true;
return false;
}
示例3: onDrop
private static bool onDrop(int x, int y)
{
bool success = false;
if (HoveredControl != null)
{
HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);
success = HoveredControl.DragAndDrop_HandleDrop(CurrentPackage, x, y);
}
// Report back to the source control, to tell it if we've been successful.
SourceControl.DragAndDrop_EndDragging(success, x, y);
CurrentPackage = null;
SourceControl = null;
return true;
}
示例4: ControlDeleted
public static void ControlDeleted(Base control)
{
if (SourceControl == control)
{
SourceControl = null;
CurrentPackage = null;
HoveredControl = null;
m_LastPressedControl = null;
}
if (m_LastPressedControl == control)
m_LastPressedControl = null;
if (HoveredControl == control)
HoveredControl = null;
if (m_NewHoveredControl == control)
m_NewHoveredControl = null;
}
示例5: ShouldStartDraggingControl
private static bool ShouldStartDraggingControl( int x, int y )
{
// We're not holding a control down..
if (m_LastPressedControl == null)
return false;
// Not been dragged far enough
int length = Math.Abs(x - m_LastPressedPos.X) + Math.Abs(y - m_LastPressedPos.Y);
if (length < 5)
return false;
// Create the dragging package
CurrentPackage = m_LastPressedControl.DragAndDrop_GetPackage(m_LastPressedPos.X, m_LastPressedPos.Y);
// We didn't create a package!
if (CurrentPackage == null)
{
m_LastPressedControl = null;
SourceControl = null;
return false;
}
// Now we're dragging something!
SourceControl = m_LastPressedControl;
InputHandler.MouseFocus = null;
m_LastPressedControl = null;
CurrentPackage.DrawControl = null;
// Some controls will want to decide whether they should be dragged at that moment.
// This function is for them (it defaults to true)
if (!SourceControl.DragAndDrop_ShouldStartDrag())
{
SourceControl = null;
CurrentPackage = null;
return false;
}
SourceControl.DragAndDrop_StartDragging(CurrentPackage, m_LastPressedPos.X, m_LastPressedPos.Y);
return true;
}
示例6: DragAndDrop_HandleDrop
public override bool DragAndDrop_HandleDrop (Package p, int x, int y)
{
var item = p.UserData as Tuple<int, int, InventoryButton, ItemComponent>;
int pos_x = X / boxSize - item.Item1;
int pos_y = Y / boxSize - item.Item2;
int pos_w = item.Item3.Width / boxSize;
int pos_h = item.Item3.Height / boxSize;
if (pos_x < 0 || pos_x + pos_w >= inventory.Size.X || pos_y < 0 || pos_y + pos_h >= inventory.Size.Y)
return false;
var bar_pos = inventory.GetPositionOfBarItem(item.Item4);
if (bar_pos < inventory.InventoryBar.Length)
inventory.RemoveFromBar(bar_pos);
var old_pos = inventory.GetPositionOfItem (item.Item4);
inventory.TakeOut (item.Item4);
if (inventory.Insert (item.Item4, new Vector2i (pos_x, pos_y)))
{
if (bar_pos < inventory.InventoryBar.Length)
inventory.PutInBar(pos_x, pos_y, bar_pos);
item.Item3.X = pos_x * boxSize + 1;
item.Item3.Y = pos_y * boxSize + 1;
return true;
}
if (!inventory.Insert (item.Item4, old_pos))
{
Logger.Log.AddLogEntry (LogLevel.Error, "InventorySpace", "Lost an item from inventory!");
item.Item3.DelayedDelete ();
}
return false;
}
示例7: DragAndDrop_HoverLeave
// receiver
public virtual void DragAndDrop_HoverLeave(Package p)
{
}
示例8: DragAndDrop_HandleDrop
// receiver
public virtual bool DragAndDrop_HandleDrop(Package p, int x, int y)
{
DragAndDrop.SourceControl.Parent = this;
return true;
}
示例9: DragAndDrop_Hover
public override void DragAndDrop_Hover(Package p, int x, int y)
{
Point localPos = CanvasPosToLocal(new Point(x, y));
Base droppedOn = GetControlAt(localPos.X, localPos.Y);
if (droppedOn != null && droppedOn != this)
{
Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y));
m_TabDragControl.SetBounds(new Rectangle(0, 0, 3, Height));
m_TabDragControl.BringToFront();
m_TabDragControl.SetPosition(droppedOn.X - 1, 0);
if (dropPos.X > droppedOn.Width/2)
{
m_TabDragControl.MoveBy(droppedOn.Width - 1, 0);
}
m_TabDragControl.Dock = Pos.None;
}
else
{
m_TabDragControl.Dock = Pos.Left;
m_TabDragControl.BringToFront();
}
}
示例10: DragAndDrop_StartDragging
public override void DragAndDrop_StartDragging(Package package, int x, int y)
{
DragAndDrop.SourceControl = Parent;
DragAndDrop.SourceControl.DragAndDrop_StartDragging(package, x, y);
}
示例11: DragAndDrop_Hover
public override void DragAndDrop_Hover(Package p, int x, int y)
{
Point pos = CanvasPosToLocal(new Point(x, y));
Pos dir = GetDroppedTabDirection(pos.X, pos.Y);
if (dir == Pos.Fill)
{
if (null == m_DockedTabControl)
{
m_HoverRect = Rectangle.Empty;
return;
}
m_HoverRect = InnerBounds;
return;
}
m_HoverRect = RenderBounds;
int HelpBarWidth = 0;
if (dir == Pos.Left)
{
HelpBarWidth = (int)(m_HoverRect.Width * 0.25f);
m_HoverRect.Width = HelpBarWidth;
}
if (dir == Pos.Right)
{
HelpBarWidth = (int)(m_HoverRect.Width * 0.25f);
m_HoverRect.X = m_HoverRect.Width - HelpBarWidth;
m_HoverRect.Width = HelpBarWidth;
}
if (dir == Pos.Top)
{
HelpBarWidth = (int)(m_HoverRect.Height * 0.25f);
m_HoverRect.Height = HelpBarWidth;
}
if (dir == Pos.Bottom)
{
HelpBarWidth = (int)(m_HoverRect.Height * 0.25f);
m_HoverRect.Y = m_HoverRect.Height - HelpBarWidth;
m_HoverRect.Height = HelpBarWidth;
}
if ((dir == Pos.Top || dir == Pos.Bottom) && !m_DropFar)
{
if (m_Left != null && m_Left.IsVisible)
{
m_HoverRect.X += m_Left.Width;
m_HoverRect.Width -= m_Left.Width;
}
if (m_Right != null && m_Right.IsVisible)
{
m_HoverRect.Width -= m_Right.Width;
}
}
if ((dir == Pos.Left || dir == Pos.Right) && !m_DropFar)
{
if (m_Top != null && m_Top.IsVisible)
{
m_HoverRect.Y += m_Top.Height;
m_HoverRect.Height -= m_Top.Height;
}
if (m_Bottom != null && m_Bottom.IsVisible)
{
m_HoverRect.Height -= m_Bottom.Height;
}
}
}
示例12: DragAndDrop_HoverEnter
public override void DragAndDrop_HoverEnter(Package p, int x, int y)
{
if (m_TabDragControl != null)
{
throw new InvalidOperationException("ERROR! TabStrip::DragAndDrop_HoverEnter");
}
m_TabDragControl = new Highlight(this);
m_TabDragControl.MouseInputEnabled = false;
m_TabDragControl.SetSize(3, Height);
}
示例13: DragAndDrop_HoverEnter
public override void DragAndDrop_HoverEnter(Package p, int x, int y)
{
m_DrawHover = true;
}
示例14: DragAndDrop_HoverLeave
public override void DragAndDrop_HoverLeave(Package p)
{
m_DrawHover = false;
}
示例15: DragAndDrop_HandleDrop
public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
{
Point pos = CanvasPosToLocal(new Point(x, y));
Pos dir = GetDroppedTabDirection(pos.X, pos.Y);
DockedTabControl addTo = m_DockedTabControl;
if (dir == Pos.Fill && addTo == null)
return false;
if (dir != Pos.Fill)
{
DockBase dock = GetChildDock(dir);
addTo = dock.m_DockedTabControl;
if (!m_DropFar)
dock.BringToFront();
else
dock.SendToBack();
}
if (p.Name == "TabButtonMove")
{
TabButton tabButton = DragAndDrop.SourceControl as TabButton;
if (null == tabButton)
return false;
addTo.AddPage(tabButton);
}
if (p.Name == "TabWindowMove")
{
DockedTabControl tabControl = DragAndDrop.SourceControl as DockedTabControl;
if (null == tabControl)
return false;
if (tabControl == addTo)
return false;
tabControl.MoveTabsTo(addTo);
}
Invalidate();
return true;
}