Exemplo n.º 1
0
        private void Draw(DrawContext context, MessageCommandModel command)
        {
            if (command.Command == MessageCommand.PrintText)
            {
                DrawText(context, command);
            }
            else if (command.Command == MessageCommand.PrintComplex)
            {
                DrawText(context, command);
            }
            else if (command.Command == MessageCommand.PrintIcon)
            {
                DrawIcon(context, command.Data[0]);
            }
            else if (command.Command == MessageCommand.Color)
            {
                SetColor(context, command.Data);
            }
            else if (command.Command == MessageCommand.Reset)
            {
                context.Reset();
            }
            else if (command.Command == MessageCommand.Clear)
            {
                context.NewLine(_msgContext.FontHeight);
                context.y += 4;
                _drawing.FillRectangle(new RectangleF(
                                           8,
                                           (float)context.y,
                                           Math.Max(1.0f, (float)(context.WindowWidth - 16)),
                                           2), Color.White);
                context.y += 4;
            }
            else if (command.Command == MessageCommand.Position)
            {
                context.x = command.PositionX;
                context.y = command.PositionY;
            }
            else if (command.Command == MessageCommand.TextWidth)
            {
                context.WidthMultiplier = command.TextWidth;
            }
            else if (command.Command == MessageCommand.TextScale)
            {
                context.Scale = command.TextScale;
            }
            else if (command.Command == MessageCommand.Tabulation)
            {
                context.x += 16; // TODO this is not the real tabulation size
            }
            else if (command.Command == MessageCommand.NewLine)
            {
                context.NewLine(_msgContext.FontHeight);
            }

            context.Width  = Math.Max(context.Width, context.x);
            context.Height = Math.Max(context.Height, context.y + _msgContext.FontHeight * context.Scale);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draws the view
        /// </summary>
        /// <param name="drawing">drawing wrapper</param>
        /// <param name="options">drawing options</param>
        /// <param name="margin">drawing margin</param>
        public virtual void Draw(IDrawing drawing, IDrawOptions options, IMargin margin)
        {
            if (drawing == null || margin == null)
            {
                throw new InvalidArgumentException("parameter is null");
            }
            if (!(options is BackgroundDrawOptions))
            {
                throw new InvalidArgumentException("options is not compatible");
            }
            var state = ((BackgroundDrawOptions)options).State;

            drawing.FillRectangle(state.PenColor, state.BackgroundColor, 0, 0, options.CanvasSize.Width - 1, options.CanvasSize.Height - 1);
        }