Skip to content

Instantly share code, notes, and snippets.

Avatar

Mads Kristensen madskristensen

View GitHub Profile
@madskristensen
madskristensen / ImportMefComponent.cs
Last active May 3, 2020
Import MEF components from non-MEF exported classes
View ImportMefComponent.cs
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.TableManager;
public class ExtensionPackage : Package
{
[Import]
private ITableManagerProvider _tableManagerProvider;
protected override void Initialize()
@madskristensen
madskristensen / KnownMonikersToBitmap.cs
Created Sep 24, 2015
Uses the IVsImageService2 to convert a KnownMoniker to BitmapSource
View KnownMonikersToBitmap.cs
public static BitmapSource GetImage(ImageMoniker moniker, int size)
{
ImageAttributes imageAttributes = new ImageAttributes();
imageAttributes.Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags;
imageAttributes.ImageType = (uint)_UIImageType.IT_Bitmap;
imageAttributes.Format = (uint)_UIDataFormat.DF_WPF;
imageAttributes.LogicalHeight = size;
imageAttributes.LogicalWidth = size;
imageAttributes.StructSize = Marshal.SizeOf(typeof(ImageAttributes));