Exemplo n.º 1
0
 public override IEnumerable<Tuple<object, object>> GetResourceKeyValues(MyHighlightingColor hlColor)
 {
     if (ForegroundResourceKey != null) {
         Debug.Assert(hlColor.Foreground != null);
         if (ForegroundOpacity == null)
             yield return new Tuple<object, object>(ForegroundResourceKey, hlColor.Foreground.GetBrush(null));
         else {
             var color = hlColor.Foreground.GetColor(null).Value;
             var brush = new SolidColorBrush(color) { Opacity = ForegroundOpacity.Value };
             yield return new Tuple<object, object>(ForegroundResourceKey, brush);
         }
     }
     if (BackgroundResourceKey != null) {
         Debug.Assert(hlColor.Background != null);
         if (BackgroundOpacity == null)
             yield return new Tuple<object, object>(BackgroundResourceKey, hlColor.Background.GetBrush(null));
         else {
             var color = hlColor.Background.GetColor(null).Value;
             var brush = new SolidColorBrush(color) { Opacity = BackgroundOpacity.Value };
             yield return new Tuple<object, object>(BackgroundResourceKey, brush);
         }
     }
 }
Exemplo n.º 2
0
 public override IEnumerable<Tuple<object, object>> GetResourceKeyValues(MyHighlightingColor hlColor)
 {
     var br = new RadialGradientBrush() {
         RadiusX = 1,
         RadiusY = 1,
     };
     if (RelativeTransform != null)
         br.RelativeTransform = RelativeTransform;
     if (Center != null)
         br.Center = Center.Value;
     if (GradientOrigin != null)
         br.GradientOrigin = GradientOrigin.Value;
     if (RadiusX != null)
         br.RadiusX = RadiusX.Value;
     if (RadiusY != null)
         br.RadiusY = RadiusY.Value;
     if (Opacity != null)
         br.Opacity = Opacity.Value;
     for (int i = 0; i < GradientOffsets.Length; i++)
         br.GradientStops.Add(new GradientStop(((SolidColorBrush)hlColor.GetHighlightingBrush(i).GetBrush(null)).Color, GradientOffsets[i]));
     br.Freeze();
     yield return new Tuple<object, object>(ResourceKey, br);
 }
Exemplo n.º 3
0
        MyHighlightingColor ReadColor(XElement color, ref ColorType colorType)
        {
            var name = color.Attribute("name");
            if (name == null)
                return null;
            colorType = ToColorType(name.Value);
            if (colorType == ColorType.Last)
                return null;

            var colorInfo = colorInfos[(int)colorType];

            var hl = new MyHighlightingColor();
            hl.Name = colorType.ToString();

            var fg = GetAttribute(color, "fg", colorInfo.DefaultForeground);
            if (fg != null)
                hl.Foreground = CreateColor(fg);

            var bg = GetAttribute(color, "bg", colorInfo.DefaultBackground);
            if (bg != null)
                hl.Background = CreateColor(bg);

            var color3 = GetAttribute(color, "color3", colorInfo.DefaultColor3);
            if (color3 != null)
                hl.Color3 = CreateColor(color3);

            var color4 = GetAttribute(color, "color4", colorInfo.DefaultColor4);
            if (color4 != null)
                hl.Color4 = CreateColor(color4);

            var italics = color.Attribute("italics") ?? color.Attribute("italic");
            if (italics != null)
                hl.FontStyle = (bool)italics ? FontStyles.Italic : FontStyles.Normal;

            var bold = color.Attribute("bold");
            if (bold != null)
                hl.FontWeight = (bool)bold ? FontWeights.Bold : FontWeights.Normal;

            return hl;
        }
Exemplo n.º 4
0
 public override IEnumerable<Tuple<object, object>> GetResourceKeyValues(MyHighlightingColor hlColor)
 {
     var br = new LinearGradientBrush() {
         StartPoint = StartPoint,
         EndPoint = EndPoint,
     };
     if (MappingMode != null)
         br.MappingMode = MappingMode.Value;
     for (int i = 0; i < GradientOffsets.Length; i++)
         br.GradientStops.Add(new GradientStop(((SolidColorBrush)hlColor.GetHighlightingBrush(i).GetBrush(null)).Color, GradientOffsets[i]));
     br.Freeze();
     yield return new Tuple<object, object>(ResourceKey, br);
 }
Exemplo n.º 5
0
        MyHighlightingColor CreateHighlightingColor(ColorType colorType)
        {
            var hl = new MyHighlightingColor { Name = colorType.ToString() };

            var colorInfo = colorInfos[(int)colorType];

            if (colorInfo.DefaultForeground != null)
                hl.Foreground = CreateColor(colorInfo.DefaultForeground);

            if (colorInfo.DefaultBackground != null)
                hl.Background = CreateColor(colorInfo.DefaultBackground);

            if (colorInfo.DefaultColor3 != null)
                hl.Color3 = CreateColor(colorInfo.DefaultColor3);

            if (colorInfo.DefaultColor4 != null)
                hl.Color4 = CreateColor(colorInfo.DefaultColor4);

            return hl;
        }
Exemplo n.º 6
0
 public abstract IEnumerable<Tuple<object, object>> GetResourceKeyValues(MyHighlightingColor hlColor);
Exemplo n.º 7
0
 public override IEnumerable<Tuple<object, object>> GetResourceKeyValues(MyHighlightingColor hlColor)
 {
     if (ForegroundResourceKey != null) {
         Debug.Assert(hlColor.Foreground != null);
         yield return new Tuple<object, object>(ForegroundResourceKey, ((SolidColorBrush)hlColor.Foreground.GetBrush(null)).Color);
     }
     if (BackgroundResourceKey != null) {
         Debug.Assert(hlColor.Background != null);
         yield return new Tuple<object, object>(BackgroundResourceKey, ((SolidColorBrush)hlColor.Background.GetBrush(null)).Color);
     }
 }