示例#1
1
        //private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksOutside),
        //                                        Bitmap.BitmapImageType.Gif);
        //private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksInside),
        //                                        Bitmap.BitmapImageType.Gif);


        public override void Render(Bitmap screen)
        {
            if (_screen == null) _screen = screen;

            screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);

            var text = "AGENT";
            Point textLocation = new Point(
                AGENT.Center.X - (drawing.MeasureString(text, smallFont) / 2), AGENT.Center.Y - 25);
            screen.DrawText(text, smallFont, Color.White, textLocation.X, textLocation.Y);

            var date = Settings.Now.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.MonthDayPattern);
            ; //time.MonthNameShort + " " + time.Day;

            Point dateLocation = new Point(
                AGENT.Center.X - (drawing.MeasureString(date, smallFont) / 2), AGENT.Center.Y + 20);
            screen.DrawText(date, smallFont, Color.White, dateLocation.X, dateLocation.Y);

            //draw our hands
            drawing.PaintSkinnyHands(screen, Settings.Now, AGENT.Center);


            
            drawing.DrawTray(screen, _notificationProvider, smallFont);

        }
示例#2
0
        public void Render(Bitmap screen, bool military, ArrayList forecast)
        {
            DateTime now = DateTime.Now;
            string display = "";
            string hour, minute = now.Minute.ToString();
            if (military)
            {
                hour = now.Hour.ToString();
            }
            else
            {
                int h = now.Hour;
                if (h >= 12) h = h - 12;
                if (h == 0) h = 12;
                hour = h.ToString();
            }
            if (minute.Length == 1) minute = "0" + minute;

            display = hour + ":" + minute;
            screen.DrawLine(Color.White, 2, 0, Program.AgentSize/2, Program.AgentSize, Program.AgentSize/2);

            int left = Program.AgentSize - Program.MeasureString(display, bigfont);
            screen.DrawText(display, bigfont, Color.White, left, (Program.AgentSize/2) +2);
 
            string dow = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[(int) now.DayOfWeek];
            screen.DrawText(dow.ToString(), font, Color.White, 5, 10);

            string date = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames[(int) now.Month];
            date = date + " " + now.Day.ToString();
            screen.DrawText(date, font, Color.White, 5, 30);

        }
