コード例 #1
0
ファイル: HexTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		public static ITabSaver TryCreate(Lazy<IDocumentSaver> documentSaver, IDocumentTab tab) {
			var uiContext = tab.UIContext as HexViewDocumentTabUIContext;
			if (uiContext == null)
				return null;
			var buffer = uiContext.HexView.Buffer;
			return new HexTabSaver(documentSaver, buffer);
		}
コード例 #2
0
ファイル: NodeTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		NodeTabSaver(IMessageBoxService messageBoxService, IDocumentTab tab, IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDecompiler decompiler, IDocumentViewer documentViewer, DocumentTreeNodeData[] nodes) {
			this.messageBoxService = messageBoxService;
			this.tab = tab;
			this.documentTreeNodeDecompiler = documentTreeNodeDecompiler;
			this.decompiler = decompiler;
			this.documentViewer = documentViewer;
			this.nodes = nodes;
		}
コード例 #3
0
ファイル: SaveService.cs プロジェクト: manojdjoshi/dnSpy
		ITabSaver GetTabSaver(IDocumentTab tab) {
			if (tab == null)
				return null;
			foreach (var provider in tabSaverProviders) {
				var ts = provider.Create(tab);
				if (ts != null)
					return ts;
			}
			return null;
		}
コード例 #4
0
ファイル: HexTabSaver.cs プロジェクト: zz110/dnSpy
        public static ITabSaver TryCreate(Lazy <IDocumentSaver> documentSaver, IDocumentTab tab)
        {
            var uiContext = tab.UIContext as HexViewDocumentTabUIContext;

            if (uiContext == null)
            {
                return(null);
            }
            var buffer = uiContext.HexView.Buffer;

            return(new HexTabSaver(documentSaver, buffer));
        }
コード例 #5
0
ファイル: BamlTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		public static BamlTabSaver TryCreate(IDocumentTab tab, IMessageBoxService messageBoxService) {
			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, messageBoxService);
		}
コード例 #6
0
ファイル: NodeTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		public static NodeTabSaver TryCreate(IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDocumentTab tab, IMessageBoxService messageBoxService) {
			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(messageBoxService, tab, documentTreeNodeDecompiler, decompiler, uiContext, nodes);
		}
コード例 #7
0
 ITabSaver GetTabSaver(IDocumentTab tab)
 {
     if (tab == null)
     {
         return(null);
     }
     foreach (var provider in tabSaverProviders)
     {
         var ts = provider.Create(tab);
         if (ts != null)
         {
             return(ts);
         }
     }
     return(null);
 }
コード例 #8
0
        bool MustRefresh(IDocumentTab tab, IEnumerable <IDsDocument> documents)
        {
            var modules = new HashSet <IDsDocument>(documents);

            if (InModifiedModuleHelper.IsInModifiedModule(modules, tab.Content.Nodes))
            {
                return(true);
            }
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer != null && InModifiedModuleHelper.IsInModifiedModule(DocumentTreeView.DocumentService, modules, documentViewer.Content.ReferenceCollection.Select(a => a.Data.Reference)))
            {
                return(true);
            }

            return(false);
        }
コード例 #9
0
        public override void GoToLocation(IDocumentTab tab, MethodDef method, ModuleTokenId module, uint offset, bool newTab)
        {
            bool specialIpOffset;

            if (offset == EPILOG)
            {
                specialIpOffset = true;
                var mod = dbgMetadataService.Value.TryGetMetadata(module.Module, DbgLoadModuleOptions.AutoLoaded);
                if (mod?.ResolveToken(module.Token) is MethodDef md && md.Body is not null && md.Body.Instructions.Count > 0)
                {
                    offset = md.Body.Instructions[md.Body.Instructions.Count - 1].Offset;
                }
                else
                {
                    return;
                }
            }
コード例 #10
0
ファイル: TabCommands.cs プロジェクト: formylover/dnSpy-1
        static string GetHeader(int i, IDocumentTab 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)));
        }
コード例 #11
0
ファイル: HexTabSaver.cs プロジェクト: formylover/dnSpy-1
        public static ITabSaver TryCreate(Lazy <IDocumentSaver> documentSaver, IDocumentTab tab)
        {
            var uiContext = tab.UIContext as HexBoxDocumentTabUIContext;

            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));
        }
コード例 #12
0
        static string GetHeader(int i, IDocumentTab tab)
        {
            string s;

            if (i == 10)
            {
                s = "1_0";
            }
            else if (i > 10)
            {
                s = i.ToString();
            }
            else
            {
                s = $"_{i}";
            }
            return($"{s} {GetShortMenuItemHeader(tab.Content.Title)}");
        }
