System.Drawing.Point.Round(System.Drawing.PointF)

Here are the examples of the csharp api class System.Drawing.Point.Round(System.Drawing.PointF) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

31 Examples 7

1. Example

Project: SharpMap
Source File: SharpDXVectorStyle.cs
public static Vector2 ToSharpDXPoint(PointF symbolOffset)
        {
            var tmp = System.Drawing.Point.Round(symbolOffset);
            return new Vector2(tmp.X, tmp.Y);
        }

2. Example

Project: Gorgon
Source File: formMain.cs
private void DrawSpray(GorgonJoystick joystick, int index)
		{
			SprayCan state = _sprayStates[index];

	        // Update the origin of the spray.
			state.Origin = _stickPosition[index];

			// Find out if we're spraying.
			if (joystick.Throttle > joystick.Capabilities.ThrottleAxisRange.Minimum) 
			{
				if ((!state.IsActive) && (!state.NeedReset))
				{
					// Convert the throttle value to a unit value.
					float throttleUnit = ((float)(joystick.Throttle - joystick.Capabilities.ThrottleAxisRange.Minimum) / joystick.Capabilities.ThrottleAxisRange.Range);

					// Set up the spray state.
					state.Position = state.Origin;
					state.Amount = joystick.Capabilities.ThrottleAxisRange.Range / 2.0f;
					state.Time = throttleUnit * 10.0f;
					state.VibrationAmount = joystick.Capabilities.VibrationMotorRanges[1].Maximum;
					state.SprayAlpha = (throttleUnit * 239.0f) + 16;
					state.IsActive = true;
				}
			}
			else
			{
				state.IsActive = false;
			}

		    if (!state.IsActive)
		    {
			    return;
		    }

		    // Update the state spray effect.
		    state.Update();
		    _surface.DrawPoint(Point.Round(state.Position), state.SprayColor, state.SprayPointSize);
		}

3. Example

Project: ImageGlass
Source File: ImageListViewRenderer.cs
public virtual void DrawFileIcon(Graphics g, ImageListViewItem item, Rectangle bounds)
            {
                Image icon = item.GetCachedImage(CachedImageType.SmallIcon);
                if (icon != null)
                {
                    Size size = icon.Size;
                    PointF ptf = new PointF((float)bounds.X + ((float)bounds.Width - (float)size.Width) / 2.0f,
                        (float)bounds.Y + ((float)bounds.Height - (float)size.Height) / 2.0f);
                    Point pt = Point.Round(ptf);
                    g.DrawImage(icon, pt.X, pt.Y);
                }
            }

4. Example

Project: imagelistview
Source File: ImageListViewRenderer.cs
public virtual void DrawFileIcon(Graphics g, ImageListViewItem item, Rectangle bounds)
            {
                Image icon = item.GetCachedImage(CachedImageType.SmallIcon);
                if (icon != null)
                {
                    Size size = icon.Size;
                    PointF ptf = new PointF((float)bounds.X + ((float)bounds.Width - (float)size.Width) / 2.0f,
                        (float)bounds.Y + ((float)bounds.Height - (float)size.Height) / 2.0f);
                    Point pt = Point.Round(ptf);
                    g.DrawImage(icon, pt.X, pt.Y);
                }
            }

5. Example

Project: HTML-Renderer
Source File: HtmlPanel.cs
public virtual void ScrollToElement(string elementId)
        {
            ArgChecker.AssertArgNotNullOrEmpty(elementId, "elementId");

            if (_htmlContainer != null)
            {
                var rect = _htmlContainer.GetElementRectangle(elementId);
                if (rect.HasValue)
                {
                    UpdateScroll(Point.Round(rect.Value.Location));
                    _htmlContainer.HandleMouseMove(this, new MouseEventArgs(MouseButtons, 0, MousePosition.X, MousePosition.Y, 0));
                }
            }
        }

6. Example

