コード例 #1
0
		public override void OnShow(IShowContext ctx) {
			// Get the real type, created by CreateUIContext() above.
			var uiCtx = (AssemblyChildNodeUIContext)ctx.UIContext;

			// You could initialize some stuff, eg. update its DataContext or whatever
			uiCtx.Initialize("some input"); // pretend we need to initialize something
		}
コード例 #2
0
        public override void OnShowAsync(IShowContext ctx, IAsyncShowResult result)
        {
            var decompileContext = (DecompileContext)ctx.Tag;
            var documentViewer   = (IDocumentViewer)ctx.UIContext;

            var contentType = decompileContext.DecompileNodeContext.ContentType;

            if (contentType == null)
            {
                var contentTypeString = decompileContext.DecompileNodeContext.ContentTypeString;
                if (contentTypeString == null)
                {
                    contentTypeString = ContentTypesHelper.TryGetContentTypeStringByExtension(decompileContext.DecompileNodeContext.Decompiler.FileExtension) ?? ContentTypes.PlainText;
                }
                contentType = decompileDocumentTabContentFactory.ContentTypeRegistryService.GetContentType(contentTypeString) ??
                              decompileDocumentTabContentFactory.ContentTypeRegistryService.GetContentType(ContentTypes.Text) ??
                              decompileDocumentTabContentFactory.ContentTypeRegistryService.UnknownContentType;
            }

            DocumentViewerContent content;

            if (result.IsCanceled)
            {
                var docViewContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
                docViewContentFactory.Output.Write(dnSpy_Resources.DecompilationCanceled, BoxedTextColor.Error);
                content = docViewContentFactory.CreateContent(documentViewer, contentType);
            }
            else if (result.Exception != null)
            {
                var docViewContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
                docViewContentFactory.Output.Write(dnSpy_Resources.DecompilationException, BoxedTextColor.Error);
                docViewContentFactory.Output.WriteLine();
                docViewContentFactory.Output.Write(result.Exception.ToString(), BoxedTextColor.Text);
                content = docViewContentFactory.CreateContent(documentViewer, contentType);
            }
            else
            {
                content = decompileContext.CachedContent;
                if (content == null)
                {
                    bool canBeCached = decompileContext.DocumentViewerContentFactory.Output.CanBeCached;
                    content = decompileContext.DocumentViewerContentFactory.CreateContent(documentViewer, contentType);
                    if (canBeCached)
                    {
                        decompileDocumentTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Decompiler, nodes, content, contentType);
                    }
                }
            }

            if (result.CanShowOutput)
            {
                WasNewContent = documentViewer.SetContent(content, contentType);
            }
            else
            {
                WasNewContent = false;
            }
        }
コード例 #3
0
        public override void OnShow(IShowContext ctx)
        {
            UpdateLanguage();
            var decompileContext = CreateDecompileContext(ctx);

            decompileContext.CachedContent = decompileDocumentTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Decompiler, nodes, out var contentType);
            decompileContext.DecompileNodeContext.ContentType = contentType;
            ctx.Tag = decompileContext;
        }
コード例 #4
0
        public void OnShow(IShowContext ctx)
        {
            UpdateLanguage();
            var decompileContext = CreateDecompileContext(ctx);
            IHighlightingDefinition highlighting;

            decompileContext.CachedOutput = decompileFileTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Language, nodes, out highlighting);
            decompileContext.DecompileNodeContext.HighlightingDefinition = highlighting;
            ctx.UserData = decompileContext;
        }
コード例 #5
0
        public void OnShow(IShowContext ctx)
        {
            UpdateLanguage();
            var          decompileContext = CreateDecompileContext(ctx);
            IContentType contentType;

            decompileContext.CachedContent = decompileFileTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Language, nodes, out contentType);
            decompileContext.DecompileNodeContext.ContentType = contentType;
            ctx.UserData = decompileContext;
        }
