public void Load(ColorStorage colorStorage) { ColorableItemInfo[] colors = new ColorableItemInfo[1]; var hr = colorStorage.Storage.GetItem(this.classificationName, colors); ErrorHandler.ThrowOnFailure(hr); this.foregroundChanged = false; if (colors[0].bForegroundValid != 0) { this.foreground = MapColor(colorStorage, colors[0].crForeground); } else { this.foreground = Color.Transparent; } this.backgroundChanged = false; if (colors[0].bBackgroundValid != 0) { this.background = MapColor(colorStorage, colors[0].crBackground); } else { this.background = Color.Transparent; } this.fontFlagsChanged = false; if (colors[0].bFontFlagsValid != 0) { this.fontFlags = MapFontFlags(colors[0].dwFontFlags); } }
private void AssignForSave(ColorStorage colorStorage, ColorableItemInfo[] colors) { if (this.foregroundChanged) { if (this.foreground == Color.Transparent) { colors[0].crForeground = colorStorage.GetAutomaticColor(); } else { colors[0].crForeground = (uint)ColorTranslator.ToWin32(this.foreground); } colors[0].bForegroundValid = 1; } if (this.backgroundChanged) { if (this.background == Color.Transparent) { colors[0].crBackground = colorStorage.GetAutomaticColor(); } else { colors[0].crBackground = (uint)ColorTranslator.ToWin32(this.background); } colors[0].bBackgroundValid = 1; } if (this.fontFlagsChanged) { colors[0].dwFontFlags = ToFontFlags(this.fontFlags); colors[0].bFontFlagsValid = 1; } }
private Color FromVsColor(ColorStorage storage, uint colorRef) { var hr = storage.Utilities.GetEncodedVSColor(colorRef, out int vsColor); ErrorHandler.ThrowOnFailure(hr); hr = storage.Shell.GetVSSysColorEx(vsColor, out uint rgb); ErrorHandler.ThrowOnFailure(hr); return(FromWin32(rgb)); }
private Color FromColorIndex(ColorStorage storage, uint colorRef) { COLORINDEX[] index = new COLORINDEX[1]; var hr = storage.Utilities.GetEncodedIndex(colorRef, index); ErrorHandler.ThrowOnFailure(hr); uint rgb; hr = storage.Utilities.GetRGBOfIndex(index[0], out rgb); ErrorHandler.ThrowOnFailure(hr); return(FromWin32(rgb)); }
public void Save(ColorStorage colorStorage) { if (this.HasChanged()) { ColorableItemInfo[] colors = new ColorableItemInfo[1]; var hr = colorStorage.Storage.GetItem(this.classificationName, colors); ErrorHandler.ThrowOnFailure(hr); AssignForSave(colorStorage, colors); hr = colorStorage.Storage.SetItem(this.classificationName, colors); ErrorHandler.ThrowOnFailure(hr); } }
private Color FromColorIndex(ColorStorage storage, uint colorRef) { COLORINDEX[] index = new COLORINDEX[1]; var hr = storage.Utilities.GetEncodedIndex(colorRef, index); ErrorHandler.ThrowOnFailure(hr); // useful when the color is marked as "automatic" in VS if (index[0] == COLORINDEX.CI_SYSTEXT_BK || index[0] == COLORINDEX.CI_SYSTEXT_FG) { return(Color.Transparent); } hr = storage.Utilities.GetRGBOfIndex(index[0], out uint rgb); ErrorHandler.ThrowOnFailure(hr); return(FromWin32(rgb)); }
private Color MapColor(ColorStorage storage, uint colorRef) { int type; var hr = storage.Utilities.GetColorType(colorRef, out type); switch ((__VSCOLORTYPE)type) { case __VSCOLORTYPE.CT_SYSCOLOR: case __VSCOLORTYPE.CT_RAW: return(FromWin32(colorRef)); case __VSCOLORTYPE.CT_COLORINDEX: return(FromColorIndex(storage, colorRef)); case __VSCOLORTYPE.CT_VSCOLOR: return(FromVsColor(storage, colorRef)); default: throw new InvalidOperationException("Invalid VS color type"); } }
public void Save(ColorStorage colorStorage) { if (this.backgroundChanged || this.foregroundChanged) { ColorableItemInfo[] colors = new ColorableItemInfo[1]; var hr = colorStorage.Storage.GetItem(classificationName, colors); ErrorHandler.ThrowOnFailure(hr); if (this.foregroundChanged) { colors[0].crForeground = (uint)ColorTranslator.ToWin32(foreground); colors[0].bForegroundValid = 1; } if (this.backgroundChanged) { colors[0].crBackground = (uint)ColorTranslator.ToWin32(background); colors[0].bBackgroundValid = 1; } hr = colorStorage.Storage.SetItem(classificationName, colors); ErrorHandler.ThrowOnFailure(hr); } }
public ClassificationList(ColorStorage colorStorage) { storage = colorStorage; classifications = new Dictionary <String, ClassificationColors>(); }