|
|
|
@ -3,6 +3,7 @@
@@ -3,6 +3,7 @@
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Windows; |
|
|
|
@ -14,36 +15,30 @@ using System.Windows.Input;
@@ -14,36 +15,30 @@ using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.TreeView |
|
|
|
|
{ |
|
|
|
|
public class SharpTreeNode : INotifyPropertyChanged |
|
|
|
|
public partial class SharpTreeNode : INotifyPropertyChanged |
|
|
|
|
{ |
|
|
|
|
SharpTreeNodeCollection modelChildren; |
|
|
|
|
internal SharpTreeNode modelParent; |
|
|
|
|
bool isVisible = true; |
|
|
|
|
|
|
|
|
|
#region Main
|
|
|
|
|
|
|
|
|
|
static SharpTreeNode() |
|
|
|
|
public SharpTreeNode() |
|
|
|
|
{ |
|
|
|
|
SelectedNodes = new HashSet<SharpTreeNode>(); |
|
|
|
|
ActiveNodes = new HashSet<SharpTreeNode>(); |
|
|
|
|
//StartCuttedDataWatcher();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static HashSet<SharpTreeNode> SelectedNodes { get; private set; } |
|
|
|
|
public static HashSet<SharpTreeNode> ActiveNodes { get; private set; } |
|
|
|
|
|
|
|
|
|
static SharpTreeNode[] ActiveNodesArray |
|
|
|
|
{ |
|
|
|
|
get |
|
|
|
|
{ |
|
|
|
|
return ActiveNodes.ToArray(); |
|
|
|
|
public SharpTreeNodeCollection Children { |
|
|
|
|
get { |
|
|
|
|
if (modelChildren == null) |
|
|
|
|
modelChildren = new SharpTreeNodeCollection(this); |
|
|
|
|
return modelChildren; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public SharpTreeNode() |
|
|
|
|
{ |
|
|
|
|
Children = new SharpTreeNodeCollection(this); |
|
|
|
|
public SharpTreeNode Parent { |
|
|
|
|
get { return modelParent; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public SharpTreeNodeCollection Children { get; private set; } |
|
|
|
|
public SharpTreeNode Parent { get; internal set; } |
|
|
|
|
|
|
|
|
|
public virtual object Text |
|
|
|
|
{ |
|
|
|
|
get { return null; } |
|
|
|
@ -69,35 +64,62 @@ namespace ICSharpCode.TreeView
@@ -69,35 +64,62 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
get { return Parent == null; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//bool isSelected;
|
|
|
|
|
bool isHidden; |
|
|
|
|
|
|
|
|
|
public bool IsHidden |
|
|
|
|
{ |
|
|
|
|
get { return isHidden; } |
|
|
|
|
set { |
|
|
|
|
if (isHidden != value) { |
|
|
|
|
isHidden = value; |
|
|
|
|
RaisePropertyChanged("IsHidden"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool isSelected; |
|
|
|
|
|
|
|
|
|
//public bool IsSelected
|
|
|
|
|
//{
|
|
|
|
|
// get { return isSelected; }
|
|
|
|
|
// set
|
|
|
|
|
// {
|
|
|
|
|
// isSelected = value;
|
|
|
|
|
// RaisePropertyChanged("IsSelected");
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
public bool IsSelected |
|
|
|
|
{ |
|
|
|
|
get { return isSelected; } |
|
|
|
|
set { |
|
|
|
|
if (isSelected != value) { |
|
|
|
|
isSelected = value; |
|
|
|
|
RaisePropertyChanged("IsSelected"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual ContextMenu GetContextMenu() |
|
|
|
|
{ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal protected void OnChildrenChanged(NotifyCollectionChangedEventArgs e) |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region OnChildrenChanged
|
|
|
|
|
internal void OnChildrenChanged(NotifyCollectionChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (e.OldItems != null) { |
|
|
|
|
foreach (SharpTreeNode node in e.OldItems) { |
|
|
|
|
Debug.Assert(node.modelParent == this); |
|
|
|
|
node.modelParent = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (e.NewItems != null) { |
|
|
|
|
foreach (SharpTreeNode node in e.NewItems) { |
|
|
|
|
Debug.Assert(node.modelParent == null); |
|
|
|
|
node.modelParent = this; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RaisePropertyChanged("ShowExpander"); |
|
|
|
|
RaiseIsLastChangedIfNeeded(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Expanding / LazyLoading
|
|
|
|
|
|
|
|
|
|
public event EventHandler Collapsing; |
|
|
|
|
|
|
|
|
|
public virtual object ExpandedIcon |
|
|
|
|
{ |
|
|
|
|
get { return Icon; } |
|
|
|
@ -108,11 +130,6 @@ namespace ICSharpCode.TreeView
@@ -108,11 +130,6 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
get { return Children.Count > 0 || LazyLoading; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//public virtual bool ShowLoading
|
|
|
|
|
//{
|
|
|
|
|
// get { return false; }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
bool isExpanded; |
|
|
|
|
|
|
|
|
|
public bool IsExpanded |
|
|
|
@ -125,11 +142,6 @@ namespace ICSharpCode.TreeView
@@ -125,11 +142,6 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
if (isExpanded) { |
|
|
|
|
EnsureLazyChildren(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
if (Collapsing != null) { |
|
|
|
|
Collapsing(this, EventArgs.Empty); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
RaisePropertyChanged("IsExpanded"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -178,40 +190,22 @@ namespace ICSharpCode.TreeView
@@ -178,40 +190,22 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
|
|
|
|
|
public IEnumerable<SharpTreeNode> Descendants() |
|
|
|
|
{ |
|
|
|
|
foreach (var child in Children) { |
|
|
|
|
foreach (var child2 in child.DescendantsAndSelf()) { |
|
|
|
|
yield return child2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return TreeTraversal.PreOrder(this.Children, n => n.Children); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IEnumerable<SharpTreeNode> DescendantsAndSelf() |
|
|
|
|
{ |
|
|
|
|
yield return this; |
|
|
|
|
foreach (var child in Descendants()) { |
|
|
|
|
yield return child; |
|
|
|
|
} |
|
|
|
|
return TreeTraversal.PreOrder(this, n => n.Children); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IEnumerable<SharpTreeNode> ExpandedDescendants() |
|
|
|
|
{ |
|
|
|
|
foreach (var child in Children) { |
|
|
|
|
foreach (var child2 in child.ExpandedDescendantsAndSelf()) { |
|
|
|
|
yield return child2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return TreeTraversal.PreOrder(this.Children, n => n.IsExpanded ? n.Children : null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IEnumerable<SharpTreeNode> ExpandedDescendantsAndSelf() |
|
|
|
|
{ |
|
|
|
|
yield return this; |
|
|
|
|
if (IsExpanded) { |
|
|
|
|
foreach (var child in Children) { |
|
|
|
|
foreach (var child2 in child.ExpandedDescendantsAndSelf()) { |
|
|
|
|
yield return child2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return TreeTraversal.PreOrder(this, n => n.IsExpanded ? n.Children : null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IEnumerable<SharpTreeNode> Ancestors() |
|
|
|
@ -268,18 +262,15 @@ namespace ICSharpCode.TreeView
@@ -268,18 +262,15 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
|
|
|
|
|
#region Checkboxes
|
|
|
|
|
|
|
|
|
|
public virtual bool IsCheckable |
|
|
|
|
{ |
|
|
|
|
public virtual bool IsCheckable { |
|
|
|
|
get { return false; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool? isChecked; |
|
|
|
|
|
|
|
|
|
public bool? IsChecked |
|
|
|
|
{ |
|
|
|
|
public bool? IsChecked { |
|
|
|
|
get { return isChecked; } |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
set { |
|
|
|
|
SetIsChecked(value, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -327,101 +318,101 @@ namespace ICSharpCode.TreeView
@@ -327,101 +318,101 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
#region Cut / Copy / Paste / Delete
|
|
|
|
|
|
|
|
|
|
public bool IsCut { get { return false; } } |
|
|
|
|
/* |
|
|
|
|
static List<SharpTreeNode> cuttedNodes = new List<SharpTreeNode>(); |
|
|
|
|
static IDataObject cuttedData; |
|
|
|
|
static EventHandler requerySuggestedHandler; // for weak event
|
|
|
|
|
|
|
|
|
|
static void StartCuttedDataWatcher() |
|
|
|
|
{ |
|
|
|
|
requerySuggestedHandler = new EventHandler(CommandManager_RequerySuggested); |
|
|
|
|
CommandManager.RequerySuggested += requerySuggestedHandler; |
|
|
|
|
} |
|
|
|
|
/* |
|
|
|
|
static List<SharpTreeNode> cuttedNodes = new List<SharpTreeNode>(); |
|
|
|
|
static IDataObject cuttedData; |
|
|
|
|
static EventHandler requerySuggestedHandler; // for weak event
|
|
|
|
|
|
|
|
|
|
static void CommandManager_RequerySuggested(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (cuttedData != null && !Clipboard.IsCurrent(cuttedData)) { |
|
|
|
|
ClearCuttedData(); |
|
|
|
|
static void StartCuttedDataWatcher() |
|
|
|
|
{ |
|
|
|
|
requerySuggestedHandler = new EventHandler(CommandManager_RequerySuggested); |
|
|
|
|
CommandManager.RequerySuggested += requerySuggestedHandler; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ClearCuttedData() |
|
|
|
|
{ |
|
|
|
|
foreach (var node in cuttedNodes) { |
|
|
|
|
node.IsCut = false; |
|
|
|
|
static void CommandManager_RequerySuggested(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (cuttedData != null && !Clipboard.IsCurrent(cuttedData)) { |
|
|
|
|
ClearCuttedData(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
cuttedNodes.Clear(); |
|
|
|
|
cuttedData = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//static public IEnumerable<SharpTreeNode> PurifyNodes(IEnumerable<SharpTreeNode> nodes)
|
|
|
|
|
//{
|
|
|
|
|
// var list = nodes.ToList();
|
|
|
|
|
// var array = list.ToArray();
|
|
|
|
|
// foreach (var node1 in array) {
|
|
|
|
|
// foreach (var node2 in array) {
|
|
|
|
|
// if (node1.Descendants().Contains(node2)) {
|
|
|
|
|
// list.Remove(node2);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return list;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
bool isCut; |
|
|
|
|
static void ClearCuttedData() |
|
|
|
|
{ |
|
|
|
|
foreach (var node in cuttedNodes) { |
|
|
|
|
node.IsCut = false; |
|
|
|
|
} |
|
|
|
|
cuttedNodes.Clear(); |
|
|
|
|
cuttedData = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool IsCut |
|
|
|
|
{ |
|
|
|
|
get { return isCut; } |
|
|
|
|
private set |
|
|
|
|
//static public IEnumerable<SharpTreeNode> PurifyNodes(IEnumerable<SharpTreeNode> nodes)
|
|
|
|
|
//{
|
|
|
|
|
// var list = nodes.ToList();
|
|
|
|
|
// var array = list.ToArray();
|
|
|
|
|
// foreach (var node1 in array) {
|
|
|
|
|
// foreach (var node2 in array) {
|
|
|
|
|
// if (node1.Descendants().Contains(node2)) {
|
|
|
|
|
// list.Remove(node2);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return list;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
bool isCut; |
|
|
|
|
|
|
|
|
|
public bool IsCut |
|
|
|
|
{ |
|
|
|
|
isCut = value; |
|
|
|
|
RaisePropertyChanged("IsCut"); |
|
|
|
|
get { return isCut; } |
|
|
|
|
private set |
|
|
|
|
{ |
|
|
|
|
isCut = value; |
|
|
|
|
RaisePropertyChanged("IsCut"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal bool InternalCanCut() |
|
|
|
|
{ |
|
|
|
|
return InternalCanCopy() && InternalCanDelete(); |
|
|
|
|
} |
|
|
|
|
internal bool InternalCanCut() |
|
|
|
|
{ |
|
|
|
|
return InternalCanCopy() && InternalCanDelete(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void InternalCut() |
|
|
|
|
{ |
|
|
|
|
ClearCuttedData(); |
|
|
|
|
cuttedData = Copy(ActiveNodesArray); |
|
|
|
|
Clipboard.SetDataObject(cuttedData); |
|
|
|
|
internal void InternalCut() |
|
|
|
|
{ |
|
|
|
|
ClearCuttedData(); |
|
|
|
|
cuttedData = Copy(ActiveNodesArray); |
|
|
|
|
Clipboard.SetDataObject(cuttedData); |
|
|
|
|
|
|
|
|
|
foreach (var node in ActiveNodes) { |
|
|
|
|
node.IsCut = true; |
|
|
|
|
cuttedNodes.Add(node); |
|
|
|
|
foreach (var node in ActiveNodes) { |
|
|
|
|
node.IsCut = true; |
|
|
|
|
cuttedNodes.Add(node); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal bool InternalCanCopy() |
|
|
|
|
{ |
|
|
|
|
return CanCopy(ActiveNodesArray); |
|
|
|
|
} |
|
|
|
|
internal bool InternalCanCopy() |
|
|
|
|
{ |
|
|
|
|
return CanCopy(ActiveNodesArray); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void InternalCopy() |
|
|
|
|
{ |
|
|
|
|
Clipboard.SetDataObject(Copy(ActiveNodesArray)); |
|
|
|
|
} |
|
|
|
|
internal void InternalCopy() |
|
|
|
|
{ |
|
|
|
|
Clipboard.SetDataObject(Copy(ActiveNodesArray)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal bool InternalCanPaste() |
|
|
|
|
{ |
|
|
|
|
return CanPaste(Clipboard.GetDataObject()); |
|
|
|
|
} |
|
|
|
|
internal bool InternalCanPaste() |
|
|
|
|
{ |
|
|
|
|
return CanPaste(Clipboard.GetDataObject()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void InternalPaste() |
|
|
|
|
{ |
|
|
|
|
Paste(Clipboard.GetDataObject()); |
|
|
|
|
internal void InternalPaste() |
|
|
|
|
{ |
|
|
|
|
Paste(Clipboard.GetDataObject()); |
|
|
|
|
|
|
|
|
|
if (cuttedData != null) { |
|
|
|
|
DeleteCore(cuttedNodes.ToArray()); |
|
|
|
|
ClearCuttedData(); |
|
|
|
|
if (cuttedData != null) { |
|
|
|
|
DeleteCore(cuttedNodes.ToArray()); |
|
|
|
|
ClearCuttedData(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
public virtual bool CanDelete() |
|
|
|
|
{ |
|
|
|
@ -444,118 +435,118 @@ namespace ICSharpCode.TreeView
@@ -444,118 +435,118 @@ namespace ICSharpCode.TreeView
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
public virtual bool CanCopy(SharpTreeNode[] nodes) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
public virtual bool CanCopy(SharpTreeNode[] nodes) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual bool CanPaste(IDataObject data) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
public virtual bool CanPaste(IDataObject data) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual void Paste(IDataObject data) |
|
|
|
|
{ |
|
|
|
|
EnsureLazyChildren(); |
|
|
|
|
Drop(data, Children.Count, DropEffect.Copy); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
public virtual void Paste(IDataObject data) |
|
|
|
|
{ |
|
|
|
|
EnsureLazyChildren(); |
|
|
|
|
Drop(data, Children.Count, DropEffect.Copy); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Drag and Drop
|
|
|
|
|
/* |
|
|
|
|
internal bool InternalCanDrag() |
|
|
|
|
{ |
|
|
|
|
return CanDrag(ActiveNodesArray); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal bool InternalCanDrag() |
|
|
|
|
{ |
|
|
|
|
return CanDrag(ActiveNodesArray); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void InternalDrag(DependencyObject dragSource) |
|
|
|
|
{ |
|
|
|
|
DragDrop.DoDragDrop(dragSource, Copy(ActiveNodesArray), DragDropEffects.All); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal bool InternalCanDrop(DragEventArgs e, int index) |
|
|
|
|
{ |
|
|
|
|
var finalEffect = GetFinalEffect(e, index); |
|
|
|
|
e.Effects = GetDragDropEffects(finalEffect); |
|
|
|
|
return finalEffect != DropEffect.None; |
|
|
|
|
} |
|
|
|
|
internal void InternalDrag(DependencyObject dragSource) |
|
|
|
|
{ |
|
|
|
|
DragDrop.DoDragDrop(dragSource, Copy(ActiveNodesArray), DragDropEffects.All); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal void InternalDrop(DragEventArgs e, int index) |
|
|
|
|
{ |
|
|
|
|
if (LazyLoading) { |
|
|
|
|
EnsureLazyChildren(); |
|
|
|
|
index = Children.Count; |
|
|
|
|
internal bool InternalCanDrop(DragEventArgs e, int index) |
|
|
|
|
{ |
|
|
|
|
var finalEffect = GetFinalEffect(e, index); |
|
|
|
|
e.Effects = GetDragDropEffects(finalEffect); |
|
|
|
|
return finalEffect != DropEffect.None; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var finalEffect = GetFinalEffect(e, index); |
|
|
|
|
Drop(e.Data, index, finalEffect); |
|
|
|
|
internal void InternalDrop(DragEventArgs e, int index) |
|
|
|
|
{ |
|
|
|
|
if (LazyLoading) { |
|
|
|
|
EnsureLazyChildren(); |
|
|
|
|
index = Children.Count; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var finalEffect = GetFinalEffect(e, index); |
|
|
|
|
Drop(e.Data, index, finalEffect); |
|
|
|
|
|
|
|
|
|
if (finalEffect == DropEffect.Move) { |
|
|
|
|
foreach (SharpTreeNode node in ActiveNodesArray) |
|
|
|
|
node.DeleteCore(); |
|
|
|
|
if (finalEffect == DropEffect.Move) { |
|
|
|
|
foreach (SharpTreeNode node in ActiveNodesArray) |
|
|
|
|
node.DeleteCore(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DropEffect GetFinalEffect(DragEventArgs e, int index) |
|
|
|
|
{ |
|
|
|
|
var requestedEffect = GetDropEffect(e); |
|
|
|
|
var result = CanDrop(e.Data, requestedEffect); |
|
|
|
|
if (result == DropEffect.Move) { |
|
|
|
|
if (!ActiveNodesArray.All(n => n.CanDelete())) { |
|
|
|
|
return DropEffect.None; |
|
|
|
|
DropEffect GetFinalEffect(DragEventArgs e, int index) |
|
|
|
|
{ |
|
|
|
|
var requestedEffect = GetDropEffect(e); |
|
|
|
|
var result = CanDrop(e.Data, requestedEffect); |
|
|
|
|
if (result == DropEffect.Move) { |
|
|
|
|
if (!ActiveNodesArray.All(n => n.CanDelete())) { |
|
|
|
|
return DropEffect.None; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static DropEffect GetDropEffect(DragEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (e.Data != null) { |
|
|
|
|
var all = DragDropKeyStates.ControlKey | DragDropKeyStates.ShiftKey | DragDropKeyStates.AltKey; |
|
|
|
|
static DropEffect GetDropEffect(DragEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (e.Data != null) { |
|
|
|
|
var all = DragDropKeyStates.ControlKey | DragDropKeyStates.ShiftKey | DragDropKeyStates.AltKey; |
|
|
|
|
|
|
|
|
|
if ((e.KeyStates & all) == DragDropKeyStates.ControlKey) { |
|
|
|
|
return DropEffect.Copy; |
|
|
|
|
} |
|
|
|
|
if ((e.KeyStates & all) == DragDropKeyStates.AltKey) { |
|
|
|
|
return DropEffect.Link; |
|
|
|
|
} |
|
|
|
|
if ((e.KeyStates & all) == (DragDropKeyStates.ControlKey | DragDropKeyStates.ShiftKey)) { |
|
|
|
|
return DropEffect.Link; |
|
|
|
|
if ((e.KeyStates & all) == DragDropKeyStates.ControlKey) { |
|
|
|
|
return DropEffect.Copy; |
|
|
|
|
} |
|
|
|
|
if ((e.KeyStates & all) == DragDropKeyStates.AltKey) { |
|
|
|
|
return DropEffect.Link; |
|
|
|
|
} |
|
|
|
|
if ((e.KeyStates & all) == (DragDropKeyStates.ControlKey | DragDropKeyStates.ShiftKey)) { |
|
|
|
|
return DropEffect.Link; |
|
|
|
|
} |
|
|
|
|
return DropEffect.Move; |
|
|
|
|
} |
|
|
|
|
return DropEffect.Move; |
|
|
|
|
return DropEffect.None; |
|
|
|
|
} |
|
|
|
|
return DropEffect.None; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static DragDropEffects GetDragDropEffects(DropEffect effect) |
|
|
|
|
{ |
|
|
|
|
switch (effect) { |
|
|
|
|
case DropEffect.Copy: |
|
|
|
|
return DragDropEffects.Copy; |
|
|
|
|
case DropEffect.Link: |
|
|
|
|
return DragDropEffects.Link; |
|
|
|
|
case DropEffect.Move: |
|
|
|
|
return DragDropEffects.Move; |
|
|
|
|
static DragDropEffects GetDragDropEffects(DropEffect effect) |
|
|
|
|
{ |
|
|
|
|
switch (effect) { |
|
|
|
|
case DropEffect.Copy: |
|
|
|
|
return DragDropEffects.Copy; |
|
|
|
|
case DropEffect.Link: |
|
|
|
|
return DragDropEffects.Link; |
|
|
|
|
case DropEffect.Move: |
|
|
|
|
return DragDropEffects.Move; |
|
|
|
|
} |
|
|
|
|
return DragDropEffects.None; |
|
|
|
|
} |
|
|
|
|
return DragDropEffects.None; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual bool CanDrag(SharpTreeNode[] nodes) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual DropEffect CanDrop(IDataObject data, DropEffect requestedEffect) |
|
|
|
|
{ |
|
|
|
|
return DropEffect.None; |
|
|
|
|
} |
|
|
|
|
public virtual bool CanDrag(SharpTreeNode[] nodes) |
|
|
|
|
{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual void Drop(IDataObject data, int index, DropEffect finalEffect) |
|
|
|
|
{ |
|
|
|
|
throw new NotSupportedException(GetType().Name + " does not support Drop()"); |
|
|
|
|
} |
|
|
|
|
public virtual DropEffect CanDrop(IDataObject data, DropEffect requestedEffect) |
|
|
|
|
{ |
|
|
|
|
return DropEffect.None; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual void Drop(IDataObject data, int index, DropEffect finalEffect) |
|
|
|
|
{ |
|
|
|
|
throw new NotSupportedException(GetType().Name + " does not support Drop()"); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IsLast (for TreeView lines)
|
|
|
|
|