//this function will be called twiced, from the two linked anchors // and so will receive two different anchor in parameter public void OnAfterDeserialize(Anchor anchor) { if (anchor.anchorType == AnchorType.Output) { fromAnchor = anchor; } else { toAnchor = anchor; } if (fromAnchor != null) { fromNode = fromAnchor.nodeRef; } if (toAnchor != null) { toNode = toAnchor.nodeRef; } //update link color: if (fromAnchor != null) { colorSchemeName = fromAnchor.colorSchemeName; } }
/// <summary> /// Determines if any Classification foreground colors have been customized in Fonts and Colors. /// </summary> public bool AreForegroundColorsCustomized(ColorSchemeName schemeName, Guid themeId) { AssertIsForeground(); // Ensure we are initialized if (_fontAndColorStorage is null) { _fontAndColorStorage = _serviceProvider.GetService <SVsFontAndColorStorage, IVsFontAndColorStorage>(); _fontAndColorUtilities = (IVsFontAndColorUtilities)_fontAndColorStorage !; } // Make no changes when in high contast mode or in unknown theme. if (SystemParameters.HighContrast || !_colorSchemes.TryGetValue(schemeName, out var colorScheme) || !colorScheme.TryGetValue(themeId, out var colorSchemeTheme)) { return(false); } var coreThemeColors = (themeId == KnownColorThemes.Dark) ? DarkThemeForeground : BlueLightThemeForeground; // Open Text Editor category for readonly access and do not load items if they are defaulted. if (_fontAndColorStorage.OpenCategory(TextEditorMEFItemsColorCategory, (uint)__FCSTORAGEFLAGS.FCSF_READONLY) != VSConstants.S_OK) { // We were unable to access color information. return(false); } try { foreach (var classification in Classifications) { var colorItems = new ColorableItemInfo[1]; if (_fontAndColorStorage.GetItem(classification, colorItems) != VSConstants.S_OK) { // Classifications that are still defaulted will not have entries. continue; } var colorItem = colorItems[0]; if (IsClassificationCustomized(coreThemeColors, colorSchemeTheme, colorItem, classification)) { return(true); } } } finally { _fontAndColorStorage.CloseCategory(); } return(false); }
/// <summary> /// Determines if any Classification foreground colors have been customized in Fonts and Colors. /// </summary> public async Task <bool> AreForegroundColorsCustomizedAsync( ColorSchemeName schemeName, Guid themeId, CancellationToken cancellationToken) { // Make no changes when in high contast mode or in unknown theme. if (SystemParameters.HighContrast || !_colorSchemes.TryGetValue(schemeName, out var colorScheme) || !colorScheme.TryGetValue(themeId, out var colorSchemeTheme)) { return(false); } // Ensure we are initialized if (_fontAndColorStorage is null) { await TaskScheduler.Default; _fontAndColorStorage = await _asyncServiceProvider.GetServiceAsync <SVsFontAndColorStorage, IVsFontAndColorStorage>(_threadingContext.JoinableTaskFactory).ConfigureAwait(false); } await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); _fontAndColorUtilities ??= (IVsFontAndColorUtilities)_fontAndColorStorage; var coreThemeColors = themeId == KnownColorThemes.Dark ? DarkThemeForeground : BlueLightThemeForeground; // Open Text Editor category for readonly access and do not load items if they are defaulted. if (_fontAndColorStorage.OpenCategory(TextEditorMEFItemsColorCategory, (uint)__FCSTORAGEFLAGS.FCSF_READONLY) == VSConstants.S_OK) { try { foreach (var classification in _classifications) { var colorItems = new ColorableItemInfo[1]; if (_fontAndColorStorage.GetItem(classification, colorItems) != VSConstants.S_OK) { // Classifications that are still defaulted will not have entries. continue; } var colorItem = colorItems[0]; if (IsClassificationCustomized(coreThemeColors, colorSchemeTheme, colorItem, classification)) { return(true); } } } finally { _fontAndColorStorage.CloseCategory(); } } return(false); }
public NodeTypeInfoList(int allowedGraphMask, string title, ColorSchemeName colorSchemeName, params object[] nodeTypeInfos) { this.allowedGraphMask = allowedGraphMask; this.title = title; this.colorSchemeName = colorSchemeName; if (nodeTypeInfos != null) { for (int i = 0; i < nodeTypeInfos.Length - 1; i += 2) { typeInfos.Add(new NodeTypeInfo(nodeTypeInfos[i] as string, nodeTypeInfos[i + 1] as Type)); } } }
Rect DrawSelectorCase(string name, ColorSchemeName colorSchemeName, bool title = false) { if (title) { GUI.color = ColorTheme.GetSelectorHeaderColor(colorSchemeName); GUILayout.Label(name, nodeSelectorTitleStyle); GUI.color = Color.white; } else { GUILayout.Label(name, nodeSelectorCaseStyle); } return(GUILayoutUtility.GetLastRect()); }
public void ApplyColorScheme(ColorSchemeName schemeName, ImmutableArray <RegistryItem> registryItems) { using var registryRoot = VSRegistry.RegistryRoot(_serviceProvider, __VsLocalRegistryType.RegType_Configuration, writable: true); foreach (var item in registryItems) { using var itemKey = registryRoot.CreateSubKey(item.SectionName); itemKey.SetValue(RegistryItem.ValueName, item.ValueData); // Flush RegistryKeys out of paranoia itemKey.Flush(); } registryRoot.Flush(); SetAppliedColorScheme(schemeName); // Broadcast that system color settings have changed to force the ColorThemeService to reload colors. NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, NativeMethods.WM_SYSCOLORCHANGE, wparam: IntPtr.Zero, lparam: IntPtr.Zero); }
private static Stream GetColorSchemeXmlStream(ColorSchemeName schemeName) { var assembly = Assembly.GetExecutingAssembly(); return(assembly.GetManifestResourceStream($"Microsoft.VisualStudio.LanguageServices.ColorSchemes.{schemeName}.xml")); }
private static ColorScheme GetColorScheme(ColorSchemeName schemeName) { using var colorSchemeStream = GetColorSchemeXmlStream(schemeName); return(ColorSchemeReader.ReadColorScheme(colorSchemeStream)); }
void DrawSelectedBezier(Vector3 startPos, Vector3 endPos, Vector3 startTan, Vector3 endTan, ColorSchemeName colorSchemeName, int width, LinkHighlightMode highlight) { switch (highlight) { case LinkHighlightMode.Selected: Handles.DrawBezier(startPos, endPos, startTan, endTan, ColorTheme.selectedColor, null, width + 3); break; case LinkHighlightMode.Delete: case LinkHighlightMode.DeleteAndReset: Handles.DrawBezier(startPos, endPos, startTan, endTan, ColorTheme.deletedColor, null, width + 2); break; default: break; } Color c = ColorTheme.GetLinkColor(colorSchemeName); Handles.DrawBezier(startPos, endPos, startTan, endTan, c, null, width); }
public static Color GetSelectorCellColor(ColorSchemeName csn) { return(colorSchemes[csn].selectorCellColor); }
public static Color GetNodeColor(ColorSchemeName csn) { return(colorSchemes[csn].nodeColor); }
public static Color GetAnchorColor(ColorSchemeName csn) { return(colorSchemes[csn].anchorColor); }
public static Color GetLinkColor(ColorSchemeName csn) { return(colorSchemes[csn].linkColor); }