当前位置: 首页>>代码示例>>C#>>正文


C# Bitmap.DrawTextInRect方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Bitmap.DrawTextInRect方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.DrawTextInRect方法的具体用法?C# Bitmap.DrawTextInRect怎么用?C# Bitmap.DrawTextInRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Bitmap的用法示例。


在下文中一共展示了Bitmap.DrawTextInRect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        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);
                }
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:19,代码来源:KodFilemon.cs

示例2: Run

        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);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:42,代码来源:DrawText.cs

示例3: Main

 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);
 }
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:41,代码来源:Program.cs

示例4: Run

        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);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:39,代码来源:DrawTextInRect.cs

示例5: PaintEvent

        /// <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);
            }
        }
开发者ID:nicksi,项目名称:tdw,代码行数:69,代码来源:ToDoEvent.cs

示例6: Refresh

 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));
     }
 }
开发者ID:andrei-tatar,项目名称:MediaPlayer.NETMF,代码行数:19,代码来源:YahooWeatherControl.cs

示例7: DrawItem

            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);
                }
            }
开发者ID:andrei-tatar,项目名称:MediaPlayer.NETMF,代码行数:33,代码来源:ComboBoxListViewDesktop.cs

示例8: DrawItem

        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);
                }
            }
        }
开发者ID:andrei-tatar,项目名称:MediaPlayer.NETMF,代码行数:39,代码来源:ListBox.cs

示例9: Run

		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 );
			}
		}
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:34,代码来源:Main.cs


注:本文中的Microsoft.SPOT.Bitmap.DrawTextInRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。