Example #1
0
        public override void Execute(IMenuItemContext context)
        {
            var modules = GetModules();
            if (modules.Length == 0)
                return;

            var lang = languageManager.Language;
            if (lang.ProjectFileExtension == null) {
                lang = languageManager.AllLanguages.FirstOrDefault(a => a.ProjectFileExtension != null);
                Debug.Assert(lang != null);
                if (lang == null)
                    return;
            }

            var task = new ExportTask(this, modules);
            var vm = new ExportToProjectVM(new PickDirectory(), languageManager, task, bamlDecompiler != null);
            task.vm = vm;
            vm.ProjectVersion = exportToProjectSettings.ProjectVersion;
            vm.CreateResX = fileTreeViewSettings.DeserializeResources;
            vm.DontReferenceStdLib = modules.Any(a => a.Assembly.IsCorLib());
            vm.Language = lang;
            vm.SolutionFilename = GetSolutionFilename(modules);
            vm.FilesToExportMessage = CreateFilesToExportMessage(modules);

            var win = new ExportToProjectDlg();
            task.dlg = win;
            win.DataContext = vm;
            win.Owner = appWindow.MainWindow;
            using (fileTreeView.FileManager.DisableAssemblyLoad())
                win.ShowDialog();
            if (vm.IsComplete)
                exportToProjectSettings.ProjectVersion = vm.ProjectVersion;
        }
Example #2
0
 public override void Execute(IMenuItemContext context)
 {
     var res = GetReference(context);
     if (res == null)
         return;
     searchManager.Value.FollowResult(res, newTab);
 }
Example #3
0
			public override void Execute(IMenuItemContext context) {
				var type = GetTypeRef(context, guid)?.ResolveTypeDef();
				if (type == null)
					return;
				foreach (var method in type.Methods)
					breakpointService.Value.Add(method);
			}
Example #4
0
 public override bool IsVisible(IMenuItemContext context)
 {
     if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
         return false;
     var uiContext = context.Find<ITextEditorUIContext>();
     return uiContext != null && uiContext.HasSelectedText;
 }
Example #5
0
			static MethodDef GetEntryPoint(IMenuItemContext context) {
				if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID))
					return null;
				var nodes = context.Find<TreeNodeData[]>();
				var node = nodes == null || nodes.Length == 0 ? null : nodes[0];
				var module = node.GetModule();
				return module == null ? null : module.EntryPoint as MethodDef;
			}
Example #6
0
		public IEnumerable<CreatedMenuItem> Create(IMenuItemContext context) {
			foreach (var theme in themeService.VisibleThemes) {
				var attr = new ExportMenuItemAttribute { Header = theme.GetMenuName() };
				var tmp = theme;
				var item = new MyMenuItem(ctx => themeService.Theme = tmp, theme == themeService.Theme);
				yield return new CreatedMenuItem(attr, item);
			}
		}
Example #7
0
		public override bool IsVisible(IMenuItemContext context) {
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
				return false;
			var uiContext = context.Find<ITextEditorUIContext>();
			if (uiContext == null)
				return false;
			var nodes = uiContext.FileTab.Content.Nodes.ToArray();
			return nodes.Length == 1 && nodes[0] is BamlResourceElementNode;
		}
Example #8
0
		public override bool IsVisible(IMenuItemContext context) {
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID))
				return false;
			var uiContext = context.Find<IDocumentViewer>();
			if (uiContext == null)
				return false;
			var nodes = uiContext.DocumentTab.Content.Nodes.ToArray();
			return nodes.Length == 1 && nodes[0] is BamlResourceElementNode;
		}
Example #9
0
		public override void Execute(IMenuItemContext context) {
			var md = GetTokenObj(context);
			if (md != null) {
				try {
					Clipboard.SetText(string.Format("{0:X8}", md.MDToken.Raw));
				}
				catch (ExternalException) { }
			}
		}
Example #10
0
			internal static uint? GetReference(IMenuItemContext context, string guid) {
				if (context.CreatorObject.Guid != new Guid(guid))
					return null;
				var @ref = context.Find<CodeReference>();
				if (@ref != null && @ref.Reference is IMDTokenProvider)
					return ((IMDTokenProvider)@ref.Reference).MDToken.Raw;
				if (@ref != null && @ref.Reference is TokenReference)
					return ((TokenReference)@ref.Reference).Token;
				return null;
			}
