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


C# Bitmap.DrawLine方法代码示例

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


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

示例1: Run

        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    bmp.DrawLine(Colors.Red, 1,
                                 Dimensions.Width/2, Dimensions.Height/2,
                                 Dimensions.Width, Dimensions.Height/2);

                    bmp.DrawLine(Colors.Green, 1,
                                 Dimensions.Width/2, Dimensions.Height/2,
                                 Dimensions.Width/2, 0);

                    bmp.Flush();
                }

                Thread.Sleep(3000);
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:25,代码来源:Orientation.cs

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

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

示例4: Render

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

        }
开发者ID:nothingmn,项目名称:Agent.TripleFace,代码行数:32,代码来源:WatchFace.cs

示例5: Render

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

        }
开发者ID:nothingmn,项目名称:Agent.TripleFace,代码行数:59,代码来源:WeatherFace.cs

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

示例7: SetupZeroBuffer

        public static void SetupZeroBuffer()
        {
            //add it to our buffer context
            var bmp = new Bitmap(10, 10);
            bmp.DrawLine(Color.White, 1, 0, 0, 1, 1);
            _buffer.Add(bmp);

            //render it right away
            _screen.Clear();
            _screen.DrawImage(0, 0, bmp, 0, 0, bmp.Width, bmp.Height);
            _screen.Flush();
        }
开发者ID:nothingmn,项目名称:BufferingTests,代码行数:12,代码来源:Program.cs

示例8: seePicture_WebEventReceived

        void seePicture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            if (pic != null)
            {
                Bitmap b = new Bitmap(320, 240);
                b.DrawLine(Colors.Red, 20, 0, 0, 319, 239);
                byte[] buff = new byte[320 * 240 * 3 + 54];
                GHIElectronics.NETMF.System.Util.BitmapToBMPFile(b.GetBitmap(), 320, 240, buff);

                GT.Picture picture = new GT.Picture(buff, GT.Picture.PictureEncoding.BMP);

                responder.Respond(picture);
            }
            else
                responder.Respond("Take picture first");
        }
开发者ID:simonmonk,项目名称:gadgeteer_book,代码行数:16,代码来源:Program.cs

示例9: SetupOtherBuffers

        public static void SetupOtherBuffers()
        {
            int lineLength = 10;
            for (int x = 1; x <= lineLength; x++)
            {
                int x0 = x;
                int y0 = x;
                int x1 = x0+x;
                int y1 = y0+x;
                //create the buffered image
                var bmp = new Bitmap(lineLength, lineLength);
                bmp.DrawLine(Color.White, x, x0, y0, x1, y1);
                //add it to our list of buffered images
                _buffer.Add(bmp);
            }

            evt.Set();
        }
开发者ID:nothingmn,项目名称:BufferingTests,代码行数:18,代码来源:Program.cs

示例10: Render

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


        }
开发者ID:nothingmn,项目名称:AGENT.Contrib,代码行数:38,代码来源:DigitalTimeFace.cs

示例11: 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++)
                    {
                        bmp.DrawLine((Color) rand.Next(0xFFFFFF), 1,
                                     rand.Next(Dimensions.Width), rand.Next(Dimensions.Height),
                                     rand.Next(Dimensions.Width), rand.Next(Dimensions.Height));
                        bmp.Flush();
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:23,代码来源:RandomDrawLine.cs

示例12: Run

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

                bmp.DrawLine( Utility.FromRGB( 255, 0, 0 ),
                    1,
                    Dimensions.Width / 2, Dimensions.Height / 2, Dimensions.Width, Dimensions.Height / 2 );

                bmp.DrawLine( Utility.FromRGB( 0, 255, 0 ),
                    1,
                    Dimensions.Width / 2, Dimensions.Height / 2, Dimensions.Width / 2, 0 );

                bmp.Flush();

                Thread.Sleep( 3000 );
                Pass = true;
            }
            catch(Exception e)
            {
                UnexpectedException( e );
            }
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:24,代码来源:Main.cs