コード例 #13
0
        void OnNewTabContentShownDelay(IDocumentTab documentTab)
        {
            var newNodes = documentTab.Content.Nodes.ToArray();

            if (Equals(DocumentTreeView.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 (DocumentTreeView.TreeView.UIObject.IsKeyboardFocusWithin)
            {
                focusedElem = null;
            }
            bool tabGroupHasFocus = TabGroupService.TabGroups.Any(a => a.IsKeyboardFocusWithin);

            disableSelectionChangedEventCounter++;
            try {
                DocumentTreeView.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
                {
                    wpfFocusService.Focus(focusedElem);
                }
            }
        }
コード例 #14
0
ファイル: DockManager.cs プロジェクト: nopara73/Dock
        internal bool ValidateDocumentTab(IDocumentTab documentTab, IView targetView, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetView)
            {
            case IRootDock targetRoot:
            {
                return(DockIntoWindow(documentTab, targetView, action, operation, bExecute));
            }

            case IToolTab targetToolTab:
            {
                return(false);
            }

            case IDocumentTab targetDocumentTab:
            {
                return(DockIntoTab(documentTab, targetDocumentTab, action, operation, bExecute));
            }

            case ILayoutDock targetLayout:
            {
                return(false);
            }

            case IToolDock targetTool:
            {
                return(false);
            }

            case IDocumentDock targetTab:
            {
                return(DockIntoTab(documentTab, targetTab, action, operation, bExecute));
            }

            default:
            {
#if DEBUG
                Console.WriteLine($"Not supported type {targetView.GetType()}: {documentTab} -> {targetView}");
#endif
                return(false);
            }
            }
        }
コード例 #15
0
        bool GoTo(IDocumentTab 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);
        }
コード例 #16
0
        public void Close(IDocumentTab tab)
        {
            if (tab == null)
            {
                throw new ArgumentNullException(nameof(tab));
            }
            var impl = tab as TabContentImpl;

            if (impl == null)
            {
                throw new InvalidOperationException();
            }
            var g = GetTabGroup(impl);

            if (g == null)
            {
                throw new InvalidOperationException();
            }
            g.Close(impl);
        }
コード例 #17
0
        ToggleCreateBreakpointInfoResult GetToggleCreateBookmarkInfo(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            using (var info = GetLocation(tab, position)) {
                var locRes = info.locRes;
                var bms    = locRes == null?Array.Empty <Bookmark>() : GetBookmarks(locRes.Value);

                if (bms.Length != 0)
                {
                    return(new ToggleCreateBreakpointInfoResult(bookmarksService, ToggleCreateBookmarkKind.Delete, bms, null));
                }
                else
                {
                    if (locRes == null || locRes.Value.Location == null)
                    {
                        return(new ToggleCreateBreakpointInfoResult(bookmarksService, ToggleCreateBookmarkKind.None, Array.Empty <Bookmark>(), null));
                    }
                    return(new ToggleCreateBreakpointInfoResult(bookmarksService, ToggleCreateBookmarkKind.Add, Array.Empty <Bookmark>(), info.TakeOwnership(locRes.Value.Location)));
                }
            }
        }
コード例 #18
0
        static ListView FindListView(IDocumentTab 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);
        }
コード例 #19
0
ファイル: BamlTabSaver.cs プロジェクト: andrew-p0/dnSpy
        public static BamlTabSaver TryCreate(IDocumentTab tab, IMessageBoxService messageBoxService)
        {
            if (tab.IsAsyncExecInProgress)
            {
                return(null);
            }
            if (tab.UIContext is not IDocumentViewer uiContext)
            {
                return(null);
            }
            var nodes = tab.Content.Nodes.ToArray();

            if (nodes.Length != 1)
            {
                return(null);
            }
            if (nodes[0] is not BamlResourceElementNode bamlNode)
            {
                return(null);
            }
            return(new BamlTabSaver(tab, bamlNode, uiContext, messageBoxService));
        }
コード例 #20
0
        public override TextViewBookmarkLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }

            // A bookmark should be set on the current line if possible, and the current position
            // isn't necessarily at the start of the line.
            int startPos = position.Position.GetContainingLine().Start.Position;

            foreach (var data in documentViewer.ReferenceCollection.FindFrom(startPos))
            {
                if (!data.Data.IsDefinition)
                {
                    continue;
                }
                var def = data.Data.Reference as IMemberDef;
                if (def == null)
                {
                    continue;
                }
                var span = data.Span;

                var snapshot = textView.TextSnapshot;
                if (span.End > snapshot.Length)
                {
                    return(null);
                }

                var moduleId = moduleIdProvider.Create(def.Module);
                var location = dotNetBookmarkLocationFactory.Value.CreateTokenLocation(moduleId, def.MDToken.Raw);
                return(new TextViewBookmarkLocationResult(location, new SnapshotSpan(snapshot, span)));
            }

            return(null);
        }
