本文整理汇总了C#中Mono.TextEditor.Highlighting.ColorScheme.CopyValues方法的典型用法代码示例。如果您正苦于以下问题:C# ColorScheme.CopyValues方法的具体用法?C# ColorScheme.CopyValues怎么用?C# ColorScheme.CopyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.Highlighting.ColorScheme
的用法示例。
在下文中一共展示了ColorScheme.CopyValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFrom
public static ColorScheme LoadFrom (Stream stream)
{
var result = new ColorScheme ();
var reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader (stream, 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 != TextEditorOptions.DefaultColorStyle)
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, Cairo.Color> ();
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;
}
示例2: Clone
public ColorScheme Clone ()
{
var result = new ColorScheme () {
Name = this.Name,
BaseScheme = this.BaseScheme,
Originator = this.Originator,
Description = this.Description
};
result.CopyValues (this);
return result;
}