예제 #1
0
			public void Dropped(IDropInfo dropInfo, DragDropEffects effects)
			{
				bool isCopy, isMove;
				GuiHelper.ConvertDragDropEffectToCopyMove(effects, out isCopy, out isMove);

				_projectBrowseControl._controller.FolderTree_DragEnded(isCopy, isMove);
			}
        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);
            }
        }
        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);
        }
        /// <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;
            }
              }
        }
 public virtual void DragOver(IDropInfo dropInfo)
 {
     if (CanAcceptData(dropInfo)) {
     dropInfo.Effects = DragDropEffects.Copy;
     dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
       }
 }
    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);
    }
예제 #7
0
        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;
        }
        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;
                }
            }
        }
        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);
            }
        }
 protected override void OnImported(IEnumerable<Track> tracks, IDropInfo dropInfo)
 {
     Track track = tracks.First();
     if (playCommand.CanExecute(track))
     {
         playCommand.Execute(track);
     }
 }
 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;
     }
 }
예제 #12
0
 //
 // 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
0
        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); 
                }
            }
        }
예제 #14
0
        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;
            }
        }
 public void DragOver(IDropInfo dropInfo)
 {
   // Call default DragOver method, cause most stuff should work by default
   GongSolutions.Wpf.DragDrop.DragDrop.DefaultDropHandler.DragOver(dropInfo);
   if (dropInfo.TargetGroup == null)
   {
     dropInfo.Effects = System.Windows.DragDropEffects.None;
   }
 }
예제 #16
0
			public void DragOver(IDropInfo dropInfo)
			{
				DragDropEffects resultingEffect;
				if (CanAcceptData(dropInfo, out resultingEffect))
				{
					dropInfo.Effects = resultingEffect;
					dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
				}
			}
            public override void Drop(IDropInfo dropInfo)
            {
                if (dropInfo.TargetCollection.Cast<object>().Contains(dropInfo.Data))
                {
                    return;
                }

                base.Drop(dropInfo);
            }
예제 #18
0
        public void Drop(IDropInfo dropInfo)
        {
            // TODO(Matthew) clean this up a bit
            DockTileDirection direction = DetermineDirectionDropped(dropInfo.VisualTarget.RenderSize, dropInfo.DropPosition);

            var data = dropInfo.Data;
            var target = (dropInfo.VisualTarget as FrameworkElement).DataContext;
            View.MoveTile(target, data, direction);
        }
 public override void Dropped(IDropInfo dropInfo)
 {
     var tc = dropInfo.TargetItem as TestCase;
     if (tc != null)
     {
         TestScenario scenario = tc.Scenario;
         scenario.Manager.EndChangeSetBatch();
     }
 }
예제 #20
0
        public void DragOver(IDropInfo dropInfo)
        {
            if (dropInfo.DragInfo.Data is CustomDataModel) {
            dropInfo.Effects = DragDropEffects.Copy;
            dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;

            // test for handled
            dropInfo.NotHandled = true; // now the DefaultDropHandler should work
              }
        }
        public void Drop(IDropInfo dropInfo)
        {
            if (!DropItemCommand.CanExecute(dropInfo))
            {
                //dropInfo.IsNotHandled = true;
                return;
            }

            DropItemCommand.Execute(dropInfo);
        }
예제 #22
0
        public void DragOver(IDropInfo dropInfo)
        {
            var item = dropInfo.Data as ReportLayoutItemViewModel;
            if (item == null) return;

            if (!_predicate(item)) return;

            dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
            dropInfo.Effects = DragDropEffects.Move;
        }
예제 #23
0
			public void Drop(IDropInfo dropInfo)
			{
				bool isCopy, isMove;
				_projectBrowseControl._controller.ListView_Drop(
					dropInfo.Data is System.Windows.IDataObject ? GuiHelper.ToAltaxo((System.Windows.IDataObject)dropInfo.Data) : dropInfo.Data,
					dropInfo.KeyStates.HasFlag(DragDropKeyStates.ControlKey),
					dropInfo.KeyStates.HasFlag(DragDropKeyStates.ShiftKey),
					out isCopy, out isMove);

				dropInfo.Effects = GuiHelper.ConvertCopyMoveToDragDropEffect(isCopy, isMove); // it is important to get back the resulting effect to dropInfo, because dropInfo informs the drag handler about the resulting effect, which can e.g. delete the items after a move operation
			}