コード例 #6
0
        public void EndAsyncShow(IShowContext ctx, IAsyncShowResult result)
        {
            var decompileContext = (DecompileContext)ctx.UserData;
            var documentViewer   = (IDocumentViewer)ctx.UIContext;

            var contentType = decompileContext.DecompileNodeContext.ContentType;

            if (contentType == null)
            {
                var contentTypeString = decompileContext.DecompileNodeContext.ContentTypeString;
                if (contentTypeString == null)
                {
                    contentTypeString = ContentTypes.TryGetContentTypeStringByExtension(decompileContext.DecompileNodeContext.Language.FileExtension) ?? ContentTypes.PlainText;
                }
                contentType = decompileFileTabContentFactory.ContentTypeRegistryService.GetContentType(contentTypeString);
                Debug.Assert(contentType != null);
            }

            DocumentViewerContent content;

            if (result.IsCanceled)
            {
                var docViewerOutput = new DocumentViewerOutput();
                docViewerOutput.Write(dnSpy_Resources.DecompilationCanceled, BoxedTextColor.Error);
                content = CreateContent(documentViewer, docViewerOutput);
            }
            else if (result.Exception != null)
            {
                var docViewerOutput = new DocumentViewerOutput();
                docViewerOutput.Write(dnSpy_Resources.DecompilationException, BoxedTextColor.Error);
                docViewerOutput.WriteLine();
                docViewerOutput.Write(result.Exception.ToString(), BoxedTextColor.Text);
                content = CreateContent(documentViewer, docViewerOutput);
            }
            else
            {
                content = decompileContext.CachedContent;
                if (content == null)
                {
                    var docViewerOutput = (DocumentViewerOutput)decompileContext.DecompileNodeContext.Output;
                    content = CreateContent(documentViewer, docViewerOutput);
                    if (docViewerOutput.CanBeCached)
                    {
                        decompileFileTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Language, nodes, content, contentType);
                    }
                }
            }

            if (result.CanShowOutput)
            {
                documentViewer.SetContent(content, contentType);
            }
        }
コード例 #7
0
        public override void OnShow(IShowContext ctx)
        {
            Debug.Assert(!isVisible);
            isVisible = true;
            var documentViewer = (IDocumentViewer)ctx.UIContext;

            if (cachedDocumentViewerContent == null)
            {
                (cachedDocumentViewerContent, cachedContentType) = CreateContent(documentViewer);
            }
            documentViewer.SetContent(cachedDocumentViewerContent, cachedContentType);
        }
コード例 #8
0
        public bool CanStartAsyncWorker(IShowContext ctx)
        {
            var decompileContext = (DecompileContext)ctx.UserData;

            if (decompileContext.CachedContent != null)
            {
                return(false);
            }

            var uiCtx = (IDocumentViewer)ctx.UIContext;

            uiCtx.ShowCancelButton(dnSpy_Resources.Decompiling, () => decompileContext.CancellationTokenSource.Cancel());
            return(true);
        }
コード例 #9
0
        public bool CanStartAsyncWorker(IShowContext ctx)
        {
            var decompileContext = (DecompileContext)ctx.UserData;

            if (decompileContext.CachedOutput != null)
            {
                return(false);
            }

            var uiCtx = (ITextEditorUIContext)ctx.UIContext;

            uiCtx.ShowCancelButton(() => decompileContext.CancellationTokenSource.Cancel(), dnSpy_Resources.Decompiling);
            return(true);
        }
コード例 #10
0
        public override bool NeedAsyncWork(IShowContext ctx)
        {
            var decompileContext = (DecompileContext)ctx.Tag;

            if (decompileContext.CachedContent != null)
            {
                return(false);
            }

            var uiCtx = (IDocumentViewer)ctx.UIContext;

            uiCtx.ShowCancelButton(dnSpy_Resources.Decompiling, () => decompileContext.AsyncShowContext.Cancel());
            return(true);
        }