Project: Gorgon
Source File: formMain.cs
private void DrawJoystickCursor(GorgonJoystick joystick, int index)
		{
			var playerColorValue = (i/n ..... /n //View Source file for more details /n }

7. Example

Project: BotSuite
Source File: Mouse.cs
public static bool Move(Point targetPosition, bool human = true, int steps = 100)
		{
			if(!human)
			{
				Cursor.Position = targetPosition;
				return true;
			}

			Point start = GetPosition();
			PointF iterPoint = start;

			PointF slope = new PointF(targetPosition.X - start.X, targetPosition.Y - start.Y);

			slope.X = slope.X / steps;
			slope.Y = slope.Y / steps;

			for(int i = 0; i < steps; i++)
			{
				iterPoint = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);
				Cursor.Position = Point.Round(iterPoint);
				Utility.RandomDelay(5, 10);
			}

			// test if it works
			return (Cursor.Position.X == targetPosition.X) && (Cursor.Position.Y == targetPosition.Y);
		}

8. Example

Project: BotSuite
Source File: Mouse.cs
public static Boolean Move(Point targetPosition, Boolean human = true, Int32 steps = 100)
        {
            if (!human)
            {
                Cursor.Position = targetPosition;
                return true;
            }
            Point start = GetPosition();
            PointF iterPoint = start;

            var slope = new PointF(targetPosition.X - start.X, targetPosition.Y - start.Y);

            slope.X = slope.X/steps;
            slope.Y = slope.Y/steps;

            for (int i = 0; i < steps; i++)
            {
                iterPoint = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);
                Cursor.Position = Point.Round(iterPoint);
                Utility.Delay(5, 10);
            }

            // test if it works
            if ((Cursor.Position.X == targetPosition.X) && (Cursor.Position.Y == targetPosition.Y))
                return true;
            return false;
        }

9. Example

Project: ClearCanvas
Source File: VerticesControlGraphic.cs
protected virtual void DeleteVertex()
		{
			if (!_canAddRemoveVertices || !Enabled)
				return;

			object memento = this.CreateMemento();

			IPointsGraphic subject = this.Subject;
			if (subject.Points.Count > 1)
			{
				int index = this.HitTestControlPoint(Point.Round(_lastContextMenuPoint));
				if (index >= 0 && index < subject.Points.Count)
				{
					subject.Points.RemoveAt(index);
				}
			}

			AddToCommandHistory(this, memento, this.CreateMemento());
		}

10. Example

Project: ClearCanvas
Source File: VerticesControlGraphic.cs
public override IActionSet GetExportedActions(string site, IMouseInformation mouseInformation)
		{
	/n ..... /n //View Source file for more details /n }

11. Example

Project: ClearCanvas
Source File: RoiCalloutGraphic.cs
public void Rename()
		{
			var parent = ParentGraphic;
			if (parent == null)
				return;

			this.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				EditBox editBox = new EditBox(parent.Name ?? string.Empty);
				editBox.Location = Point.Round(base.TextGraphic.Location);
				editBox.Size = Size.Round(base.TextGraphic.BoundingBox.Size);
				editBox.FontName = base.TextGraphic.Font;
				editBox.FontSize = base.TextGraphic.SizeInPoints;
				editBox.Multiline = false;
				editBox.ValueAccepted += OnEditBoxAccepted;
				editBox.ValueCancelled += OnEditBoxCancelled;
				base.ParentPresentationImage.Tile.EditBox = editBox;
			}
			finally
			{
				this.ResetCoordinateSystem();
			}
		}

12. Example

Project: ImageGlass
Source File: ImageListViewRenderer.cs
public virtual void DrawCheckBox(Graphics g, ImageListViewItem item, Rectangle bounds)
            {
                Size size = CheckBoxRenderer.GetGlyphSize(g, CheckBoxState.CheckedNormal);
                PointF pt = new PointF((float)bounds.X + ((float)bounds.Width - (float)size.Width) / 2.0f,
                    (float)bounds.Y + ((float)bounds.Height - (float)size.Height) / 2.0f);
                CheckBoxState state = CheckBoxState.UncheckedNormal;
                if (item.Enabled)
                    state = item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
                else
                    state = item.Checked ? CheckBoxState.CheckedDisabled : CheckBoxState.UncheckedDisabled;
                CheckBoxRenderer.DrawCheckBox(g, Point.Round(pt), state);
            }