Example #11
0
 public IEnumerable<CreatedMenuItem> Create(IMenuItemContext context)
 {
     foreach (var theme in themeManager.AllThemesSorted) {
         if (!themeManager.Settings.ShowAllThemes && !themeManager.IsHighContrast && theme.IsHighContrast)
             continue;
         var attr = new ExportMenuItemAttribute { Header = GetThemeHeaderName(theme) };
         var tmp = theme;
         var item = new MyMenuItem(ctx => themeManager.Theme = tmp, theme == themeManager.Theme);
         yield return new CreatedMenuItem(attr, item);
     }
 }
Example #12
0
		public static IList<MethodSourceStatement> GetStatements(IMenuItemContext context) {
			if (context == null)
				return null;
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID))
				return null;
			var uiContext = context.Find<IDocumentViewer>();
			if (uiContext == null)
				return null;
			var pos = context.Find<TextEditorPosition>();
			if (pos == null)
				return null;
			return GetStatements(uiContext, pos.Position);
		}
Example #13
0
 public override void Execute(IMenuItemContext context)
 {
     var tabs = tabCreators.SelectMany(a => a.Value.Create()).OrderBy(a => a.Order).ToArray();
     var dlg = new AppSettingsDlg(tabs);
     dlg.Owner = appWindow.MainWindow;
     bool saveSettings = dlg.ShowDialog() == true;
     var appRefreshSettings = new AppRefreshSettings();
     foreach (var tab in tabs)
         tab.OnClosed(saveSettings, appRefreshSettings);
     if (saveSettings) {
         foreach (var listener in listeners)
             listener.Value.OnSettingsModified(appRefreshSettings);
     }
 }
Example #14
0
 public override void Execute(IMenuItemContext context)
 {
     // Known problem: explorer can't show files in the .NET 2.0 GAC.
     var filename = GetFilename(context);
     if (filename == null)
         return;
     var args = string.Format("/select,{0}", filename);
     try {
         Process.Start(new ProcessStartInfo("explorer.exe", args));
     }
     catch (IOException) {
     }
     catch (Win32Exception) {
     }
 }
Example #15
0
		public override void Execute(IMenuItemContext context) {
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID))
				return;
			var asms = new List<IDsDocument>();
			foreach (var node in (context.Find<TreeNodeData[]>() ?? Array.Empty<TreeNodeData>())) {
				var file = GetDocument(node);
				if (file != null)
					asms.Add(file);
			}
			foreach (var asm in asms) {
				var peImage = asm.PEImage;
				if (peImage != null)
					peImage.UnsafeDisableMemoryMappedIO();
			}
		}
Example #16
0
		public override void Execute(IMenuItemContext context) {
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID))
				return;
			var asms = new List<IDnSpyFile>();
			foreach (var node in (context.Find<ITreeNodeData[]>() ?? new ITreeNodeData[0])) {
				var file = GetDnSpyFile(node);
				if (file != null)
					asms.Add(file);
			}
			foreach (var asm in asms) {
				var peImage = asm.PEImage;
				if (peImage != null)
					peImage.UnsafeDisableMemoryMappedIO();
			}
		}
Example #17
0
		TreeNodeData GetReference(IMenuItemContext context) {
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID))
				return null;

			var nodes = context.Find<TreeNodeData[]>();
			if (nodes == null || nodes.Length != 1)
				return null;

			var tokenNode = nodes[0] as IMDTokenNode;
			if (tokenNode != null && tokenNode.Reference != null) {
				if (!analyzerService.Value.CanFollowNode(nodes[0], useCodeRef))
					return null;
				return nodes[0];
			}

			return null;
		}