예제 #24
0
        void IDropTarget.Drop(IDropInfo _dropInfo)
        {
            ListBox listBoxTarget, listBoxSource;
            listBoxTarget = (ListBox)_dropInfo.VisualTarget;
            listBoxSource = (ListBox)_dropInfo.DragInfo.VisualSource;

            if (listBoxTarget.Name == "ZoneTracklistControl")
                this.DropOnZoneTrackList(_dropInfo);
            if (listBoxTarget.Name == "PlaylistManagementListControl")
                this.DropOnPlaylistManagementList(_dropInfo);
        }
예제 #25
0
 public override void Drop(IDropInfo drop_info)
 {
     switch (current_drop)
     {
         case DropType.Default:
             base.Drop(drop_info);
             break;
         case DropType.PatternToCategory:
             HandlePatternToCategoryDrop(drop_info);
             break;
     }
 }
 protected static bool CanAcceptData(IDropInfo dropInfo)
 {
   if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection)
     return GetList(dropInfo.TargetCollection) != null;
   if (dropInfo.DragInfo.SourceCollection is ItemCollection)
     return false;
   
   if (!TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data))
     return false;
   
   return !IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem);
 }
예제 #27
0
 public new void Drop(IDropInfo dropInfo)
 {
     var game = dropInfo.TargetItem as ToSell;
     if (game != null)
     {
         game.PicturePaths.Clear();
         foreach (string file in ((DataObject)dropInfo.Data).GetFileDropList())
         {
             game.PicturePaths.Add(file);
         }
     }
 }
예제 #28
0
 void IDropTarget.DragOver(IDropInfo dropInfo)
 {
     if (((dropInfo.Data is PlayableBase || dropInfo.Data is IEnumerable<PlayableBase>) && dropInfo.TargetItem is IPlaylist && dropInfo.DragInfo.SourceCollection != MainViewModel.Instance.MusicManager.FavoritePlaylist.ViewSource))
     {
         dropInfo.DropTargetAdorner = typeof (DropTargetHighlightAdorner);
         dropInfo.Effects = DragDropEffects.Move;
     }
     else if (dropInfo.Data is NormalPlaylist)
     {
         dropInfo.DropTargetAdorner = typeof(DropTargetInsertionAdorner);
         dropInfo.Effects = DragDropEffects.Move;
     }
 }
예제 #29
0
			protected bool CanAcceptData(IDropInfo dropInfo, out System.Windows.DragDropEffects resultingEffect)
			{
				bool canCopy, canMove;
				_projectBrowseControl._controller.ListView_DropCanAcceptData(
					dropInfo.Data is System.Windows.IDataObject ? GuiHelper.ToAltaxo((System.Windows.IDataObject)dropInfo.Data) : dropInfo.Data,
					dropInfo.KeyStates.HasFlag(DragDropKeyStates.ControlKey),
					dropInfo.KeyStates.HasFlag(DragDropKeyStates.ShiftKey),
					out canCopy, out canMove);

				resultingEffect = GuiHelper.ConvertCopyMoveToDragDropEffect(canCopy, canMove);

				return canCopy | canMove;
			}
        public void DragOver(IDropInfo dropInfo)
        {
            Console.WriteLine("Dragging over surrounding area");

            if (!DropItemCommand.CanExecute(dropInfo))
            {
                //dropInfo.IsNotHandled = true;
                return;
            }

            dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
            dropInfo.Effects = DragDropEffects.Move;
        }
        public void Drop(IDropInfo dropInfo)
        {
            var draggedItem = (DraggableItemViewModel)dropInfo.Data;

            if (dropInfo.Effects == DragDropEffects.Move)
            {
                Item             = draggedItem.Item;
                draggedItem.Item = null;
            }
            else if (dropInfo.Effects == DragDropEffects.Copy)
            {
                Item = new Item(draggedItem.Item);
            }
            else if (dropInfo.Effects == DragDropEffects.Link)
            {
                // Link = Swap
                var item = draggedItem.Item;
                draggedItem.Item = Item;
                Item             = item;
            }
        }
예제 #32
0
        /// <summary>
        /// Updates the current drag state.
        /// </summary>
        /// <param name="dropInfo">
        ///  Information about the drag operation.
        /// </param>
        /// <remarks>
        /// To allow a drop at the current drag position, the <see cref="DropInfo.Effects"/> property on
        /// <paramref name="dropInfo"/> should be set to a value other than <see cref="DragDropEffects.None"/>
        /// and <see cref="DropInfo.Payload"/> should be set to a non-null value.
        /// </remarks>
        public void DragOver(IDropInfo dropInfo)
        {
            logger.Trace("drag over {0}", dropInfo.TargetItem);

            Tuple <DomainOfExpertise, Participant> tuple;

            this.Session.OpenIterations.TryGetValue(this.Thing, out tuple);

            if (tuple.Item1 == null)
            {
                dropInfo.Effects = DragDropEffects.None;
                return;
            }

            var droptarget = dropInfo.TargetItem as IDropTarget;

            if (droptarget != null)
            {
                droptarget.DragOver(dropInfo);
            }
        }
