当前位置: 首页>>代码示例>>C#>>正文


C# TreeView.SharpTreeViewItem类代码示例

本文整理汇总了C#中ICSharpCode.TreeView.SharpTreeViewItem的典型用法代码示例。如果您正苦于以下问题:C# SharpTreeViewItem类的具体用法?C# SharpTreeViewItem怎么用?C# SharpTreeViewItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SharpTreeViewItem类属于ICSharpCode.TreeView命名空间,在下文中一共展示了SharpTreeViewItem类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SharpTreeViewItemAutomationPeer

        internal SharpTreeViewItemAutomationPeer(SharpTreeViewItem owner)
            : base(owner)
        {
            SharpTreeViewItem.DataContextChanged += OnDataContextChanged;
            SharpTreeNode node = SharpTreeViewItem.DataContext as SharpTreeNode;
            if (node == null) return;

            node.PropertyChanged += OnPropertyChanged;
        }
开发者ID:MeteorAdminz,项目名称:ILSpy,代码行数:9,代码来源:SharpTreeViewItemAutomationPeer.cs

示例2: TryAddDropTarget

        void TryAddDropTarget(List<DropTarget> targets, SharpTreeViewItem item, DropPlace place, DragEventArgs e)
        {
            SharpTreeNode node;
            int index;

            GetNodeAndIndex(item, place, out node, out index);

            if (node != null) {
                e.Effects = DragDropEffects.None;
                if (node.CanDrop(e, index)) {
                    DropTarget target = new DropTarget() {
                        Item = item,
                        Place = place,
                        Node = node,
                        Index = index
                    };
                    targets.Add(target);
                }
            }
        }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:20,代码来源:SharpTreeView.cs

示例3: ShowPreview

        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;
            }
        }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:51,代码来源:SharpTreeView.cs

示例4: GetNodeAndIndex

        void GetNodeAndIndex(SharpTreeViewItem item, DropPlace place, out SharpTreeNode node, out int index)
        {
            node = null;
            index = 0;

            if (place == DropPlace.Inside) {
                node = item.Node;
                index = node.Children.Count;
            }
            else if (place == DropPlace.Before) {
                if (item.Node.Parent != null) {
                    node = item.Node.Parent;
                    index = node.Children.IndexOf(item.Node);
                }
            }
            else {
                if (item.Node.Parent != null) {
                    node = item.Node.Parent;
                    index = node.Children.IndexOf(item.Node) + 1;
                }
            }
        }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:22,代码来源:SharpTreeView.cs

示例5: GetDropTarget

 DropTarget GetDropTarget(SharpTreeViewItem item, DragEventArgs e)
 {
     var dropTargets = BuildDropTargets(item, e);
     var y = e.GetPosition(item).Y;
     foreach (var target in dropTargets) {
         if (target.Y >= y) {
             return target;
         }
     }
     return null;
 }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:11,代码来源:SharpTreeView.cs

示例6: BuildDropTargets

        List<DropTarget> BuildDropTargets(SharpTreeViewItem item, DragEventArgs e)
        {
            var result = new List<DropTarget>();
            var node = item.Node;

            if (AllowDropOrder) {
                TryAddDropTarget(result, item, DropPlace.Before, e);
            }

            TryAddDropTarget(result, item, DropPlace.Inside, e);

            if (AllowDropOrder) {
                if (node.IsExpanded && node.Children.Count > 0) {
                    var firstChildItem = ItemContainerGenerator.ContainerFromItem(node.Children[0]) as SharpTreeViewItem;
                    TryAddDropTarget(result, firstChildItem, DropPlace.Before, e);
                }
                else {
                    TryAddDropTarget(result, item, DropPlace.After, e);
                }
            }

            var h = item.ActualHeight;
            var y1 = 0.2 * h;
            var y2 = h / 2;
            var y3 = h - y1;

            if (result.Count == 2) {
                if (result[0].Place == DropPlace.Inside &&
                    result[1].Place != DropPlace.Inside) {
                    result[0].Y = y3;
                }
                else if (result[0].Place != DropPlace.Inside &&
                         result[1].Place == DropPlace.Inside) {
                    result[0].Y = y1;
                }
                else {
                    result[0].Y = y2;
                }
            }
            else if (result.Count == 3) {
                result[0].Y = y1;
                result[1].Y = y3;
            }
            if (result.Count > 0) {
                result[result.Count - 1].Y = h;
            }
            return result;
        }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:48,代码来源:SharpTreeView.cs

示例7: HandleDrop

        internal void HandleDrop(SharpTreeViewItem item, DragEventArgs e)
        {
            try {
                HidePreview();

                var target = GetDropTarget(item, e);
                if (target != null) {
                    e.Handled = true;
                    target.Node.InternalDrop(e, target.Index);
                }
            } catch (Exception ex) {
                Debug.WriteLine(ex.ToString());
                throw;
            }
        }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:15,代码来源:SharpTreeView.cs

示例8: HandleDragOver

        internal void HandleDragOver(SharpTreeViewItem item, DragEventArgs e)
        {
            HidePreview();

            var target = GetDropTarget(item, e);
            if (target != null) {
                e.Handled = true;
                ShowPreview(target.Item, target.Place);
            }
        }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:10,代码来源:SharpTreeView.cs

示例9: HandleDragLeave

 internal void HandleDragLeave(SharpTreeViewItem item, DragEventArgs e)
 {
     HidePreview();
     e.Handled = true;
 }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:5,代码来源:SharpTreeView.cs

示例10: HandleDragEnter

 internal void HandleDragEnter(SharpTreeViewItem item, DragEventArgs e)
 {
     HandleDragOver(item, e);
 }
开发者ID:HEskandari,项目名称:ILSpy,代码行数:4,代码来源:SharpTreeView.cs

示例11: HandleDrop

		internal void HandleDrop(SharpTreeViewItem item, DragEventArgs e)
		{
			HidePreview();
			e.Handled = true;

			var target = GetDropTarget(item, e);
			if (target != null) {
				target.Node.InternalDrop(e, target.Index);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:10,代码来源:SharpTreeView.cs


注:本文中的ICSharpCode.TreeView.SharpTreeViewItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。