Ejemplo n.º 1
0
 private void removeAdorner()
 {
     if (adorner != null)
     {
         AdornerLayer.GetAdornerLayer(adorner).Remove(adorner);
         adorner = null;
     }
 }
Ejemplo n.º 2
0
        private void ShowAdorner(UIElement element, bool fullBorder = false)
        {
            AdornerLayer aLayer = AdornerLayer.GetAdornerLayer(element);

            removeAdorner();
            adorner = new DropAdorner(element, fullBorder);
            adorner.IsHitTestVisible = false;
            aLayer.Add(adorner);
        }
Ejemplo n.º 3
0
 private void DeckDragEnter(object sender, DragEventArgs e)
 {
     if (!e.Data.GetDataPresent("Card"))
     {
         e.Effects = DragDropEffects.None;
     }
     else
     {
         if (e.Effects == DragDropEffects.Copy)
         {
             Expander          exp         = FindAncestor <Expander>(sender as FrameworkElement);
             ObservableSection dropSection = (ObservableSection)((FrameworkElement)exp).DataContext;
             var dragCard = e.Data.GetData("Card") as IMultiCard;
             var element  = dropSection.Cards.FirstOrDefault(c => c.Id == dragCard.Id);
             if (element == null) //i.e. card is not found
             {
                 e.Effects = DragDropEffects.All;
             }
         }
         if (e.Effects == DragDropEffects.All)
         {
             DataGridRow row  = FindAncestor <DataGridRow>(e.OriginalSource as FrameworkElement);
             DataGrid    grid = (DataGrid)FindAncestor <Expander>(e.OriginalSource as FrameworkElement).Content;
             if (row != null)
             {
                 AdornerLayer aLayer = AdornerLayer.GetAdornerLayer(row);
                 removeAdorner();
                 adorner = new DropAdorner(row);
                 adorner.IsHitTestVisible = false;
                 aLayer.Add(adorner);
             }
             else
             {
                 removeAdorner();
                 if (grid != null)
                 {
                     AdornerLayer aLayer = AdornerLayer.GetAdornerLayer(grid);
                     adorner = new DropAdorner(grid, true);
                     adorner.IsHitTestVisible = false;
                     aLayer.Add(adorner);
                 }
             }
         }
     }
 }