示例13: DrawBattery

        /// <summary>
        /// Draw a simple battery to the screen
        /// </summary>
        /// <param name="screen"></param>
        /// <param name="batteryPosition"></param>
        /// <param name="batteryWidth"></param>
        /// <param name="batteryHeight"></param>
        /// <param name="borderThickness"></param>
        /// <param name="batteryColor"></param>
        /// <param name="backColor"></param>
        public Size DrawBattery(Bitmap screen, Point batteryPosition, int batteryWidth, int batteryHeight,
                                int borderThickness, Color batteryColor, Color backColor, bool charging, int batteryLevel)
        {
            
            //calculate filler
            double fillerWidth = (batteryWidth - (borderThickness*1));
            double percent = ((double)batteryLevel * 0.01);
            double actualFillerWidth = fillerWidth*percent;

            //calculate nub
            double nubHight = batteryHeight*0.5;
            double nubWidth = batteryHeight*0.1;
            double nubTop = (((double) batteryHeight)/2) - (nubHight/2);
            Point nubPosition = new Point(batteryPosition.X + batteryWidth,
                                          batteryPosition.Y + (int) System.Math.Floor(nubTop));

           //draw filler
            int paintedFiller = (int) actualFillerWidth;
            if (paintedFiller < 0) paintedFiller = 0;
            screen.DrawRectangle(backColor, 1, batteryPosition.X + 1, batteryPosition.Y + 1, paintedFiller,
                                 batteryHeight - 2, 0, 0, batteryColor, 0, 0, batteryColor, 0, 0, 255);

            //draw main battery outline
            screen.DrawRectangle(batteryColor, borderThickness, batteryPosition.X, batteryPosition.Y, batteryWidth,
                                 batteryHeight, 0, 0, backColor, 0, 0, backColor, 0, 0, 0);
            
            //draw battery nub
            screen.DrawRectangle(batteryColor, 1, nubPosition.X, nubPosition.Y, (int) nubWidth, (int) nubHight, 0, 0,
                                 batteryColor, 0, 0, batteryColor, 0, 0, 255);
            //draw inner border
            var batterySize = new Size(batteryWidth + (int) nubWidth, batteryHeight);
            if (charging)
            {
                //draw charging indicator
                double iconHeight = (int)(nubHight*0.20);
                double iconTop = batteryPosition.Y + ((double)batteryHeight/2 - iconHeight/2)+1;
                double iconLeft = batteryPosition.X + 4;
                double iconWidth = (int)(iconLeft + actualFillerWidth - 5);

                screen.DrawLine(backColor, (int)iconHeight, (int)iconLeft, (int)iconTop, (int)iconWidth, (int)iconTop);


            }
            return batterySize;
        }
开发者ID:nothingmn,项目名称:WP8-Running.AGENT,代码行数:55,代码来源:Drawing.cs

示例14: _DrawUnfilledPoly

        private static void _DrawUnfilledPoly(Bitmap screen, Point[] points, Color borderColor, short borderWidth, Point basePoint)
        {
            for (int i = 0; i < points.Length - 1; ++i)
            {
                screen.DrawLine(borderColor, borderWidth, points[i].X - basePoint.X, points[i].Y - basePoint.Y, points[i + 1].X - basePoint.X, points[i + 1].Y - basePoint.Y);
            }

            screen.DrawLine(borderColor, borderWidth, points[0].X - basePoint.X, points[0].Y - basePoint.Y, points[points.Length - 1].X - basePoint.X, points[points.Length - 1].Y - basePoint.Y);
        }
开发者ID:nothingmn,项目名称:WP8-Running.AGENT,代码行数:9,代码来源:Drawing.cs

示例15: PaintLine

 /// <summary>
 /// Paint a line from two points
 /// </summary>
 /// <param name="screen"></param>
 /// <param name="color"></param>
 /// <param name="thickness"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 public void PaintLine(Bitmap screen, Color color, int thickness, Point start, Point end)
 {
     screen.DrawLine(color, thickness, start.X, start.Y, end.X, end.Y);
 }
开发者ID:nothingmn,项目名称:WP8-Running.AGENT,代码行数:12,代码来源:Drawing.cs


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