public void DrawHandler( ICtdMessageEncoder encoder, FontsArc.Font fontContext, Ctd.Message message, Ctd.Layout layout) { DrawPspScreen(); DrawDialog(layout); int BeginX = layout.DialogX + layout.TextX; int BeginY = layout.DialogY + layout.TextY; var x = BeginX; var y = BeginY; var texture1 = DrawingContext.CreateSurface(fontContext.Image1); var texture2 = DrawingContext.CreateSurface(fontContext.Image2); foreach (var ch in encoder.ToUcs(message.Data)) { if (ch >= 0x20) { var chInfo = fontContext.CharactersInfo.FirstOrDefault(info => info.Id == ch); if (chInfo == null) { if (ch == 0x20) { x += fontContext.Info.CharacterWidth / 2; } continue; } if (chInfo.Palette >= 2) { continue; } var texture = chInfo.Palette == 0 ? texture1 : texture2; var source = new Rectangle { X = chInfo.PositionX, Y = chInfo.PositionY, Width = chInfo.Width, Height = fontContext.Info.CharacterHeight }; DrawingContext.DrawSurface(texture, source, x, y); x += source.Width + layout.HorizontalSpace; } else { switch (ch) { case 0x0a: // '\n' x = BeginX; y += 16 + layout.VerticalSpace; break; } } } }
public MessageViewModel( IDrawHandler drawHandler, Ctd ctd, Ctd.Message message) { _drawHandler = drawHandler; _ctd = ctd; Message = message; DrawHandler = new RelayCommand(_ => { if (FontContext == null) { return; } var layout = _ctd.Layouts[Message.LayoutIndex]; _drawHandler.DrawHandler(CtdEncoders.International, FontContext, Message, layout); _drawHandler.DrawingContext.Flush(); }); }