Exemplo n.º 1
0
        protected override void CreateResources()
        {
            _sceneBrush = RenderTarget.CreateSolidColorBrush(Color.Black);

            // Background grid brush
            var bitmapTarget = RenderTarget.CreateCompatibleRenderTarget(new SizeF(10, 10));
            var gridBrush    = bitmapTarget.CreateSolidColorBrush(new ColorF(.93f, .94f, .96f));

            bitmapTarget.BeginDraw();
            bitmapTarget.FillRectangle(RectangleF.FromLTRB(0, 0, 10, 1), gridBrush);
            bitmapTarget.FillRectangle(RectangleF.FromLTRB(0, 0, 1, 10), gridBrush);
            bitmapTarget.EndDraw().ThrowIfFailed();
            IBitmap bitmap = bitmapTarget.GetBitmap();

            _gridPatternBrush = RenderTarget.CreateBitmapBrush(bitmap, new BitmapBrushProperties(ExtendMode.Wrap, ExtendMode.Wrap));

            // Gradient brush
            Span <GradientStop> stops = stackalloc[]
            {
                new GradientStop(0.0f, Color.Gold),
                new GradientStop(0.85f, new ColorF(Color.Orange, 0.8f)),
                new GradientStop(1.0f, new ColorF(Color.OrangeRed, 0.7f))
            };

            _radialGradientBrush = RenderTarget.CreateRadialGradientBrush(
                new RadialGradientBrushProperties(new PointF(330, 330), new PointF(140, 140), 140, 140),
                RenderTarget.CreateGradienStopCollection(stops));
        }
Exemplo n.º 2
0
        public ISolidColorBrush RandomColor()
        {
            var r     = new Random().Next(0, 5);
            var color = new ISolidColorBrush [] { Brushes.Red, Brushes.Blue, Brushes.Green, Brushes.Yellow, Brushes.Purple };

            return(color[r]);
        }
Exemplo n.º 3
0
 private void SetXButtonBrush(ISolidColorBrush brush)
 {
     if (brush != _xbuttonBrush)
     {
         _xbuttonBrush = brush;
         XButton.Brush = brush;
         this.InvalidateVisual();
     }
 }
Exemplo n.º 4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var param = "DEFAULT";

            try {
                param = value.ToString().ToUpperInvariant();
            }
            catch (Exception ex) {
                Logging.Log(Logger, new LogItem(ex, true));
            }

            ISolidColorBrush brush = ColorStringToBrush(Settings.Default.DefaultProgressBarForeground);

            switch (param)
            {
            case "PLD":
                brush = ColorStringToBrush(Settings.Default.PLDProgressBarForeground);
                break;

            case "DRG":
                brush = ColorStringToBrush(Settings.Default.DRGProgressBarForeground);
                break;

            case "BLM":
                brush = ColorStringToBrush(Settings.Default.BLMProgressBarForeground);
                break;

            case "WAR":
                brush = ColorStringToBrush(Settings.Default.WARProgressBarForeground);
                break;

            case "WHM":
                brush = ColorStringToBrush(Settings.Default.WHMProgressBarForeground);
                break;

            case "SCH":
                brush = ColorStringToBrush(Settings.Default.SCHProgressBarForeground);
                break;

            case "MNK":
                brush = ColorStringToBrush(Settings.Default.MNKProgressBarForeground);
                break;

            case "BRD":
                brush = ColorStringToBrush(Settings.Default.BRDProgressBarForeground);
                break;

            case "SMN":
                brush = ColorStringToBrush(Settings.Default.SMNProgressBarForeground);
                break;
            }

            return(brush);
        }
Exemplo n.º 5
0
        public MazeCanvas() : base()
        {
            _mazeTileBrush = Avalonia.Media.Brushes.Black;
            _mazeTilePen   = new Avalonia.Media.Pen(_mazeTileBrush);

            BusyGeneratingMaze2 = new Subject <bool>();
            BusyGeneratingMaze2.OnNext(false);
            GenerateMazeBind = ReactiveCommand.CreateFromTask(GenerateMaze, canExecute: BusyGeneratingMaze2);
            BusyGeneratingMaze2.OnNext(false);
            BusyGeneratingMaze = true;
        }
Exemplo n.º 6
0
 public SolidColorBrushImpl(ISolidColorBrush brush, SharpDX.Direct2D1.RenderTarget target)
 {
     PlatformBrush = new SharpDX.Direct2D1.SolidColorBrush(
         target,
         brush?.Color.ToDirect2D() ?? new SharpDX.Mathematics.Interop.RawColor4(),
         new SharpDX.Direct2D1.BrushProperties
         {
             Opacity = brush != null ? (float)brush.Opacity : 1.0f,
             Transform = target.Transform
         }
     );
 }
 public SolidColorBrushImpl(ISolidColorBrush brush, SharpDX.Direct2D1.RenderTarget target)
 {
     PlatformBrush = new SharpDX.Direct2D1.SolidColorBrush(
         target,
         brush?.Color.ToDirect2D() ?? new SharpDX.Mathematics.Interop.RawColor4(),
         new SharpDX.Direct2D1.BrushProperties
     {
         Opacity   = brush != null ? (float)brush.Opacity : 1.0f,
         Transform = target.Transform
     }
         );
 }
Exemplo n.º 8
0
 public void SetAsicColumnColor(ISolidColorBrush colorBrush)
 {
     ColumnList.Chain[j].Background     = colorBrush;
     ColumnList.Frequency[j].Background = colorBrush;
     ColumnList.Status[j].Background    = colorBrush;
     ColumnList.Watts[j].Background     = colorBrush;
     ColumnList.GHideal[j].Background   = colorBrush;
     ColumnList.HW[j].Background        = colorBrush;
     ColumnList.TempChip[j].Background  = colorBrush;
     ColumnList.GHRT[j].Background      = colorBrush;
     ColumnList.TempPCB[j].Background   = colorBrush;
 }
