Example #1
0
        public virtual void ChangeMessage(string message, bool keepOffset = false)
        {
            this.Message = string.IsNullOrWhiteSpace(message)
                               ? LedMessageBoard.Properties.Settings.Default.Global_DefaultViewPortMessage
                               : message;

            this.MessageWidth = LedFont.StringWidth(message);

            if (!keepOffset)
            {
                this.Offset = this.Width;
            }
        }
        public static ViewPort GetViewPort(string message, int width = ViewPort.MaxWidth)
        {
            width = Math.Min(width, ViewPort.MaxWidth);

            if (LedFont.StringWidth(message) > width)
            {
                return(new ScrollingViewPort(width, message));
            }
            else
            {
                return(new StaticViewPort(message));
            }
        }
Example #3
0
        private bool[,] RenderAsBools()
        {
            var result = new bool[MaxWidth, Height];

            int xloc = this.Offset + this.LeftMargin;

            foreach (var c in this.Message.ToCharArray())
            {
                this.RenderChar(c, xloc, ref result);
                xloc = xloc + LedFont.CharWidth(c) + 1;
            }

            return(result);
        }
Example #4
0
        private void RenderChar(char c, int offset, ref bool[,] buffer)
        {
            var charWidth   = LedFont.CharWidth(c);
            var blankOffset = LedFont.LeftBlankColumns(c);

            for (var x = 0; x < charWidth; x++)
            {
                var xi = x + offset;

                if (xi < this.LeftMargin || xi >= this.Width + this.LeftMargin)
                {
                    continue;
                }

                var xchar = x + blankOffset;

                for (var y = 0; y < Height; y++)
                {
                    var bit = LedFont.IsSet(c, xchar, y);

                    buffer[xi, y] = bit;
                }
            }
        }
 public StaticViewPort(string message) : base(LedFont.StringWidth(message), message)
 {
 }