當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。