Exemplo n.º 9
0
        // Helper Methods
        protected static Ellipse GenerateIOPort(Point pos, ISolidColorBrush color)
        {
            const double diameter = MainWindow.GridCellSize / 2.0;
            var          result   = new Ellipse {
                Fill = color, Width = diameter, Height = diameter
            };

            App.MainWindow.GridCanvas.Canvas.Children.Add(result);
            Canvas.SetLeft(result, pos.X - diameter / 2);
            Canvas.SetTop(result, pos.Y - diameter / 2);
            return(result);
        }
Exemplo n.º 10
0
        protected override void CreateResources()
        {
            string text = "Hello World From ... DirectWrite!";

            _blackBrush = RenderTarget.CreateSolidColorBrush(Color.Black);
            _textLayout = DirectWriteFactory.CreateTextLayout(text, _textFormat, RenderTarget.GetSize());

            // (21, 12) is the range around "DirectWrite!"
            _textLayout.SetFontSize(100, (21, 12));
            _typography = DirectWriteFactory.CreateTypography();
            _typography.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
            _textLayout.SetTypography(_typography, (0, text.Length));
            _textLayout.SetUnderline(true, (21, 12));
            _textLayout.SetFontWeight(FontWeight.Bold, (21, 12));
        }
Exemplo n.º 11
0
 protected override void CreateResources()
 {
     _blackBrush  = RenderTarget.CreateSolidColorBrush(Color.Black);
     _silverBrush = RenderTarget.CreateSolidColorBrush(Color.Silver);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Append rich text to the scrolling element
 /// </summary>
 /// <param name="text">Text to add, including newlines</param>
 /// <param name="color">Color to format the text</param>
 public void AppendToTextBox(string text, ISolidColorBrush color)
 {
     // TODO: Use brush color
     this.Find <TextBox>("Output").Text += $"{text}\n";
 }
Exemplo n.º 13
0
 internal SimpleHighlightingBrush(ISolidColorBrush brush)
 {
     _brush = brush;
 }
Exemplo n.º 14
0
            static IReadOnlyList <ImmutableGradientStop> CreateStopsFromSolidColorBrush(ISolidColorBrush solidColorBrush, IReadOnlyList <IGradientStop> baseStops)
            {
                var stops = new ImmutableGradientStop[baseStops.Count];

                for (int index = 0; index < baseStops.Count; index++)
                {
                    stops[index] = new ImmutableGradientStop(baseStops[index].Offset, solidColorBrush.Color);
                }
                return(stops);
            }
Exemplo n.º 15
0
 protected override void CreateResources()
 {
     _lightSlateGrayBrush = RenderTarget.CreateSolidColorBrush(Color.LightSlateGray);
     _cornflowerBlueBrush = RenderTarget.CreateSolidColorBrush(Color.CornflowerBlue);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableSolidColorBrush"/> class.
 /// </summary>
 /// <param name="source">The brush from which this brush's properties should be copied.</param>
 public ImmutableSolidColorBrush(ISolidColorBrush source)
     : this(source.Color, source.Opacity)
 {
 }
 public static ISolidColorBrush CreateRef(this ISolidColorBrush objectRef) =>
 ((ISolidColorBrush)objectRef.CreateRef(typeof(ISolidColorBrush)));
Exemplo n.º 18
0
        internal static IGradientBrush ConvertSolidColorBrushToGradient(IGradientBrush gradientBrush, ISolidColorBrush solidColorBrush)
        {
            switch (gradientBrush)
            {
            case IRadialGradientBrush oldRadial:
                return(new ImmutableRadialGradientBrush(
                           CreateStopsFromSolidColorBrush(solidColorBrush, oldRadial.GradientStops), solidColorBrush.Opacity,
                           oldRadial.SpreadMethod, oldRadial.Center, oldRadial.GradientOrigin, oldRadial.Radius));

            case IConicGradientBrush oldConic:
                return(new ImmutableConicGradientBrush(
                           CreateStopsFromSolidColorBrush(solidColorBrush, oldConic.GradientStops), solidColorBrush.Opacity,
                           oldConic.SpreadMethod, oldConic.Center, oldConic.Angle));

            case ILinearGradientBrush oldLinear:
                return(new ImmutableLinearGradientBrush(
                           CreateStopsFromSolidColorBrush(solidColorBrush, oldLinear.GradientStops), solidColorBrush.Opacity,
                           oldLinear.SpreadMethod, oldLinear.StartPoint, oldLinear.EndPoint));

            default:
                throw new NotSupportedException($"Gradient of type {gradientBrush?.GetType()} is not supported");
            }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableSolidColorBrush"/> class.
 /// </summary>
 /// <param name="source">The brush from which this brush's properties should be copied.</param>
 public ImmutableSolidColorBrush(ISolidColorBrush source)
     : this(source.Color, source.Opacity, source.Transform?.ToImmutable())
 {
 }
 static SpecialCharacterTextRun()
 {
     DarkGrayBrush = new ImmutableSolidColorBrush(Color.FromArgb(200, 128, 128, 128));
 }
Exemplo n.º 21
0
 private static TextBlock CreateTextBlock(string text, int fontSize, int width, Thickness margin, ISolidColorBrush color)
 {
     return(new TextBlock()
     {
         Text = text,
         FontSize = fontSize,
         Width = width,
         Margin = margin,
         Background = color
     });
 }