public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as IResourceElementNode; var b = y as IResourceElementNode; if (a == null) { return(-1); } if (b == null) { return(1); } int c = StringComparer.OrdinalIgnoreCase.Compare(a.ResourceElement.Name, b.ResourceElement.Name); if (c != 0) { return(c); } int cx = (int)a.ResourceElement.ResourceData.Code.FixUserType(); int cy = (int)b.ResourceElement.ResourceData.Code.FixUserType(); return(cx.CompareTo(cy)); }
public void FollowNode(ITreeNodeData node, bool newTab, bool?useCodeRef) { var tokNode = node as IMDTokenNode; var @ref = tokNode?.Reference; var entityNode = node as EntityNode; var srcRef = entityNode?.SourceRef; bool code = useCodeRef ?? srcRef != null; if (code) { if (srcRef == null) { return; } fileTabManager.FollowReference(srcRef.Value.Method, newTab, true, a => { if (!a.HasMovedCaret && a.Success && srcRef != null) { a.HasMovedCaret = GoTo(a.Tab, srcRef.Value.Method, srcRef.Value.ILOffset, srcRef.Value.Reference); } }); } else { if (@ref == null) { return; } fileTabManager.FollowReference(@ref, newTab); } }
void OnDropFiles(int index, string[] filenames) { if (!context.CanDragAndDrop) { return; } var existingFiles = new HashSet <string>(fileManager.GetFiles().Select(a => a.Filename ?? string.Empty), StringComparer.OrdinalIgnoreCase); filenames = filenames.Where(a => File.Exists(a) && !existingFiles.Contains(a)).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); ITreeNodeData newSelectedNode = null; for (int i = 0, j = 0; i < filenames.Length; i++) { var file = fileManager.TryCreateOnly(DnSpyFileInfo.CreateFile(filenames[i])); if (file == null) { continue; } var node = CreateNode(null, file); fileManager.ForceAdd(file, false, new AddFileInfo(node, index + j++)); if (newSelectedNode == null) { newSelectedNode = node; } } if (newSelectedNode != null) { treeView.SelectItems(new[] { newSelectedNode }); } }
/// <summary> /// Gets the <see cref="IDnSpyFileNode"/> top node or null if none was found /// </summary> /// <param name="self"></param> /// <returns></returns> public static IDnSpyFileNode GetTopNode(this ITreeNodeData self) { var root = self == null ? null : self.TreeNode.TreeView.Root; while (self != null) { var found = self as IDnSpyFileNode; if (found != null) { var p = found.TreeNode.Parent; Debug.Assert(p != null); if (p == null || p == root) { return(found); } } var parent = self.TreeNode.Parent; if (parent == null) { break; } self = parent.Data; } return(null); }
public void OnRemoved(ITreeNodeData node) { if (NodeRemoved != null) { NodeRemoved(this, new TVNodeRemovedEventArgs(node, true)); } }
protected void AddNode(ITreeNodeData node) { lock (lockObj) { nodesToAdd.Add(node); if (nodesToAdd.Count == 1) ExecInUIThread(AddNodes_UI); } }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as IResourceNode; var b = y as IResourceNode; if (a == null) { return(-1); } if (b == null) { return(1); } int c = StringComparer.OrdinalIgnoreCase.Compare(a.Resource.Name, b.Resource.Name); if (c != 0) { return(c); } return(a.Resource.MDToken.Raw.CompareTo(b.Resource.MDToken.Raw)); }
public override IEnumerable <ITreeNodeData> CreateChildren() { if (newChild != null) { yield return(newChild); } newChild = null; }
public TreeNodeImpl(TreeViewImpl treeViewImpl, ITreeNodeData data) { Debug.Assert(data.TreeNode == null); this.treeViewImpl = treeViewImpl; this.nodeList = new SharpTreeNodeChildrenList(this); this.data = data; this.data.TreeNode = this; }
public TreeNodeImpl(TreeViewImpl treeViewImpl, ITreeNodeData data) { Debug.Assert(data.TreeNode == null); this.TreeView = treeViewImpl; this.nodeList = new SharpTreeNodeChildrenList(this); this.Data = data; this.Data.TreeNode = this; }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { IEnumerable <ITreeNodeData> sourceCollection = value as IEnumerable <ITreeNodeData>; if (destinationType == typeof(string)) { if (sourceCollection == null) { return(base.ConvertTo(context, culture, value, destinationType)); } bool limitItemCountReached = sourceCollection.Count() == MAX_LIMIT_ITEM_COUNT; StringBuilder itemList = sourceCollection.Take(MAX_LIMIT_ITEM_COUNT).Aggregate(new StringBuilder(), (builder, data) => builder.AppendFormat("{0}{1},", data.DisplayValue, data.IconIndex == TreeNodeProxy.ICON_INDEX_SORT_DESC ? ":DESC" : string.Empty), stringBuilder => { if (stringBuilder.Length > 0) { StringBuilder sb = stringBuilder.Remove(stringBuilder.Length - 1, 1); if (limitItemCountReached) { sb.Append("..."); } return(sb); } stringBuilder.Append("(Empty)"); return(stringBuilder); }); return(itemList.ToString()); } Type itemType = destinationType.GetGenericArguments().Single(); Type genericCollectionType = baseCollectionType.MakeGenericType(itemType); object targetInstance = Activator.CreateInstance(genericCollectionType); IList targetCollection = (IList)targetInstance; foreach (ITreeNodeData sourceItem in sourceCollection) { ITreeNodeData targetItem = sourceItem; if (sourceItem is ICloneable) { targetItem = (ITreeNodeData)(sourceItem as ICloneable).Clone(); } targetCollection.Add(targetItem); } return(targetCollection); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IMessageNode; var b = y as IMessageNode; if (a == null) return -1; if (b == null) return 1; return 0; }
public void Init(ITreeNodeData TreeNodeData) { //this.data = TreeNodeData; //this.Title = this.data.NodeText; //UnitContentData ucd = this.data as UnitContentData; //if (ucd != null) //{ // base.ItemImage = ucd.Icon; // descipution = ucd.SecondInfo; // tip = ucd.Tip; // ptDesc = new PointF(base.fontLocation.X, titleBottom + 8); // if (string.IsNullOrEmpty(tip) == false) // { // this.toolTip = new ToolTip(); // toolTip.SetToolTip(this, tip); // } // this.Enabled = ucd.Enabled; // return; //} //UnitNodeData und = this.data as UnitNodeData; //if (und != null) //{ //switch (und.NodeType) //{ // case EnumNodeType.CYC: // case EnumNodeType.YT: // case EnumNodeType.Other: // descipution1 = "共有" + und.ChildPacketCount + "个分组"; // descipution2 = "共有" + und.ChildUnitCount + "个单元"; // ptDesc1 = new PointF(base.fontLocation.X + 8, titleBottom + 8); // ptDesc2 = new PointF(base.fontLocation.X + 8, titleBottom * 2 - 8); // break; // case EnumNodeType.DY: // this.descipution1 = ""; // this.descipution2 = ""; // this.ItemImage = Properties.Resources.map2_72; // int leftIndex = this.Title.IndexOf("(", 0); // if (leftIndex > 0) // { // this.descipution1 = this.Title.Substring(leftIndex + 1, this.Title.Length - leftIndex - 1); // if (this.descipution1.EndsWith(")")) // this.descipution1 = this.descipution1.Substring(0, this.descipution1.Length - 1); // ptDesc1 = new PointF(base.fontLocation.X, titleBottom + 8); // this.Title = this.Title.Substring(0, leftIndex); // } // break; // default: // break; //} //} }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IAssemblyReferenceNode; var b = y as IAssemblyReferenceNode; if (a == null) return -1; if (b == null) return 1; return StringComparer.OrdinalIgnoreCase.Compare(a.AssemblyRef.FullName, b.AssemblyRef.FullName); }
protected void AddNode(ITreeNodeData node) { lock (lockObj) { nodesToAdd.Add(node); if (nodesToAdd.Count == 1) { ExecInUIThread(AddNodes_UI); } } }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as AssemblyChildNode; var b = y as AssemblyChildNode; if (a == null) return -1; if (b == null) return 1; // More checks can be added here... return 0; }
protected AsyncNodeCreator(ITreeNodeData targetNode) { this.lockObj = new object(); this.targetNode = targetNode; this.dispatcher = Dispatcher.CurrentDispatcher; this.uiThreadActions = new List<Action>(); this.cancellationTokenSource = new CancellationTokenSource(); this.cancellationToken = cancellationTokenSource.Token; this.thread = new Thread(ThreadMethodImpl); thread.IsBackground = true; }
/// <summary> /// Constructor /// </summary> /// <param name="targetNode">Target node that will be the parent of the new nodes</param> protected AsyncNodeProvider(ITreeNodeData targetNode) { this.lockObj = new object(); this.targetNode = targetNode; this.dispatcher = Dispatcher.CurrentDispatcher; this.uiThreadActions = new List <Action>(); this.cancellationTokenSource = new CancellationTokenSource(); this.cancellationToken = cancellationTokenSource.Token; this.thread = new Thread(ThreadMethodImpl); thread.IsBackground = true; }
public object ToImplNode(ITreeNodeData node) { if (node == null) { return(null); } var impl = node.TreeNode as TreeNodeImpl; Debug.Assert(impl != null); return(impl?.Node); }
public static void CancelSelfAndChildren(ITreeNodeData node) { foreach (var c in node.DescendantsAndSelf()) { var id = c as IAsyncCancellable; if (id != null) { id.Cancel(); } } }
// public static void RegisterNodeDataType<T>(this LabelEditEnhancedTreeView @this) where T : ITreeNodeData, new() // { // @this.Tag = new Func<string, T>(s => (T) CreateNodeDataInstance<T>(s)); // } public static ITreeNodeData CreateNewNodeData(this LabelEditEnhancedTreeView @this, string displayValue) { //Func<string, ITreeNodeData> createFunc = (Func<string, ITreeNodeData>)@this.Tag; //return createFunc(displayValue); Type type = (Type)@this.Tag; ITreeNodeData newData = (ITreeNodeData)System.Activator.CreateInstance(type); newData.DisplayValue = displayValue; return(newData); }
static IDnSpyFile GetDnSpyFile(ITreeNodeData node) { var fileNode = node as IDnSpyFileNode; if (fileNode == null) return null; var peImage = fileNode.DnSpyFile.PEImage; if (peImage == null) { var mod = fileNode.DnSpyFile.ModuleDef as ModuleDefMD; peImage = mod == null ? null : mod.MetaData.PEImage; } return peImage != null && peImage.IsMemoryMappedIO ? fileNode.DnSpyFile : null; }
private void lvItems_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { var hitTest = lvItems.HitTest(e.Location); if (hitTest.Location == TreeViewHitTestLocations.Image && hitTest.Node != null && !hitTest.Node.IsNewItemNode() && SupportSortingIcons()) { int iconIndex = hitTest.Node.ImageIndex; iconIndex = iconIndex == TreeNodeProxy.ICON_INDEX_SORT_ASC ? TreeNodeProxy.ICON_INDEX_SORT_DESC : TreeNodeProxy.ICON_INDEX_SORT_ASC; UpdateNodeIcon(hitTest.Node, iconIndex); ITreeNodeData treeNodeData = hitTest.Node.GetNodeData(); treeNodeData.IconIndex = iconIndex; } }
public bool CanFollowNode(ITreeNodeData node, bool useCodeRef) { var tokNode = node as IMDTokenNode; var @ref = tokNode?.Reference; var entityNode = node as EntityNode; var srcRef = entityNode?.SourceRef; if (useCodeRef) { return(srcRef != null); } return(@ref != null); }
public static TreeNode CreateNewItemNode(this LabelEditEnhancedTreeView @this) { ITreeNodeData treeNodeData = @this.CreateNewNodeData(TreeNodeProxy.NEW_ITEM_NODE_TEXT); TreeNode treeNode = CreateNode(@this, treeNodeData); treeNode.ForeColor = Color.Gray; treeNode.ImageIndex = 0; treeNode.StateImageIndex = 0; treeNode.SelectedImageIndex = 0; TreeNodeProxy treeNodeProxy = treeNode.GetNodeProxy(); treeNodeProxy.IsNewItemNode = true; return(treeNode); }
/// <summary> /// Adds a new node /// </summary> /// <param name="node">New node</param> protected void AddNode(ITreeNodeData node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } lock (lockObj) { nodesToAdd.Add(node); if (nodesToAdd.Count == 1) { ExecInUIThread(AddNodes_UI); } } }
/// <summary> /// Constructor /// </summary> /// <param name="text">Text to classify</param> /// <param name="treeView">Treeview</param> /// <param name="node">Node to classify</param> /// <param name="isToolTip">true if the content will be shown in a tooltip</param> /// <param name="colorize">true if it should be colorized</param> /// <param name="colors">Default colors or null. It doesn't have to be sorted and elements can overlap. The colors /// must be <see cref="IClassificationType"/>s or <see cref="TextColor"/>s</param> public TreeViewNodeClassifierContext(string text, ITreeView treeView, ITreeNodeData node, bool isToolTip, bool colorize, IReadOnlyCollection <SpanData <object> > colors = null) : base(text, string.Empty, colorize, colors) { if (treeView == null) { throw new ArgumentNullException(nameof(treeView)); } if (node == null) { throw new ArgumentNullException(nameof(node)); } TreeView = treeView; Node = node; IsToolTip = isToolTip; }
TreeNodeImpl Create(ITreeNodeData data) { Debug.Assert(data.TreeNode == null); var impl = new TreeNodeImpl(this, data); if (treeViewListener != null) { treeViewListener.OnEvent(this, new TreeViewListenerEventArgs(TreeViewListenerEvent.NodeCreated, impl)); } data.Initialize(); if (!impl.LazyLoading) { AddChildren(impl); } return(impl); }
int Compare(ITreeNodeData a, ITreeNodeData b, ITreeNodeGroup ga, ITreeNodeGroup gb) { if (ga.Order < gb.Order) { return(-1); } if (ga.Order > gb.Order) { return(1); } if (ga.GetType() != gb.GetType()) { Debug.Fail(string.Format("Two different groups have identical order: {0} vs {1}", ga.GetType(), gb.GetType())); return(ga.GetType().GetHashCode().CompareTo(gb.GetType().GetHashCode())); } return(ga.Compare(a, b)); }
static IDsDocument GetDocument(ITreeNodeData node) { var fileNode = node as IDsDocumentNode; if (fileNode == null) { return(null); } var peImage = fileNode.Document.PEImage; if (peImage == null) { peImage = (fileNode.Document.ModuleDef as ModuleDefMD)?.MetaData?.PEImage; } return(peImage != null && peImage.IsMemoryMappedIO ? fileNode.Document : null); }
static IDnSpyFile GetDnSpyFile(ITreeNodeData node) { var fileNode = node as IDnSpyFileNode; if (fileNode == null) { return(null); } var peImage = fileNode.DnSpyFile.PEImage; if (peImage == null) { peImage = (fileNode.DnSpyFile.ModuleDef as ModuleDefMD)?.MetaData?.PEImage; } return(peImage != null && peImage.IsMemoryMappedIO ? fileNode.DnSpyFile : null); }
/// <summary> /// Gets the ancestor of a certain type /// </summary> /// <typeparam name="T">Desired type</typeparam> /// <param name="self">This</param> /// <returns></returns> public static T GetAncestorOrSelf <T>(this ITreeNodeData self) where T : class, ITreeNodeData { while (self != null) { var found = self as T; if (found != null) { return(found); } var parent = self.TreeNode.Parent; if (parent == null) { break; } self = parent.Data; } return(null); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as IPropertyNode; var b = y as IPropertyNode; if (a == null) { return(-1); } if (b == null) { return(1); } return(PropertyDefComparer.Instance.Compare(a.PropertyDef, b.PropertyDef)); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as IEventNode; var b = y as IEventNode; if (a == null) { return(-1); } if (b == null) { return(1); } return(EventDefComparer.Instance.Compare(a.EventDef, b.EventDef)); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as IMessageNode; var b = y as IMessageNode; if (a == null) { return(-1); } if (b == null) { return(1); } return(0); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as INamespaceNode; var b = y as INamespaceNode; if (a == null) { return(-1); } if (b == null) { return(1); } return(StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name)); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) { return(0); } var a = x as IDerivedTypesFolderNode; var b = y as IDerivedTypesFolderNode; if (a == null) { return(-1); } if (b == null) { return(1); } return(-1); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IMethodNode; var b = y as IMethodNode; if (a == null) return -1; if (b == null) return 1; return MethodDefComparer.Instance.Compare(a.MethodDef, b.MethodDef); }
public void FollowNode(ITreeNodeData node, bool newTab, bool? useCodeRef) { var tokNode = node as IMDTokenNode; var @ref = tokNode == null ? null : tokNode.Reference; var entityNode = node as EntityNode; var srcRef = entityNode == null ? null : entityNode.SourceRef; bool code = useCodeRef ?? srcRef != null; if (code) { if (srcRef == null) return; fileTabManager.FollowReference(srcRef.Value.Method, newTab, true, a => { if (!a.HasMovedCaret && a.Success && srcRef != null) a.HasMovedCaret = GoTo(a.Tab, srcRef.Value.Method, srcRef.Value.ILOffset, srcRef.Value.Reference); }); } else { if (@ref == null) return; fileTabManager.FollowReference(@ref, newTab); } }
internal static void DeleteNodes(ITreeNodeData[] nodes) { if (nodes != null) { foreach (var node in nodes) { AnalyzerTreeNodeData.CancelSelfAndChildren(node); node.TreeNode.Parent.Children.Remove(node.TreeNode); } } }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IResourceNode; var b = y as IResourceNode; if (a == null) return -1; if (b == null) return 1; int c = StringComparer.OrdinalIgnoreCase.Compare(a.Resource.Name, b.Resource.Name); if (c != 0) return c; return a.Resource.MDToken.Raw.CompareTo(b.Resource.MDToken.Raw); }
ITreeNode ITreeView.Create(ITreeNodeData data) { return Create(data); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IAnalyzerTreeNodeData; var b = y as IAnalyzerTreeNodeData; if (a == null) return -1; if (b == null) return 1; return StringComparer.OrdinalIgnoreCase.Compare(a.ToString(), b.ToString()); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IEventNode; var b = y as IEventNode; if (a == null) return -1; if (b == null) return 1; return EventDefComparer.Instance.Compare(a.EventDef, b.EventDef); }
public override IEnumerable<ITreeNodeData> CreateChildren() { if (newChild != null) yield return newChild; newChild = null; }
TreeNodeImpl Create(ITreeNodeData data) { Debug.Assert(data.TreeNode == null); var impl = new TreeNodeImpl(this, data); if (treeViewListener != null) treeViewListener.OnEvent(this, new TreeViewListenerEventArgs(TreeViewListenerEvent.NodeCreated, impl)); data.Initialize(); if (!impl.LazyLoading) AddChildren(impl); return impl; }
int Compare(ITreeNodeData a, ITreeNodeData b, ITreeNodeGroup ga, ITreeNodeGroup gb) { if (ga.Order < gb.Order) return -1; if (ga.Order > gb.Order) return 1; if (ga.GetType() != gb.GetType()) { Debug.Fail(string.Format("Two different groups have identical order: {0} vs {1}", ga.GetType(), gb.GetType())); return ga.GetType().GetHashCode().CompareTo(gb.GetType().GetHashCode()); } return ga.Compare(a, b); }
public object ToImplNode(ITreeNodeData node) { if (node == null) return null; var impl = node.TreeNode as TreeNodeImpl; Debug.Assert(impl != null); return impl == null ? null : impl.Node; }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IPropertyNode; var b = y as IPropertyNode; if (a == null) return -1; if (b == null) return 1; return PropertyDefComparer.Instance.Compare(a.PropertyDef, b.PropertyDef); }
public static void CancelSelfAndChildren(ITreeNodeData node) { foreach (var c in node.DescendantsAndSelf()) { var id = c as IAsyncCancellable; if (id != null) id.Cancel(); } }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IMessageNode; var b = y as IMessageNode; if (a == null) return -1; if (b == null) return 1; return StringComparer.OrdinalIgnoreCase.Compare(a.Text, b.Text); }
internal static ITreeNodeData[] GetNodes(ITreeNodeData[] nodes) { if (nodes == null) return null; if (nodes.Length == 0 || !nodes.All(a => a.TreeNode.Parent != null && a.TreeNode.Parent.Parent == null)) return null; return nodes; }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as INamespaceNode; var b = y as INamespaceNode; if (a == null) return -1; if (b == null) return 1; return StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name); }
/// <summary> /// Constructor /// </summary> /// <param name="node">Node</param> /// <param name="removed">true if it was removed</param> public TVNodeRemovedEventArgs(ITreeNodeData node, bool removed) { this.Node = node; this.Removed = removed; }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IResourceElementNode; var b = y as IResourceElementNode; if (a == null) return -1; if (b == null) return 1; int c = StringComparer.OrdinalIgnoreCase.Compare(a.ResourceElement.Name, b.ResourceElement.Name); if (c != 0) return c; int cx = (int)a.ResourceElement.ResourceData.Code.FixUserType(); int cy = (int)b.ResourceElement.ResourceData.Code.FixUserType(); return cx.CompareTo(cy); }
static ResourceRef TryCreate(ITreeNodeData[] nodes) { if (nodes == null || nodes.Length != 1) return null; var tokNode = nodes[0] as IMDTokenNode; if (tokNode != null) return ResourceRef.TryCreate(tokNode.Reference); return null; }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as IResourcesFolderNode; var b = y as IResourcesFolderNode; if (a == null) return -1; if (b == null) return 1; return -1; }
public void OnRemoved(ITreeNodeData node) { if (NodeRemoved != null) NodeRemoved(this, new TVNodeRemovedEventArgs(node, true)); }
public int Compare(ITreeNodeData x, ITreeNodeData y) { if (x == y) return 0; var a = x as ITypeNode; var b = y as ITypeNode; if (a == null) return -1; if (b == null) return 1; var an = a.TypeDef.FullName; var bn = b.TypeDef.FullName; return StringComparer.OrdinalIgnoreCase.Compare(an, bn); }
public bool CanFollowNode(ITreeNodeData node, bool useCodeRef) { var tokNode = node as IMDTokenNode; var @ref = tokNode == null ? null : tokNode.Reference; var entityNode = node as EntityNode; var srcRef = entityNode == null ? null : entityNode.SourceRef; if (useCodeRef) return srcRef != null; return @ref != null; }