예제 #33
0
        //Handle Hovering Items
        public void DragOver(IDropInfo dropInfo)
        {
            Item   sourceItem = dropInfo.Data as Item;
            string target     = (dropInfo.VisualTarget as FrameworkElement).Name;
            string source     = (dropInfo.DragInfo.VisualSource as FrameworkElement).Name;

            if (target == "CommandBin")
            {
                dropInfo.Effects = DragDropEffects.Move;
            }
            else if (target == "CommandPanel" && source == "CommandSource")
            {
                dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                dropInfo.Effects           = DragDropEffects.Copy;
            }
            else if (target == "CommandPanel" && source == "CommandPanel")
            {
                dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                dropInfo.Effects           = DragDropEffects.Move;
            }
        }
        /// <summary>
        /// Performs the drop operation
        /// </summary>
        /// <param name="dropInfo">
        /// Information about the drop operation.
        /// </param>
        public async Task Drop(IDropInfo dropInfo)
        {
            // moving
            if (dropInfo.Payload is Parameter parameter)
            {
                await this.Drop(dropInfo, parameter);
            }

            // moving the group into this parameter's group
            if (dropInfo.Payload is ParameterGroup group && (dropInfo.Effects == DragDropEffects.Move))
            {
                await this.Drop(dropInfo, group);
            }

            if (dropInfo.Payload is RelationalExpression expression && this.ThingCreator.IsCreateBinaryRelationshipForRequirementVerificationAllowed(this.Thing, expression))
            {
                await this.Drop(this.Thing, expression);
            }

            dropInfo.Effects = DragDropEffects.None;
        }
예제 #35
0
 void IDropTarget.Drop(IDropInfo dropInfo)
 {
     if (dropInfo != null)
     {
         if (dropInfo.VisualTarget is FrameworkElement frameworkElement)
         {
             if (frameworkElement.Name == "CloudItemDataGrid" ||
                 frameworkElement.Name == "DragAndDropInfoTextTextBlock")
             {
                 if (dropInfo.Data is IFileRecordInfo recordInfo)
                 {
                     AddCloudEntry(recordInfo, null);
                 }
                 else if (dropInfo.Data is IEnumerable <IFileRecordInfo> recordInfos)
                 {
                     recordInfos.ForEach(info => AddCloudEntry(info, null));
                 }
             }
         }
     }
 }
예제 #36
0
        /// <summary>
        /// Updates the current drag state.
        /// </summary>
        /// <param name="dropInfo">
        ///  Information about the drag operation.
        /// </param>
        /// <remarks>
        /// To allow a drop at the current drag position, the <see cref="DropInfo.Effects"/> property on
        /// <paramref name="dropInfo"/> should be set to a value other than <see cref="DragDropEffects.None"/>
        /// and <see cref="DropInfo.Payload"/> should be set to a non-null value.
        /// </remarks>
        public void DragOver(IDropInfo dropInfo)
        {
            var rowPayload = dropInfo.Payload as Thing;

            if (rowPayload != null)
            {
                if (!this.ThingDiagramItems.OfType <NamedThingDiagramContentItem>().Select(x => x.Thing).Contains(rowPayload))
                {
                    dropInfo.Effects = DragDropEffects.Copy;
                    return;
                }
            }

            if (dropInfo.Payload is Tuple <ParameterType, MeasurementScale> tuplePayload)
            {
                dropInfo.Effects = DragDropEffects.Copy;
                return;
            }

            dropInfo.Effects = DragDropEffects.None;
        }
예제 #37
0
        /// <summary>
        /// Event handler for the <see cref="PreviewDragOver"/> event
        /// </summary>
        /// <param name="sender">the sender of the event</param>
        /// <param name="e">the <see cref="DragEventArgs"/> associated to the event</param>
        /// <remarks>
        /// Occurs when the input system reports an underlying drag event with this element as the potential drop target.
        /// </remarks>
        private void PreviewDragOver(object sender, DragEventArgs e)
        {
            this.dropInfo = new DropInfo(sender, e);

            var dropTarget = this.AssociatedObject.DataContext as IDropTarget;

            if (dropTarget != null)
            {
                dropTarget.DragOver(this.dropInfo);

                e.Effects = this.dropInfo.Effects;
                e.Handled = true;
            }

            var dependencyObject = sender as DependencyObject;

            if (dependencyObject != null)
            {
                this.Scroll(dependencyObject, e);
            }
        }