コード例 #21
0
        LocationsResult GetLocations(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            var allLocations = new List <DbgCodeLocation>();
            var textView     = GetTextView(tab);

            if (textView == null)
            {
                return(new LocationsResult(dbgManager, null, allLocations));
            }
            var pos = position ?? textView.Caret.Position.VirtualBufferPosition;

            if (pos.Position.Snapshot != textView.TextSnapshot)
            {
                throw new ArgumentException();
            }
            DbgTextViewBreakpointLocationResult?res = null;

            foreach (var loc in dbgTextViewCodeLocationService.Value.CreateLocation(tab, textView, pos))
            {
                UpdateResult(allLocations, textView, ref res, loc, useIfSameSpan: false);
            }
            SnapshotSpan span;

            if (res != null)
            {
                var resSpan  = res.Value.Span.SnapshotSpan;
                var newStart = Min(pos.Position, resSpan.Start);
                var newEnd   = Max(pos.Position, resSpan.End);
                span = new SnapshotSpan(newStart, newEnd);
            }
            else
            {
                span = new SnapshotSpan(pos.Position, new SnapshotPoint(pos.Position.Snapshot, pos.Position.Snapshot.Length));
            }
            // This one has higher priority since it already exists (eg. could be a stack frame BP location)
            UpdateResult(allLocations, textView, ref res, breakpointMarker.Value.GetLocations(textView, span), useIfSameSpan: true);
            return(new LocationsResult(dbgManager, res, allLocations));
        }
コード例 #22
0
        public override DbgTextViewBreakpointLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();

            if (methodDebugService == null)
            {
                return(null);
            }
            var methodStatements = methodDebugService.FindByTextPosition(position.Position, FindByTextPositionOptions.None);

            if (methodStatements.Count == 0)
            {
                return(null);
            }
            var textSpan = methodStatements[0].Statement.TextSpan;
            var snapshot = textView.TextSnapshot;

            if (textSpan.End > snapshot.Length)
            {
                return(null);
            }
            var span      = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length)));
            var locations = new DbgCodeLocation[methodStatements.Count];

            for (int i = 0; i < methodStatements.Count; i++)
            {
                var statement = methodStatements[i];
                var moduleId  = moduleIdProvider.Create(statement.Method.Module);
                locations[i] = dbgDotNetCodeLocationFactory.Value.Create(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start);
            }
            return(new DbgTextViewBreakpointLocationResult(locations, span));
        }
        public override TextViewBookmarkLocationResult?CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position)
        {
            var documentViewer = tab.TryGetDocumentViewer();

            if (documentViewer == null)
            {
                return(null);
            }
            var methodDebugService = documentViewer.GetMethodDebugService();

            if (methodDebugService == null)
            {
                return(null);
            }
            // A bookmark should be set on the current line if possible, and the current position
            // isn't necessarily at the start of the line.
            var startPos         = position.Position.GetContainingLine().Start;
            var methodStatements = methodDebugService.FindByTextPosition(startPos, FindByTextPositionOptions.None);

            if (methodStatements.Count == 0)
            {
                return(null);
            }
            var textSpan = methodStatements[0].Statement.TextSpan;
            var snapshot = textView.TextSnapshot;

            if (textSpan.End > snapshot.Length)
            {
                return(null);
            }
            var span = new VirtualSnapshotSpan(new SnapshotSpan(snapshot, new Span(textSpan.Start, textSpan.Length)));

            var statement = methodStatements[0];
            var moduleId  = moduleIdProvider.Create(statement.Method.Module);
            var location  = dotNetBookmarkLocationFactory.Value.CreateMethodBodyLocation(moduleId, statement.Method.MDToken.Raw, statement.Statement.ILSpan.Start);

            return(new TextViewBookmarkLocationResult(location, span));
        }
コード例 #24
0
        public static BamlTabSaver TryCreate(IDocumentTab tab, IMessageBoxService messageBoxService)
        {
            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, messageBoxService));
        }