コード例 #11
0
        public void EndAsyncShow(IShowContext ctx, IAsyncShowResult result)
        {
            var decompileContext = (DecompileContext)ctx.UserData;
            var uiCtx            = (ITextEditorUIContext)ctx.UIContext;

            IHighlightingDefinition highlighting;

            if (decompileContext.DecompileNodeContext.HighlightingDefinition != null)
            {
                highlighting = decompileContext.DecompileNodeContext.HighlightingDefinition;
            }
            else if (decompileContext.DecompileNodeContext.HighlightingExtension != null)
            {
                highlighting = HighlightingManager.Instance.GetDefinitionByExtension(decompileContext.DecompileNodeContext.HighlightingExtension);
            }
            else
            {
                highlighting = decompileContext.DecompileNodeContext.Language.GetHighlightingDefinition();
            }

            AvalonEditTextOutput output;

            if (result.IsCanceled)
            {
                output = new AvalonEditTextOutput();
                output.Write(dnSpy_Resources.DecompilationCanceled, TextTokenKind.Error);
            }
            else if (result.Exception != null)
            {
                output = new AvalonEditTextOutput();
                output.Write(dnSpy_Resources.DecompilationException, TextTokenKind.Error);
                output.WriteLine();
                output.Write(result.Exception.ToString(), TextTokenKind.Text);
            }
            else
            {
                output = decompileContext.CachedOutput;
                if (output == null)
                {
                    output = (AvalonEditTextOutput)decompileContext.DecompileNodeContext.Output;
                    decompileFileTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Language, nodes, output, highlighting);
                }
            }

            if (result.CanShowOutput)
            {
                uiCtx.SetOutput(output, highlighting);
            }
        }
