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


C# Rectangle.Offset方法代码示例

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


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

示例1: PenAlignment_Paint

		private void PenAlignment_Paint(object sender, PaintEventArgs e)
		{
			// Example of border problem.
			//Rectangle rect = new Rectangle(10, 10, 110, 110);
			//Pen pen = new Pen(Color.Red, 1);
			//Brush brush = Brushes.LightBlue;
			//e.Graphics.DrawRectangle(pen, rect);
			//e.Graphics.FillRectangle(brush, rect);

			
			Rectangle rect = new Rectangle(10, 10, 110, 110);
			Pen pen = new Pen(Color.White, 11);
			Pen penOutline = new Pen(Color.Black, 1);
			penOutline.Alignment = PenAlignment.Inset;
			pen.Alignment = PenAlignment.Center;
			e.Graphics.DrawString("11-Pixel Centered Pen", SystemFonts.DefaultFont, Brushes.Black, rect.Location);
			rect.Offset(0, 25);
			e.Graphics.FillRectangle(Brushes.LightBlue, rect);
			e.Graphics.DrawRectangle(pen, rect);
			e.Graphics.DrawRectangle(penOutline, rect);
			
			rect.Offset(150, -25);
			e.Graphics.DrawString("11-Pixel Inset Pen", SystemFonts.DefaultFont, Brushes.Black, rect.Location);
			rect.Offset(0, 25);
			pen.Alignment = PenAlignment.Inset;
			e.Graphics.FillRectangle(Brushes.LightBlue, rect);
			e.Graphics.DrawRectangle(pen, rect);
			e.Graphics.DrawRectangle(penOutline, rect);
			
			
			pen.Dispose();
		}
开发者ID:ehershey,项目名称:development,代码行数:32,代码来源:PenAlignments.cs

示例2: PaintTransparentBackground

        protected void PaintTransparentBackground(Graphics g, Rectangle clipRect) {
            // check if we have a parent
            if (this.Parent != null) {
                // convert the clipRects coordinates from ours to our parents
                clipRect.Offset(this.Location);

                PaintEventArgs e = new PaintEventArgs(g, clipRect);
                GraphicsState state = g.Save();

                try {
                    // move the graphics object so that we are drawing in
                    // the correct place
                    g.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);

                    // draw the parents background and foreground
                    this.InvokePaintBackground(this.Parent, e);
                    this.InvokePaint(this.Parent, e);

                    return;
                } finally {
                    // reset everything back to where they were before
                    g.Restore(state);
                    clipRect.Offset(-this.Location.X, -this.Location.Y);
                }
            }

            // we don't have a parent, so fill the rect with
            // the default control color
            g.FillRectangle(SystemBrushes.Control, clipRect);
        }
开发者ID:dropbox,项目名称:DropboxBusinessAdminTool,代码行数:30,代码来源:ButtonEx.cs

示例3: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            float factor1 = isHover ? 0.40f : 0.20f;
            float factor2 = isHover ? 0.85f : 0.65f;

            Brush brush1 = new SolidBrush(ColorMagic.GetIntermediateColor(ColorBack, ColorFore, factor1));
            Brush brush2 = new SolidBrush(ColorMagic.GetIntermediateColor(ColorBack, ColorFore, factor2));

            var outside = new Rectangle(1, 3, 14, 3);
            var inside = new Rectangle(2, 4, 12, 1);
            var offset = new Point(0, 4);

            g.FillRectangle(brush1, outside);
            g.FillRectangle(brush2, inside);

            outside.Offset(offset);
            inside.Offset(offset);

            g.FillRectangle(brush1, outside);
            g.FillRectangle(brush2, inside);

            outside.Offset(offset);
            inside.Offset(offset);

            g.FillRectangle(brush1, outside);
            g.FillRectangle(brush2, inside);
        }
开发者ID:jorgealvarado212,项目名称:Forex-Strategy-Builder,代码行数:29,代码来源:ContextButton.cs

示例4: pictureBox1_Paint

 private void pictureBox1_Paint(object sender, PaintEventArgs e)
 {
     Color[] cols = null;
     try
     {
         if (pal != null)
             cols = pal.getPal(checkBox1.Checked, checkBox2.Checked, checkBox3.Checked);
         e.Graphics.FillRectangle(new SolidBrush(Color.Black), e.ClipRectangle);
         int minrect = e.ClipRectangle.Width / 16;
         if (e.ClipRectangle.Height / 16 < minrect)
             minrect = e.ClipRectangle.Height / 16;
         Rectangle rct = new Rectangle(0, 0, minrect, minrect);
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 Color c = pal == null ? Color.Black : cols[i * 16 + j];
                 e.Graphics.FillRectangle(new SolidBrush(c), rct);
                 rct.Offset(minrect, 0);
             }
             rct.Offset(-rct.X, minrect);
         }
     }
     catch (Exception ex)
     {
         MainForm.clearResource(ex);
     }
 }