Example #18
0
		public void Initialize(IMenuItemContext context, ContextMenu menu) {
			if (context.OpenedFromKeyboard) {
				IScrollInfo scrollInfo = textEditor.TextArea.TextView;
				var pos = textEditor.TextArea.TextView.GetVisualPosition(textEditor.TextArea.Caret.Position, VisualYPosition.TextBottom);
				pos = new Point(pos.X - scrollInfo.HorizontalOffset, pos.Y - scrollInfo.VerticalOffset);

				menu.HorizontalOffset = pos.X;
				menu.VerticalOffset = pos.Y;
				ContextMenuService.SetPlacement(ctrl, PlacementMode.Relative);
				ContextMenuService.SetPlacementTarget(ctrl, textEditor.TextArea.TextView);
				menu.Closed += (s, e2) => {
					ctrl.ClearValue(ContextMenuService.PlacementProperty);
					ctrl.ClearValue(ContextMenuService.PlacementTargetProperty);
				};
			}
			else {
				ctrl.ClearValue(ContextMenuService.PlacementProperty);
				ctrl.ClearValue(ContextMenuService.PlacementTargetProperty);
			}
		}
		bool TrySetPlacement(IMenuItemContext context, ContextMenu menu) {
			if (!context.OpenedFromKeyboard)
				return false;

			double caretRight;
			if (hexView.Caret.IsValuesCaretPresent && hexView.Caret.Position.Position.ActiveColumn == HexColumnType.Values)
				caretRight = hexView.Caret.ValuesRight;
			else if (hexView.Caret.IsAsciiCaretPresent && hexView.Caret.Position.Position.ActiveColumn == HexColumnType.Ascii)
				caretRight = hexView.Caret.AsciiRight;
			else
				return false;

			var line = hexView.Caret.ContainingHexViewLine;
			menu.HorizontalOffset = Math.Min(Math.Max(0, caretRight - hexView.ViewportLeft), hexView.ViewportWidth);
			menu.VerticalOffset = Math.Min(Math.Max(0, line.TextBottom - hexView.ViewportTop), hexView.ViewportHeight);
			ContextMenuService.SetPlacement(ctrl, PlacementMode.Relative);
			ContextMenuService.SetPlacementTarget(ctrl, hexView.VisualElement);
			menu.Closed += (s, e2) => ClearPlacementProperties();
			return true;
		}
Example #20
0
		internal static IMDTokenProvider GetReference(IMenuItemContext context, Guid guid) {
			if (context.CreatorObject.Guid != guid)
				return null;

			var @ref = context.Find<TextReference>();
			if (@ref != null) {
				var realRef = @ref.Reference;
				if (realRef is Parameter)
					realRef = ((Parameter)realRef).ParamDef;
				if (realRef is IMDTokenProvider)
					return (IMDTokenProvider)realRef;
			}

			var nodes = context.Find<TreeNodeData[]>();
			if (nodes != null && nodes.Length != 0) {
				var node = nodes[0] as IMDTokenNode;
				if (node != null)
					return node.Reference;
			}

			return null;
		}
Example #21
0
			internal static IEnumerable<TreeNodeData> GetNodes(IMenuItemContext context, string guid) {
				if (context.CreatorObject.Guid != new Guid(guid))
					yield break;
				var nodes = context.Find<TreeNodeData[]>();
				if (nodes == null)
					yield break;
				foreach (var node in nodes) {
					var tokNode = node as IMDTokenNode;
					if (tokNode != null) {
						if (IsPublic(tokNode.Reference as IMemberRef))
							yield return node;
						continue;
					}

					var nsNode = node as NamespaceNode;
					if (nsNode != null) {
						if (!string.IsNullOrEmpty(nsNode.Name))
							yield return node;
						continue;
					}
				}
			}
Example #22
0
 public override bool IsEnabled(IMenuItemContext context)
 {
     return fileTreeView.CanSortTopNodes;
 }
Example #23
0
 /// <inheritdoc/>
 public override bool IsEnabled(IMenuItemContext context) => GetCommandTarget(context)?.CanExecute(group, cmdId) == CommandTargetStatus.Handled;
Example #24
0
 public override bool IsVisible(IMenuItemContext context) => !(GetEntryPoint(documentTabService, context) is null);
Example #25
0
 public override void Execute(IMenuItemContext context) => action(context);
Example #26
0
 public override bool IsVisible(IMenuItemContext context) => context.CreatorObject.Guid == new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID);
Example #27
0
 IEnumerable <IMemberRef> GetMemberRefs(IMenuItemContext context)
 {
     return(FilesCommand.GetMemberRefs(context, MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID, true, languageManager));
 }
Example #28
0
 public override void Execute(IMenuItemContext context)
 {
     fileTreeView.TreeView.CollapseUnusedNodes();
 }
Example #29
0
 public override void Execute(IMenuItemContext context) => analyzerSettings.SyntaxHighlight = !analyzerSettings.SyntaxHighlight;
Example #30
0
 public override bool IsVisible(IMenuItemContext context)
 {
     return GetFilename(context) != null;
 }
Example #31
0
		public override bool IsVisible(IMenuItemContext context) {
			if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
				return false;
			return CanExecute(context.Find<ITextEditorUIContext>());
		}
Example #32
0
 public override bool IsVisible(IMenuItemContext context)
 {
     return(GetMemberRefs(context).Any());
 }
Example #33
0
 static IEnumerable <IMemberRef> GetMemberRefs(IMenuItemContext context)
 {
     return(CodeCommand.GetMemberRefs(context, MenuConstants.GUIDOBJ_SEARCH_GUID));
 }