コード例 #12
0
        public override void OnShowAsync(IShowContext ctx, IAsyncShowResult result)
        {
            var decompileContext = (DecompileContext)ctx.Tag !;
            var documentViewer   = (IDocumentViewer)ctx.UIContext;

            Debug.Assert(!(decompileContext.DecompileNodeContext is null));
            Debug.Assert(!(decompileContext.DocumentViewerContentFactory is null));
            var contentType = decompileContext.DecompileNodeContext.ContentType;

            if (contentType is null)
            {
                var contentTypeString = decompileContext.DecompileNodeContext.ContentTypeString;
                if (contentTypeString is null)
                {
                    contentTypeString = ContentTypesHelper.TryGetContentTypeStringByExtension(decompileContext.DecompileNodeContext.Decompiler.FileExtension) ?? ContentTypes.PlainText;
                }
                contentType = decompileDocumentTabContentFactory.ContentTypeRegistryService.GetContentType(contentTypeString) ??
                              decompileDocumentTabContentFactory.ContentTypeRegistryService.GetContentType(ContentTypes.Text) ??
                              decompileDocumentTabContentFactory.ContentTypeRegistryService.UnknownContentType;
            }

            DocumentViewerContent?content;

            if (result.IsCanceled)
            {
                var docViewContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
                docViewContentFactory.Output.Write(dnSpy_Resources.DecompilationCanceled, BoxedTextColor.Error);
                content = docViewContentFactory.CreateContent(documentViewer, contentType);
            }
            else if (!(result.Exception is null))
            {
                var docViewContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
                docViewContentFactory.Output.Write(dnSpy_Resources.DecompilationException, BoxedTextColor.Error);
                docViewContentFactory.Output.WriteLine();
                docViewContentFactory.Output.Write(result.Exception.ToString(), BoxedTextColor.Text);
                content = docViewContentFactory.CreateContent(documentViewer, contentType);
            }
コード例 #13
0
 void OnShown(object uiState, Action <ShowTabContentEventArgs> onShownHandler, IShowContext showCtx, bool success)
 {
     if (uiState != null)
     {
         RestoreUIState(uiState);
     }
     if (onShownHandler != null || showCtx.OnShown != null)
     {
         var e = new ShowTabContentEventArgs(success, this);
         onShownHandler?.Invoke(e);
         showCtx.OnShown?.Invoke(e);
     }
 }
コード例 #14
0
		DecompileContext CreateDecompileContext(IShowContext ctx) {
			var decompileContext = new DecompileContext();
			var decompilationContext = new DecompilationContext();
			decompilationContext.CalculateILRanges = true;
			decompilationContext.GetDisableAssemblyLoad = () => decompileFileTabContentFactory.FileManager.DisableAssemblyLoad();
			decompilationContext.IsBodyModified = m => decompileFileTabContentFactory.MethodAnnotations.IsBodyModified(m);
			var output = new AvalonEditTextOutput();
			var dispatcher = Dispatcher.CurrentDispatcher;
			decompileContext.DecompileNodeContext = new DecompileNodeContext(decompilationContext, language, output, dispatcher);
			if (ctx.IsRefresh) {
				decompileContext.SavedRefPos = ((ITextEditorUIContext)ctx.UIContext).SaveReferencePosition();
				if (decompileContext.SavedRefPos != null) {
					ctx.OnShown = e => {
						if (e.Success && !e.HasMovedCaret) {
							e.HasMovedCaret = ((ITextEditorUIContext)ctx.UIContext).RestoreReferencePosition(decompileContext.SavedRefPos);
							if (!e.HasMovedCaret) {
								((ITextEditorUIContext)ctx.UIContext).ScrollAndMoveCaretTo(1, 1);
								e.HasMovedCaret = true;
							}
						}
					};
				}
			}
			return decompileContext;
		}
コード例 #15
0
		public void EndAsyncShow(IShowContext ctx, IAsyncShowResult result) {
			var decompileContext = (DecompileContext)ctx.UserData;
			var uiCtx = (ITextEditorUIContext)ctx.UIContext;

			IHighlightingDefinition highlighting;
			if (decompileContext.DecompileNodeContext.HighlightingDefinition != null)
				highlighting = decompileContext.DecompileNodeContext.HighlightingDefinition;
			else if (decompileContext.DecompileNodeContext.HighlightingExtension != null)
				highlighting = HighlightingManager.Instance.GetDefinitionByExtension(decompileContext.DecompileNodeContext.HighlightingExtension);
			else
				highlighting = decompileContext.DecompileNodeContext.Language.GetHighlightingDefinition();

			AvalonEditTextOutput output;
			if (result.IsCanceled) {
				output = new AvalonEditTextOutput();
				output.Write(dnSpy_Resources.DecompilationCanceled, TextTokenKind.Error);
			}
			else if (result.Exception != null) {
				output = new AvalonEditTextOutput();
				output.Write(dnSpy_Resources.DecompilationException, TextTokenKind.Error);
				output.WriteLine();
				output.Write(result.Exception.ToString(), TextTokenKind.Text);
			}
			else {
				output = decompileContext.CachedOutput;
				if (output == null) {
					output = (AvalonEditTextOutput)decompileContext.DecompileNodeContext.Output;
					decompileFileTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Language, nodes, output, highlighting);
				}
			}

			if (result.CanShowOutput)
				uiCtx.SetOutput(output, highlighting);
		}
コード例 #16
0
 public ShowRepository(IShowContext showContext, IMapper mapper)
 {
     _showCollection = showContext.Show;
     _mapper         = mapper;
 }
コード例 #17
0
		public bool CanStartAsyncWorker(IShowContext ctx) {
			var decompileContext = (DecompileContext)ctx.UserData;
			if (decompileContext.CachedOutput != null)
				return false;

			var uiCtx = (ITextEditorUIContext)ctx.UIContext;
			uiCtx.ShowCancelButton(() => decompileContext.CancellationTokenSource.Cancel(), dnSpy_Resources.Decompiling);
			return true;
		}
コード例 #18
0
 /// <summary>
 /// Called in the main UI thread after the worker thread has exited or was interrupted
 /// </summary>
 /// <param name="ctx">Context</param>
 /// <param name="result">Result</param>
 public abstract void OnShowAsync(IShowContext ctx, IAsyncShowResult result);