コード例 #25
0
        ToggleCreateBreakpointInfoResult GetToggleCreateBreakpointInfo(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            using (var info = GetLocations(tab, position)) {
                var locRes = info.locRes;
                var bps    = locRes == null?Array.Empty <DbgCodeBreakpoint>() : GetBreakpoints(locRes.Value);

                if (bps.Length != 0)
                {
                    if (bps.All(a => a.IsEnabled))
                    {
                        return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.Delete, bps, Array.Empty <DbgCodeLocation>()));
                    }
                    return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.Enable, bps, Array.Empty <DbgCodeLocation>()));
                }
                else
                {
                    if (locRes == null || locRes.Value.Locations.Length == 0)
                    {
                        return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.None, Array.Empty <DbgCodeBreakpoint>(), Array.Empty <DbgCodeLocation>()));
                    }
                    return(new ToggleCreateBreakpointInfoResult(dbgManager, ToggleCreateBreakpointKind.Add, Array.Empty <DbgCodeBreakpoint>(), locRes.Value.Locations.Select(a => a.Clone()).ToArray()));
                }
            }
        }
コード例 #26
0
        LocationsResult GetLocation(IDocumentTab tab, VirtualSnapshotPoint?position)
        {
            var allLocations = new List <BookmarkLocation>();
            var textView     = GetTextView(tab);

            if (textView == null)
            {
                return(new LocationsResult(bookmarksService, null, allLocations));
            }
            var pos = position ?? textView.Caret.Position.VirtualBufferPosition;

            if (pos.Position.Snapshot != textView.TextSnapshot)
            {
                throw new ArgumentException();
            }
            TextViewBookmarkLocationResult?res = null;

            foreach (var lz in textViewBookmarkLocationProviders)
            {
                var result = lz.Value.CreateLocation(tab, textView, pos);
                if (result?.Location == null)
                {
                    continue;
                }
                allLocations.Add(result.Value.Location);
                if (result.Value.Span.Snapshot != textView.TextSnapshot)
                {
                    continue;
                }
                if (res == null || result.Value.Span.Start < res.Value.Span.Start)
                {
                    res = result;
                }
            }
            return(new LocationsResult(bookmarksService, res, allLocations));
        }
コード例 #27
0
ファイル: SaveService.cs プロジェクト: manojdjoshi/dnSpy
		public string GetMenuHeader(IDocumentTab tab) {
			var ts = GetTabSaver(tab);
			return (ts == null ? null : ts.MenuHeader) ?? dnSpy_Resources.Button_Save;
		}
コード例 #28
0
ファイル: SaveService.cs プロジェクト: manojdjoshi/dnSpy
		public bool CanSave(IDocumentTab tab) {
			var ts = GetTabSaver(tab);
			return ts != null && ts.CanSave;
		}
コード例 #29
0
ファイル: DebugService.cs プロジェクト: manojdjoshi/dnSpy
		void JumpToCurrentStatement(IDocumentTab 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 IDocumentViewer);
					if (e.Success && !e.HasMovedCaret) {
						MoveCaretToCurrentStatement(e.Tab.UIContext as IDocumentViewer, canRefreshMethods);
						e.HasMovedCaret = true;
					}
				});
			}));
		}
コード例 #30
0
 public BookmarkDocumentImpl(IDocumentTab tab) => this.tab = tab ?? throw new ArgumentNullException(nameof(tab));
コード例 #31
0
 public abstract IEnumerable <DbgTextViewBreakpointLocationResult> CreateLocation(IDocumentTab tab, ITextView textView, VirtualSnapshotPoint position);
コード例 #32
0
 public abstract void GoToLocation(IDocumentTab tab, MethodDef method, in ModuleTokenId module, uint offset);
コード例 #33
0
ファイル: HexTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		public ITabSaver Create(IDocumentTab tab) => HexTabSaver.TryCreate(documentSaver, tab);
コード例 #34
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="result">Result></param>
 /// <param name="tab">Tab</param>
 public ShowTabContentEventArgs(ShowTabContentResult result, IDocumentTab tab)
 {
     Result        = result;
     HasMovedCaret = false;
     Tab           = tab;
 }
コード例 #35
0
ファイル: SerializedTabs.cs プロジェクト: manojdjoshi/dnSpy
		public static SerializedTab TryCreate(IDocumentTabContentFactoryService documentTabContentFactoryService, IDocumentTab tab) {
			var contentSect = new SettingsSection(CONTENT_SECTION);
			var guid = documentTabContentFactoryService.Serialize(tab.Content, contentSect);
			if (guid == null)
				return null;
			contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

			var uiSect = new SettingsSection(UI_SECTION);
			tab.UIContext.SerializeUIState(uiSect, tab.UIContext.CreateUIState());

			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 autoLoadedDocuments = new List<DsDocumentInfo>();
			foreach (var f in GetAutoLoadedDocuments(tab.Content.Nodes))
				autoLoadedDocuments.Add(f);

			return new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedDocuments);
		}
