static bool TreeView_IsVisible(TextViewContext context) { ModuleDef module; return context.TreeView == MainWindow.Instance.treeView && ((module = ILSpyTreeNode.GetModule(context.SelectedTreeNodes)) != null) && module.EntryPoint is MethodDef; }
public override void Execute(TextViewContext context) { if (context.SelectedTreeNodes.Length != 1) { throw new Exception("SelectedTreeNodes = " + context.SelectedTreeNodes.Length); } var xCurrentProperty = context.SelectedTreeNodes[0] as PropertyTreeNode; if (xCurrentProperty == null) { throw new Exception("Current TreeNode is not a Property!"); } if (MessageBox.Show("Do you want to generate plug code to your clipboard?", "Cosmos Plug tool", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } var xProp = xCurrentProperty.PropertyDefinition; var xSB = new StringBuilder(); if (xProp.GetMethod != null) { xSB.AppendLine(GenerateMethodPlugEntry.GenerateMethod(xProp.GetMethod)); xSB.AppendLine(); } if (xProp.SetMethod != null) { xSB.AppendLine(GenerateMethodPlugEntry.GenerateMethod(xProp.SetMethod)); xSB.AppendLine(); } Clipboard.SetText(xSB.ToString().Trim()); MessageBox.Show("Done", "Cosmos Plug tool"); }
internal static void RenameSelectedNode(this IRenamerContextMenu item, TextViewContext context, Action<TextViewContext> action) { var treeView = context.TreeView; var activeHandler = BaseContextMenu.ILSpyPackage.ActiveHandler; if (treeView == null || activeHandler == null) return; var targetObject = activeHandler.TargetObject; if (targetObject == null) return; var instance = MainWindow.Instance; var oldNode = treeView.SelectedItem as ILSpyTreeNode; var path = instance.GetPathForNode(oldNode); var oldName = RenameHelper.GetName(targetObject); action(context); var newNode = item.FindRenamedNode(oldNode, path, oldName, targetObject); if (newNode == null) return; instance.SelectNode(newNode); newNode.IsExpanded = oldNode != null && oldNode.IsExpanded; }
public override void Execute(TextViewContext context) { if (context.SelectedTreeNodes.Length != 1) { throw new Exception("SelectedTreeNodes = " + context.SelectedTreeNodes.Length); } var xCurrentField = context.SelectedTreeNodes[0] as FieldTreeNode; if (xCurrentField == null) { throw new Exception("Current TreeNode is not a Field!"); } if (MessageBox.Show("Do you want to generate FieldAccess code to your clipboard?", "Cosmos Plug tool", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } Clipboard.SetText(String.Format("[FieldAccess(Name = \"{0} {1}.{2}\")] ref {3} field{2}", xCurrentField.FieldDefinition.FieldType.FullName, xCurrentField.FieldDefinition.DeclaringType.FullName, xCurrentField.FieldDefinition.Name, Utilities.GetCSharpTypeName(xCurrentField.FieldDefinition.FieldType))); MessageBox.Show("Done", "Cosmos Plug tool"); }
protected static void PreserveNodeSelection(TextViewContext context, Action action) { var treeView = context.TreeView; if (treeView == null) return; var instance = MainWindow.Instance; var oldNode = treeView.SelectedItem as SharpTreeNode; var path = MainWindow.GetPathForNode(oldNode); action(); var newNode = instance.FindNodeByPath(path, false); // If not found let's try parent node if (newNode == null && path.Length > 1) { newNode = instance.FindNodeByPath(path.Take(path.Length - 1).ToArray(), false); if (oldNode != null) oldNode = oldNode.Parent; } if (newNode == null) return; instance.SelectNode(newNode); newNode.IsExpanded = oldNode != null && oldNode.IsExpanded; }
static bool TextEditor_IsVisible(TextViewContext context) { ModuleDef module; return context.TextView != null && (module = GetModule()) != null && module.EntryPoint is MethodDef; }
public bool IsVisible(TextViewContext context) { return context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length == 1 && context.SelectedTreeNodes[0] is AssemblyTreeNode && !string.IsNullOrWhiteSpace(((AssemblyTreeNode)context.SelectedTreeNodes[0]).LoadedAssembly.FileName); }
public void Execute(TextViewContext context) { if (TreeView_IsVisible(context)) MainWindow.Instance.JumpToReference(ILSpyTreeNode.GetModule(context.SelectedTreeNodes).EntryPoint); else if (TextEditor_IsVisible(context)) MainWindow.Instance.JumpToReference(GetModule().EntryPoint); }
public void Execute(TextViewContext context) { var types = context.SelectedTreeNodes .OfType<TypeTreeNode>() .Select(n => HAL.Converter.Type(n.TypeDefinition)) .ToArray(); Services.BrowseInteractions(types, true); }
public bool IsVisible(TextViewContext context) { var list = GetMappings(context); return list != null && list.Count != 0 && list[0].MemberMapping.MethodDefinition != null && list[0].MemberMapping.MethodDefinition.Body != null && list[0].MemberMapping.MethodDefinition.Body.Instructions.Count > 0; }
public void Execute(TextViewContext context) { var assemblyDefinitions = context.SelectedTreeNodes .OfType<AssemblyTreeNode>() .Select(n => Converter.Assembly(n.LoadedAssembly.AssemblyDefinition)) .ToList(); Services.BrowseAssemblies(assemblyDefinitions); }
public bool IsVisible(TextViewContext context) { if (context.SelectedTreeNodes == null) { return false; } return context.SelectedTreeNodes.All(n => n is AssemblyTreeNode); }
public bool IsVisible(TextViewContext context) { if (context.SelectedTreeNodes == null) { return false; } return context.SelectedTreeNodes.OfType<AssemblyTreeNode>().Count() > 0; }
public void Execute(TextViewContext context) { var assemblyDefinitions = context.SelectedTreeNodes .OfType<AssemblyTreeNode>() .Select(n => HAL.Converter.Assembly(n.LoadedAssembly.AssemblyDefinition)) .ToList(); var window = WindowManager.AssemblyBrowsers.Single(); window.ViewModel.AddAssemblies(assemblyDefinitions); }
public bool IsVisible(TextViewContext context) { if (context.SelectedTreeNodes == null) { return false; } return (context.SelectedTreeNodes.Count() == 1) && (context.SelectedTreeNodes.Single() is TypeTreeNode); }
internal static IList<SourceCodeMapping> GetMappings(TextViewContext context) { if (context.TextView == null || context.Position == null) return null; var list = SourceCodeMappingUtils.Find(context.TextView, context.Position.Value.Line, context.Position.Value.Column); if (list.Count == 0) return null; if (!(list[0].StartLocation.Line <= context.Position.Value.Line && context.Position.Value.Line <= list[0].EndLocation.Line)) return null; return list; }
public override void Execute(TextViewContext context) { var obj = GetReference(context); if (obj != null) { var member = MainWindow.ResolveReference(obj); if (member == null) MainWindow.Instance.ShowMessageBox("Could not resolve member definition"); else Execute(member); } }
public void Execute(TextViewContext context) { var typeDefinition = context.SelectedTreeNodes .OfType<TypeTreeNode>() .Single().TypeDefinition; var window = new AncestryBrowserWindow(HAL.Converter.Type(typeDefinition)) { Owner = MainWindow.Instance }; window.Show(); }
public void Execute(TextViewContext context) { var assemblyDefinitions = context.SelectedTreeNodes .OfType<AssemblyTreeNode>() .Select(n => n.LoadedAssembly.AssemblyDefinition); var window = new DependencyBrowserWindow(assemblyDefinitions.Select(HAL.Converter.Assembly)) { Owner = Services.MainWindow }; window.Show(); }
public override bool IsVisible(TextViewContext context) { if (context.SelectedTreeNodes.Length != 1) { return false; } var xCurrentType = context.SelectedTreeNodes[0] as TypeTreeNode; if (xCurrentType == null) { return false; } return true; }
public void Execute(TextViewContext context) { // Known problem: explorer can't show files in the .NET 2.0 GAC. var asmNode = (AssemblyTreeNode)context.SelectedTreeNodes[0]; var filename = asmNode.LoadedAssembly.FileName; var args = string.Format("/select,{0}", filename); try { Process.Start(new ProcessStartInfo("explorer.exe", args)); } catch (IOException) { } catch (Win32Exception) { } }
public void Execute(TextViewContext context) { var typeDefinition = context.SelectedTreeNodes .OfType<TypeTreeNode>() .Single().TypeDefinition; var type = HAL.Converter.Type(typeDefinition); var assembly = type.Module.Assembly; var window = new AssemblyBrowserWindow(new [] { assembly }, type) { Owner = MainWindow.Instance }; window.Show(); }
public bool IsVisible(TextViewContext context) { if (WindowManager.AssemblyBrowsers.Count != 1) { return false; } var window = WindowManager.AssemblyBrowsers.Single(); if (!window.ViewModel.Screen.AllowAssemblyDrop) { return false; } return context.SelectedTreeNodes.All(n => n is AssemblyTreeNode); }
public override bool IsVisible(TextViewContext context) { if (context?.SelectedTreeNodes != null) { foreach (var node in context.SelectedTreeNodes) { var xCurrentProperty = node as PropertyTreeNode; if (xCurrentProperty != null) { return true; } } } return false; }
public void Execute(TextViewContext context, bool includeAssemblyVersion) { try { string typeName = GetFullyQualifiedName(context, includeAssemblyVersion); if (typeName != null) { Clipboard.SetText(typeName); } } catch (Exception) { } }
public override bool IsVisible(TextViewContext context) { if (context?.SelectedTreeNodes != null) { foreach (var node in context.SelectedTreeNodes) { var xCurrentField = node as FieldTreeNode; if ((xCurrentField != null) && !xCurrentField.FieldDefinition.HasConstant) { return true; } } } return false; }
public void Execute(TextViewContext context) { var list = GetMappings(context); if (list == null) return; var method = list[0].MemberMapping.MethodDefinition; var methodNode = MainWindow.Instance.AssemblyListTreeNode.FindMethodNode(method); if (methodNode == null) { MainWindow.Instance.ShowMessageBox(string.Format("Could not find method: {0}", method)); return; } MethodBodySettingsCommand.Execute(new ILSpyTreeNode[] { methodNode }, GetInstructionOffsets(method, list)); }
public void Execute(TextViewContext context) { if (context.SelectedTreeNodes == null) return; AssemblyTreeNode node = (AssemblyTreeNode)context.SelectedTreeNodes[0]; var mod = node.LoadedAssembly.ModuleDefinition; if (mod != null) { SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = node.LoadedAssembly.FileName; dlg.Filter = "Assembly|*.dll;*.exe"; if (dlg.ShowDialog(MainWindow.Instance) == true) { mod.Write(dlg.FileName); } } }
public virtual void Execute(TextViewContext context) { var treeView = context.TreeView; if (treeView == null) return; var node = treeView.SelectedItem as SharpTreeNode; if (node != null) { // Be sure to validate any modifications ILSpyPackage.ReflexilWindow.ValidateChildren(ValidationConstraints.Enabled); Execute(node); } }
protected string GetFullyQualifiedName(TextViewContext context, bool includeAssemblyVersion) { string assemblyName = string.Empty; string namespaceName = string.Empty; string typeName = string.Empty; var node = context.SelectedTreeNodes.First(); var derivedTypesNode = node as IMemberTreeNode; if (derivedTypesNode != null) { var typeReference = derivedTypesNode.Member as TypeReference; AssemblyNameReference assemblyReference = typeReference.Scope as AssemblyNameReference; ModuleDefinition moduleDefinition = typeReference.Scope as ModuleDefinition; if (includeAssemblyVersion) { if (assemblyReference != null) { assemblyName = assemblyReference.FullName; } else if (moduleDefinition != null) { assemblyName = moduleDefinition.Assembly.FullName; } } else { if (assemblyReference != null) { assemblyName = assemblyReference.Name; } else if (moduleDefinition != null) { assemblyName = moduleDefinition.Assembly.Name.Name; } } namespaceName = typeReference.Namespace; typeName = typeReference.Name; return string.Format("{1}.{2}, {0}", assemblyName, namespaceName, typeName); } return null; }
public bool IsVisible(TextViewContext context) { return(context.TextView != null && context.Reference != null); }
public void Initialize(TextViewContext context, MenuItem menuItem) { menuItem.InputGestureText = context.OpenedFromKeyboard ? "Ctrl+F12" : "Ctrl+Click"; }
public void Execute(TextViewContext context) { MainWindow.Instance.OpenReferenceInNewTab(context.TextView, context.Reference); }
public void Execute(TextViewContext context) { base.Execute(null); }
public bool IsEnabled(TextViewContext context) { return(MainWindow.Instance.IsDecompilerTabControl(context.TabControl) && IsEnabledInternal()); }
public void Execute(TextViewContext context) { Pdb2XmlCommand.Execute(context.SelectedTreeNodes.OfType <AssemblyTreeNode>()); }
public bool IsEnabled(TextViewContext context) { return(CanExecute(null)); }
public bool IsVisible(TextViewContext context) { return(MainWindow.Instance.IsDecompilerTabControl(context.TabControl) && MainWindow.Instance.ActiveTabState != null); }
public void Initialize(TextViewContext context, MenuItem menuItem) { Initialize(menuItem); }
public bool IsVisible(TextViewContext context) { return(MainWindow.Instance.IsDecompilerTabControl(context.TabControl) && CanExecute(null)); }
public bool IsVisible(TextViewContext context) { return(context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length > 0 && context.TreeView == MainWindow.Instance.treeView); }
public void Execute(TextViewContext context) { MainWindow.Instance.CloseAllTabs(); }
public bool IsVisible(TextViewContext context) { return(GetMemberNodeFromContext(context) != null); }
private IMemberTreeNode GetMemberNodeFromContext(TextViewContext context) { return(context.SelectedTreeNodes?.Length == 1 ? context.SelectedTreeNodes[0] as IMemberTreeNode : null); }
public void Execute(TextViewContext context) { MainWindow.Instance.CloneActiveTab(); }
public void Execute(TextViewContext context) { ExecuteInternal(); }
public void Execute(TextViewContext context) { MainWindow.Instance.OpenNewTab(); }
public bool IsVisible(TextViewContext context) { return(context.SelectedTreeNodes?.Length == 1 && context.SelectedTreeNodes?.FirstOrDefault() is AssemblyTreeNode tn && tn.LoadedAssembly.IsLoadedAsValidAssembly); }
public bool IsEnabled(TextViewContext context) { return(MainWindow.Instance.IsDecompilerTabControl(context.TabControl) && MainWindow.Instance.CloseAllButActiveTabCanExecute()); }
public bool IsEnabled(TextViewContext context) { return(true); }
public bool IsEnabled(TextViewContext context) { return(GetAssembly(context) != null); }
bool ShowContextMenu(TextViewContext context, out ContextMenu menu) { menu = new ContextMenu(); var menuGroups = new Dictionary <string, Lazy <IContextMenuEntry, IContextMenuEntryMetadata>[]>(); Lazy <IContextMenuEntry, IContextMenuEntryMetadata>[] topLevelGroup = null; foreach (var group in entries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.ParentMenuID)) { if (group.Key == null) { topLevelGroup = group.ToArray(); } else { menuGroups.Add(group.Key, group.ToArray()); } } BuildMenu(topLevelGroup ?? Array.Empty <Lazy <IContextMenuEntry, IContextMenuEntryMetadata> >(), menu.Items); return(menu.Items.Count > 0); void BuildMenu(Lazy <IContextMenuEntry, IContextMenuEntryMetadata>[] menuGroup, ItemCollection parent) { foreach (var category in menuGroup.GroupBy(c => c.Metadata.Category)) { bool needSeparatorForCategory = parent.Count > 0; foreach (var entryPair in category) { IContextMenuEntry entry = entryPair.Value; if (entry.IsVisible(context)) { if (needSeparatorForCategory) { parent.Add(new Separator()); needSeparatorForCategory = false; } MenuItem menuItem = new MenuItem(); menuItem.Header = MainWindow.GetResourceString(entryPair.Metadata.Header); menuItem.InputGestureText = entryPair.Metadata.InputGestureText; if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) { menuItem.Icon = new Image { Width = 16, Height = 16, Source = Images.Load(entryPair.Value, entryPair.Metadata.Icon) }; } if (entryPair.Value.IsEnabled(context)) { menuItem.Click += delegate { entry.Execute(context); }; } else { menuItem.IsEnabled = false; } parent.Add(menuItem); if (entryPair.Metadata.MenuID != null && menuGroups.TryGetValue(entryPair.Metadata.MenuID, out var group)) { BuildMenu(group, menuItem.Items); } } } } } }
public bool IsEnabled(TextViewContext context) => true;
public bool IsVisible(TextViewContext context) { return(GetAssembly(context) != null); }