예제 #38
0
        /// <summary>
        /// Handle the drop of a <see cref="ElementDefinition"/>
        /// </summary>
        /// <param name="dropInfo">The <see cref="IDropInfo"/> containing the payload</param>
        /// <param name="elementDefinition">The <see cref="ElementDefinition"/></param>
        private async Task Drop(IDropInfo dropInfo, ElementDefinition elementDefinition)
        {
            if (this.ThingCreator == null)
            {
                this.ThingCreator = new ThingCreator();
            }

            try
            {
                var currentDomain = this.Session.QuerySelectedDomainOfExpertise(this.Thing.GetContainerOfType <Iteration>());
                if (elementDefinition.TopContainer == this.Thing.TopContainer)
                {
                    await this.ThingCreator.CreateElementUsage(this.Thing, elementDefinition, currentDomain, this.Session);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                this.ErrorMsg = ex.Message;
            }
        }
예제 #39
0
        private static void UpdateTargetDropAdorner(DependencyObject target, IDropInfo dropInfo)
        {
            UIElement adornedElement = target.GetVisualDescendent <ItemsPresenter>();

            if (dropInfo.DropTargetAdorner == null)
            {
                DropTargetAdorner = null;
            }
            else if (!dropInfo.DropTargetAdorner.IsInstanceOfType(DropTargetAdorner))
            {
                DropTargetAdorner = DropTargetAdorner.Create(dropInfo.DropTargetAdorner, adornedElement);
            }

            if (DropTargetAdorner == null)
            {
                return;
            }

            DropTargetAdorner.DropInfo = dropInfo;
            DropTargetAdorner.InvalidateVisual();
        }
예제 #40
0
        protected virtual int PrepareSourceList(IDropInfo dropInfo, object[] data, IList sourceList, IList destinationList)
        {
            var insertIndex = dropInfo.InsertIndex;

            if (!Equals(dropInfo.DragInfo.VisualSource, dropInfo.VisualTarget))
            {
                return(insertIndex);
            }

            foreach (var index in data.Select(sourceList.IndexOf).Where(index => index != -1))
            {
                sourceList.RemoveAt(index);

                if (Equals(sourceList, destinationList) && index < insertIndex)
                {
                    --insertIndex;
                }
            }

            return(insertIndex);
        }
예제 #41
0
 void IDropTarget.Drop(IDropInfo dropInfo)
 {
     if (dropInfo.Data is TECIOModule module)
     {
         bool foundModule = false;
         foreach (var item in IOModules)
         {
             if (item.Item == module)
             {
                 item.Quantity++;
                 foundModule = true;
                 break;
             }
         }
         if (!foundModule)
         {
             ControllerType.IOModules.Add(module);
             IOModules.Add(module);
         }
     }
 }
        /// <summary>
        /// Updates the current drag state.
        /// </summary>
        /// <param name="dropInfo">
        ///  Information about the drag operation.
        /// </param>
        /// <remarks>
        /// To allow a drop at the current drag position, the <see cref="DropInfo.Effects"/> property on
        /// <paramref name="dropInfo"/> should be set to a value other than <see cref="DragDropEffects.None"/>
        /// and <see cref="DropInfo.Payload"/> should be set to a non-null value.
        /// </remarks>
        public void DragOver(IDropInfo dropInfo)
        {
            try
            {
                logger.Trace("drag over {0}", dropInfo.TargetItem);
                var droptarget = dropInfo.TargetItem as IDropTarget;
                if (droptarget != null)
                {
                    droptarget.DragOver(dropInfo);
                    return;
                }

                dropInfo.Effects = DragDropEffects.None;
            }
            catch (Exception ex)
            {
                dropInfo.Effects = DragDropEffects.None;
                logger.Error(ex, "drag-over caused an error");
                throw;
            }
        }
        /// <summary>
        /// Performs the drop operation
        /// </summary>
        /// <param name="dropInfo">
        /// Information about the drop operation.
        /// </param>
        public async Task Drop(IDropInfo dropInfo)
        {
            var droptarget = dropInfo.TargetItem as IDropTarget;

            if (droptarget != null)
            {
                try
                {
                    this.IsBusy = true;
                    await droptarget.Drop(dropInfo);
                }
                catch (Exception ex)
                {
                    this.Feedback = ex.Message;
                }
                finally
                {
                    this.IsBusy = false;
                }
            }
        }
예제 #44
0
        public void Drop(IDropInfo dropInfo)
        {
            WartośćWewnętrznegoKlockaZwracającegoWartość docelowaKolekcja = (WartośćWewnętrznegoKlockaZwracającegoWartość)dropInfo.TargetCollection;
            KlocekZwracającyWartość upuszczanyKlocek = (KlocekZwracającyWartość)dropInfo.Data;

            upuszczanyKlocek.MiejsceUmieszczenia = docelowaKolekcja;
            upuszczanyKlocek.ZPrzybornika        = false;
            docelowaKolekcja[0] = upuszczanyKlocek;
            ManipulacjaKlockiemZwracającymWartość manipulacja = new ManipulacjaKlockiemZwracającymWartość(ManipulacjeKlockiem.Dodanie, upuszczanyKlocek)
            {
                Cel = docelowaKolekcja
            };
            WartośćWewnętrznegoKlockaZwracającegoWartość źródło = dropInfo.DragInfo.SourceCollection as WartośćWewnętrznegoKlockaZwracającegoWartość;

            if (źródło != null)
            {
                manipulacja.Źródło = źródło;
            }

            _metodaZachowującaStanAplikacji(manipulacja);
        }
예제 #45
0
 public void DragOver(IDropInfo dropInfo)
 {
     try
     {
         var data = dropInfo.Data as IDataObject;
         var path = (string[])data.GetData(DataFormats.FileDrop);
         var file = new FileInfo(path.First());
         if (Asset.GetAssetType(file.Extension) != Controller.TargetAssetType)
         {
             dropInfo.Effects = DragDropEffects.None;
         }
         else
         {
             dropInfo.Effects = DragDropEffects.Copy;
         }
     }
     catch
     {
         dropInfo.Effects = DragDropEffects.None;
     }
 }
예제 #46
0
        private async Task ReorderSelectedPlaylistTracksAsync(IDropInfo dropInfo)
        {
            var tracks = new List <TrackViewModel>();

            await Task.Run(() =>
            {
                try
                {
                    foreach (var item in dropInfo.TargetCollection)
                    {
                        tracks.Add(((KeyValuePair <string, TrackViewModel>)item).Value);
                    }
                }
                catch (Exception ex)
                {
                    LogClient.Error("Could not get the dropped tracks. Exception: {0}", ex.Message);
                }
            });

            await this.playlistService.SetPlaylistOrderAsync(tracks, this.SelectedPlaylistName);
        }
예제 #47
0
        private async Task AddDroppedFilesToHoveredPlaylist(IDropInfo dropInfo)
        {
            PlaylistViewModel     hoveredPlaylist = null;
            List <TrackViewModel> tracks          = null;

            try
            {
                hoveredPlaylist = (PlaylistViewModel)dropInfo.TargetItem;
                var filenames = base.GetDroppedFilenames(dropInfo);
                tracks = await this.fileService.ProcessFilesAsync(filenames);

                if (hoveredPlaylist != null && tracks != null)
                {
                    await this.playlistService.AddTracksToPlaylistAsync(tracks, hoveredPlaylist.Name);
                }
            }
            catch (Exception ex)
            {
                LogClient.Error("Could not add dropped files to hovered playlist. Exception: {0}", ex.Message);
            }
        }
예제 #48
0
        public override void Drop(IDropInfo dropInfo)
        {
            if (dropInfo?.DragInfo == null)
            {
                return;
            }

            var targetList = dropInfo.TargetCollection.TryGetList();

            var sourceIndex      = targetList.IndexOf(dropInfo.Data);
            var destinationIndex = dropInfo.InsertIndex;

            if (sourceIndex == destinationIndex)
            {
                return;
            }

            var subjectViewModel = (DrawOrderItemViewModel)dropInfo.Data;

            _editor.MoveSpriteNodeInFrontOfTarget(subjectViewModel.NodeId, destinationIndex);
        }
예제 #49
0
        public void DragOver(IDropInfo dropInfo)
        {
            if (dropInfo.Data is ResultListItem && dropInfo.TargetItem is PlaylistItem)
            {
                var sourceItem = dropInfo.Data as ResultListItem;
                var targetItem = dropInfo.TargetItem as PlaylistItem;

                if (sourceItem != null && targetItem != null)
                {
                    dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
                    dropInfo.Effects           = DragDropEffects.Copy;
                }
            }

            else if (dropInfo.Data is IEnumerable <ResultListItem> && dropInfo.TargetItem is PlaylistItem)
            {
                var sourceItem = dropInfo.Data as IEnumerable <ResultListItem>;
                var targetItem = dropInfo.TargetItem as PlaylistItem;

                if (sourceItem != null && targetItem != null)
                {
                    dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
                    dropInfo.Effects           = DragDropEffects.Copy;
                }
            }
            else if (dropInfo.Data is Rally && dropInfo.TargetItem is PlaylistItem)
            {
                dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
                dropInfo.Effects           = DragDropEffects.Copy;
            }
            else if (dropInfo.TargetItem is PlaylistItem)
            {
                Rally data = ((DataObject)dropInfo.Data).GetData(typeof(Rally)) as Rally;
                if (data != null)
                {
                    dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
                    dropInfo.Effects           = DragDropEffects.Copy;
                }
            }
        }
예제 #50
0
        private async Task AddDroppedTracksToHoveredPlaylist(IDropInfo dropInfo)
        {
            if ((dropInfo.Data is KeyValuePair <string, TrackViewModel> | dropInfo.Data is List <KeyValuePair <string, TrackViewModel> >) &&
                dropInfo.TargetItem is PlaylistViewModel)
            {
                try
                {
                    string hoveredPlaylistName = ((PlaylistViewModel)dropInfo.TargetItem).Name;

                    if (hoveredPlaylistName.Equals(this.SelectedPlaylistName))
                    {
                        return;                                                        // Don't add tracks to the same playlist
                    }
                    var tracks = new List <PlayableTrack>();

                    await Task.Run(() =>
                    {
                        if (dropInfo.Data is KeyValuePair <string, TrackViewModel> )
                        {
                            // We dropped a single track
                            tracks.Add(((KeyValuePair <string, TrackViewModel>)dropInfo.Data).Value.Track);
                        }
                        else if (dropInfo.Data is List <KeyValuePair <string, TrackViewModel> > )
                        {
                            // We dropped multiple tracks
                            foreach (KeyValuePair <string, TrackViewModel> pair in (List <KeyValuePair <string, TrackViewModel> >)dropInfo.Data)
                            {
                                tracks.Add(pair.Value.Track);
                            }
                        }
                    });

                    await this.playlistService.AddTracksToPlaylistAsync(tracks, hoveredPlaylistName);
                }
                catch (Exception ex)
                {
                    CoreLogger.Current.Error("Could not add dropped tracks to hovered playlist. Exception: {0}", ex.Message);
                }
            }
        }
예제 #51
0
        public void Drop(IDropInfo dropInfo)
        {
            var  draggedModel         = dropInfo.Data as TemplateTreeItemViewModel;
            bool isStringDraggedModel = dropInfo.Data is string;

            if (draggedModel == null && !isStringDraggedModel)
            {
                return;
            }
            if (!isStringDraggedModel && draggedModel.Template == null)
            {
                return;
            }

            if (dropInfo.Data is string)
            {
                string dragText = dropInfo.Data as string;

                if (dragText == VariablesEditor.ExpressionEditorText)
                {
                    ExecuteExpressionCommand();
                    dragText = string.Empty;
                }
                else
                {
                    if (!this.CaretInExpression)
                    {
                        dragText = SqlStringHandler.CreateSqlExpression(dragText);
                    }
                    var editor     = dropInfo.VisualTarget as TextEditor;
                    var caretIndex = editor.CaretOffset;
                    editor.Text        = editor.Text.Insert(caretIndex, dragText);
                    editor.CaretOffset = caretIndex + dragText.Length;
                }
            }
            else
            {
                InsertTemplate(draggedModel.Template);
            }
        }
예제 #52
0
        /// <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?.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.TargetCollection is null)
            {
                return(false);
            }

            if (ReferenceEquals(dropInfo.DragInfo.SourceCollection, dropInfo.TargetCollection))
            {
                var targetList = dropInfo.TargetCollection.TryGetList();
                return(targetList != null);
            }

            if (TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data))
            {
                var isChildOf = IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem);
                return(!isChildOf);
            }

            return(false);
        }
        public void Drop(IDropInfo dropInfo)
        {
            var l = dropInfo.TargetCollection.TryGetList();

            if (l.Cast <Cooldown>().Any(cd =>
            {
                var ret = dropInfo.Data switch
                {
                    Skill s => (cd.Skill.IconName == s.IconName),
                    Item i => (cd.Skill.IconName == i.IconName),
                    Abnormality a => (cd.Skill.IconName == a.IconName),
                    _ => false
                };

                return(ret);
            }))
            {
                return;
            }

            switch (dropInfo.Data)
            {
            case Skill s:
                l.Add(new Cooldown(s, false));
                break;

            case Item i:
                Game.DB !.ItemsDatabase.TryGetItemSkill(i.Id, out var itemSkill);
                l.Add(new Cooldown(itemSkill, false, CooldownType.Item));
                break;

            case Abnormality a:
                l.Add(new Cooldown(new Skill(a.Id, Class.None, a.Name, a.ToolTip)
                {
                    IconName = a.IconName
                }, false, CooldownType.Passive));
                break;
            }
            //dropInfo.DragInfo.SourceCollection.TryGetList().Remove(dropInfo.Data);
        }