开发者ID:winterheart,项目名称:game-utilities,代码行数:28,代码来源:ViewPalette.cs

示例5: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            Bitmap image = new Bitmap("apple.jpg");                 //加载图像
            ImageProcessing.GreyImage(image);                       //生成灰度图像
            Rectangle rectImage = new Rectangle(new Point(), image.Size);
            G.DrawImage(image, rectImage);

            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.ExtractEdge(image);                     //提取边缘
            G.DrawImage(image, rectImage);

            rectImage.Offset(-rectImage.Width, rectImage.Height);
            Bitmap image2 = image.Clone() as Bitmap;
            ImageProcessing.BinaryImage(image2, 0, 20, 255);        //在灰度20到255的范围提取边界
            G.DrawImage(image2, rectImage);

            image2.Dispose();

            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.BinaryImage(image, 0, 40, 255);         //在灰度40到255的范围提取边界
            G.DrawImage(image, rectImage);

            image.Dispose();
        }
开发者ID:dalinhuang,项目名称:wdeqawes-efrwserd-rgtedrtf,代码行数:27,代码来源:FormEdgeExtraction.cs

示例6: Render

        public void Render(Graphics gfx)
        {
            gfx.Clear(Form1.DefaultBackColor);

            Pen myPen = new Pen(Color.RoyalBlue, 2);
            Rectangle rect = new Rectangle(0, 0, 50, 50);
            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    gfx.DrawRectangle(myPen, rect);
                    rect.Offset(0, 50);
                }

                rect.Offset(50, 0);
            }

            Point cp;
            foreach (ConsumerHolder ch in m_consumers)
            {
                cp = ch.GetPosition();
                cp.X *= 50;
                cp.Y *= 50;

                // Offset to match the center of the grid spot.
                cp.Offset(-25, -25);

                // Factor in the size of the object.
                cp.Offset(-1 * (ch.Strength / 2), -1 * (ch.Strength / 2));

                Pen pen = new Pen(Color.DarkRed, 2);
                Rectangle cr = new Rectangle(cp, new Size(ch.Strength, ch.Strength));
                gfx.DrawEllipse(pen, cr);
            }

            Point rp;
            foreach (IResource res in m_resources)
            {
                rp = res.Position();
                rp.X *= 50;
                rp.Y *= 50;

                // Offset to match the center of the grid spot.
                rp.Offset(-25, -25);

                Pen pen = null;
                if (res.IsConsumed())
                {
                    pen = new Pen(Color.Gray, 2);
                }
                else
                {
                    pen = new Pen(Color.Tomato, 2);
                }
                Rectangle cr = new Rectangle(rp, new Size(5, 5));
                gfx.DrawRectangle(pen, cr);
            }
        }
开发者ID:ChrisVance,项目名称:Consumption,代码行数:58,代码来源:World.cs

示例7: Contains

        public bool Contains(Point p)
        {
            Rectangle draw_rect = new Rectangle(Position.Location, new Size(4, 4));
            draw_rect.Offset(-2, -2);

            return draw_rect.Contains(p);
        }
开发者ID:whoo24,项目名称:geometry_tool_on_csharp,代码行数:7,代码来源:PointObject.cs

示例8: MultiScreenInfo

        private MultiScreenInfo()
        {
            allScreen = Rectangle.Empty;
            foreach (var scr in Screen.AllScreens)
            {
                allScreen = Rectangle.Union(allScreen, scr.Bounds);
            }

            allScreenOffset = new Point(-allScreen.Left, -allScreen.Top);

            allScreenOffsetted = allScreen;
            allScreenOffsetted.Offset(allScreenOffset);

            List<SingleScreenInfo> lstScrs = new List<SingleScreenInfo>();
            foreach (var scr in Screen.AllScreens)
            {
                lstScrs.Add(new SingleScreenInfo(scr, allScreenOffset));
            }
            scrs = lstScrs.ToArray();

            var toStr = this.ToString();
            var s = Settings.Instance;
            if (toStr != s.ScreensRects)
            {
                s.ScreensRects = toStr;

                IsChanged = true;
            }
            else
            {
                IsChanged = false;
            }
        }
开发者ID:iamxail,项目名称:DailyWallpainter,代码行数:33,代码来源:ScreenInfo.cs

