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


C# Bitmap.DrawRectangle方法代码示例

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


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

示例1: Main

        public static void Main()
        {
            LCD myApplication = new LCD();

            Window mainWindow = myApplication.CreateWindow();
            
            // Start the application
            //myApplication.Run(mainWindow);

            Bitmap bitmap1 = new Bitmap(SystemMetrics.ScreenWidth,SystemMetrics.ScreenHeight);
            Bitmap bitmap2 = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);

            int ox = 0;
            int oy = 0;
            int rx = bitmap1.Width;
            int ry = bitmap1.Height;
            int sd=0;
            if (rx < ry)
                sd = rx;
            else
                sd = ry;


            bitmap1.DrawLine(Colors.Blue, 1, 0, 0, rx, ry);
            bitmap1.DrawLine(Colors.Blue, 1, rx, 0, 0, ry);
            bitmap1.DrawRectangle(Color.White, 10, ox, oy, rx, ry, 1, 1, 
                Color.White, ox, oy, Color.White, rx, ry, 0xFF);

            for(int i=0; i < sd; i += 10)
                bitmap1.DrawRectangle(Color.White, 1, ox+i, oy+i, rx-i, ry-i, 1, 1, 
                    Colors.Green, ox, oy, Colors.Green, rx, ry, 0xFF);

            
            bitmap2.DrawLine(Colors.Black, 1, 0, 0, rx, ry);
            bitmap2.DrawLine(Microsoft.SPOT.Presentation.Media.Color.Black, 1, rx, 0, 0, ry);

            for (int i = 0; i < sd; i += 10)
                bitmap1.DrawRectangle(Color.White, 1, ox + i, oy + i, rx - i, ry - i, 1, 1,
                    Colors.Green, ox, oy, Colors.Green, rx, ry, 0xFF);

            while (true)
            {
                bitmap1.Flush();
                Thread.Sleep(50);
                bitmap2.Flush();
                Thread.Sleep(50);
            }

        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:49,代码来源:lcd.cs