예제 #54
0
        /// <summary>
        /// Updates the current drag state.
        /// </summary>
        /// <param name="dropInfo">
        ///  Information about the drag operation.
        /// </param>
        /// <remarks>
        /// To allow a drop at the current drag position, the <see cref="DropInfo.Effects"/> property on
        /// <paramref name="dropInfo"/> should be set to a value other than <see cref="DragDropEffects.None"/>
        /// and <see cref="DropInfo.Payload"/> should be set to a non-null value.
        /// </remarks>
        public void DragOver(IDropInfo dropInfo)
        {
            try
            {
                logger.Trace("drag over {0}", dropInfo.TargetItem);
                var droptarget = dropInfo.TargetItem as IDropTarget;
                if (droptarget != null)
                {
                    droptarget.DragOver(dropInfo);
                    return;
                }

                var elementDefinition = dropInfo.Payload as ElementDefinition;
                if (elementDefinition != null)
                {
                    if (elementDefinition.Iid == Guid.Empty)
                    {
                        logger.Debug("Copying an Element Definition that has been created as template - iid is the empty guid");

                        dropInfo.Effects = DragDropEffects.Move;
                        return;
                    }
                    else
                    {
                        dropInfo.Effects = elementDefinition.TopContainer == this.Thing.TopContainer
                            ? DragDropEffects.None
                            : DragDropEffects.Copy;
                        return;
                    }
                }

                dropInfo.Effects = DragDropEffects.None;
            }
            catch (Exception ex)
            {
                dropInfo.Effects = DragDropEffects.None;
                logger.Error(ex, "drag-over caused an error");
                throw;
            }
        }
        private async Task AddDroppedTracksToHoveredPlaylist(IDropInfo dropInfo)
        {
            if ((dropInfo.Data is TrackViewModel | dropInfo.Data is IList <TrackViewModel>) &&
                dropInfo.TargetItem is PlaylistViewModel)
            {
                try
                {
                    string hoveredPlaylistName = ((PlaylistViewModel)dropInfo.TargetItem).Name;

                    if (hoveredPlaylistName.Equals(this.SelectedPlaylistName))
                    {
                        return;                                                        // Don't add tracks to the same playlist
                    }
                    var tracks = new List <TrackViewModel>();

                    await Task.Run(() =>
                    {
                        if (dropInfo.Data is TrackViewModel)
                        {
                            // We dropped a single track
                            tracks.Add((TrackViewModel)dropInfo.Data);
                        }
                        else if (dropInfo.Data is IList <TrackViewModel> )
                        {
                            // We dropped multiple tracks
                            foreach (TrackViewModel track in (IList <TrackViewModel>)dropInfo.Data)
                            {
                                tracks.Add(track);
                            }
                        }
                    });

                    await this.playlistService.AddTracksToPlaylistAsync(tracks, hoveredPlaylistName);
                }
                catch (Exception ex)
                {
                    LogClient.Error("Could not add dropped tracks to hovered playlist. Exception: {0}", ex.Message);
                }
            }
        }