コード例 #19
0
ファイル: HexBoxFileTabContent.cs プロジェクト: yueding/dnSpy
 public void OnShow(IShowContext ctx)
 {
 }
コード例 #20
0
ファイル: AboutScreen.cs プロジェクト: n017/dnSpy
 public void OnShow(IShowContext ctx)
 {
     var uiCtx = (ITextEditorUIContext)ctx.UIContext;
     var output = new AvalonEditTextOutput();
     Write(output);
     uiCtx.SetOutput(output, null);
 }
コード例 #21
0
		public override bool NeedAsyncWork(IShowContext ctx) {
			var decompileContext = (DecompileContext)ctx.Tag;
			if (decompileContext.CachedContent != null)
				return false;

			var uiCtx = (IDocumentViewer)ctx.UIContext;
			uiCtx.ShowCancelButton(dnSpy_Resources.Decompiling, () => decompileContext.AsyncShowContext.Cancel());
			return true;
		}
コード例 #22
0
		public void OnShow(IShowContext ctx) {
			UpdateLanguage();
			var decompileContext = CreateDecompileContext(ctx);
			IHighlightingDefinition highlighting;
			decompileContext.CachedOutput = decompileFileTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Language, nodes, out highlighting);
			decompileContext.DecompileNodeContext.HighlightingDefinition = highlighting;
			ctx.UserData = decompileContext;
		}
コード例 #23
0
		/// <summary>
		/// Called in the main UI thread after the worker thread has exited or was interrupted
		/// </summary>
		/// <param name="ctx">Context</param>
		/// <param name="result">Result</param>
		public abstract void OnShowAsync(IShowContext ctx, IAsyncShowResult result);
コード例 #24
0
		/// <summary>
		/// Returns true if <see cref="CreateContentAsync(IAsyncShowContext)"/>
		/// should be called
		/// </summary>
		/// <param name="ctx">Context</param>
		/// <returns></returns>
		public abstract bool NeedAsyncWork(IShowContext ctx);
コード例 #25
0
ファイル: AboutScreen.cs プロジェクト: manojdjoshi/dnSpy
		public override void OnShow(IShowContext ctx) {
			var documentViewer = (IDocumentViewer)ctx.UIContext;
			var contentFactory = documentViewerContentFactoryProvider.Create();
			Write(contentFactory.Output);
			documentViewer.SetContent(contentFactory.CreateContent(documentViewer, aboutContentType), aboutContentType);
		}
コード例 #26
0
 public ShowRepository(IShowContext showContext)
 {
     _showContext = showContext;
 }
コード例 #27
0
 public ShowRepository(IShowContext showContext, IOptions <RepositorySettings> settings, ILogger <ShowRepository> logger)
 {
     _context  = showContext;
     _logger   = logger;
     _idColumn = settings.Value.IdColumn;
 }
コード例 #28
0
ファイル: DocumentTabContent.cs プロジェクト: zz110/dnSpy
 /// <summary>
 /// Called to show its content in the UI. Derive from <see cref="AsyncDocumentTabContent"/> to
 /// create the content in a worker thread.
 /// </summary>
 /// <param name="ctx">UI Context created by <see cref="CreateUIContext(IDocumentTabUIContextLocator)"/></param>
 /// <returns></returns>
 public virtual void OnShow(IShowContext ctx)
 {
 }
コード例 #29
0
 public AsyncShowContext(IShowContext showContext, AsyncWorkerContext asyncWorkerContext)
 {
     this.showContext        = showContext;
     this.asyncWorkerContext = asyncWorkerContext;
 }
