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


C# Point.Offset方法代码示例

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


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

示例1: Redraw

        public override void Redraw(Graphics g)
        {
            if (txt == null)
                return;

            Point position = txt.GetPositionFromCharIndex(startIndex);
            Point centerPos = new Point(position.X, (int)(position.Y + (txt.Font.Size * 0.75)));
            float thirdFontSize = txt.Font.Size / 3;

            centerPos.Offset((int)thirdFontSize, 0);
            centerPos.Offset((int)thirdFontSize, 0);
            Brush brush = new SolidBrush(BrushColor);
            Pen pen = new Pen(brush);

            //the horizontal line
            Point lineEnd = new Point((int)(centerPos.X + thirdFontSize), centerPos.Y);
            g.DrawLine(pen, centerPos, lineEnd);

            //the verical line from top
            PointF verticalLineStart = new PointF(lineEnd.X, (lineEnd.Y - thirdFontSize));
            g.DrawLine(pen, verticalLineStart, lineEnd);

            //the arrow on the left pointing left
            PointF topArrowHead = new PointF(centerPos.X, (centerPos.Y - thirdFontSize));
            PointF bottomArrowHead = new PointF(centerPos.X, (centerPos.Y + thirdFontSize));
            PointF middleArrowHead = new PointF(centerPos.X - thirdFontSize, centerPos.Y);

            g.DrawPolygon(pen, new PointF[] { topArrowHead, bottomArrowHead, middleArrowHead });
            g.FillPolygon(brush, new PointF[] { topArrowHead, bottomArrowHead, middleArrowHead });
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:30,代码来源:NewLineMarker.cs

示例2: Outline

        public Outline(Point center)
        {
            var sideLength = 50;
            center.Offset(-sideLength / 2, -sideLength/2);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            center.Offset(0, sideLength);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            center.Offset(sideLength, 0);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            center.Offset(0, -sideLength);
            nodes.Add(PanAndZoom.fromLocalToGlobal(center));

            //parent.Controls.Add(this);
            //BringToFront();

            foreach(var n in nodes){
                var marker = new VertexMarker();
                marker.setPosition(n);
                marker.MouseClick += new MouseEventHandler(deleteMarker);
                markers.Add(marker);

                marker.BringToFront();

                var c = new CreaterMarker();
                c.MouseClick += new MouseEventHandler(createMarker);
                //parent.Controls.Add(c);
                creaters.Add(c);
            }
            paintEvent = new PaintEventHandler(paint);
        }
开发者ID:Scrivener07,项目名称:moddingSuite,代码行数:33,代码来源:Outline.cs

示例3: Draw

        public override void Draw(Graphics gr, Point position, Range range)
        {
            string text = range.Text;
            int iChar = range.Start.iChar;

            while (text != "")
            {
                bool replaced = false;
                foreach (var pair in ImagesByText)
                {
                    if (text.StartsWith(pair.Key))
                    {
                        float k = (float)(pair.Key.Length * range.tb.CharWidth) / pair.Value.Width;
                        if (k > 1)
                            k = 1f;
                        //
                        text = text.Substring(pair.Key.Length);
                        RectangleF rect = new RectangleF(position.X + range.tb.CharWidth * pair.Key.Length / 2 - pair.Value.Width * k / 2, position.Y, pair.Value.Width * k, pair.Value.Height * k);
                        gr.DrawImage(pair.Value, rect);
                        position.Offset(range.tb.CharWidth * pair.Key.Length, 0);
                        replaced = true;
                        iChar += pair.Key.Length;
                        break;
                    }
                }
                if (!replaced && text.Length > 0)
                {
                    Range r = new Range(range.tb, iChar, range.Start.iLine, iChar + 1, range.Start.iLine);
                    base.Draw(gr, position, r);
                    position.Offset(range.tb.CharWidth, 0);
                    text = text.Substring(1);
                }
            }
        }
开发者ID:phaufe,项目名称:ynoteclassic,代码行数:34,代码来源:ImageRenderer.cs

示例4: Process

        public override void Process()
        {
            DrawLocation = new Point((CurrentLocation.X - User.Movement.X + MapControl.OffSetX) * MapControl.CellWidth, (CurrentLocation.Y - User.Movement.Y + MapControl.OffSetY) * MapControl.CellHeight);
            DrawLocation.Offset((MapControl.CellWidth - Size.Width) / 2, (MapControl.CellHeight - Size.Height) / 2);
            DrawLocation.Offset(User.OffSetMove);
            DrawLocation.Offset(GlobalDisplayLocationOffset);
            FinalDrawLocation = DrawLocation;

            DisplayRectangle = new Rectangle(DrawLocation, Size);
        }
开发者ID:Pete107,项目名称:Mir2,代码行数:10,代码来源:ItemObject.cs

示例5: ToAbsolute

 public static Point ToAbsolute(Anchor anchor, Point point, Rectangle rect)
 {
     switch (anchor)
     {
         case Anchor.TopLeft:
             point.Offset(rect.Left, rect.Top);
             break;
         case Anchor.TopCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top);
             break;
         case Anchor.TopRight:
             point.Offset(rect.Right, rect.Top);
             break;
         case Anchor.MiddleLeft:
             point.Offset(rect.Left, rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleRight:
             point.Offset(rect.Right, rect.Top + (rect.Height / 2));
             break;
         case Anchor.BottomLeft:
             point.Offset(rect.Left, rect.Bottom);
             break;
         case Anchor.BottomCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Bottom);
             break;
         case Anchor.BottomRight:
             point.Offset(rect.Right, rect.Bottom);
             break;
     }
     return point;
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:34,代码来源:RelativePoint.cs

示例6: GetAbsolute

        public static Point GetAbsolute(Point point, Control sourceControl, Control rootControl)
        {
            Point tempPoint = new Point();
            for (Control iterator = sourceControl; iterator != rootControl; iterator = iterator.Parent)
            {
                tempPoint.Offset(iterator.Left, iterator.Top);
            }

            tempPoint.Offset(point.X, point.Y);
            return tempPoint;
        }
开发者ID:0anion0,项目名称:IBN,代码行数:11,代码来源:Utils.cs

示例7: BlitVoxelToSurface

		private unsafe void BlitVoxelToSurface(DrawingSurface ds, DrawingSurface vxl_ds, GameObject obj, DrawProperties props) {
			Point d = new Point(obj.Tile.Dx * TileWidth / 2, (obj.Tile.Dy - obj.Tile.Z) * TileHeight / 2);
			d.Offset(props.GetOffset(obj));
			d.Offset(-vxl_ds.BitmapData.Width / 2, -vxl_ds.BitmapData.Height / 2);

			// rows inverted!
			var w_low = (byte*)ds.BitmapData.Scan0;
			byte* w_high = w_low + ds.BitmapData.Stride * ds.BitmapData.Height;
			var zBuffer = ds.GetZBuffer();
			var shadowBufVxl = vxl_ds.GetShadows();
			var shadowBuf = ds.GetShadows();
			// int rowsTouched = 0;

			// short firstRowTouched = short.MaxValue;
			for (int y = 0; y < vxl_ds.Height; y++) {
				byte* src_row = (byte*)vxl_ds.BitmapData.Scan0 + vxl_ds.BitmapData.Stride * (vxl_ds.Height - y - 1);
				byte* dst_row = ((byte*)ds.BitmapData.Scan0 + (d.Y + y) * ds.BitmapData.Stride + d.X * 3);
				int zIdx = (d.Y + y) * ds.Width + d.X;
				if (dst_row < w_low || dst_row >= w_high) continue;

				for (int x = 0; x < vxl_ds.Width; x++) {
					// only non-transparent pixels
					if (*(src_row + x * 4 + 3) > 0) {
						*(dst_row + x * 3) = *(src_row + x * 4);
						*(dst_row + x * 3 + 1) = *(src_row + x * 4 + 1);
						*(dst_row + x * 3 + 2) = *(src_row + x * 4 + 2);

						// if (y < firstRowTouched)
						// 	firstRowTouched = (short)y;

						short zBufVal = (short)((obj.Tile.Rx + obj.Tile.Ry + obj.Tile.Z) * TileHeight / 2);
						if (zBufVal >= zBuffer[zIdx])
							zBuffer[zIdx] = zBufVal;
					}
					// or shadows
					else if (shadowBufVxl[x + y * vxl_ds.Height]) {
						int shadIdx = (d.Y + y) * ds.Width + d.X + x;
						if (!shadowBuf[shadIdx]) {
							*(dst_row + x * 3) /= 2;
							*(dst_row + x * 3 + 1) /= 2;
							*(dst_row + x * 3 + 2) /= 2;
							shadowBuf[shadIdx] = true;
						}
					}
					zIdx++;
				}
			}
		}
开发者ID:dkeetonx,项目名称:ccmaps-net,代码行数:48,代码来源:VoxelDrawable.cs

示例8: BaseTableForm_MouseWheel

 private void BaseTableForm_MouseWheel(object sender, MouseEventArgs e)
 {
     Point mousePoint = new Point(e.X, e.Y);
     mousePoint.Offset(this.Location.X, this.Location.Y);
     if (panelContent.RectangleToScreen(panelContent.DisplayRectangle).Contains(mousePoint))
         panelContent.AutoScrollPosition = new Point(0, panelContent.VerticalScroll.Value - e.Delta);
 }
开发者ID:Oman,项目名称:Maleos,代码行数:7,代码来源:BaseTableForm.cs

示例9: DisplayAtCursor

        public void DisplayAtCursor(Point position)
        {
            // [experimental]
            // a fix to stop the tooltip flickering
            // on some machines
            position.Offset(1, 1);

            Rectangle rect = this.Bounds;
            rect.X = position.X + Cursor.HotSpot.X;
            rect.Y = position.Y + Cursor.HotSpot.Y;

            if (Screen.PrimaryScreen.WorkingArea.Contains(rect) == false)
            {
                if ((rect.X + rect.Width) > Screen.PrimaryScreen.WorkingArea.Width)
                    rect.X -= Cursor.HotSpot.X + rect.Width;

                if ((rect.Y + rect.Height) > Screen.PrimaryScreen.WorkingArea.Height)
                    rect.Y -= Cursor.HotSpot.Y + rect.Height;

                if (rect.Y < 0)
                    rect.Y = Screen.PrimaryScreen.WorkingArea.Height - rect.Height;

                if (rect.X < 0)
                    rect.X = Screen.PrimaryScreen.WorkingArea.Width - rect.Width;
            }

            this.Location = rect.Location;

            if (this.Visible == false)
                this.Visible = true;
        }
开发者ID:sonygod,项目名称:dotahit,代码行数:31,代码来源:ItemToolTipForm.cs

示例10: AddCardDiscardPile

        private void AddCardDiscardPile(MouseEventArgs e, Panel sourcePanel, DiscardPile discardPile, ref Point lastLocation, MouseEventHandler methodToHandle)
        {
            if (e.Button == MouseButtons.Left)
            {
            if (wPile.getCount() > 0)
            {
                Card card = wPile.getLastCardInPile();
                discardPile.AddToPile(card);
                if (discardPile.getCount() == 1)
                    sourcePanel.BackgroundImage = card.getCardImage();
                else
                {
                    Panel p = new Panel();
                    p.BackgroundImage = card.getCardImage();
                    p.Height = sourcePanel.Height;
                    p.Width = sourcePanel.Width;
                    lastLocation.Offset(0, 20);
                    p.Location = lastLocation;
                    lastLocation = p.Location;
                    p.MouseDown += new System.Windows.Forms.MouseEventHandler(methodToHandle);
                    this.Controls.Add(p);
                    p.BringToFront();
                }

                //Remove card from the waste pile
                wPile.removeCard(card);
                wastePilePicture.BackgroundImage = null;
            }
            }
        }
开发者ID:jmutabaz,项目名称:OOP-Solitaire-Part-I,代码行数:30,代码来源:CalculationGame.cs

示例11: Wygrana

 private void Wygrana()
 {
     nrmapy++;
     
     switch (nrmapy)
     {
         case 1:
             game_board1.Image = Game.Properties.Resources.lvl1;
             StartPoint = game_board1.Location;
             StartPoint.Offset(200, 23);
             StartMouse();
             break;
         case 2:
             game_board1.Image = Game.Properties.Resources.lvl2;
             StartPoint = game_board1.Location;
             StartPoint.Offset(472, 462);
             StartMouse();
             break;
         case 3:
             game_board1.Image = Game.Properties.Resources.lvl3;
             la.Visible = true;
             hiden.Visible = true;
             StartPoint = game_board1.Location;
             StartPoint.Offset(254, 468);
             StartMouse();
             break;
             
     }
 }
开发者ID:daro5g,项目名称:Maze,代码行数:29,代码来源:Form1.cs

示例12: Draw

        public void Draw(Point displayLocation)
        {
            long timeRemaining = ExpireTime - CMain.Time;

            if (DamageLabel == null)
            {
                DamageLabel = new MirLabel
                {
                    AutoSize = true,
                    BackColour = Color.Transparent,
                    ForeColour = Colour,
                    OutLine = true,
                    OutLineColour = Color.Black,
                    Text = Text,
                    Font = new Font(Settings.FontName, 10F, FontStyle.Bold)
                };
                DamageLabel.Disposing += label_Disposing;

                MapObject.DamageLabelList.Add(DamageLabel);
            }

            displayLocation.Offset((int)(15 - (Text.Length * 3)), (int)(((int)((double)timeRemaining / Factor)) - Distance) - 75 - Offset);

            DamageLabel.Location = displayLocation;
            DamageLabel.Draw();
        }
开发者ID:Pete107,项目名称:Mir2,代码行数:26,代码来源:Damage.cs

示例13: DrawString

 public static void DrawString(this Graphics g, string str, Font font, Brush brush, Point center, double angle, Point pt, StringFormat stringFormat)
 {
     Point newPt = new Point(pt.X, pt.Y);
     newPt.Offset(-center.X, -center.Y);
     g.ResetTransform();
     g.TranslateTransform(g.ClipBounds.Left + center.X, g.ClipBounds.Top + center.Y);
     g.RotateTransform((float)MathHelper.Rad2Deg(angle));
     g.DrawString(str, font, brush, newPt, stringFormat);
 }
开发者ID:joeferner,项目名称:fivevolt,代码行数:9,代码来源:GraphicsHelper.cs

示例14: ShowContextMenu

		private static void ShowContextMenu(ContextMenuStrip contextMenuStrip, ActionModelNode actionModel, Point screenPoint, int minWidth, bool alignRight)
		{
			ToolStripBuilder.Clear(contextMenuStrip.Items);
			if (actionModel != null)
			{
				ToolStripBuilder.BuildMenu(contextMenuStrip.Items, actionModel.ChildNodes);
				if (alignRight)
					screenPoint.Offset(-contextMenuStrip.Width, 0);
				contextMenuStrip.Show(screenPoint);
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:11,代码来源:StudyFilterTableView.cs

示例15: Points

 public static void Points(out Point midTop, out Point midBottom, out Point midLeft, out Point midRight, Rectangle region)
 {
     midTop = region.Location;
     midTop.Offset(region.Width / 2, 0);
     midBottom = midTop;
     midBottom.Offset(0, region.Height);
     midRight = region.Location;
     midRight.Offset(region.Width, region.Height / 2);
     midLeft = midRight;
     midLeft.Offset(-region.Width, 0);
 }
开发者ID:theradeonxt,项目名称:FastImageEditor,代码行数:11,代码来源:MidpointGeometryRegion.cs


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