bool GoTo(IFileTab tab, MethodDef method, uint?ilOffset, object @ref) { if (method == null || ilOffset == null) { return(false); } var uiContext = tab.TryGetTextEditorUIContext(); if (uiContext == null) { return(false); } var cm = uiContext.GetCodeMappings(); var mapping = cm.Find(method, ilOffset.Value); if (mapping == null) { return(false); } var location = mapping.StartPosition; var loc = FindLocation(uiContext.GetCodeReferences(location.Line, location.Column), mapping.EndPosition, @ref); if (loc == null) { loc = new TextEditorLocation(location.Line, location.Column); } uiContext.ScrollAndMoveCaretTo(loc.Value.Line, loc.Value.Column); return(true); }
public void FollowReference(object @ref, bool newTab, bool setFocus, Action <ShowTabContentEventArgs> onShown) { if (@ref == null) { return; } IFileTab tab = ActiveTabContentImpl; var sourceTab = tab; if (tab == null) { tab = SafeActiveTabContentImpl; } else if (newTab) { var g = TabGroupManager.ActiveTabGroup; Debug.Assert(g != null); if (g == null) { return; } tab = OpenEmptyTab(g); } tab.FollowReference(@ref, sourceTab == null ? null : sourceTab.Content, onShown); if (setFocus) { SetFocus(tab); } }
internal void OnNewTabContentShown(IFileTab fileTab) { if (fileTab == null) { return; } if (!isTreeViewVisible) { return; } if (!tabsLoaded) { return; } if (disableSelectTreeNodes > 0) { return; } if (fileTab != ActiveTabContentImpl) { return; } Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { if (fileTab == ActiveTabContentImpl) { OnNewTabContentShownDelay(fileTab); } })); }
BamlTabSaver(IFileTab tab, BamlResourceElementNode bamlNode, ITextEditorUIContext uiContext, IMessageBoxManager messageBoxManager) { this.tab = tab; this.bamlNode = bamlNode; this.uiContext = uiContext; this.messageBoxManager = messageBoxManager; }
public void Save(IFileTab tab) { var ts = GetTabSaver(tab); if (ts == null || !ts.CanSave) return; ts.Save(); }
public TabVM(TabsVM owner, IFileTab tab) { this.owner = owner; this.tab = tab; var node = tab.Content.Nodes.FirstOrDefault().GetTopNode(); this.file = node == null ? null : node.DnSpyFile; }
bool GoTo(IFileTab tab, MethodDef method, uint?ilOffset, object @ref) { if (method == null || ilOffset == null) { return(false); } var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null) { return(false); } var methodDebugService = documentViewer.GetMethodDebugService(); var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset.Value); if (methodStatement == null) { return(false); } var textSpan = methodStatement.Value.Statement.TextSpan; var loc = FindLocation(documentViewer.Content.ReferenceCollection.FindFrom(textSpan.Start), documentViewer.TextView.TextSnapshot, methodStatement.Value.Statement.TextSpan.End, @ref); if (loc == null) { loc = textSpan.Start; } documentViewer.MoveCaretToPosition(loc.Value); return(true); }
BamlTabSaver(IFileTab tab, BamlResourceElementNode bamlNode, IDocumentViewer documentViewer, IMessageBoxManager messageBoxManager) { this.tab = tab; this.bamlNode = bamlNode; this.documentViewer = documentViewer; this.messageBoxManager = messageBoxManager; }
NodeTabSaver(IMessageBoxManager messageBoxManager, IFileTab tab, IFileTreeNodeDecompiler fileTreeNodeDecompiler, ILanguage language, ITextEditorUIContext uiContext, IFileTreeNodeData[] nodes) { this.messageBoxManager = messageBoxManager; this.tab = tab; this.fileTreeNodeDecompiler = fileTreeNodeDecompiler; this.language = language; this.uiContext = uiContext; this.nodes = nodes; }
NodeTabSaver(IMessageBoxManager messageBoxManager, IFileTab tab, IFileTreeNodeDecompiler fileTreeNodeDecompiler, IDecompiler decompiler, IDocumentViewer documentViewer, IFileTreeNodeData[] nodes) { this.messageBoxManager = messageBoxManager; this.tab = tab; this.fileTreeNodeDecompiler = fileTreeNodeDecompiler; this.decompiler = decompiler; this.documentViewer = documentViewer; this.nodes = nodes; }
static ITokenResolver GetResolver(IFileTabManager fileTabManager, out IFileTab tab) { tab = fileTabManager.ActiveTab; if (tab == null) { return(null); } return(tab.Content.Nodes.FirstOrDefault().GetModule()); }
public void Save(IFileTab tab) { var ts = GetTabSaver(tab); if (ts == null || !ts.CanSave) { return; } ts.Save(); }
public static ITabSaver TryCreate(Lazy<IDocumentSaver> documentSaver, IFileTab tab) { var uiContext = tab.UIContext as HexBoxFileTabUIContext; if (uiContext == null) return null; var doc = uiContext.DnHexBox.Document as AsmEdHexDocument; Debug.Assert(doc != null); if (doc == null) return null; return new HexTabSaver(documentSaver, doc); }
ITabSaver GetTabSaver(IFileTab tab) { if (tab == null) return null; foreach (var creator in creators) { var ts = creator.Create(tab); if (ts != null) return ts; } return null; }
public static BamlTabSaver TryCreate(IFileTab tab, IMessageBoxManager messageBoxManager) { var uiContext = tab.UIContext as ITextEditorUIContext; if (uiContext == null) return null; var nodes = tab.Content.Nodes.ToArray(); if (nodes.Length != 1) return null; var bamlNode = nodes[0] as BamlResourceElementNode; if (bamlNode == null) return null; return new BamlTabSaver(tab, bamlNode, uiContext, messageBoxManager); }
ITabSaver GetTabSaver(IFileTab tab) { if (tab == null) { return(null); } foreach (var provider in tabSaverProviders) { var ts = provider.Create(tab); if (ts != null) { return(ts); } } return(null); }
ITabSaver GetTabSaver(IFileTab tab) { if (tab == null) { return(null); } foreach (var creator in creators) { var ts = creator.Create(tab); if (ts != null) { return(ts); } } return(null); }
bool MustRefresh(IFileTab tab, IEnumerable <IDnSpyFile> files) { var modules = new HashSet <IDnSpyFile>(files); if (InModifiedModuleHelper.IsInModifiedModule(modules, tab.Content.Nodes)) { return(true); } var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer != null && InModifiedModuleHelper.IsInModifiedModule(FileTreeView.FileManager, modules, documentViewer.Content.ReferenceCollection.Select(a => a.Data.Reference))) { return(true); } return(false); }
bool MustRefresh(IFileTab tab, IEnumerable <IDnSpyFile> files) { var modules = new HashSet <IDnSpyFile>(files); if (InModifiedModuleHelper.IsInModifiedModule(modules, tab.Content.Nodes)) { return(true); } var uiContext = tab.TryGetTextEditorUIContext(); if (uiContext != null && InModifiedModuleHelper.IsInModifiedModule(FileTreeView.FileManager, modules, uiContext.References)) { return(true); } return(false); }
public static ITabSaver TryCreate(Lazy <IDocumentSaver> documentSaver, IFileTab tab) { var uiContext = tab.UIContext as HexBoxFileTabUIContext; if (uiContext == null) { return(null); } var doc = uiContext.DnHexBox.Document as AsmEdHexDocument; Debug.Assert(doc != null); if (doc == null) { return(null); } return(new HexTabSaver(documentSaver, doc)); }
static string GetHeader(int i, IFileTab tab) { string s; if (i == 10) { s = "1_0"; } else if (i > 10) { s = i.ToString(); } else { s = string.Format("_{0}", i); } return(string.Format("{0} {1}", s, GetShortMenuItemHeader(tab.Content.Title))); }
void OnNewTabContentShownDelay(IFileTab fileTab) { var newNodes = fileTab.Content.Nodes.ToArray(); if (Equals(fileTreeView.TreeView.SelectedItems, newNodes)) { return; } // The treeview steals the focus so remember the current focused element. Don't restore // the focus if it's a node in the treeview. var focusedElem = Keyboard.FocusedElement; if (((UIElement)fileTreeView.TreeView.UIObject).IsKeyboardFocusWithin) { focusedElem = null; } bool tabGroupHasFocus = tabGroupManager.TabGroups.Any(a => a.IsKeyboardFocusWithin); disableSelectionChangedEventCounter++; try { fileTreeView.TreeView.SelectItems(newNodes); } finally { disableSelectionChangedEventCounter--; } if (focusedElem != null && Keyboard.FocusedElement != focusedElem) { if (tabGroupHasFocus) { var tab = ActiveTabContentImpl; Debug.Assert(tab != null); if (tab != null) { tab.TrySetFocus(); } } else { wpfFocusManager.Focus(focusedElem); } } }
bool GoTo(IFileTab tab, MethodDef method, uint ilOffset) { var documentViewer = tab.TryGetDocumentViewer(); if (documentViewer == null || method == null) { return(false); } var methodDebugService = documentViewer.GetMethodDebugService(); var methodStatement = methodDebugService.FindByCodeOffset(method, ilOffset); if (methodStatement == null) { return(false); } documentViewer.MoveCaretToPosition(methodStatement.Value.Statement.TextSpan.Start); return(true); }
public void Close(IFileTab tab) { if (tab == null) { throw new ArgumentNullException(); } var impl = tab as TabContentImpl; if (impl == null) { throw new InvalidOperationException(); } var g = GetTabGroup(impl); if (g == null) { throw new InvalidOperationException(); } g.Close(impl); }
static ListView FindListView(IFileTab tab) { var o = tab.UIContext.UIObject as DependencyObject; while (o != null) { var lv = o as ListView; if (lv != null && InitDataTemplateAP.GetInitialize(lv)) { return(lv); } var children = UIUtils.GetChildren(o).ToArray(); if (children.Length != 1) { return(null); } o = children[0]; } return(null); }
bool GoTo(IFileTab tab, MethodDef method, uint ilOffset) { var uiContext = tab.TryGetTextEditorUIContext(); if (uiContext == null || method == null) { return(false); } var cm = uiContext.GetCodeMappings(); var mapping = cm.Find(method, ilOffset); if (mapping == null) { return(false); } var location = mapping.StartPosition; uiContext.ScrollAndMoveCaretTo(location.Line, location.Column); return(true); }
public static BamlTabSaver TryCreate(IFileTab tab, IMessageBoxManager messageBoxManager) { var uiContext = tab.UIContext as IDocumentViewer; if (uiContext == null) { return(null); } var nodes = tab.Content.Nodes.ToArray(); if (nodes.Length != 1) { return(null); } var bamlNode = nodes[0] as BamlResourceElementNode; if (bamlNode == null) { return(null); } return(new BamlTabSaver(tab, bamlNode, uiContext, messageBoxManager)); }
public static SerializedTab TryCreate(IFileTabContentFactoryManager creator, IFileTab tab) { var contentSect = new SettingsSection(CONTENT_SECTION); var guid = creator.Serialize(tab.Content, contentSect); if (guid == null) return null; contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value); var uiSect = new SettingsSection(UI_SECTION); tab.UIContext.SaveSerialized(uiSect, tab.UIContext.Serialize()); var tabUISect = new SettingsSection(TAB_UI_SECTION); tab.SerializeUI(tabUISect); var paths = new List<SerializedPath>(); foreach (var node in tab.Content.Nodes) paths.Add(SerializedPath.Create(node)); var autoLoadedFiles = new List<DnSpyFileInfo>(); foreach (var f in GetAutoLoadedFiles(tab.Content.Nodes)) autoLoadedFiles.Add(f); return new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedFiles); }
public static NodeTabSaver TryCreate(IFileTreeNodeDecompiler fileTreeNodeDecompiler, IFileTab tab, IMessageBoxManager messageBoxManager) { if (tab.IsAsyncExecInProgress) { return(null); } var uiContext = tab.UIContext as IDocumentViewer; if (uiContext == null) { return(null); } var decompiler = (tab.Content as IDecompilerTabContent)?.Decompiler; if (decompiler == null) { return(null); } var nodes = tab.Content.Nodes.ToArray(); if (nodes.Length == 0) { return(null); } return(new NodeTabSaver(messageBoxManager, tab, fileTreeNodeDecompiler, decompiler, uiContext, nodes)); }
public ITabSaver Create(IFileTab tab) => NodeTabSaver.TryCreate(fileTreeNodeDecompiler, tab, messageBoxManager);
bool GoTo(IFileTab tab, MethodDef method, uint ilOffset) { var uiContext = tab.TryGetTextEditorUIContext(); if (uiContext == null || method == null) return false; var cm = uiContext.GetCodeMappings(); var mapping = cm.Find(method, ilOffset); if (mapping == null) return false; var location = mapping.StartPosition; uiContext.ScrollAndMoveCaretTo(location.Line, location.Column); return true; }
/// <summary> /// Returns the tab's <see cref="IDocumentViewer"/> or null if it's not visible /// </summary> /// <param name="tab">Tab</param> /// <returns></returns> public static IDocumentViewer TryGetDocumentViewer(this IFileTab tab) => tab?.UIContext as IDocumentViewer;
public ITabSaver Create(IFileTab tab) { return BamlTabSaver.TryCreate(tab, messageBoxManager); }
void JumpToCurrentStatement(IFileTab tab, bool canRefreshMethods) { if (tab == null) return; if (currentMethod == null) return; // The file could've been added lazily to the list so add a short delay before we select it Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { tab.FollowReference(currentMethod, false, e => { Debug.Assert(e.Tab == tab); Debug.Assert(e.Tab.UIContext is ITextEditorUIContext); if (e.Success && !e.HasMovedCaret) { MoveCaretToCurrentStatement(e.Tab.UIContext as ITextEditorUIContext, canRefreshMethods); e.HasMovedCaret = true; } }); })); }
public ITabSaver Create(IFileTab tab) => HexTabSaver.TryCreate(documentSaver, tab);
public void JumpToCurrentStatement(IFileTab tab) { JumpToCurrentStatement(tab, true); }
public static NodeTabSaver TryCreate(IFileTreeNodeDecompiler fileTreeNodeDecompiler, IFileTab tab, IMessageBoxManager messageBoxManager) { if (tab.IsAsyncExecInProgress) return null; var uiContext = tab.UIContext as ITextEditorUIContext; if (uiContext == null) return null; var langContent = tab.Content as ILanguageTabContent; var lang = langContent == null ? null : langContent.Language; if (lang == null) return null; var nodes = tab.Content.Nodes.ToArray(); if (nodes.Length == 0) return null; return new NodeTabSaver(messageBoxManager, tab, fileTreeNodeDecompiler, lang, uiContext, nodes); }
public ITabSaver Create(IFileTab tab) { return NodeTabSaver.TryCreate(fileTreeNodeDecompiler, tab, messageBoxManager); }
public ITabSaver Create(IFileTab tab) { return HexTabSaver.TryCreate(documentSaver, tab); }
static ITokenResolver GetResolver(IFileTabManager fileTabManager, out IFileTab tab) { tab = fileTabManager.ActiveTab; if (tab == null) return null; return tab.Content.Nodes.FirstOrDefault().GetModule(); }
bool GoTo(IFileTab tab, MethodDef method, uint? ilOffset, object @ref) { if (method == null || ilOffset == null) return false; var uiContext = tab.TryGetTextEditorUIContext(); if (uiContext == null) return false; var cm = uiContext.GetCodeMappings(); var mapping = cm.Find(method, ilOffset.Value); if (mapping == null) return false; var location = mapping.StartPosition; var loc = FindLocation(uiContext.GetCodeReferences(location.Line, location.Column), mapping.EndPosition, @ref); if (loc == null) loc = new TextEditorLocation(location.Line, location.Column); uiContext.ScrollAndMoveCaretTo(loc.Value.Line, loc.Value.Column); return true; }
public ITabSaver Create(IFileTab tab) => BamlTabSaver.TryCreate(tab, messageBoxManager);
/// <summary> /// Constructor /// </summary> /// <param name="success">See <see cref="Success"/></param> /// <param name="tab">Tab</param> public ShowTabContentEventArgs(bool success, IFileTab tab) { this.Success = success; this.HasMovedCaret = false; this.Tab = tab; }
public bool CanSave(IFileTab tab) { var ts = GetTabSaver(tab); return ts != null && ts.CanSave; }
public string GetMenuHeader(IFileTab tab) { var ts = GetTabSaver(tab); return (ts == null ? null : ts.MenuHeader) ?? dnSpy_Resources.Button_Save; }