Example #34
0
 static IEnumerable <IMemberRef> GetMemberRefs(IMenuItemContext context)
 {
     return(GetMemberRefs(context, MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID));
 }
Example #35
0
 /// <inheritdoc/>
 public override void Execute(IMenuItemContext context) => GetCommandTarget(context)?.Execute(group, cmdId);
Example #36
0
 public override void Execute(IMenuItemContext context)
 {
     AboutHelpers.OpenWebPage(AboutHelpers.BUILD_URL, messageBoxManager);
 }
Example #37
0
 public override bool IsVisible(IMenuItemContext context) => GetReference(context) != null;
Example #38
0
 public override void Execute(IMenuItemContext context) => analyzerSettings.ShowToken = !analyzerSettings.ShowToken;
Example #39
0
 public override bool IsChecked(IMenuItemContext context) => analyzerSettings.SyntaxHighlight;
Example #40
0
 public override void Execute(IMenuItemContext context) => ExecuteInternal(analyzerService);
Example #41
0
 /// <summary>
 /// Returns the <see cref="ICommandTarget"/> or null if none
 /// </summary>
 /// <param name="context">Context</param>
 /// <returns></returns>
 protected abstract ICommandTarget GetCommandTarget(IMenuItemContext context);
Example #42
0
 IEnumerable <IMemberRef> GetMemberRefs(IMenuItemContext context)
 {
     return(GetMemberRefs(context, MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID, false, languageManager));
 }
Example #43
0
 public override bool IsChecked(IMenuItemContext context) => analyzerSettings.ShowToken;
Example #44
0
 public override bool IsVisible(IMenuItemContext context) => IsVisibleInternal(editCodeVMCreator, context);
Example #45
0
 public override bool IsEnabled(IMenuItemContext context) => CanExecuteInternal(analyzerService);
Example #46
0
 internal static bool IsVisibleInternal(EditCodeVMCreator editCodeVMCreator, IMenuItemContext context) => IsVisible(editCodeVMCreator, BodyCommandUtils.GetStatements(context));
Example #47
0
 public override bool IsChecked(IMenuItemContext context) => isChecked;
Example #48
0
 public override void Execute(IMenuItemContext context) => Execute(BodyCommandUtils.GetStatements(context));
Example #49
0
 protected sealed override DnHexBox CreateContext(IMenuItemContext context) => context.CreatorObject.Object as DnHexBox;
Example #50
0
 public override bool IsChecked(IMenuItemContext context) => cultureService.Language.Equals(langInfo);
Example #51
0
 public override void Execute(IMenuItemContext context)
 {
     Analyze(mainToolWindowManager, analyzerManager, languageManager.Language, GetMemberRefs(context));
 }
Example #52
0
 /// <inheritdoc/>
 public override bool IsVisible(IMenuItemContext context) => GetCommandTarget(context) != null;
Example #53
0
 static string GetFilename(IMenuItemContext context)
 {
     if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID))
         return null;
     var nodes = context.Find<ITreeNodeData[]>();
     if (nodes == null || nodes.Length != 1)
         return null;
     var fileNode = nodes[0] as IDnSpyFileNode;
     if (fileNode == null)
         return null;
     var filename = fileNode.DnSpyFile.Filename;
     if (!File.Exists(filename))
         return null;
     return filename;
 }
Example #54
0
 public override bool IsVisible(IMenuItemContext context)
 {
     return(GetNodes(context) != null);
 }
Example #55
0
		public override void Execute(IMenuItemContext context) {
			if (context.CreatorObject.Guid == new Guid(MenuConstants.GUIDOBJ_TEXTEDITORCONTROL_GUID))
				Execute(context.Find<ITextEditorUIContext>(), methodAnnotations);
		}
Example #56
0
 public override void Execute(IMenuItemContext context)
 {
     RemoveAnalyzeCommand.DeleteNodes(GetNodes(context));
 }
Example #57
0
 public override bool IsChecked(IMenuItemContext context)
 {
     return window.IsFullScreen;
 }
Example #58
0
 public override ImageReference?GetIcon(IMenuItemContext context) => editCodeVMCreator.GetIcon();
Example #59
0
 public override void Execute(IMenuItemContext context)
 {
     AboutHelpers.OpenWebPage(AboutHelpers.BASE_URL + @"issues", messageBoxManager);
 }
Example #60
0
 public override string GetHeader(IMenuItemContext context) => editCodeVMCreator.GetHeader();