示例2: Run

        public override void Run()
        {
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                using (var img = Resources.GetBitmap(Resources.BitmapResources.compass2))
                {
                    int da = 3;
                    for (int angle = 0; angle <= 360 && angle >= 0; angle += da)
                    {
                        bitmap.DrawRectangle(Colors.White, 0, 0, 0,
                                             Dimensions.Width, Dimensions.Height,
                                             0, 0, Colors.White, 0, 0, Colors.White, 0, 0,
                                             Bitmap.OpacityOpaque);

                        int xdst = (Dimensions.Width - img.Width)/2,
                            ydst = (Dimensions.Height - img.Height)/2;
                        bitmap.RotateImage(angle, xdst, ydst, img, 0, 0, img.Width, img.Height, 0x00);
                        
                        bitmap.Flush();

                        if (angle > 180)
                            da = -da;
                    }
                }
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:26,代码来源:Rotate.cs

示例3: Run

        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var rand = new Random();

                    for (int i = 0; i < 100; i++)
                    {
                        var fillColor = (Color)rand.Next(0xFFFFFF);
                        bmp.DrawRectangle((Color) rand.Next(0xFFFFFF), rand.Next(1),
                                          rand.Next(Dimensions.Width), rand.Next(Dimensions.Height),
                                          rand.Next(Dimensions.Width), rand.Next(Dimensions.Height),
                                          0, 0, fillColor, 0, 0, fillColor, 0, 0, (ushort) rand.Next(256));
                        bmp.Flush();
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:25,代码来源:RandomDrawRectangle.cs

示例4: RenderRectangle

        protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
        {
            Color outlineColor = (pen != null) ? pen.Color : (Color)0x0;
            ushort outlineThickness = (pen != null) ? pen.Thickness : (ushort)0;

            int x1, y1;
            int x2, y2;

            switch (MappingMode)
            {
                case BrushMappingMode.RelativeToBoundingBox:
                    x1 = x + (int)((long)(width - 1) * StartX / RelativeBoundingBoxSize);
                    y1 = y + (int)((long)(height - 1) * StartY / RelativeBoundingBoxSize);
                    x2 = x + (int)((long)(width - 1) * EndX / RelativeBoundingBoxSize);
                    y2 = y + (int)((long)(height - 1) * EndY / RelativeBoundingBoxSize);
                    break;
                default: //case BrushMappingMode.Absolute:
                    x1 = StartX;
                    y1 = StartY;
                    x2 = EndX;
                    y2 = EndY;
                    break;
            }

            bmp.DrawRectangle((MSMedia.Color)outlineColor, outlineThickness, x, y, width, height, 0, 0, (MSMedia.Color)StartColor, x1, y1, (MSMedia.Color)EndColor, x2, y2, Opacity);
        }
开发者ID:KonstantinKolesnik,项目名称:Typhoon,代码行数:26,代码来源:LinearGradientBrush.cs

示例5: Main

        public static void Main()
        {
            LCD myApplication = new LCD();

            Window mainWindow = myApplication.CreateWindow();
            
            // Start the application
            //myApplication.Run(mainWindow);

            Bitmap bitmap1 = new Bitmap(SystemMetrics.ScreenWidth,SystemMetrics.ScreenHeight);
            Bitmap bitmap2 = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);

            int ox = 0;
            int oy = 0;
            int rx = bitmap1.Width;
            int ry = bitmap1.Height;
            int sd=0;
            if (rx < ry)
                sd = rx;
            else
                sd = ry;


	    //
	    // Draw Diagonals
	    //
            bitmap1.DrawLine(Colors.Blue, 3, 0, 0, rx, ry);
            bitmap1.DrawLine(Colors.Blue, 3, rx, 0, 0, ry);

            bitmap2.DrawLine(Colors.Red, 3, 0, 0, rx, ry);
            bitmap2.DrawLine(Colors.Red, 3, rx, 0, 0, ry);


            for(int ioff=0; ioff < sd; ioff += 10)
	    {
		int oX  = ox+ioff;
		int oY  = oy+ioff;
		int wX  = rx - 2*ioff;
		int wY  = ry - 2*ioff;
                bitmap1.DrawRectangle(Colors.White, 1, oX, oY, wX, wY, 1, 1, 
                    Colors.Green, ox, oy, Colors.Green, rx, ry, 0xFF);
                bitmap2.DrawEllipse(Colors.White, rx/2, ry/2, wX, wY);
	    }

            


            while (true)
            {
                bitmap1.Flush();
                Thread.Sleep(250);
                bitmap2.Flush();
                Thread.Sleep(200);
            }

        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:56,代码来源:lcd.cs

示例6: Main

        static void Main(string[] args)
        {
            int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
            HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                                      out bitsPerPixel, out orientationDeg);
            Bitmap bmp = new Bitmap(screenWidth, screenHeight);
            //drawing white background
            bmp.DrawRectangle(Color.White,           // outline color
                              0,                     // outline thickness
                              0, 0,                  // x and y of top left corner
                              bmp.Width, bmp.Height, // width and height
                              0, 0,                  // y and y corner radius
                              Color.White,           // gradient start color
                              0, 0,                  // gradient start coordinates
                              Color.White,           // gradient end color
                              0, 0,                  // gradient end coordinates
                              Bitmap.OpacityOpaque); // reduced opacity

            Color[] colors = new Color[] {
                                   ColorUtility.ColorFromRGB(0xFF, 0, 0), // red
                                   ColorUtility.ColorFromRGB(0, 0xFF, 0), // green
                                   ColorUtility.ColorFromRGB(0, 0, 0xFF)  // blue
            };

            for (int i = 0; i < colors.Length; ++i)
            {
                Color color = colors[i];
                bmp.DrawRectangle(color,                    // outline color
                                  0,                        // outline thickness
                                  50 + i * 20, 50 + i * 20, // x and y of top left corner
                                  200, 100,                 // width and height
                                  0, 0,                     // x and y corner radius
                                  color,                    // gradient start color
                                  0, 0,                     // gradient start coordinates
                                  color,                    // gradient end color
                                  0, 0,                     // gradient end coordinates
                                  64);                      // reduced opacity
            }

            bmp.Flush();
            Thread.Sleep(-1); //do not terminate app to see result
        }
开发者ID:meikeric,项目名称:DotCopter,代码行数:42,代码来源:Program.cs

示例7: Main

        public static void Main()
        {
            int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
            HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                                      out bitsPerPixel, out orientationDeg);
            //prepare background with a color gradient
            Bitmap backgroundImg = new Bitmap(screenWidth, screenHeight);
            backgroundImg.DrawRectangle(Color.White,           // outline color
                                        0,                     // outline thickness
                                        0, 0,                  // x and y of top left corner
                                        backgroundImg.Width,   // width
                                        backgroundImg.Height,  // height
                                        0, 0,                  // x and y corner radius
                                        Color.White,           // gradient start color
                                        0, 0,                  // gradient start coordinates
                                        Color.Black,           // gradient end color
                                        backgroundImg.Width,   // gradient end x coordinate
                                        backgroundImg.Height,  // gradient end y coordinate
                                        Bitmap.OpacityOpaque); // opacity
            //prepare a working buffer to hold graphics before flushing to display
            Bitmap bufferImg = new Bitmap(screenWidth, screenHeight);
            //our ball
            Bitmap soccerBallImg = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
            //make background of the ball transparent
            //using the color of top left corner pixel
            soccerBallImg.MakeTransparent(soccerBallImg.GetPixel(0, 0));

            int x = 100;
            int y = 50;
            int xOfs = 1;
            int yOfs = 1;
            while (true)
            {
                //copy background to buffer
                bufferImg.DrawImage(0, 0, backgroundImg, 0, 0,
                                    backgroundImg.Width, backgroundImg.Height);
                //paint moving sprite object
                bufferImg.DrawImage(x, y,     // destination coordinates
                                    soccerBallImg, // source image
                                    0, 0,       // source coordinates
                                    soccerBallImg.Width, soccerBallImg.Height,
                                    Bitmap.OpacityOpaque);
                bufferImg.Flush(); //flush buffer to display
                Thread.Sleep(10);
                //invert direction if ball bounces at a wall
                if (x <= 0 || x >= screenWidth - soccerBallImg.Width)
                    xOfs = -xOfs;
                if (y <= 0 || y >= screenHeight - soccerBallImg.Height)
                    yOfs = -yOfs;
                //calculate new coordinates
                x += xOfs;
                y += yOfs;
            }
        }