コード例 #30
0
		public override void OnShowAsync(IShowContext ctx, IAsyncShowResult result) {
			var decompileContext = (DecompileContext)ctx.Tag;
			var documentViewer = (IDocumentViewer)ctx.UIContext;

			var contentType = decompileContext.DecompileNodeContext.ContentType;
			if (contentType == null) {
				var contentTypeString = decompileContext.DecompileNodeContext.ContentTypeString;
				if (contentTypeString == null)
					contentTypeString = ContentTypesHelper.TryGetContentTypeStringByExtension(decompileContext.DecompileNodeContext.Decompiler.FileExtension) ?? ContentTypes.PlainText;
				contentType = decompileDocumentTabContentFactory.ContentTypeRegistryService.GetContentType(contentTypeString) ??
					decompileDocumentTabContentFactory.ContentTypeRegistryService.GetContentType(ContentTypes.Text) ??
					decompileDocumentTabContentFactory.ContentTypeRegistryService.UnknownContentType;
			}

			DocumentViewerContent content;
			if (result.IsCanceled) {
				var docViewContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
				docViewContentFactory.Output.Write(dnSpy_Resources.DecompilationCanceled, BoxedTextColor.Error);
				content = docViewContentFactory.CreateContent(documentViewer, contentType);
			}
			else if (result.Exception != null) {
				var docViewContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
				docViewContentFactory.Output.Write(dnSpy_Resources.DecompilationException, BoxedTextColor.Error);
				docViewContentFactory.Output.WriteLine();
				docViewContentFactory.Output.Write(result.Exception.ToString(), BoxedTextColor.Text);
				content = docViewContentFactory.CreateContent(documentViewer, contentType);
			}
			else {
				content = decompileContext.CachedContent;
				if (content == null) {
					bool canBeCached = decompileContext.DocumentViewerContentFactory.Output.CanBeCached;
					content = decompileContext.DocumentViewerContentFactory.CreateContent(documentViewer, contentType);
					if (canBeCached)
						decompileDocumentTabContentFactory.DecompilationCache.Cache(decompileContext.DecompileNodeContext.Decompiler, nodes, content, contentType);
				}
			}

			if (result.CanShowOutput)
				WasNewContent = documentViewer.SetContent(content, contentType);
			else
				WasNewContent = false;
		}
コード例 #31
0
		public override void OnShow(IShowContext ctx) {
			UpdateLanguage();
			var decompileContext = CreateDecompileContext(ctx);
			IContentType contentType;
			decompileContext.CachedContent = decompileDocumentTabContentFactory.DecompilationCache.Lookup(decompileContext.DecompileNodeContext.Decompiler, nodes, out contentType);
			decompileContext.DecompileNodeContext.ContentType = contentType;
			ctx.Tag = decompileContext;
		}
コード例 #32
0
 /// <summary>
 /// Returns true if <see cref="CreateContentAsync(IAsyncShowContext)"/>
 /// should be called
 /// </summary>
 /// <param name="ctx">Context</param>
 /// <returns></returns>
 public abstract bool NeedAsyncWork(IShowContext ctx);
コード例 #33
0
ファイル: TabContentImpl.cs プロジェクト: manojdjoshi/dnSpy
		void OnShown(object uiState, Action<ShowTabContentEventArgs> onShownHandler, IShowContext showCtx, ShowTabContentResult result) {
			if (uiState != null)
				RestoreUIState(uiState);
			if (onShownHandler != null || showCtx.OnShown != null) {
				var e = new ShowTabContentEventArgs(result, this);
				onShownHandler?.Invoke(e);
				showCtx.OnShown?.Invoke(e);
			}
		}
コード例 #34
0
ファイル: TabContentImpl.cs プロジェクト: yueding/dnSpy
 void OnShown(object serializedUI, Action<ShowTabContentEventArgs> onShownHandler, IShowContext showCtx, bool success)
 {
     if (serializedUI != null)
         Deserialize(serializedUI);
     if (onShownHandler != null || showCtx.OnShown != null) {
         var e = new ShowTabContentEventArgs(success, this);
         if (onShownHandler != null)
             onShownHandler(e);
         if (showCtx.OnShown != null)
             showCtx.OnShown(e);
     }
 }