コード例 #36
0
ファイル: TabVM.cs プロジェクト: manojdjoshi/dnSpy
		public TabVM(TabsVM owner, IDocumentTab tab) {
			Owner = owner;
			Tab = tab;
			var node = tab.Content.Nodes.FirstOrDefault().GetTopNode();
			document = node?.Document;
		}
コード例 #37
0
ファイル: DebugService.cs プロジェクト: manojdjoshi/dnSpy
		public void JumpToCurrentStatement(IDocumentTab tab) => JumpToCurrentStatement(tab, true);
コード例 #38
0
ファイル: SerializedTabs.cs プロジェクト: zquans/dnSpy
        public static SerializedTab TryCreate(IDocumentTabContentFactoryService documentTabContentFactoryService, IDocumentTab tab)
        {
            var contentSect = new SettingsSection(CONTENT_SECTION);
            var guid        = documentTabContentFactoryService.Serialize(tab.Content, contentSect);

            if (guid == null)
            {
                return(null);
            }
            contentSect.Attribute(CONTENT_GUID_ATTR, guid.Value);

            var uiSect = new SettingsSection(UI_SECTION);

            tab.UIContext.SerializeUIState(uiSect, tab.UIContext.CreateUIState());

            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 autoLoadedDocuments = new List <DsDocumentInfo>();

            foreach (var f in GetAutoLoadedDocuments(tab.Content.Nodes))
            {
                autoLoadedDocuments.Add(f);
            }

            return(new SerializedTab(contentSect, tabUISect, uiSect, paths, autoLoadedDocuments));
        }
コード例 #39
0
ファイル: SaveService.cs プロジェクト: manojdjoshi/dnSpy
		public void Save(IDocumentTab tab) {
			var ts = GetTabSaver(tab);
			if (ts == null || !ts.CanSave)
				return;
			ts.Save();
		}
コード例 #40
0
ファイル: NodeTabSaver.cs プロジェクト: zhanggvi/dnSpy
 public ITabSaver Create(IDocumentTab tab) => NodeTabSaver.TryCreate(documentTreeNodeDecompiler, tab, messageBoxService);
コード例 #41
0
 public override void GoToLocation(IDocumentTab tab, MethodDef method, in ModuleTokenId module, uint offset)
コード例 #42
0
ファイル: NodeTabSaver.cs プロジェクト: zhanggvi/dnSpy
        public static NodeTabSaver TryCreate(IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDocumentTab tab, IMessageBoxService messageBoxService)
        {
            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(messageBoxService, tab, documentTreeNodeDecompiler, decompiler, uiContext, nodes));
        }
コード例 #43
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="result">Result></param>
		/// <param name="tab">Tab</param>
		public ShowTabContentEventArgs(ShowTabContentResult result, IDocumentTab tab) {
			Result = result;
			HasMovedCaret = false;
			Tab = tab;
		}
コード例 #44
0
ファイル: AnalyzerService.cs プロジェクト: manojdjoshi/dnSpy
		bool GoTo(IDocumentTab 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;
		}
コード例 #45
0
ファイル: BamlTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		BamlTabSaver(IDocumentTab tab, BamlResourceElementNode bamlNode, IDocumentViewer documentViewer, IMessageBoxService messageBoxService) {
			this.tab = tab;
			this.bamlNode = bamlNode;
			this.documentViewer = documentViewer;
			this.messageBoxService = messageBoxService;
		}
コード例 #46
0
ファイル: GoToTokenCommand.cs プロジェクト: manojdjoshi/dnSpy
		static ITokenResolver GetResolver(IDocumentTabService documentTabService, out IDocumentTab tab) {
			tab = documentTabService.ActiveTab;
			if (tab == null)
				return null;
			return tab.Content.Nodes.FirstOrDefault().GetModule();
		}
コード例 #47
0
 ITextView GetTextView(IDocumentTab tab) => (tab?.UIContext as IDocumentViewer)?.TextView;
コード例 #48
0
ファイル: SearchService.cs プロジェクト: manojdjoshi/dnSpy
		bool GoTo(IDocumentTab 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;
		}
コード例 #49
0
ファイル: BamlTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		public ITabSaver Create(IDocumentTab tab) => BamlTabSaver.TryCreate(tab, messageBoxService);
コード例 #50
0
ファイル: NodeTabSaver.cs プロジェクト: manojdjoshi/dnSpy
		public ITabSaver Create(IDocumentTab tab) => NodeTabSaver.TryCreate(documentTreeNodeDecompiler, tab, messageBoxService);