13. Example

Project: MultiversePlatform
Source File: UiComponents.cs
public override void SetupWindowPosition()
        {
            base.SetupWindowPosition();
            if (browser != null)
            {
                browser.BrowserSize = System.Drawing.Size.Round(this.Size);
                browser.BrowserLocation = Point.Round(this.Position);
                browser.PositionBrowser();
            }
        }

14. Example

Project: imagelistview
Source File: ImageListViewRenderer.cs
public virtual void DrawCheckBox(Graphics g, ImageListViewItem item, Rectangle bounds)
            {
                Size size = CheckBoxRenderer.GetGlyphSize(g, CheckBoxState.CheckedNormal);
                PointF pt = new PointF((float)bounds.X + ((float)bounds.Width - (float)size.Width) / 2.0f,
                    (float)bounds.Y + ((float)bounds.Height - (float)size.Height) / 2.0f);
                CheckBoxState state = CheckBoxState.UncheckedNormal;
                if (item.Enabled)
                    state = item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
                else
                    state = item.Checked ? CheckBoxState.CheckedDisabled : CheckBoxState.UncheckedDisabled;
                CheckBoxRenderer.DrawCheckBox(g, Point.Round(pt), state);
            }

15. Example

Project: SharpMap
Source File: HeatLayer.cs
private void DrawPoints(MapViewport map, IEnumerable<DataRow> features, Bitmap dot, Bitmap image)
        {
            var size = new Size(dot.Width, dot.Height);

            foreach (FeatureDataRow row in features)
            {
                var heatValue = HeatValueComputer(row);
                if (heatValue <= 0) continue;
                if (heatValue >= 1f) heatValue = 1;

                var c = row.Geometry.PointOnSurface.Coordinate;
                if (CoordinateTransformation != null)
                {
                    c = GeometryTransform.TransformCoordinate(c, CoordinateTransformation.MathTransform);
                }
                var posF = map.WorldToImage(c);
                var pos = Point.Round(posF);
                //var pos = Point.Round(PointF.Subtract(posF, halfSize));

                using (var tmpDot = ApplyHeatValueToImage(dot, heatValue))
                {
                    ImageBlender.BlendImages(image, pos.X, pos.Y, size.Width, size.Height,
                                             tmpDot, 0, 0, BlendOperation.BlendMultiply);
                }
            }
        }

16. Example

Project: Gorgon
Source File: formMain.cs
private void UpdateMouseLabel(PointF position, PointingDeviceButtons button)
        {
            if ((button & PointingDeviceButtons.Button1) == PointingDeviceButtons.Button1)
            {
                _spray.SprayPoint(Point.Round(position));
                _currentCursor = Resources.hand_pointer_icon;
            }
            else
            {
                _currentCursor = Resources.hand_icon;
            }

            _mousePosition = new Point((int)position.X, (int)_mouse.Position.Y);

            labelMouse.Text = string.Format("{0}: {1}x{2}.  Button: {3}.  Using {4} for data retrieval.",
                                _mouse.Name,
                                position.X.ToString("0.#"),
                                position.Y.ToString("0.#"),
                                button,
                                (_usePolling ? "Polling" : "Events"));
        }

17. Example