开发者ID:meikeric,项目名称:DotCopter,代码行数:54,代码来源:Program.cs

示例8: RenderRectangle

        protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height, int xCornerRadius, int yCornerRadius)
        {
            if (Stretch == Stretch.None)
                bmp.DrawImage(x, y, BitmapSource, 0, 0, BitmapSource.Width, BitmapSource.Height, Opacity);
            else if (width == BitmapSource.Width && height == BitmapSource.Height)
                bmp.DrawImage(x, y, BitmapSource, 0, 0, width, height, Opacity);
            else
                bmp.StretchImage(x, y, BitmapSource, width, height, Opacity);

            if (pen != null && pen.Thickness > 0)
                bmp.DrawRectangle((MSMedia.Color)pen.Color, pen.Thickness, x, y, width, height, xCornerRadius, yCornerRadius, (MSMedia.Color)0, 0, 0, (MSMedia.Color)0, 0, 0, 0);
        }
开发者ID:KonstantinKolesnik,项目名称:MFE,代码行数:12,代码来源:ImageBrush.cs

示例9: DrawItem

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

示例10: DrawString

 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;
 }
开发者ID:richoxski,项目名称:netmf-community-ports,代码行数:17,代码来源:Display.cs

示例11: Main

 static void Main(string[] args)
 {
     int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
     HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
                                               out bitsPerPixel, out orientationDeg);
     Bitmap bmp = new Bitmap(screenWidth, screenHeight);
     bmp.DrawRectangle(Color.White,           // outline color
                       1,                     // outline thickness
                       100, 100,              // x and y of top left corner
                       200, 100,              // width and height
                       10, 30,                // x and y corner radius
                       Color.White,           // gradient start color
                       0, 0,                  // gradient start coordinate
                       Color.White,           // gradient end color
                       0, 0,                  // gradient end coordinate
                       Bitmap.OpacityOpaque); // opacity
     bmp.Flush();
     Thread.Sleep(-1); //do not terminate app to see result
 }
开发者ID:meikeric,项目名称:DotCopter,代码行数:19,代码来源:Program.cs

示例12: Draw

        public void Draw(Bitmap DrawingSurface)
        {
            if (Thickness > 0)
            {
                DrawingSurface.DrawRectangle(Color.White, Thickness, 1, 1, Device.AgentSize, Device.AgentSize, 0, 0,
                                             Color.Black, 0, 0, Color.Black, 0, 0, 0);

                if (HeaderHeight > 0)
                {
                    DrawingSurface.DrawLine(Color.White, Thickness, 1, HeaderHeight, Device.AgentSize, HeaderHeight);

                }
                if (FooterHeight > 0)
                {
                    DrawingSurface.DrawLine(Color.White, Thickness, 1, Device.AgentSize - FooterHeight, Device.AgentSize, Device.AgentSize - FooterHeight);

                }
            }
        }
开发者ID:nothingmn,项目名称:Agent.Faces,代码行数:19,代码来源:Border.cs

示例13: Render

        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);
            }
        }
开发者ID:nothingmn,项目名称:AGENT.Contrib,代码行数:19,代码来源:CalculatorButton.cs

示例14: 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

示例15: 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


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