本文整理汇总了C#中IDropInfo类的典型用法代码示例。如果您正苦于以下问题:C# IDropInfo类的具体用法?C# IDropInfo怎么用?C# IDropInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDropInfo类属于命名空间,在下文中一共展示了IDropInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Drop
public virtual void Drop(IDropInfo dropInfo)
{
int insertIndex = dropInfo.InsertIndex;
IList destinationList = GetList(dropInfo.TargetCollection);
IEnumerable data = ExtractData(dropInfo.Data);
if (dropInfo.DragInfo.VisualSource == dropInfo.VisualTarget)
{
IList sourceList = GetList(dropInfo.DragInfo.SourceCollection);
foreach (object o in data)
{
int index = sourceList.IndexOf(o);
if (index == -1)
continue;
sourceList.RemoveAt(index);
if (sourceList == destinationList && index < insertIndex)
--insertIndex;
}
}
foreach (object o in data)
destinationList.Insert(insertIndex++, o);
}
示例2: Drop
public void Drop(IDropInfo dropInfo)
{
var insertIndex = dropInfo.InsertIndex;
MediaItemViewModel[] mediaItemViewModels = { dropInfo.Data as MediaItemViewModel };
var destinationList = _trackViewModel.Track.MediaItems;
var sourceList = mediaItemViewModels.First().TrackViewModel.Track.MediaItems;
foreach (var index in mediaItemViewModels.Select(o => sourceList.IndexOf(o.MediaItem)).Where(index => index != -1))
{
sourceList.RemoveAt(index);
if (sourceList == destinationList && index < insertIndex)
{
--insertIndex;
}
}
foreach (var o in mediaItemViewModels)
{
if (insertIndex < destinationList.Count)
destinationList.Insert(insertIndex++, o.MediaItem);
else
destinationList.Add(o.MediaItem);
}
}
示例3: Dropped
public void Dropped(IDropInfo dropInfo, DragDropEffects effects)
{
bool isCopy, isMove;
GuiHelper.ConvertDragDropEffectToCopyMove(effects, out isCopy, out isMove);
_projectBrowseControl._controller.FolderTree_DragEnded(isCopy, isMove);
}
示例4: DragOverPlaylistManagementList
protected void DragOverPlaylistManagementList(IDropInfo _dropInfo)
{
MediaItem mediaItem = (MediaItem)_dropInfo.DragInfo.SourceItem;
ListBox listBoxTarget, listBoxSource;
PlaylistObjectMediaList playlistList = this.currentPlaylistManagementList();
listBoxTarget = (ListBox)_dropInfo.VisualTarget;
listBoxSource = (ListBox)_dropInfo.DragInfo.VisualSource;
if (playlistList == null || !mediaItem.isAllowedToDropOnTrackList() || !playlistList.isEditable)
{
_dropInfo.Effects = System.Windows.DragDropEffects.None;
return;
}
this.savePlaylistManagementListPosition();
listBoxTarget = (ListBox)_dropInfo.VisualTarget;
listBoxSource = (ListBox)_dropInfo.DragInfo.VisualSource;
if (listBoxTarget.Name == listBoxSource.Name)
_dropInfo.Effects = System.Windows.DragDropEffects.Move;
else
_dropInfo.Effects = System.Windows.DragDropEffects.Copy;
}
示例5: DragOver
public virtual void DragOver(IDropInfo dropInfo)
{
if (CanAcceptData(dropInfo)) {
dropInfo.Effects = DragDropEffects.Copy;
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
}
}
示例6: CanAcceptData
public static bool CanAcceptData(IDropInfo dropInfo)
{
if (dropInfo == null || dropInfo.DragInfo == null)
{
return false;
}
if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection)
{
return GetList(dropInfo.TargetCollection) != null;
}
else if (dropInfo.DragInfo.SourceCollection is ItemCollection)
{
return false;
}
else
{
if (TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data))
{
return !IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem);
}
else
{
return false;
}
}
}
示例7: Drop
public virtual void Drop(IDropInfo dropInfo)
{
var insertIndex = dropInfo.InsertIndex;
var destinationList = GetList(dropInfo.TargetCollection);
var data = ExtractData(dropInfo.Data);
if (dropInfo.DragInfo.VisualSource == dropInfo.VisualTarget)
{
var sourceList = GetList(dropInfo.DragInfo.SourceCollection);
foreach (var o in data)
{
var index = sourceList.IndexOf(o);
if (index != -1)
{
sourceList.RemoveAt(index);
if (sourceList == destinationList && index < insertIndex)
{
--insertIndex;
}
}
}
}
foreach (var o in data)
{
destinationList.Insert(insertIndex++, o);
}
}
示例8: NotSupportedException
void IDropTarget.Drop(IDropInfo dropInfo)
{
var target = dropInfo.TargetItem as IExpressionTreeNode;
if (target == null)
return;
var source = dropInfo.Data as IExpressionTreeNode;
if (source == null)
return;
if (source is PredicateNode && target is PredicateNode)
{
Tree.InjectInto(source, target);
}
else
{
throw new NotSupportedException();
}
// todo: do this as XamlVirutalizingCollection
var ft = new ExpressionTreeTraversingCollection();
ft.UpdateRoot(Tree.Root);
FlattenedTree = ft;
//FlattenedTree.UpdateRoot(Tree.Root);
}
示例9: CanAcceptData
/// <summary>
/// Test the specified drop information for the right data.
/// </summary>
/// <param name="dropInfo">The drop information.</param>
public static bool CanAcceptData(IDropInfo dropInfo)
{
if (dropInfo == null || dropInfo.DragInfo == null) {
return false;
}
if (!dropInfo.IsSameDragDropContextAsSource) {
return false;
}
// do not drop on itself
var isTreeViewItem = dropInfo.InsertPosition.HasFlag(RelativeInsertPosition.TargetItemCenter)
&& dropInfo.VisualTargetItem is TreeViewItem;
if (isTreeViewItem && dropInfo.VisualTargetItem == dropInfo.DragInfo.VisualSourceItem) {
return false;
}
if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection) {
var targetList = dropInfo.TargetCollection.TryGetList();
return targetList != null;
}
// else if (dropInfo.DragInfo.SourceCollection is ItemCollection) {
// return false;
// }
else if (dropInfo.TargetCollection == null) {
return false;
} else {
if (TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data)) {
var isChildOf = IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem);
return !isChildOf;
} else {
return false;
}
}
}
示例10: DragOver
public void DragOver(IDropInfo dropInfo)
{
if (dropInfo.Data is IList<MediaItemViewModel> || dropInfo.Data is MediaItemViewModel)
{
dropInfo.Effects = DragDropEffects.Copy | DragDropEffects.Move;
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
}
}
示例11: OnImported
protected override void OnImported(IEnumerable<Track> tracks, IDropInfo dropInfo)
{
Track track = tracks.First();
if (playCommand.CanExecute(track))
{
playCommand.Execute(track);
}
}
示例12:
//
// The drop handler is only used for the grouping example.
//
void IDropTarget.DragOver(IDropInfo dropInfo)
{
DragDrop.DefaultDropHandler.DragOver(dropInfo);
if (dropInfo.TargetGroup == null)
{
dropInfo.Effects = System.Windows.DragDropEffects.None;
}
}
示例13: DragOver
public void DragOver(IDropInfo dropInfo)
{
if (this.IsFileDropInfo(dropInfo))
{
dropInfo.Effects = DragDropEffects.Link;
return;
}
ITreeItem source = dropInfo.Data as ITreeItem;
ITreeItem target = dropInfo.TargetItem as ITreeItem;
if (source == null
|| target == null
|| source == target)
{
return;
}
// Cannot drag if the source's parent is read only
if (source.Parent != null && (source.Parent.IsReadOnly || !source.IsEnabled))
{
return;
}
// Ensure the source isn't a parent to the target
ITreeItem node = target.Parent;
while (node != null)
{
if (node == source)
{
return;
}
node = node.Parent;
}
// Determine the action to perform
switch (dropInfo.InsertPosition)
{
// Handle dropping directly onto a node
case RelativeInsertPosition.TargetItemCenter:
if (!target.IsReadOnly && target.IsEnabled)
{
dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
dropInfo.Effects = DragDropEffects.Move;
}
break;
// Insertion cases
default:
if (target.Parent == null || (!target.Parent.IsReadOnly && target.IsEnabled))
{
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
dropInfo.Effects = DragDropEffects.Move;
}
break;
}
}
示例14: Drop
public void Drop(IDropInfo dropInfo)
{
var collection = (ObservableCollection<PlayableBase>)((ICollectionView)dropInfo.TargetCollection).SourceCollection;
if (dropInfo.Data is PlayableBase)
{
var track = (PlayableBase)dropInfo.Data;
int newIndex;
var currentIndex = dropInfo.DragInfo.SourceIndex;
if (dropInfo.InsertIndex > collection.Count - 1)
{
newIndex = collection.Count - 1;
}
else
{
newIndex = dropInfo.InsertIndex;
if (newIndex > 0 && newIndex > currentIndex) newIndex--;
}
if (currentIndex == newIndex) return;
collection.Move(currentIndex, newIndex);
MainViewModel.Instance.MusicManager.SelectedTrack = collection[newIndex];
}
else if (dropInfo.Data is IEnumerable<PlayableBase>)
{
var tracks = ((IEnumerable<PlayableBase>)dropInfo.Data).OrderBy(x => collection.IndexOf(x)).ToList();
int index;
if (dropInfo.InsertIndex >= collection.Count)
{
index = collection.Count - 1;
}
else
{
index = dropInfo.InsertIndex;
if (collection.IndexOf(tracks.Last()) < index)
{
index--;
}
}
if (tracks.Any(track => collection.IndexOf(track) == index))
{
return;
}
if (index < collection.IndexOf(tracks[0]))
{
tracks.Reverse();
}
foreach (var track in tracks)
{
collection.Move(collection.IndexOf(track), index);
}
}
}
示例15: Drop
public override void Drop(IDropInfo dropInfo)
{
if (dropInfo.TargetCollection.Cast<object>().Contains(dropInfo.Data))
{
return;
}
base.Drop(dropInfo);
}