public override AmbientColor GetBackgroundMarkerColor (ColorScheme style) { return (ReferenceUsageType & ReferenceUsageType.Write) != 0 || (ReferenceUsageType & ReferenceUsageType.Declariton) != 0? style.ChangingUsagesRectangle : style.UsagesRectangle; }
public SignatureMarkupCreator (DocumentContext ctx, int offset) { this.offset = offset; this.colorStyle = SyntaxModeService.GetColorStyle (Ide.IdeApp.Preferences.ColorScheme); if (!this.colorStyle.FitsIdeSkin (Ide.IdeApp.Preferences.UserInterfaceSkin)) this.colorStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceSkin); this.ctx = ctx; if (ctx != null) { this.options = ctx.GetOptionSet (); } else { this.options = MonoDevelop.Ide.TypeSystem.TypeSystemService.Workspace.Options; } }
public SignatureMarkupCreator (DocumentContext ctx, int offset) { this.offset = offset; this.colorStyle = SyntaxModeService.GetColorStyle (MonoDevelop.Ide.IdeApp.Preferences.ColorScheme); this.ctx = ctx; if (ctx != null) { if (ctx.ParsedDocument == null || ctx.AnalysisDocument == null) { LoggingService.LogError ("Signature markup creator created with invalid context." + Environment.NewLine + Environment.StackTrace); } this.options = ctx.GetOptionSet (); } else { this.options = MonoDevelop.Ide.TypeSystem.TypeSystemService.Workspace.Options; } }
public SignatureMarkupCreator (DocumentContext ctx, int offset) { this.offset = offset; try { this.colorStyle = SyntaxModeService.GetColorStyle (Ide.IdeApp.Preferences.ColorScheme); if (!this.colorStyle.FitsIdeTheme (Ide.IdeApp.Preferences.UserInterfaceTheme)) this.colorStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceTheme); } catch (Exception e) { LoggingService.LogError ("Error while getting the color style : " + Ide.IdeApp.Preferences.ColorScheme + " in ide theme : " + Ide.IdeApp.Preferences.UserInterfaceTheme, e); this.colorStyle = SyntaxModeService.DefaultColorStyle; } this.ctx = ctx; if (ctx != null) { this.options = ctx.GetOptionSet (); } else { this.options = MonoDevelop.Ide.TypeSystem.TypeSystemService.Workspace.Options; } }
internal static ColorScheme Import (string fileName, Stream stream) { var result = new ColorScheme (); result.Name = Path.GetFileNameWithoutExtension (fileName); result.Description = "Imported color scheme"; result.Originator = "Imported from " + fileName; var colors = new Dictionary<string, VSSettingColor> (); using (var reader = XmlReader.Create (stream)) { while (reader.Read ()) { if (reader.LocalName == "Item") { var color = VSSettingColor.Create (reader); if (colors.ContainsKey (color.Name)) { Console.WriteLine ("Warning: {0} is defined twice in vssettings.", color.Name); continue; } colors[color.Name] = color; } } } HashSet<string> importedAmbientColors = new HashSet<string> (); // convert ambient colors foreach (var ambient in ambientColors.Values) { if (!string.IsNullOrEmpty (ambient.Attribute.VSSetting)) { var import = AmbientColor.Import (colors, ambient.Attribute.VSSetting); if (import != null) { importedAmbientColors.Add (import.Name); ambient.Info.SetValue (result, import, null); continue; } } } // convert text colors foreach (var vsc in colors.Values) { bool found = false; foreach (var color in textColors) { if (color.Value.Attribute.VSSetting == null) continue; var split = color.Value.Attribute.VSSetting.Split ('?'); foreach (var s in split) { if (s == vsc.Name) { /* if (vsc.Foreground == "0x02000000" && vsc.Background == "0x02000000") { color.Value.Info.SetValue (result, result.PlainText, null); found = true; continue; }*/ var textColor = ChunkStyle.Import (color.Value.Attribute.Name, vsc); if (textColor != null) { color.Value.Info.SetValue (result, textColor, null); found = true; } } } } if (!found && !importedAmbientColors.Contains (vsc.Name)) Console.WriteLine (vsc.Name + " not imported!"); } result.IndentationGuide = new AmbientColor (); result.IndentationGuide.Colors.Add (Tuple.Create ("color", AlphaBlend (result.PlainText.Foreground, result.PlainText.Background, 0.3))); result.TooltipText = result.PlainText.Clone (); var h = (HslColor)result.TooltipText.Background; h.L += 0.01; result.TooltipText.Background = h; result.TooltipPager = new AmbientColor (); result.TooltipPager.Colors.Add (Tuple.Create ("color", result.TooltipText.Background)); result.TooltipPagerTriangle = new AmbientColor (); result.TooltipPagerTriangle.Colors.Add (Tuple.Create ("color", AlphaBlend (result.PlainText.Foreground, result.PlainText.Background, 0.8))); var defaultStyle = SyntaxModeService.GetColorStyle (HslColor.Brightness (result.PlainText.Background) < 0.5 ? "Monokai" : "Default"); foreach (var color in textColors.Values) { if (color.Info.GetValue (result, null) == null) color.Info.SetValue (result, color.Info.GetValue (defaultStyle, null), null); } foreach (var color in ambientColors.Values) { if (color.Info.GetValue (result, null) == null) color.Info.SetValue (result, color.Info.GetValue (defaultStyle, null), null); } if (result.PlainText.TransparentForeground) result.PlainText.Foreground = new HslColor (0, 0, 0); return result; }
internal static ColorScheme LoadFrom (Stream stream) { var result = new ColorScheme (); byte [] bytes; using (var sr = Core.Text.TextFileUtility.OpenStream (stream)) { bytes = System.Text.Encoding.UTF8.GetBytes (sr.ReadToEnd ()); } var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (bytes, new System.Xml.XmlDictionaryReaderQuotas ()); var root = XElement.Load(reader); // The fields we'd like to extract result.Name = root.XPathSelectElement("name").Value; if (result.Name != "Default") result.CopyValues (SyntaxModeService.DefaultColorStyle); var version = Version.Parse (root.XPathSelectElement("version").Value); if (version.Major != 1) return null; var el = root.XPathSelectElement ("description"); if (el != null) result.Description = el.Value; el = root.XPathSelectElement ("originator"); if (el != null) result.Originator = el.Value; el = root.XPathSelectElement ("baseScheme"); if (el != null) result.BaseScheme = el.Value; if (result.BaseScheme != null) { var baseScheme = SyntaxModeService.GetColorStyle (result.BaseScheme); if (baseScheme != null) result.CopyValues (baseScheme); } var palette = new Dictionary<string, HslColor> (); foreach (var color in root.XPathSelectElements("palette/*")) { var name = color.XPathSelectElement ("name").Value; if (palette.ContainsKey (name)) throw new InvalidDataException ("Duplicate palette color definition for: " + name); palette.Add ( name, ParseColor (color.XPathSelectElement ("value").Value) ); } foreach (var colorElement in root.XPathSelectElements("//colors/*")) { var color = AmbientColor.Create (colorElement, palette); PropertyDecsription info; if (!ambientColors.TryGetValue (color.Name, out info)) { Console.WriteLine ("Ambient color:" + color.Name + " not found."); continue; } info.Info.SetValue (result, color, null); } foreach (var textColorElement in root.XPathSelectElements("//text/*")) { var color = ChunkStyle.Create (textColorElement, palette); PropertyDecsription info; if (!textColors.TryGetValue (color.Name, out info)) { Console.WriteLine ("Text color:" + color.Name + " not found."); continue; } info.Info.SetValue (result, color, null); } // Check scheme bool valid = true; foreach (var color in textColors.Values) { if (color.Info.GetValue (result, null) == null) { Console.WriteLine (color.Attribute.Name + " == null"); valid = false; } } foreach (var color in ambientColors.Values) { if (color.Info.GetValue (result, null) == null) { Console.WriteLine (color.Attribute.Name + " == null"); valid = false; } } if (!valid) throw new InvalidDataException ("Scheme " + result.Name + " is not valid."); return result; }
void CopyValues (ColorScheme baseScheme) { foreach (var color in textColors.Values) color.Info.SetValue (this, color.Info.GetValue (baseScheme, null), null); foreach (var color in ambientColors.Values) color.Info.SetValue (this, color.Info.GetValue (baseScheme, null), null); }
public ColorScheme Clone () { var result = new ColorScheme () { Name = this.Name, BaseScheme = this.BaseScheme, Originator = this.Originator, Description = this.Description }; result.CopyValues (this); return result; }
void UpdateStyles (object sender = null, EventArgs e = null) { highlightStyle = SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); if (!highlightStyle.FitsIdeTheme (IdeApp.Preferences.UserInterfaceTheme)) highlightStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceTheme); if (markupCache != null) markupCache = new List<Tuple<SearchResult, string>> (); if (IsRealized) { store.Foreach ((model, path, iter) => { model.EmitRowChanged (path, iter); return false; }); } }
protected override void OnRealized () { base.OnRealized (); highlightStyle = SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); }
internal static ChunkStyle Import (string name, ColorScheme.VSSettingColor vsc) { var textColor = new ChunkStyle (); textColor.Name = name; if (!string.IsNullOrEmpty (vsc.Foreground) && vsc.Foreground != "0x02000000") { textColor.Foreground = ColorScheme.ImportVsColor (vsc.Foreground); if (textColor.TransparentForeground && name != "Selected Text" && name != "Selected Text(Inactive)") textColor.Foreground = new HslColor (0, 0, 0); } if (!string.IsNullOrEmpty (vsc.Background) && vsc.Background != "0x02000000") textColor.Background = ColorScheme.ImportVsColor (vsc.Background); if (vsc.BoldFont) textColor.FontWeight = Xwt.Drawing.FontWeight.Bold; return textColor; }
internal static void AddStyle (ColorScheme style) { styles [style.Name] = style; }
static void Remove (ColorScheme style) { if (styleLookup.ContainsKey (style.Name)) styleLookup.Remove (style.Name); foreach (var kv in styles) { if (kv.Value == style) { styles.Remove (kv.Key); return; } } }
static IStreamProvider GetProvider (ColorScheme style) { if (styleLookup.ContainsKey (style.Name)) return styleLookup[style.Name]; return null; }
public virtual AmbientColor GetBackgroundMarkerColor (ColorScheme style) { return style.SearchResult; }
void SetStyle () { colorStyle = SyntaxModeService.GetColorStyle (IdeApp.Preferences.ColorScheme); }