示例9: DoStitch

        public Image DoStitch()
        {
            Image1 = Image.FromFile(_imageFile1.FullName);
            Image2 = Image.FromFile(_imageFile2.FullName);

            var outputWidth = OutputWidth();
            var outputHeight = OutputHeight();

            OutputImage = new Bitmap(outputWidth, outputHeight, PixelFormat.Format24bppRgb);
            OutputImage.SetResolution(Image1.HorizontalResolution, Image1.VerticalResolution);

            var graphics = Graphics.FromImage(OutputImage);

            var positionImage1 = new Rectangle(0, 0, Image1.Width, Image1.Height);
            var positionImage2 = new Rectangle(Image1.Width, 0, Image2.Width, Image2.Height);

            if (!Border.Inside)
            {
                positionImage1.Offset(Border.ThicknessLeft, Border.ThicknessTop);
                positionImage2.Offset(2 * Border.ThicknessLeft, Border.ThicknessTop);
            }

            graphics.DrawImage(Image1, positionImage1);
            graphics.DrawImage(Image2, positionImage2);

            Border.Draw(graphics, positionImage1);
            Border.Draw(graphics, positionImage2);

            return OutputImage;
        }
开发者ID:remko-jansen,项目名称:pet-projects,代码行数:30,代码来源:ImageStitcher.cs

