Пример #1
0
        public static long Make(ByteColor color, bool i)
        {
            Debug.Assert(Unsafe.SizeOf <bool>() == 1);

            var ii = (long)Unsafe.As <bool, byte>(ref i);

            return(ii ^ color.HashCode);
        }
Пример #2
0
        public static Pen GetPen(ByteColor color, double thickness)
        {
            var hashCode = HashCodeMaker.Make(color, thickness);

            if (_borderPens.TryGetValue(hashCode, out var p))
            {
                return(p);
            }

            p = new Pen(GetSolidColorBrush(color), thickness);
            p.Freeze();

            _borderPens.Add(hashCode, p);

            return(p);
        }
Пример #3
0
        public static SolidColorBrush GetSolidColorBrush(ByteColor color)
        {
            var hashCode = HashCodeMaker.Make(color);

            if (_solidColorBrushes.TryGetValue(hashCode, out var b))
            {
                return(b);
            }

            b = new SolidColorBrush(color.ToColor());
            b.Freeze();

            _solidColorBrushes.Add(hashCode, b);

            return(b);
        }
Пример #4
0
        public static Pen GetCapPen(ByteColor color, double thickness)
        {
            var hashCode = HashCodeMaker.Make(color, thickness);

            if (_capPens.TryGetValue(hashCode, out var p))
            {
                return(p);
            }

            p = new Pen(GetSolidColorBrush(color), thickness)
            {
                StartLineCap = PenLineCap.Round,
                EndLineCap   = PenLineCap.Round
            };
            p.Freeze();

            _capPens.Add(hashCode, p);

            return(p);
        }
Пример #5
0
        public static Pen GetDashedPen(ByteColor color, double thickness)
        {
            unchecked
            {
                var hashCode = HashCodeMaker.Make(color, thickness);

                if (_dashedPens.TryGetValue(hashCode, out var p))
                {
                    return(p);
                }

                p = new Pen(GetSolidColorBrush(color), thickness)
                {
                    DashStyle = DashStyles.Dash
                };
                p.Freeze();

                _dashedPens.Add(hashCode, p);

                return(p);
            }
        }
Пример #6
0
 public Pen GetBorderPen(ByteColor color)
 => Caches.GetPen(color, RoundLayoutValue(FrameworkElementExtensions.BorderWidth));
Пример #7
0
        public static long Make(ByteColor color, double x)
        {
            var ix = Unsafe.As <double, long>(ref x);

            return(ix ^ color.HashCode);
        }
Пример #8
0
 public static long Make(ByteColor color)
 {
     return(color.HashCode);
 }