示例#3
0
        public void Render(Bitmap screen, bool military, ArrayList forecast)
        {
            screen.DrawLine(Color.White, 2, 0, Program.AgentSize / 2, Program.AgentSize, Program.AgentSize / 2);

            DateTime now = DateTime.Now;
            int counter = (int) now.DayOfWeek;
            counter++;
            int left =  buffer;
            Forecast nowForecast = null;
            bool needsDate = false;
            DateTime lastUpdated = DateTime.Now;
            for (int x = 0; x <= days; x++)
            {
                
                string dayName = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[counter];
                if (dayName.Length >= 3) dayName = dayName.Substring(0, 3);
                int width = Program.MeasureString(dayName, font);
                screen.DrawText(dayName, font, Color.White, left, top);
                if (forecast != null && forecast.Count > 0)
                {
                    Forecast current = null;
                    var startDate = now.Date.AddDays(x);
                    foreach (Forecast f in forecast)
                    {
                        if (f.Date.Year == now.Date.Year && f.Date.Month == now.Date.Month && f.Date.Day == now.Date.Day)
                            nowForecast = f;
                        if (startDate.Year == f.Date.Year && startDate.Month == f.Date.Month && startDate.Day == f.Date.Day)
                        {
                            Debug.Print("Found match");
                            current = f;
                            break;
                        }
                    }
                    if (current != null)
                    {
                        needsDate = true;
                        screen.DrawText(current.Current.ToString(), font, Color.White, left+4, top+font.Height + 2);
                        lastUpdated = current.LastUpdated;
                    }
                }
                counter++;
                if (counter > 6) counter = 0;
                left += width + buffer;
            }
            if (nowForecast != null)
            {
                string display = nowForecast.Current.ToString();
                int forecastLeft = Program.AgentSize - Program.MeasureString(display, bigfont);
                screen.DrawText(display, bigfont, Color.White, forecastLeft, (Program.AgentSize / 2) + 2);
                needsDate = true;
                lastUpdated = nowForecast.LastUpdated;
            }
            if (needsDate)
            {
                screen.DrawText(lastUpdated.ToString(), smallFont, Color.White, 3, (Program.AgentSize / 2)-smallFont.Height-1);
                
            }

        }
        protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object it, Style cStyle)
        {
            bool selected = _selIndex == index;
            RadioStationItem item = (RadioStationItem)it;

            if (selected)
                screen.DrawRectangle(Colors.Blue, 0, x, y, width, height, 0, 0,
                    cStyle.ListBoxSelectedItemBack1, x, y,
                    cStyle.ListBoxSelectedItemBack2, x, y + height, Enabled ? (ushort)256 : (ushort)128);

            Color textColor = item.IsConnecting ? Colors.Yellow : (item.IsPlaying ? Colors.LightGreen : (Enabled ? (selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor) : cStyle.TextBoxDisabledTextColor));
            screen.DrawText(item.Name, nameFont, textColor, x + 5, y + 2);
            screen.DrawText(item.Address, textFont, textColor, x + 5, y + 2 + nameFont.Height + 2);
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    const string text = "Hello World";
                    int textWidth, textHeight;

                    Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
                    font.ComputeExtent(text, out textWidth, out textHeight);
                    int textX = (Dimensions.Width - textWidth)/2;

                    var rand = new Random();

                    for (int x = 0; x < 3; x++)
                    {
                        int baseColor = rand.Next(0xffff);
                        for (int i = 0; i < Dimensions.Height; i++)
                        {
                            bmp.Clear();
                            bmp.DrawText(text, font, (Color) (((255 - i) << 16) | baseColor), textX, i);
                            bmp.Flush();
                        }
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
示例#6
0
        /// <summary>
        /// Draw text in a vertical and horizontal position
        /// When "align" is "Center" then "margin" is ignored.
        /// Also when "vAlign" is "Middle" then "vMargin"  is ignored.
        /// </summary>
        /// <param name="screen"></param>
        /// <param name="color"></param>
        /// <param name="font"></param>
        /// <param name="inString"></param>
        /// <param name="align"></param>
        /// <param name="margin"></param>
        /// <param name="vAlign"></param>
        /// <param name="vMargin"></param>
        public void DrawAlignedText(Bitmap screen, Color color, Font font, string inString, HAlign align, int margin, VAlign vAlign, int vMargin)
        {

            Point p = new Point();
            var stringWidth = MeasureString(inString, font);
            var stringHeight = 0;
            var textAreaLength = 0;
           

            switch (align)
            {

                case HAlign.Left:

                    p.X = margin + 1;
                    break;

                case HAlign.Center:

                    textAreaLength = screen.Width - (margin * 2);
                    p.X = margin + ((textAreaLength - stringWidth) / 2);
                    break;

                case HAlign.Right:

                    textAreaLength = screen.Width - margin;
                    p.X = textAreaLength - stringWidth;
                    break;

            }

            stringHeight = font.Height;

            switch (vAlign)
            {

                case VAlign.Top:

                    p.Y = vMargin + 1;
                    break;

                case VAlign.Middle:

                    p.Y= (screen.Height / 2) - (stringHeight / 2);
                    break;

                case VAlign.Bottom:

                    p.Y = screen.Height - stringHeight - vMargin;
                    break;

            }

            screen.DrawText(inString, font, color, p.X, p.Y);

        }
示例#7
0
 public void Render(Bitmap screen)
 {
     screen.DrawText(
         Settings.Now.ToString(DateTimeFormatInfo.CurrentInfo.ShortTimePattern),
         font,
         Color.White, 
         0,
         0
         );
 }
示例#8
0
        public void Render(Bitmap screen, bool military, ArrayList forecast)
        {
            
            var time = new Time();
            time.CurrentTime = DateTime.Now;
            screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);


            var text = "agent";
            Point textLocation = new Point(
                Program.Center.X - (Program.MeasureString(text, font) / 2), Program.Center.Y - 25);
            screen.DrawText(text, font, Color.White, textLocation.X, textLocation.Y);

            var date = time.MonthNameShort + " " + time.Day;
            Point dateLocation = new Point(
                Program.Center.X - (Program.MeasureString(date, font) / 2), Program.Center.Y + 20);
            screen.DrawText(date, font, Color.White, dateLocation.X, dateLocation.Y);

            PaintSkinnyHands(screen, time);
        }
示例#9
0
        public static void Main()
        {
            IPAddress Server = IPAddress.Parse("1.2.3.4");
            string SharedSecret = "SharedSecret";
            string UserName = "******";
            string UserPassword = "******";

            Bitmap screen = new Bitmap(320, 240);   // emulator display size
            Font font = Resources.GetFont(Resources.FontResources.NinaB);

            RadiusResult result;
            using (Client client = new Client(Server, SharedSecret))
            {
                client.AddAttribute(AttributeType.UserName, UserName);
                client.AddAttribute(AttributeType.UserPassword, UserPassword);
                result = client.Authenticate();
            };

            switch (result)
            {
                case RadiusResult.LocalError:
                    screen.DrawText("Result: LocalError", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
                    break;
                case RadiusResult.NoResponse:
                    screen.DrawText("Result: NoResponse", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
                    break;
                case RadiusResult.AccessAccept:
                    screen.DrawText("Result: AccessAccept", font, ColorUtility.ColorFromRGB(0, 0xff, 0), 50, 50);
                    break;
                case RadiusResult.AccessReject:
                    screen.DrawText("Result: AccessReject", font, ColorUtility.ColorFromRGB(0xff, 0, 0), 50, 50);
                    break;
                case RadiusResult.NotImplemented:
                    screen.DrawText("Result: NotImplemented", font, ColorUtility.ColorFromRGB(0, 0, 0xff), 50, 50);
                    break;
            }
            screen.Flush();
            Thread.Sleep(Timeout.Infinite);
        }
示例#10
0
        public override void Render(Bitmap screen)
        {
            if (base._screen == null) _screen = screen;

 
            DateTime now = DateTime.Now;
            string display = "";
            string hour, minute = now.Minute.ToString();
            if (Settings.TimeInISONotatation)
            {
                hour = now.Hour.ToString();
            }
            else
            {
                int h = now.Hour;
                if (h >= 12) h = h - 12;
                if (h == 0) h = 12;
                hour = h.ToString();
            }
            if (minute.Length == 1) minute = "0" + minute;

            display = hour + ":" + minute;
            screen.DrawLine(Color.White, 2, 0, AGENT.Contrib.Device.Size/2, AGENT.Contrib.Device.Size, AGENT.Contrib.Device.Size/2);

            int left = AGENT.Contrib.Device.Size - base.drawing.MeasureString(display, bigfont);
            screen.DrawText(display, bigfont, Color.White, left, (AGENT.Contrib.Device.Size/2) + 2);

            string dow = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[(int) now.DayOfWeek];
            screen.DrawText(dow.ToString(), font, Color.White, 5, 15);

            string date = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames[(int) now.Month];
            date = date + " " + now.Day.ToString();
            screen.DrawText(date, font, Color.White, 5, 35);

            drawing.DrawTray(screen, _notificationProvider, smallFont);


        }
示例#11
0
        public static void Main()
        {
            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            Font fontNinaB = Resources.GetFont(Resources.FontResources.NinaB);
            _display.DrawText("Waiting.", fontNinaB, Color.White, 10, 64);
            _display.Flush();

            var connection = new Connection("COM3", new CSVChannel());
            connection.Open();
            connection.OnReceived+=connection_OnReceived;
            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
示例#12
0
        /// <summary>
        /// Converts this ByteMatrix to a black and white bitmap.
        /// </summary>
        /// <returns>A black and white bitmap converted from this ByteMatrix.</returns>
        public Bitmap ToBitmap(BarcodeFormat format, String content)
        {
            int width = Width;
            int height = Height;
            bool outputContent = !(content == null || content.Length == 0) && (format == BarcodeFormat.CODE_39 ||
                                                                    format == BarcodeFormat.CODE_128 ||
                                                                    format == BarcodeFormat.EAN_13 ||
                                                                    format == BarcodeFormat.EAN_8 ||
                                                                    format == BarcodeFormat.CODABAR ||
                                                                    format == BarcodeFormat.ITF ||
                                                                    format == BarcodeFormat.UPC_A);
            int emptyArea = outputContent ? 16 : 0;

            // create the bitmap and lock the bits because we need the stride
            // which is the width of the image and possible padding bytes
            var bmp = new Bitmap(width, height);
            for (int y = 0; y < height - emptyArea; y++)
            {
                for (var x = 0; x < width; x++)
                {
                    var color = this[x, y] ? Color.Black : Color.White;
                    bmp.SetPixel(x, y, color);
                }
            }

            if (outputContent)
            {
                //switch (format)
                //{
                //   case BarcodeFormat.EAN_8:
                //      if (content.Length < 8)
                //         content = OneDimensionalCodeWriter.CalculateChecksumDigitModulo10(content);
                //      content = content.Insert(4, "   ");
                //      break;
                //   case BarcodeFormat.EAN_13:
                //      if (content.Length < 13)
                //         content = OneDimensionalCodeWriter.CalculateChecksumDigitModulo10(content);
                //      content = content.Insert(7, "   ");
                //      content = content.Insert(1, "   ");
                //      break;
                //}
                bmp.DrawText(content, null, Color.Black, width / 2, height - 14);
            }

            return bmp;
        }
示例#13
0
 static public void DrawString(Font font, String text, int x, int y, UInt32 text_color, UInt32 back_color)
 {
     int width = 0;
     for (int i = 0; i < text.Length; i++)
     {
         width+=font.CharWidth((char)(text[i]));
     }
     Bitmap bmp = new Bitmap(width, font.Height);
     bmp.DrawRectangle((Microsoft.SPOT.Presentation.Media.Color)back_color, 100, 0, 0, width, font.Height, 0, 0, (Microsoft.SPOT.Presentation.Media.Color)back_color, 0, 0, (Microsoft.SPOT.Presentation.Media.Color)back_color, 0, 0, 0);
     bmp.DrawText(text, font, (Microsoft.SPOT.Presentation.Media.Color)text_color, 0, 0);
     Image imge = new Image(bmp); // Note: Maybe out of memory here
     DrawImage(imge, x, y);
     bmp.Dispose();
     bmp = null;
     imge.Dispose();
     imge = null;
 }
示例#14
0
        public void Render(Bitmap screen, Font font, int height, int width, int borderBuffer, Color ForegroundColor, Color BackgroundColor)
        {
            if (Text != null && Text != "")
            {
                Color forColor = ForegroundColor;
                Color bColor = BackgroundColor;

                if (Selected)
                {
                    forColor = BackgroundColor;
                    bColor = ForegroundColor;
                }         
                screen.DrawRectangle(forColor, 1, Point.X, Point.Y, width + borderBuffer * 2,
                                     height + borderBuffer * 2, 0, 0, bColor, 0, 0,
                                     bColor, 0, 0, 255);

                screen.DrawText(Text, font, forColor, Point.X + borderBuffer, Point.Y + borderBuffer);
            }
        }
示例#15
0
        /// <summary>
        /// A demonstration as to how to handle multiple button presses at the same time
        /// </summary>

        public static void Main()
        {

            ButtonHelper.ButtonSetup = new Buttons[]{ Buttons.TopRight, Buttons.MiddleRight, Buttons.BottomRight,};
            ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;

            buttonStates = new Hashtable();
            buttonStates.Add(Buttons.TopRight, ButtonDirection.Up);
            buttonStates.Add(Buttons.MiddleRight, ButtonDirection.Up);
            buttonStates.Add(Buttons.BottomRight, ButtonDirection.Up);

            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            _display.DrawText("Hello world.", fontNinaB, Color.White, 10, 64);
            _display.Flush();

            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
示例#16
0
文件: Program.cs 项目: cyberh0me/OTP
        public static void Main()
        {
            string key = "jk4c6nbf6huccmwp";
            string label = ".NETmf TOTP";

            Bitmap screen = new Bitmap(320, 240);   // emulator display size
            Font font = Resources.GetFont(Resources.FontResources.NinaB);

            otp = new OTP(key);

            Bitmap qrcode = otp.QRCode(key, label);
            screen.DrawImage(10, 10, qrcode, 0, 0, qrcode.Width, qrcode.Height);

            // by design (at least ms and google authenticator) change every 30 seconds(@ 0 and 30)
            while (DateTime.Now.Second != 0 && DateTime.Now.Second != 30) ;

            while (true)
            {
                screen.DrawRectangle(Color.Black, 1, 220, 10, 100, 32, 0, 0, Color.Black, 0, 0, Color.Black, 50, 30, 0xff);
                screen.DrawText(otp.TOTP, font, Color.White, 220, 10);
                screen.Flush();
                Thread.Sleep(30000);
            }
        }
示例#17
0
        public void DrawTray(Bitmap screen, IProvideNotifications notificationProvider, Font font )
        {
            //battery level
            var level = Battery.Level;// Util.Random.Next(0, 100);
            this.DrawBattery(screen, new Point(1, 0), 13, 9, 1, Color.White, Color.Black, Battery.Charging,
                                level);
            screen.DrawText(level.ToString(), font, Color.White, 15, -2);

            var notificationSummary = new NotificationSummary(notificationProvider);
            if (notificationSummary.MissedCallCount > 99) notificationSummary.MissedCallCount = 99;
            if (notificationSummary.EmailCount > 99) notificationSummary.EmailCount = 99;
            if (notificationSummary.TextCount > 99) notificationSummary.TextCount = 99;
            if (notificationSummary.VoiceCount > 99) notificationSummary.VoiceCount = 99;

            if (notificationSummary.EmailCount > 0)
            {
                Debug.Print("Emails: " + notificationSummary.EmailCount.ToString());
                screen.DrawImage(33, 0, EmailImage, 0, 0, EmailImage.Width, EmailImage.Height);
                screen.DrawText(notificationSummary.EmailCount.ToString(), font, Color.White, 45, -2);
            }
            if (notificationSummary.TextCount > 0)
            {
                Debug.Print("Text: " + notificationSummary.TextCount.ToString());
                screen.DrawImage(58, 0, TextImage, 0, 0, TextImage.Width, TextImage.Height);
                screen.DrawText(notificationSummary.TextCount.ToString(), font, Color.White, 70, -2);
            }
            if (notificationSummary.VoiceCount > 0)
            {
                Debug.Print("Voice: " + notificationSummary.VoiceCount.ToString());
                screen.DrawImage(83, 0, VoiceMailImage, 0, 0, VoiceMailImage.Width, VoiceMailImage.Height);
                screen.DrawText(notificationSummary.VoiceCount.ToString(), font, Color.White, 95, -2);
            }
            if (notificationSummary.MissedCallCount > 0)
            {
                Debug.Print("Missed Calls: " + notificationSummary.MissedCallCount.ToString());
                screen.DrawImage(106, 0, CalendarImage, 0, 0, CalendarImage.Width, CalendarImage.Height);
                screen.DrawText(notificationSummary.MissedCallCount.ToString(), font, Color.White, 117, -2);
            }


        }
        public void Render(Bitmap screen)
        {
            Screen = screen;
            if (Buttons != null)
            {
                screen.Clear();
                foreach (CalculatorButton button in Buttons)
                {
                    button.Render(screen, font, ButtonHeight, ButtonWidth, ButtonBorder, ForegroundColor,
                                  BackgroundColor);
                }


                //calculation result
                screen.DrawText(input, font, BackgroundColor, 2, 2);
                screen.DrawText(secondInput + op, font, BackgroundColor, 2, 2 + font.Height + 2);

                //draw a simple border for the digit display
                screen.DrawRectangle(ForegroundColor, 1, 1, 1, Program.AgentSize, 28, 0, 0,
                                     BackgroundColor, 0, 0, BackgroundColor, 0, 0, 0);

                //draw a simple border
                screen.DrawRectangle(Color.White, 1, 1, 1, Program.AgentSize, Program.AgentSize, 0, 0,
                                     BackgroundColor, 0, 0, BackgroundColor, 0, 0, 0);

                screen.Flush();
            }
        }
示例#19
0
        public static void WriteSimple(string str, uint x, uint y)
        {
            int withString = 0;
            int heightString = 0;
            Font font = Resources.GetFont(Resources.FontResources.small);
            font.ComputeExtent(str, out withString, out heightString);

            Bitmap textBmp = new Bitmap(withString, heightString);
            //textBmp.DrawRectangle(GT.Color.White, 1, 0, 0, 75, 12, 0, 0, GT.Color.White, 0, 0, GT.Color.White, 75, 12, 0xFF);
            textBmp.DrawText(str, font, GT.Color.White, 0, 0);
            Screen.Draw(textBmp, x, y);
            textBmp.Dispose();
        }
示例#20
0
        public override void Render(Bitmap screen)
        {
            if (base._screen == null) _screen = screen;
            screen.DrawLine(Color.White, 2, 0, AGENT.Contrib.Device.Size/2 - 10, AGENT.Contrib.Device.Size, AGENT.Contrib.Device.Size/2 - 10);
            screen.DrawImage(0, AGENT.Contrib.Device.Size - monthGrid.Height, monthGrid, 0, 0, monthGrid.Width, monthGrid.Height);
            foreach (Day day in days)
            {
                if (day.Timestamp.Date == Settings.Now.Date)
                {
                    screen.DrawRectangle(Color.White, 1, day.Point.X-2, day.Point.Y+1, 19, 11, 0, 0, Color.White, 0, 0,
                                         Color.White, 0, 0, 255);
                    screen.DrawText(day.Text, font, Color.Black, day.Point.X, day.Point.Y);
                }
                else
                {
                    screen.DrawText(day.Text, font, Color.White, day.Point.X, day.Point.Y);
                }

            }

            string date = Settings.Now.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.LongDatePattern);
            screen.DrawText(date, font, Color.White, 5, 15);


            string dow = "Day: " + Settings.Now.DayOfYear.ToString();
            screen.DrawText(dow.ToString(), font, Color.White, 5, 35);
         
            drawing.DrawTray(screen, _notificationProvider, smallFont);

        }
示例#21
0
 private void ShowSDCardMissingMessage()
 {
     var bitmap = new Bitmap(320, 240);
     bitmap.DrawText("SD Card is not mounted", Resources.GetFont(Resources.FontResources.NinaB), Colors.Yellow, 50, 100);
     bitmap.Flush();
 }
示例#22
0
 private void WriteLine(string str, uint x,uint y)
 {
     uint size = 15;
     Bitmap textBmp = new Bitmap((int)_Screen.Width, (int)size);
     //textBmp.DrawRectangle(GT.Color.White, 1, 0, 0, 75, 12, 0, 0, GT.Color.White, 0, 0, GT.Color.White, 75, 12, 0xFF);
     textBmp.DrawText(str, _FontItem, GT.Color.White, 0, 0);
     _Screen.Draw(textBmp, x, y);
     textBmp.Dispose();
 }
示例#23
0
 private void WriteLineSelected(string str, uint x, uint y)
 {
     int size = 15;
     Bitmap textBmp = new Bitmap((int)_Screen.Width, (int)size);
     textBmp.DrawRectangle(GT.Color.White, 0, 0, 0, (int)_Screen.Width, size, 0, 0, GT.Color.White, 0, 0, GT.Color.White, 0, 0, 0xFF);
     textBmp.DrawText(str, _FontTitle, GT.Color.Black, 0, 0);
     _Screen.Draw(textBmp, x, y);
     textBmp.Dispose();
 }
示例#24
0
		public override void Run()
		{
			try
			{
				Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height );
				Font font = Resources.GetFont( Resources.FontResources.GLANCEABLE );

                Random rand = new Random();

				for(int x = 0; x < 10; x++)
				{
					int baseColor = rand.Next( 0xffff );
					for(int i = 0; i < Dimensions.Height; i++)
					{
						bmp.Clear();
						bmp.DrawText( "Hello World :) 12345", font, (Presentation.Media.Color)(((255 - i) << 16) | baseColor), 0, i );
						bmp.Flush();
					}
				}
				Pass = true;
			}
			catch(Exception e)
			{
				UnexpectedException( e );
			}
		}
示例#25
0
		/// <summary>
		/// Draws a string to the display.
		/// </summary>
		/// <param name="text">The text to write.</param>
		/// <param name="x">The x coordinate where to draw.</param>
		/// <param name="y">The y coordinate where to draw.</param>
		/// <param name="font">The font to use.</param>
		/// <param name="foreColor">The color of the text.</param>
		/// <param name="backColor">The background color of the text.</param>
		public static void Draw(string text, int x, int y, Font font, Color foreColor, Color backColor)
        {
            int width = 0;
            for (int i = 0; i < text.Length; i++)
            {
                width += font.CharWidth((char)(text[i]));
            }

            Bitmap bmp = new Bitmap(width, font.Height);
			bmp.DrawRectangle(backColor, 100, 0, 0, width, font.Height, 0, 0, backColor, 0, 0, backColor, 0, 0, 0);
			bmp.DrawText(text, font, foreColor, 0, 0);

			Display.Draw(new TinyBitmap(bmp), x, y);
        }
示例#26
0
 /// <summary>
 /// Draw text right in the center of the screen
 /// </summary>
 /// <param name="screen"></param>
 /// <param name="text"></param>
 /// <param name="font"></param>
 /// <param name="color"></param>
 public void DrawTextCentered(Bitmap screen, string text, Font font, Color color)
 {
     var center = FindCenter(text, font);
     screen.DrawText(text, font, color, center.X, center.Y);
 }
示例#27
0
        private void UpdateHud(Bitmap surface, int score)
        {
            int y = 10;
              int x = 244;

              surface.DrawText("Level", _font, Colors.White, x, y);
              surface.DrawText(Level.ToString(), _font, Colors.White, x, y + 20);

              y += 45;
              surface.DrawText("Score", _font, Colors.White, x, y);
              surface.DrawText(score.ToString(), _font, Colors.White, x, y + 20);

              y += 45;
              surface.DrawText("Lives", _font, Colors.White, x, y);
              for (int i = 0; i < _pacman.Lives; ++i)
            surface.DrawImage(x + (i << 4), y + 20, _spriteSheet, 32, 0, 16, 16);
        }
示例#28
0
        private void OutputToScreen(string text)
        {
            mainWindow = new Window();
            mainWindow.Width = SystemMetrics.ScreenWidth;
            mainWindow.Height = SystemMetrics.ScreenHeight;

            Font NinaBFont = Resources.GetFont(Resources.FontResources.NinaB);
            Bitmap mp = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
            
            int x = SystemMetrics.ScreenWidth / 2 - text.Length * 2;
            int y = SystemMetrics.ScreenHeight / 2;
            mp.DrawText(text,NinaBFont, Color.White, x-70, height);
            height += 15;
            mp.Flush();
        }
示例#29
0
        protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object it, Style cStyle)
        {
            bool selected = _selIndex == index;
            FsItem item = (FsItem)it;

            if (selected)
                screen.DrawRectangle(Colors.Blue, 0, x, y, width, height, 0, 0,
                    cStyle.ListBoxSelectedItemBack1, x, y,
                    cStyle.ListBoxSelectedItemBack2, x, y + height, Enabled ? (ushort)256 : (ushort)128);

            Color textColor = _playing == it ? Colors.Green : (Enabled ? (selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor) : cStyle.TextBoxDisabledTextColor);
            Bitmap toDraw = item.IsBack ? fsBack : (item.IsDirectory ? fsFolder : (item.IsMusicFile ? fsMusic : fsNone));

            screen.DrawImage(x + 5, y + (ItemHeight - 16) / 2, toDraw, 0, 0, 16, 16);
            screen.DrawText(item.Name, nameFont, textColor, x + 26, y + (ItemHeight - nameFont.Height) / 2);
        }