示例#1
0
        void ShowPreview(SharpTreeViewItem item, DropPlace place)
        {
            previewNodeView = item.NodeView;
            previewPlace    = place;

            if (place == DropPlace.Inside)
            {
                previewNodeView.TextBackground = SystemColors.HighlightBrush;
                previewNodeView.Foreground     = SystemColors.HighlightTextBrush;
            }
            else
            {
                if (insertMarker == null)
                {
                    var adornerLayer = AdornerLayer.GetAdornerLayer(this);
                    var adorner      = new GeneralAdorner(this);
                    insertMarker  = new InsertMarker();
                    adorner.Child = insertMarker;
                    adornerLayer.Add(adorner);
                }

                insertMarker.Visibility = Visibility.Visible;

                var p1 = previewNodeView.TransformToVisual(this).Transform(new Point());
                var p  = new Point(p1.X + previewNodeView.CalculateIndent() + 4.5, p1.Y - 3);

                if (place == DropPlace.After)
                {
                    p.Y += previewNodeView.ActualHeight;
                }

                insertMarker.Margin = new Thickness(p.X, p.Y, 0, 0);

                SharpTreeNodeView secondNodeView = null;
                var index = flattener.IndexOf(item.Node);

                if (place == DropPlace.Before)
                {
                    if (index > 0)
                    {
                        secondNodeView = (ItemContainerGenerator.ContainerFromIndex(index - 1) as SharpTreeViewItem).NodeView;
                    }
                }
                else if (index + 1 < flattener.Count)
                {
                    secondNodeView = (ItemContainerGenerator.ContainerFromIndex(index + 1) as SharpTreeViewItem).NodeView;
                }

                var w = p1.X + previewNodeView.ActualWidth - p.X;

                if (secondNodeView != null)
                {
                    var p2 = secondNodeView.TransformToVisual(this).Transform(new Point());
                    w = Math.Max(w, p2.X + secondNodeView.ActualWidth - p.X);
                }

                insertMarker.Width = w + 10;
            }
        }
示例#2
0
 void HidePreview()
 {
     if (previewNodeView != null)
     {
         previewNodeView.ClearValue(SharpTreeNodeView.TextBackgroundProperty);
         previewNodeView.ClearValue(SharpTreeNodeView.ForegroundProperty);
         if (insertMarker != null)
         {
             insertMarker.Visibility = Visibility.Collapsed;
         }
         previewNodeView = null;
     }
 }
 void HidePreview()
 {
     if (previewNodeView != null)
     {
         previewNodeView.ClearValue(SharpTreeNodeView.TextBackgroundProperty);
         //previewNodeView.ClearValue(SharpTreeNodeView.ForegroundProperty);
         if (insertMarker != null)
         {
             insertMarker.IsVisible = false;
         }
         previewNodeView = null;
     }
 }
示例#4
0
        void ShowPreview(SharpTreeViewItem item, DropPlace place)
        {
            previewNodeView = item.NodeView;
            previewPlace = place;

            if (place == DropPlace.Inside) {
                previewNodeView.TextBackground = SystemColors.HighlightBrush;
                previewNodeView.Foreground = SystemColors.HighlightTextBrush;
            }
            else {
                if (insertMarker == null) {
                    var adornerLayer = AdornerLayer.GetAdornerLayer(this);
                    var adorner = new GeneralAdorner(this);
                    insertMarker = new InsertMarker();
                    adorner.Child = insertMarker;
                    adornerLayer.Add(adorner);
                }

                insertMarker.Visibility = Visibility.Visible;

                var p1 = previewNodeView.TransformToVisual(this).Transform(new Point());
                var p = new Point(p1.X + previewNodeView.CalculateIndent() + 4.5, p1.Y - 3);

                if (place == DropPlace.After) {
                    p.Y += previewNodeView.ActualHeight;
                }

                insertMarker.Margin = new Thickness(p.X, p.Y, 0, 0);

                SharpTreeNodeView secondNodeView = null;
                var index = flattener.IndexOf(item.Node);

                if (place == DropPlace.Before) {
                    if (index > 0) {
                        secondNodeView = (ItemContainerGenerator.ContainerFromIndex(index - 1) as SharpTreeViewItem).NodeView;
                    }
                }
                else if (index + 1 < flattener.Count) {
                    secondNodeView = (ItemContainerGenerator.ContainerFromIndex(index + 1) as SharpTreeViewItem).NodeView;
                }

                var w = p1.X + previewNodeView.ActualWidth - p.X;

                if (secondNodeView != null) {
                    var p2 = secondNodeView.TransformToVisual(this).Transform(new Point());
                    w = Math.Max(w, p2.X + secondNodeView.ActualWidth - p.X);
                }

                insertMarker.Width = w + 10;
            }
        }
示例#5
0
 void HidePreview()
 {
     if (previewNodeView != null) {
         previewNodeView.ClearValue(SharpTreeNodeView.TextBackgroundProperty);
         previewNodeView.ClearValue(SharpTreeNodeView.ForegroundProperty);
         if (insertMarker != null) {
             insertMarker.Visibility = Visibility.Collapsed;
         }
         previewNodeView = null;
     }
 }