public override void Run()
        {
            Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                for (int i = 0; i < 4; i++)
                {
                    bitmap.Clear();
                    bitmap.Flush();
                    Thread.Sleep(1000);

                    bitmap.DrawTextInRect("kodFilemon\n.blogspot\n.com", 0, 10,
                                          Dimensions.Width, Dimensions.Height-10,
                                          Bitmap.DT_AlignmentCenter, Colors.White, font);
                    bitmap.Flush();
                    Thread.Sleep(1000);
                }
            }
        }
        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var fonts = new[]
                                    {
                                        new FontItem {Name = "Arial 10", FontId = Resources.FontResources.arial10},
                                        new FontItem {Name = "Small", FontId = Resources.FontResources.small},
                                        new FontItem {Name = "Courier 11", FontId = Resources.FontResources.courier11}
                                    };

                    const string s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

                    foreach (var font in fonts)
                    {
                        bmp.Clear();

                        Font fnt = Resources.GetFont(font.FontId);

                        bmp.DrawRectangle((Color)0xFF0000, 0, 0, 0,
                                          Dimensions.Width, Dimensions.Height,
                                          0, 0, (Color)0xFF0000, 0, 0, (Color)0xFF0000, 0, 0,
                                          Bitmap.OpacityOpaque);

                        const Color color = (Color)0x0000FF;
                        bmp.DrawTextInRect(font.Name + " " + s, 0, 0, Dimensions.Width, Dimensions.Height,
                                           Bitmap.DT_WordWrap | Bitmap.DT_AlignmentLeft, color, fnt);

                        bmp.Flush();

                        Thread.Sleep(5000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #3
0
 public static void Main()
 {
     int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
     HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                               out bitsPerPixel, out orientationDeg);
     Bitmap bmp = new Bitmap(screenWidth, screenHeight);
     Font font = Resources.GetFont(Resources.FontResources.NinaB);
     string text = "There is another overload of the DrawTextInRect " +
                   "method. That method comes along with reference " +
                   "parameters for the input string and the x and y " +
                   "drawing positions. After drawing text, the " +
                   "method updates the x and y positions to tell you " +
                   "where on the display the drawing of the text " +
                   "finished. This allows you to draw parts of the text " +
                   "with a different color or font. Also, if the method " +
                   "cannot display the complete text within the specified " +
                   "rectangle, it returns the remaining text. " +
                   "In this case, the method returns false to indicate " +
                   "that there is some text left that could not " +
                   "displayed. This enables you to build up a display " +
                   "to show text over mulitple pages.";
     bool completed;
     do
     {
         int x = 0;
         int y = 0;
         //draw frame around text and clear old contents
         bmp.DrawRectangle(Color.White, 1, 20, 20, 150, 150, 0, 0, Color.Black, 0, 0, Color.Black, 0, 0, Bitmap.OpacityOpaque);
         completed = bmp.DrawTextInRect(
                              ref text,
                              ref x, ref y, // x and y text position
                              20, 20,       // x and y (rectangle top left)
                              150, 150,     // width and height of rectangle
                              Bitmap.DT_AlignmentLeft | Bitmap.DT_WordWrap,
                              Color.White,  // color
                              font);        // font
         bmp.Flush();
         Thread.Sleep(3000); //display each page for three seconds
     } while (!completed);
     Thread.Sleep(-1);
 }
        public override void Run()
        {
            try
            {
                Font font = Resources.GetFont(Resources.FontResources.small);
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    uint[] flags = { 
                                       Bitmap.DT_WordWrap | Bitmap.DT_AlignmentLeft,
                                       Bitmap.DT_WordWrap | Bitmap.DT_AlignmentCenter,
                                       Bitmap.DT_WordWrap | Bitmap.DT_AlignmentRight
                                   };


                    const string s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

                    for (int i = 0; i < flags.Length; i++)
                    {
                        bmp.DrawRectangle((Color) 0xFF0000, 0, 0, 0,
                                          Dimensions.Width, Dimensions.Height,
                                          0, 0, (Color) 0xFF0000, 0, 0, (Color) 0xFF0000, 0, 0,
                                          Bitmap.OpacityOpaque);

                        const Color color = (Color)0x0000FF;
                        bmp.DrawTextInRect(s, 0, 0, Dimensions.Width, Dimensions.Height,
                                           flags[i], color, font);

                        bmp.Flush();

                        Thread.Sleep(2000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Draw event on 64 x 48 bitmap
        /// </summary>
        /// <param name="bitmap">Bitmap to draw on</param>
        /// <param name="time">Current time</param>
        public void PaintEvent(Bitmap bitmap, DateTime time)
        {
            Font timeFont = Resources.GetFont(Resources.FontResources.ubuntu16c);
            Font smallFont = Resources.GetFont(Resources.FontResources.ubuntu12c);
            Painter painter = new Painter(bitmap);
            TimeSpan ts = DueDate - time;
            Bitmap todotypes;

            // draw separator
            bitmap.DrawLine(Color.White, 1, 0, 0, 64, 0);

            // if inverse draw background and use inverted icons
            if (_inverse)
            {
                bitmap.DrawRectangle(Color.White, 0, 0, 3, 64, 18, 0, 0, Color.White, 0, 0, Color.White, 64, 48, 0xFF);
                todotypes = new Bitmap(Resources.GetBytes(Resources.BinaryResources.todotypes_inverted), Bitmap.BitmapImageType.Gif);
            }
            else
                todotypes = new Bitmap(Resources.GetBytes(Resources.BinaryResources.todotypes), Bitmap.BitmapImageType.Gif);

            //// draw icon
            bitmap.DrawImage(0, 5, todotypes, 0, (int)Type * 16, 16, 16);

            if (ts.Days > 0)

                bitmap.DrawTextInRect(
                    ts.Days + "days",
                    16,
                    0,
                    48,
                    18,
                    Bitmap.DT_AlignmentCenter,
                    _inverse?Color.Black:Color.White,
                    timeFont
                    );
            else if ( ts.Days == 0 && ts.Minutes <= 0 )
                bitmap.DrawTextInRect(
                    "NOW!",
                    16,
                    0,
                    48,
                    20,
                    Bitmap.DT_AlignmentCenter,
                    _inverse ? Color.Black : Color.White,
                    timeFont
                    );

            else
                bitmap.DrawTextInRect(
                    ts.Hours + "h " + ts.Minutes + "m",
                    16,
                    0,
                    48,
                    20,
                    Bitmap.DT_AlignmentCenter,
                    _inverse ? Color.Black : Color.White,
                    timeFont
                    );

            if (Label.Length > 0)
            {
                bitmap.DrawTextInRect(Label, 0, 19, 64, 30, Bitmap.DT_WordWrap|Bitmap.DT_TruncateAtBottom, Color.White, smallFont);
            }
        }
 private void Refresh(Bitmap screen)
 {
     if (_weather == null)
     {
         Style cStyle = StyleManager.CurrentStyle;
         screen.DrawRectangle(cStyle.BackgroundColor, 0, ScreenLeft, ScreenTop, Width, Height, 0, 0, cStyle.BackgroundColor, 0, 0, cStyle.BackgroundColor, 0, 0, 256);
         screen.DrawTextInRect("No weather information, invalid location or no network connection available!", ScreenLeft + 20, ScreenTop + 30, Width - 40, Height - 60,
             Bitmap.DT_AlignmentCenter | Bitmap.DT_WordWrap, StyleManager.CurrentStyle.TextBoxEnabledInvalidBorder, Fonts.ArialItalic);
     }
     else
     {
         if (_remakeBuffer)
         {
             RemakeControlBuffer();
             _remakeBuffer = false;
         }
         screen.DrawImage(ScreenLeft, ScreenTop, _buffer, 0, 0, _buffer.Width, _buffer.Height, (ushort)(Enabled ? 256 : 128));
     }
 }
            protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object item, Style cStyle)
            {
                bool selected = _selItem == item;

                if (selected)
                {
                    screen.DrawRectangle(Colors.Blue, 0, x, y, width, height, 0, 0,
                        cStyle.ListBoxSelectedItemBack1, x, y,
                        cStyle.ListBoxSelectedItemBack2, x, y + height, 256);
                }

                Font textFont = cStyle.LabelFont;
                Color textColor = selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor;
                screen.DrawTextInRect(item.ToString(), x + 5, y + (height - textFont.Height) / 2, width - 10, height, Bitmap.DT_AlignmentLeft, textColor, textFont);

                const int rdMargin = 3;
                int rdX = x + _width - ItemHeight - rdMargin,
                    rdY = y + rdMargin,
                    rdRadius = (ItemHeight - rdMargin * 2) / 2;

                Color bColor = cStyle.RadioButtonEnabledBack;

                screen.DrawEllipse(cStyle.RadioButtonEnabledBorder, 1, rdX + rdRadius, rdY + rdRadius, rdRadius, rdRadius, bColor, 0, 0, bColor, 0, 0, 256);

                if (selected)
                {
                    const int margin = 6;
                    Color pointColor = cStyle.RadioButtonEnabledPoint;

                    _desktopOwner._screenBuffer.DrawEllipse(pointColor, 0, rdX + rdRadius, rdY + rdRadius, rdRadius - margin, rdRadius - margin,
                        pointColor, 0, 0, pointColor, 0, 0, 256);
                }
            }
        protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object item, Style cStyle)
        {
            bool selected = _allowMultipleSelection ? _selectedItems.Contains(item) : _selIndex == index;

            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);
            }

            Font textFont = cStyle.LabelFont;
            Color textColor = _enabled ? (selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor) : cStyle.TextBoxDisabledTextColor;
            screen.DrawTextInRect(item.ToString(), x + 5, y + (height - textFont.Height) / 2, width - 10, height, Bitmap.DT_AlignmentLeft, textColor, textFont);

            if (_allowMultipleSelection)
            {
                const int chkMargin = 3;

                int cX = x + width - ItemHeight,
                    cY = y + chkMargin,
                    cWidth = ItemHeight - chkMargin * 2,
                    cHeight = cWidth;

                screen.DrawRectangle(
                    _enabled ? cStyle.CheckBoxEnabledBorder : cStyle.CheckBoxDisabledBorder, 1, cX, cY, cWidth, cHeight, 0, 0,
                    _enabled ? cStyle.CheckBoxEnabledBack1 : cStyle.CheckBoxDisabledBack1, cX, cY,
                    _enabled ? cStyle.CheckBoxEnabledBack2 : cStyle.CheckBoxDisabledBack2, cX, cY + cHeight, 256);

                if (selected)
                {
                    const int margin = 4;
                    Color crossColor = _enabled ? cStyle.CheckBoxEnabledCross : cStyle.CheckBoxDisabledCross;

                    screen.DrawLine(crossColor, 2, cX + margin, cY + margin, cX + cWidth - margin, cY + cHeight - margin - 1);
                    screen.DrawLine(crossColor, 2, cX + cWidth - margin, cY + margin, cX + margin, cY + cHeight - margin - 1);
                }
            }
        }
Beispiel #9
0
		public override void Run()
		{
			try
			{
				Font font = Resources.GetFont( Resources.FontResources.GLANCEABLE );
				Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height );

				uint[] flags = { 
								   Bitmap.DT_WordWrap | Bitmap.DT_AlignmentLeft,
								   Bitmap.DT_WordWrap | Bitmap.DT_AlignmentCenter,
								   Bitmap.DT_WordWrap | Bitmap.DT_AlignmentRight,
				};


				string s = "Alas! poor Horatio. I knew him, my friend; a fellow of infinite jest, of most excellent fancy; he hath borne me on his back a thousand times; and now, where be your gibes now? your gambols? your songs? your flashes of merriment, that were wont to set the table on a roar? Not one now, to mock your own grinning? quite chapfallen? Now get you to my lady?s chamber, and tell her, let her paint an inch thick, to this favour she must come; make her laugh at that. Prithee, what say you?";

				for(int i = 0; i < flags.Length; i++)
				{
					bmp.DrawRectangle( (Presentation.Media.Color)0xFF0000, 0, 0, 0, Dimensions.Width, Dimensions.Height, 0, 0, (Presentation.Media.Color)0xFF0000, 0, 0, (Presentation.Media.Color)0xFF0000, 0, 0, Bitmap.OpacityOpaque );

					Presentation.Media.Color color = (Presentation.Media.Color)0x0000FF;
					bmp.DrawTextInRect( s, 0, 0, Dimensions.Width, Dimensions.Height, flags[i], color, font );

					bmp.Flush();

					Thread.Sleep( 2000 );
				}
				Pass = true;
			}
			catch(Exception e)
			{
				UnexpectedException( e );
			}
		}