コード例 #35
0
		public void AsyncWorker(IShowContext ctx, CancellationTokenSource source) {
			var decompileContext = (DecompileContext)ctx.UserData;
			decompileContext.CancellationTokenSource = source;
			decompileContext.DecompileNodeContext.DecompilationContext.CancellationToken = source.Token;
			decompileFileTabContentFactory.FileTreeNodeDecompiler.Decompile(decompileContext.DecompileNodeContext, nodes);
		}
コード例 #36
0
ファイル: TabContentImpl.cs プロジェクト: weimingtom/dnSpy
 void OnShown(object serializedUI, Action <ShowTabContentEventArgs> onShownHandler, IShowContext showCtx, bool success)
 {
     if (serializedUI != null)
     {
         Deserialize(serializedUI);
     }
     if (onShownHandler != null || showCtx.OnShown != null)
     {
         var e = new ShowTabContentEventArgs(success, this);
         onShownHandler?.Invoke(e);
         showCtx.OnShown?.Invoke(e);
     }
 }
コード例 #37
0
		/// <summary>
		/// Called to show its content in the UI. Derive from <see cref="AsyncDocumentTabContent"/> to
		/// create the content in a worker thread.
		/// </summary>
		/// <param name="ctx">UI Context created by <see cref="CreateUIContext(IDocumentTabUIContextLocator)"/></param>
		/// <returns></returns>
		public virtual void OnShow(IShowContext ctx) { }
コード例 #38
0
 public void OnShow(IShowContext ctx)
 {
 }
コード例 #39
0
ファイル: TabContentImpl.cs プロジェクト: manojdjoshi/dnSpy
			public AsyncShowContext(IShowContext showContext, AsyncWorkerContext asyncWorkerContext) {
				this.showContext = showContext;
				this.asyncWorkerContext = asyncWorkerContext;
			}
コード例 #40
0
 void OnShown(object uiState, Action <ShowTabContentEventArgs> onShownHandler, IShowContext showCtx, ShowTabContentResult result)
 {
     if (uiState != null)
     {
         RestoreUIState(uiState);
     }
     if (onShownHandler != null || showCtx.OnShown != null)
     {
         var e = new ShowTabContentEventArgs(result, this);
         onShownHandler?.Invoke(e);
         showCtx.OnShown?.Invoke(e);
     }
     DnSpyEventSource.Log.ShowDocumentTabContentStop();
 }
コード例 #41
0
		DecompileContext CreateDecompileContext(IShowContext ctx) {
			var decompileContext = new DecompileContext();
			var decompilationContext = new DecompilationContext();
			decompilationContext.CalculateBinSpans = true;
			decompilationContext.GetDisableAssemblyLoad = () => decompileDocumentTabContentFactory.DocumentService.DisableAssemblyLoad();
			decompilationContext.IsBodyModified = m => decompileDocumentTabContentFactory.MethodAnnotations.IsBodyModified(m);
			var dispatcher = Dispatcher.CurrentDispatcher;
			decompileContext.DocumentViewerContentFactory = decompileDocumentTabContentFactory.DocumentViewerContentFactoryProvider.Create();
			decompileContext.DecompileNodeContext = new DecompileNodeContext(decompilationContext, Decompiler, decompileContext.DocumentViewerContentFactory.Output, decompileDocumentTabContentFactory.DocumentWriterService, dispatcher);
			if (ctx.IsRefresh) {
				decompileContext.SavedRefPos = ((IDocumentViewer)ctx.UIContext).SaveReferencePosition();
				if (decompileContext.SavedRefPos != null) {
					ctx.OnShown = e => {
						if (e.Success && !e.HasMovedCaret) {
							e.HasMovedCaret = ((IDocumentViewer)ctx.UIContext).RestoreReferencePosition(decompileContext.SavedRefPos);
							if (!e.HasMovedCaret) {
								((IDocumentViewer)ctx.UIContext).MoveCaretToPosition(0);
								e.HasMovedCaret = true;
							}
						}
					};
				}
			}
			return decompileContext;
		}