Project: ClearCanvas
Source File: VerticesControlGraphic.cs
protected virtual void InsertVertex()
		{
			if (!_canAddRemoveVertices || !Enabled)
				return;

			object memento = this.CreateMemento();

			IPointsGraphic subject = this.Subject;
			subject.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				int index = this.HitTestControlPoint(Point.Round(_lastContextMenuPoint));

				if (index < 0)
				{
					// if inserting in middle of line, find which index to insert at
					index = IndexOfNextClosestPoint(subject, _lastContextMenuPoint);
				}
				else if (index == subject.Points.Count - 1)
				{
					// if inserting on last point, append instead of inserting before
					index++;
				}

				if (index >= 0)
				{
					subject.Points.Insert(index, _lastContextMenuPoint);
				}
			}
			finally
			{
				subject.ResetCoordinateSystem();
			}

			AddToCommandHistory(this, memento, this.CreateMemento());
		}

18. Example

Project: TDMaker
Source File: ZedGraphControl.Events.cs
private void HandleZoomDrag( Point mousePt )
		{
			// Hide the previous rectangle by calling the
			// DrawReversibleFrame method with the same parameters.
			Rectangle rect = CalcScreenRect( _dragStartPt, _dragEndPt );
			ControlPaint.DrawReversibleFrame( rect, this.BackColor, FrameStyle.Dashed );

			// Bound the zoom to the ChartRect
			_dragEndPt = Point.Round( BoundPointToRect( mousePt, _dragPane.Chart._rect ) );
			rect = CalcScreenRect( _dragStartPt, _dragEndPt );
			// Draw the new rectangle by calling DrawReversibleFrame again.
			ControlPaint.DrawReversibleFrame( rect, this.BackColor, FrameStyle.Dashed );
		}

19. Example

Project: MultiversePlatform
Source File: UiComponents.cs
internal override void ShowWindows()
        {
            base.ShowWindows();
            if (browser != null)
            {
                browser.Hide();
                browser.Dispose();
                browser = null;
            }
            browser = new Multiverse.Web.Browser();
            browser.BrowserSize = System.Drawing.Size.Round(this.Size);
            browser.BrowserLocation = Point.Round(this.Position);
            browser.BrowserScrollbars = scrollbars;
            browser.BrowserLine = line;
            browser.BrowserErrors = browsererrors;
            browser.Open(url);
            browser.ObjectForScripting = scriptingObj;
            browser.Show();

			this.MouseDownEvent += HandleMouseDown;
			this.window.KeyDown += this.HandleKeyDown; // -- this doesn't work --> // this.KeyDownEvent += this.HandleKeyDown;

			SetFocus();
        }

20. Example

Project: ZedGraph
Source File: ZedGraphControl.Events.cs
private void HandleZoomDrag( Point mousePt )
		{
			using (Graphics g = Graphics.FromHwnd(this.Handle))
			{
				// Hide the previous rectangle by calling the
				// DrawReversibleFrame method with the same parameters.
				Rectangle rect = this.CalcZoomRect(this._dragStartPt, this._dragEndPt);
				ReversibleFrame.Draw(g, this.BackColor, rect);

				// Bound the zoom to the ChartRect
				_dragEndPt = Point.Round(this.BoundPointToRect(mousePt, this._dragPane.Chart._rect));
				rect = this.CalcZoomRect(this._dragStartPt, this._dragEndPt);

				// Draw the new rectangle by calling DrawReversibleFrame again.
				ReversibleFrame.Draw(g, this.BackColor, rect);
			}
		}

21. Example

Project: ClearCanvas
Source File: TextEditControlGraphic.cs
public bool StartEdit()
		{
			// remove any pre-existing edit boxes
			EndEdit();

			bool result = false;
			this.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				EditBox editBox = new EditBox(this.Text ?? string.Empty);
				editBox.Location = Point.Round(this.Location);
				editBox.Size = Rectangle.Round(this.BoundingBox).Size;
				editBox.Multiline = this.Multiline;
				editBox.FontName = this.FontName;
				editBox.FontSize = this.FontSize;
				editBox.ValueAccepted += OnEditBoxComplete;
				editBox.ValueCancelled += OnEditBoxComplete;
				InstallEditBox(_currentCalloutEditBox = editBox);
				result = true;
			}
			finally
			{
				this.ResetCoordinateSystem();
			}

			return result;
		}

