mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Drag and drop now working
This commit is contained in:
@@ -112,6 +112,8 @@ namespace mRemoteNG.UI.Window
|
||||
this.olvConnections.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.olvConnections.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.olvConnections.HideSelection = false;
|
||||
this.olvConnections.IsSimpleDragSource = true;
|
||||
this.olvConnections.IsSimpleDropSink = true;
|
||||
this.olvConnections.LabelEdit = true;
|
||||
this.olvConnections.Location = new System.Drawing.Point(0, 0);
|
||||
this.olvConnections.MultiSelect = false;
|
||||
|
||||
@@ -98,9 +98,13 @@ namespace mRemoteNG.UI.Window
|
||||
olvConnections.CellClick += tvConnections_NodeMouseSingleClick;
|
||||
olvConnections.CellClick += tvConnections_NodeMouseDoubleClick;
|
||||
olvConnections.CellToolTipShowing += tvConnections_CellToolTipShowing;
|
||||
|
||||
olvConnections.ModelCanDrop += OlvConnections_OnModelCanDrop;
|
||||
olvConnections.ModelDropped += OlvConnections_OnModelDropped;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void PopulateTreeView()
|
||||
{
|
||||
olvConnections.Roots = ConnectionTreeModel.RootNodes;
|
||||
@@ -432,6 +436,34 @@ namespace mRemoteNG.UI.Window
|
||||
#endregion
|
||||
|
||||
#region Drag and Drop
|
||||
private void OlvConnections_OnModelCanDrop(object sender, ModelDropEventArgs e)
|
||||
{
|
||||
var draggedObject = e.SourceModels[0] as ConnectionInfo;
|
||||
if (!NodeIsDraggable(draggedObject)) return;
|
||||
var dropTarget = e.TargetModel as ContainerInfo;
|
||||
if (dropTarget != null)
|
||||
e.Effect = DragDropEffects.Move;
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private bool NodeIsDraggable(ConnectionInfo node)
|
||||
{
|
||||
if (node == null || node is RootNodeInfo || node is PuttySessionInfo) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OlvConnections_OnModelDropped(object sender, ModelDropEventArgs e)
|
||||
{
|
||||
var draggedObject = (IHasParent)e.SourceModels[0];
|
||||
var dropTarget = e.TargetModel as ContainerInfo;
|
||||
if (dropTarget != null)
|
||||
draggedObject.SetParent(dropTarget);
|
||||
e.RefreshObjects();
|
||||
}
|
||||
|
||||
//TODO Fix for TreeListView
|
||||
private static void tvConnections_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user