예제 #56
0
        protected static int GetInsertIndex(IDropInfo dropInfo)
        {
            var insertIndex = dropInfo.UnfilteredInsertIndex;

            if (dropInfo.VisualTarget is ItemsControl itemsControl)
            {
                if (itemsControl.Items is IEditableCollectionView editableItems)
                {
                    var newItemPlaceholderPosition = editableItems.NewItemPlaceholderPosition;
                    if (newItemPlaceholderPosition == NewItemPlaceholderPosition.AtBeginning && insertIndex == 0)
                    {
                        ++insertIndex;
                    }
                    else if (newItemPlaceholderPosition == NewItemPlaceholderPosition.AtEnd && insertIndex == itemsControl.Items.Count)
                    {
                        --insertIndex;
                    }
                }
            }

            return(insertIndex);
        }
예제 #57
0
        public void DragOver_DataIsASingleSoundAndTargetCollectionContainsSoundAndIsReadOnly_SetsEffectsToNone()
        {
            //Arrange
            Target = CreateTarget();

            ISound droppedSound = CommonStubsFactory.StubClonableSoundWithRandomName();
            ReadOnlyObservableCollection <ISound> targetCollection =
                new ReadOnlyObservableCollection <ISound>(new ObservableCollection <ISound>
            {
                droppedSound
            });
            IDropInfo dropInfo = MockRepository.GenerateStub <IDropInfo>();

            dropInfo.Stub(info => info.TargetCollection).Return(targetCollection);
            dropInfo.Stub(info => info.Data).Return(droppedSound);

            //Act
            Target.DragOver(dropInfo);

            //Assert
            dropInfo.Effects.ShouldBeEquivalentTo(DragDropEffects.None);
        }
        /// <summary>
        /// Updates the current drag state.
        /// </summary>
        /// <param name="dropInfo">
        ///  Information about the drag operation.
        /// </param>
        /// <remarks>
        /// To allow a drop at the current drag position, the <see cref="DropInfo.Effects"/> property on
        /// <paramref name="dropInfo"/> should be set to a value other than <see cref="DragDropEffects.None"/>
        /// and <see cref="DropInfo.Payload"/> should be set to a non-null value.
        /// </remarks>
        public void DragOver(IDropInfo dropInfo)
        {
            var termPayload = dropInfo.Payload as Term;
            var canDropTerm = this.PermissionService.CanWrite(ClassKind.Term, this.Thing);

            if (termPayload == null || !canDropTerm)
            {
                dropInfo.Effects = DragDropEffects.None;
                return;
            }

            // if container is the same
            if (termPayload.Container == this.Thing.Container)
            {
                dropInfo.Effects = DragDropEffects.None;
                return;
            }

            if (termPayload.IDalUri.ToString() == this.Session.DataSourceUri)
            {
                // Move only possible within the glossary of the same chain of rdl
                var payloadRdl      = (ReferenceDataLibrary)termPayload.GetContainerOfType(typeof(ReferenceDataLibrary));
                var possibleNewRdls = payloadRdl.GetRequiredRdls().ToList();
                possibleNewRdls.Add(payloadRdl);

                var currentRdl = this.Thing.GetContainerOfType(typeof(ReferenceDataLibrary));
                if (!possibleNewRdls.Contains(currentRdl))
                {
                    dropInfo.Effects = DragDropEffects.None;
                    return;
                }

                dropInfo.Effects = DragDropEffects.Move;
                return;
            }

            // different data-source
            dropInfo.Effects = DragDropEffects.Copy;
        }
