Ejemplo n.º 1
0
        private FrameworkElement GetPreviewElement(object previewItem)
        {
            if (previewItem is DifferenceViewerPreview)
            {
                // Contract is there should be only 1 diff viewer, otherwise we leak.

                // cache the diff viewer so that we can close it when panel goes away.
                // this is a bit wierd since we are mutating state here.
                _differenceViewerPreview    = (DifferenceViewerPreview)previewItem;
                PreviewDockPanel.Background = _differenceViewerPreview.Viewer.InlineView.Background;

                var previewElement = _differenceViewerPreview.Viewer.VisualElement;
                return(previewElement);
            }

            if (previewItem is string s)
            {
                return(GetPreviewForString(s));
            }

            if (previewItem is FrameworkElement frameworkElement)
            {
                return(frameworkElement);
            }

            // preview item we don't know how to show to users
            return(null);
        }
Ejemplo n.º 2
0
 void IDisposable.Dispose()
 {
     // VS editor will call Dispose at which point we should Close() the embedded IWpfDifferenceViewer.
     _differenceViewerPreview?.Dispose();
     _differenceViewerPreview = null;
 }