Esempio n. 1
0
        protected Color SelectItemColor(TItem item)
        {
            var hashBytes = ImmutableBufferPool.GetBytes(item.GetHashCode());
            var id        = BitConverter.ToInt32(hashBytes.Array, hashBytes.Offset);

            int hue   = (id & 0xFFFF) % (HSV.HueMax);
            int value = ((id & (0xFFFF << 16)) % (HSV.ValueMax * 70 / 100)) + (HSV.ValueMax * 25 / 100);

            return(HSV.ColorFromHSV(
                       (UInt16)hue, HSV.SaturationMax, (UInt16)value
                       ));
        }
Esempio n. 2
0
        static unsafe void SerializeAddresses(ref SerializationContext context, ref UInt32[] input)
        {
            var stream = context.Stream;
            var buffer = new byte[input.Length * 4];

            var lengthBytes = ImmutableBufferPool.GetBytes(input.Length);

            stream.Write(lengthBytes.Array, lengthBytes.Offset, lengthBytes.Count);

            fixed(byte *pBuffer = buffer)
            fixed(UInt32 * pInput = input)
            Native.memmove(pBuffer, (byte *)pInput, new UIntPtr((uint)buffer.Length));

            stream.Write(buffer, 0, buffer.Length);
        }
Esempio n. 3
0
        public override int GetHashCode()
        {
            var tbid = ImmutableBufferPool.GetBytes(TracebackID);

            return(BitConverter.ToInt32(tbid.Array, tbid.Offset));
        }