예제 #59
0
        /// <summary>
        /// Updates the current drag state.
        /// </summary>
        /// <param name="dropInfo">
        ///  Information about the drag operation.
        /// </param>
        /// <remarks>
        /// To allow a drop at the current drag position, the <see cref="DropInfo.Effects"/> property on
        /// <paramref name="dropInfo"/> should be set to a value other than <see cref="DragDropEffects.None"/>
        /// and <see cref="DropInfo.Payload"/> should be set to a non-null value.
        /// </remarks>
        public void DragOver(IDropInfo dropInfo)
        {
            // moving the paramenter into a group of the same element definition
            var parameter = dropInfo.Payload as Parameter;

            if (parameter != null)
            {
                this.DragOver(dropInfo, parameter);
                return;
            }

            // moving the group into a group of the same element definition
            var group = dropInfo.Payload as ParameterGroup;

            if (group != null && group.Container == this.Thing.Container)
            {
                this.DragOver(dropInfo, group);
                return;
            }

            dropInfo.Effects = DragDropEffects.None;
        }
예제 #60
0
        public void DragOver(IDropInfo dropInfo)
        {
            var source = dropInfo.Data as LayerModel;
            var target = dropInfo.TargetItem as LayerModel;

            if (source == null || target == null || source == target)
            {
                return;
            }

            if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
                target.LayerType is FolderType)
            {
                dropInfo.DropTargetAdorner = typeof(DropTargetMetroHighlightAdorner);
                dropInfo.Effects           = DragDropEffects.Copy;
            }
            else
            {
                dropInfo.DropTargetAdorner = typeof(DropTargetMetroInsertionAdorner);
                dropInfo.Effects           = DragDropEffects.Move;
            }
        }