Exemplo n.º 1
0
        public Kh2MessageRenderer(
            ISpriteDrawing drawing,
            RenderingMessageContext context)
        {
            _drawing    = drawing;
            _msgContext = context;

            _fontSpacing     = context.FontSpacing;
            _iconSpacing     = context.IconSpacing;
            _imageFont       = context.Font;
            _imageFont2      = context.Font2;
            _imageIcon       = context.Icon;
            _charPerRow      = context.Font?.Size.Width / context.FontWidth ?? 1;
            _iconPerRow      = context.Icon?.Size.Width / IconWidth ?? 1;
            _tableHeight     = context.TableHeight;
            _charTableHeight = context.TableHeight / context.FontHeight * context.FontHeight;
            _encode          = context.Encoder;

            if (_imageFont != null)
            {
                InitializeSurface(ref _spriteFont, _imageFont);
            }
            if (_imageFont2 != null)
            {
                InitializeSurface(ref _spriteFont2, _imageFont2);
            }
            if (_imageIcon != null)
            {
                InitializeSurface(ref _spriteIcon, _imageIcon);
            }
        }
Exemplo n.º 2
0
        public void EncodeNewLineCharacterCorrectly(EncoderType encoderType)
        {
            var encoder = new IMessageEncode[]
            {
                Encoders.InternationalSystem,
                Encoders.JapaneseEvent,
                Encoders.JapaneseSystem,
                Encoders.TurkishSystem
            }[(int)encoderType];

            var encoded = encoder.Encode(new List <MessageCommandModel>
            {
                new MessageCommandModel
                {
                    Command = MessageCommand.PrintText,
                    Text    = "HE\nLLO",
                }
            });

            Assert.Equal(new byte[] { 0x35, 0x32, 0x02, 0x39, 0x39, 0x3C }, encoded);
        }