示例10: CenterRectangleRelativeTo

        public void CenterRectangleRelativeTo(Rectangle destRectangle, ref Rectangle srcRectangle)
        {
            int x = destRectangle.X + (destRectangle.Width - srcRectangle.Width) / 2;
            int y = destRectangle.Y + (destRectangle.Height - srcRectangle.Height) / 2;

            srcRectangle.Offset(x, y);
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:7,代码来源:Cell.cs

示例11: Form1

      public Form1()
      {
         // initialize it to null
         this.streamWriter = null;
         this.latestFileName = "";

         InitializeComponent();

         // initialize flags
         editingText = false;
         pathSelected = false;
         writeToFile = false;

         // set location of the connectionStatusRectangle
         this.connectionStatusRectangle = new Rectangle(this.connectionStatusLabel.Location, new Size(10, 10));
         connectionStatusRectangle.Offset(45, 0);

         // set color of connectionStatusPen to be Red since by default disconnected
         this.connectionStatusPen = new Pen(Color.Red, 10);
         
         // populate port selection box
         foreach (var port in SerialPort.GetPortNames())
         {
            portComboBox.Items.Add(port);
         }

         // setup bluetooth connection
         bluetooth = new SerialPort("COM", 115200, Parity.None, 8, StopBits.One);
         
         this.DrawConnectionStatus();
      }
开发者ID:graceyha,项目名称:gcc-quadrocopter,代码行数:31,代码来源:Form1.cs

示例12: DrawItemCore

 /// <summary>
 ///     Перегружаемый метод прорисовки
 /// </summary>
 protected override void DrawItemCore(ControlGraphicsInfoArgs info, BaseListBoxViewInfo.ItemInfo itemInfo, ListBoxDrawItemEventArgs e)
 {
     base.DrawItemCore(info, itemInfo, e);
     var customInfo = itemInfo as CustomCheckedListBoxViewInfo.CustomCheckedItemInfo;
     if (customInfo == null)
     {
         return;
     }
     var rec = new Rectangle(itemInfo.Bounds.Location, new Size(itemInfo.Bounds.Width, LineWidth));
     var lineColor = ((CustomCheckedListBoxViewInfo) info.ViewInfo).DragDropLineColor;
     if (itemInfo.Index == 0)
     {
         var font = new Font(itemInfo.PaintAppearance.Font.FontFamily, itemInfo.PaintAppearance.Font.Size, FontStyle.Bold);
         info.Graphics.FillRectangle(Brushes.Lavender, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
         e.Graphics.DrawString(itemInfo.Text, font, Brushes.Black, e.Bounds.X, e.Bounds.Y + 2);
     }
     if (customInfo.IsOverLine)
     {
         if (customInfo.Index == 0)
         {
             rec.Height++;
         }
         info.Graphics.FillRectangle(info.Cache.GetSolidBrush(lineColor), rec);
     }
     if (!customInfo.IsUnderLine)
     {
         return;
     }
     rec.Offset(0, itemInfo.Bounds.Height - LineWidth);
     if (customInfo.Index == ((CustomCheckedListBoxViewInfo) info.ViewInfo).ItemCountAccessMethod() - 1)
     {
         rec.Height++;
     }
     info.Graphics.FillRectangle(info.Cache.GetSolidBrush(lineColor), rec);
 }
开发者ID:Demotron,项目名称:AdminTools,代码行数:38,代码来源:CustomPainterCheckedListBox.cs

示例13: lbxNotes_DrawItem

        private void lbxNotes_DrawItem(object sender, DrawItemEventArgs e)
        {
            Note currNote;
            if (e.Index >= 0)
            {
                e.DrawBackground();

                Rectangle timeRectangle = new Rectangle(e.Bounds.Location, new Size(lbxNotes.Width, 16));
                timeRectangle.Offset(0, 2);
                Rectangle messageRectangle = new Rectangle(timeRectangle.Location, timeRectangle.Size);
                messageRectangle.Offset(0, 10);
                messageRectangle.Height = 34;

                currNote = (Note)lbxNotes.Items[e.Index];

                Font timeFont = new Font("Serif", (float)8.0);
                e.Graphics.DrawString(currNote.StartTime.ToLongTimeString(), timeFont, Brushes.DimGray,
                    timeRectangle, StringFormat.GenericDefault);

                Font messageFont = new Font("Serif", (float)16.0);
                e.Graphics.DrawString(currNote.Message.ToString(), messageFont,
                    (currNote.Status == Note.NoteStatus.Completed) ? Brushes.Green : Brushes.Black,
                    messageRectangle, StringFormat.GenericDefault);

                e.DrawFocusRectangle();
            }
        }
开发者ID:aishwar,项目名称:taskodo,代码行数:27,代码来源:NotesDisplayer.cs

示例14: DrawButton

 protected virtual void DrawButton(Graphics g, Rectangle buttonRect)
 {
     this.BuildGraphicsPath(buttonRect);
     PathGradientBrush brush = new PathGradientBrush(this.bpath);
     brush.SurroundColors = new Color[] { this.buttonColor };
     buttonRect.Offset(this.buttonPressOffset, this.buttonPressOffset);
     if (this.bevelHeight > 0)
     {
         buttonRect.Inflate(1, 1);
         brush.CenterPoint = new PointF((float) ((buttonRect.X + (buttonRect.Width / 8)) + this.buttonPressOffset), (float) ((buttonRect.Y + (buttonRect.Height / 8)) + this.buttonPressOffset));
         brush.CenterColor = this.cColor;
         this.FillShape(g, brush, buttonRect);
         this.ShrinkShape(ref g, ref buttonRect, this.bevelHeight);
     }
     if (this.bevelDepth > 0)
     {
         this.DrawInnerBevel(g, buttonRect, this.bevelDepth, this.buttonColor);
         this.ShrinkShape(ref g, ref buttonRect, this.bevelDepth);
     }
     brush.CenterColor = this.buttonColor;
     if (this.dome)
     {
         brush.CenterColor = this.cColor;
         brush.CenterPoint = new PointF((float) ((buttonRect.X + (buttonRect.Width / 8)) + this.buttonPressOffset), (float) ((buttonRect.Y + (buttonRect.Height / 8)) + this.buttonPressOffset));
     }
     this.FillShape(g, brush, buttonRect);
     if (this.gotFocus)
     {
         this.DrawFocus(g, buttonRect);
     }
 }
开发者ID:JamesH001,项目名称:SX1231,代码行数:31,代码来源:PushBtn.cs

示例15: TestBGModel

        public void TestBGModel()
        {
            int width = 300;
             int height = 400;
             Image<Bgr, Byte> bg = new Image<Bgr, byte>(width, height);
             bg.SetRandNormal(new MCvScalar(), new MCvScalar(100, 100, 100));

             Size size = new Size(width / 10, height / 10);
             Point topLeft = new Point((width >> 1) - (size.Width >> 1), (height >> 1) - (size.Height >> 1));

             Rectangle rect = new Rectangle(topLeft, size);

             Image<Bgr, Byte> img1 = bg.Copy();
             img1.Draw(rect, new Bgr(Color.Red), -1);

             Image<Bgr, Byte> img2 = bg.Copy();
             rect.Offset(10, 0);
             img2.Draw(rect, new Bgr(Color.Red), -1);

             BGStatModel<Bgr> model1 = new BGStatModel<Bgr>(img1, Emgu.CV.CvEnum.BG_STAT_TYPE.GAUSSIAN_BG_MODEL);
             model1.Update(img2);

             BGStatModel<Bgr> model2 = new BGStatModel<Bgr>(img1, Emgu.CV.CvEnum.BG_STAT_TYPE.FGD_STAT_MODEL);
             model2.Update(img2);

             //ImageViewer.Show(model2.Foreground);
             //ImageViewer.Show(model1.Background);
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:28,代码来源:AutoTestVarious.cs


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