22. Example

Project: referencesource
Source File: ChartGraphics.cs
private void DrawSecondRowLabelMark(
			Axis axis, 
			Color markColor,
			RectangleF absPosition, 
/n ..... /n //View Source file for more details /n }

23. Example

Project: SharpMap
Source File: MapBox.cs
private void HandleMapNewTileAvaliable(ITileAsyncLayer sender, Envelope box, Bitmap bm, int sourceWidth,
                                               int sourceHeight, ImageAttributes imageAttributes)
        {
            lock (_backgroundImagesLocker)
            {
                try
                {
                    var min = Point.Round(_map.WorldToImage(box.Min()));
                    var max = Point.Round(_map.WorldToImage(box.Max()));

                    if (IsDisposed == false && _isDisposed == false)
                    {

                        using (var g = Graphics.FromImage(_imageBackground))
                        {

                            g.DrawImage(bm,
                                        new Rectangle(min.X, max.Y, (max.X - min.X), (min.Y - max.Y)),
                                        0, 0,
                                        sourceWidth, sourceHeight,
                                        GraphicsUnit.Pixel,
                                        imageAttributes);

                        }

                        UpdateImage(false);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Warn(ex.Message, ex);
                    //this can be a GDI+ Hell Exception...
                }

            }

        }

24. Example

Project: Gorgon
Source File: MainForm.cs
protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			try
			{				
				// Load the /n ..... /n //View Source file for more details /n }

25. Example

Project: ClearCanvas
Source File: InteractiveTextGraphicBuilder.cs
public bool StartEdit()
		{
			// remove any pre-existing edit boxes
			EndEdit();

			bool result = false;
			this.Graphic.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				EditBox editBox = new EditBox(_textGraphic.Text ?? string.Empty);
				if (string.IsNullOrEmpty(_textGraphic.Text))
					editBox.Value = SR.LabelEnterText;
				editBox.Multiline = true;
				editBox.Location = Point.Round(_textGraphic.Location);
				editBox.Size = Rectangle.Round(_textGraphic.BoundingBox).Size;
				editBox.FontName = _textGraphic.Font;
				editBox.FontSize = _textGraphic.SizeInPoints;
				editBox.ValueAccepted += OnEditBoxComplete;
				editBox.ValueCancelled += OnEditBoxComplete;
				InstallEditBox(_currentCalloutEditBox = editBox);
				result = true;
			}
			finally
			{
				this.Graphic.ResetCoordinateSystem();
			}

			return result;
		}

26. Example

Project: referencesource
Source File: Selection.cs
private GraphicsPath GetGraphicsPath(IList markers, object chartObject, ChartElementType elementType/n ..... /n //View Source file for more details /n }

27. Example

Project: ClearCanvas
Source File: DicomSoftcopyPresentationStateBase.cs
protected void SerializeOverlayPlane(OverlayPlaneModuleIod overlayPlaneModule, out IOverlayMapping o/n ..... /n //View Source file for more details /n }

28. Example

Project: TDMaker
Source File: ZedGraphControl.Events.cs
private void HandleSelectionFinish( object sender, MouseEventArgs e )
		{
			if ( e.Button != _selec/n ..... /n //View Source file for more details /n }

29. Example

Project: ZedGraph
Source File: ZedGraphControl.Events.cs
private void HandleSelectionFinish( object sender, MouseEventArgs e )
		{
			if ( e.Button != _selec/n ..... /n //View Source file for more details /n }

30. Example

Project: ClearCanvas
Source File: ShowAnglesToolGraphic.cs
private void Update()
			{
				const float calloutOffset = 36;
				const float largerCalloutOffset =/n ..... /n //View Source file for more details /n }

31. Example

Project: ClearCanvas
Source File: ProbeTool.cs
private void Probe(Point sourcePointRounded, bool showPixelValue, bool showVoiValue)
		{
			string p/n ..... /n //View Source file for more details /n }