C# (CSharp) Class Point, Code Examples

C# (CSharp) Point - 30 examples found. These are the top rated real world C# (CSharp) examples of class Point from package extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
0
	public static Point TranslatePoint(Point point1, Point point2, Point point3, double angle)
	{
		var angle1 = Math.Atan2(point1.Y - point2.Y, point1.X - point2.X);
		var angle2 = angle1 - angle / AngleConvert;
		var length = (point3 - point2).Length;
		return new Point(point2.X + length * Math.Cos(angle2), point2.Y + length * Math.Sin(angle2));
	}
Example #2
0
	public static int Main ()
	{
		new Point {
			X = 0,
			Y = 0
		};
		
		var markerPosition = new Point {
			X = 2 * 3,
			Y = 9
		};
		
		if (markerPosition.X != 6)
			return 1;
		
		if (markerPosition.Y != 9)
			return 2;
		
		Point[] pa = new Point[] { new Point { X = 9 }, new Point { X = 8 } };
		
		if (pa [0].X != 9)
			return 3;
		
		if (pa [1].X != 8)
			return 3;

		p = new Point { Y = -1 };
		if (p.Y != -1)
			return 4;
		
		return 0;
	}
Example #3
0
	public InstructionsForm ()
	{
		// 
		// _tabControl
		// 
		_tabControl = new TabControl ();
		_tabControl.Dock = DockStyle.Fill;
		Controls.Add (_tabControl);
		// 
		// _bugDescriptionText1
		// 
		_bugDescriptionText1 = new TextBox ();
		_bugDescriptionText1.Multiline = true;
		_bugDescriptionText1.Location = new Point (8, 8);
		_bugDescriptionText1.Dock = DockStyle.Fill;
		_bugDescriptionText1.Text = string.Format (CultureInfo.InvariantCulture,
			"Expected result on start-up:{0}{0}" +
			"1. The background color of the Form is blue and does not show " +
			"any distortions.",
			Environment.NewLine);
		// 
		// _tabPage1
		// 
		_tabPage1 = new TabPage ();
		_tabPage1.Text = "#1";
		_tabPage1.Controls.Add (_bugDescriptionText1);
		_tabControl.Controls.Add (_tabPage1);
		// 
		// InstructionsForm
		// 
		ClientSize = new Size (330, 120);
		Location = new Point (600, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "Instructions - bug #81721";
	}
	protected virtual void SetLocation()
	{
		TextArea textArea = control.ActiveTextAreaControl.TextArea;
		TextLocation caretPos  = textArea.Caret.Position;
		
		int xpos = textArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X);
		int rulerHeight = textArea.TextEditorProperties.ShowHorizontalRuler ? textArea.TextView.FontHeight : 0;
		Point pos = new Point(textArea.TextView.DrawingPosition.X + xpos,
		                      textArea.TextView.DrawingPosition.Y + (textArea.Document.GetVisibleLine(caretPos.Y)) * textArea.TextView.FontHeight
		                      - textArea.TextView.TextArea.VirtualTop.Y + textArea.TextView.FontHeight + rulerHeight);
		
		Point location = control.ActiveTextAreaControl.PointToScreen(pos);
		
		// set bounds
		Rectangle bounds = new Rectangle(location, drawingSize);
		
		if (!workingScreen.Contains(bounds)) {
			if (bounds.Right > workingScreen.Right) {
				bounds.X = workingScreen.Right - bounds.Width;
			}
			if (bounds.Left < workingScreen.Left) {
				bounds.X = workingScreen.Left;
			}
			if (bounds.Top < workingScreen.Top) {
				bounds.Y = workingScreen.Top;
			}
			if (bounds.Bottom > workingScreen.Bottom) {
				bounds.Y = bounds.Y - bounds.Height - control.ActiveTextAreaControl.TextArea.TextView.FontHeight;
				if (bounds.Bottom > workingScreen.Bottom) {
					bounds.Y = workingScreen.Bottom - bounds.Height;
				}
			}
		}
		Bounds = bounds;
	}
Example #5
0
 public Texte(string message, Point position, Color couleur)
 {
     this.message = message;
     this.position = position;
     this.couleur = couleur;
     this.police = Fonte.Arial15;
 }
Example #6
0
 protected Item(Image image, Image imageEffect, Sound soundEffect, Point initialPosition)
     : base(image, Rectangle.FromCenter(initialPosition, Size.Zero))
 {
     this.imageEffect = imageEffect;
     this.soundEffect = soundEffect;
     RenderLayer = MaxRenderLayer;
 }
Example #7
0
 public override void Draw(SpriteBatchUI spriteBatch, Point position)
 {
     Vector3 hueVector = Utility.GetHueVector(Hue);
     int width = (int)(m_PercentWidthDrawn * Width);
     spriteBatch.Draw2D(m_Texture, new Rectangle(position.X, position.Y, width, Height), new Rectangle(0, 0, width, Height), hueVector);
     base.Draw(spriteBatch, position);
 }
Example #8
0
 // -----------------------
 // Public Constructors
 // -----------------------
 /// <summary>
 ///	Rectangle Constructor
 /// </summary>
 ///
 /// <remarks>
 ///	Creates a Rectangle from Point and Size values.
 /// </remarks>
 public Rectangle(Point location, Size size)
 {
     x = location.X;
     y = location.Y;
     width = size.Width;
     height = size.Height;
 }
Example #9
0
        void mouseZone_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsActive)
            {
                _viewport.Cursor = Cursors.None;

                var centerOfViewport = _viewport.PointToScreen(new Point(_viewport.ActualWidth / 2, _viewport.ActualHeight / 2));
                var relativePos = e.MouseDevice.GetPosition(_viewport);
                var actualRelativePos = new Point(relativePos.X - _viewport.ActualWidth / 2, _viewport.ActualHeight / 2 - relativePos.Y);
                var dx = actualRelativePos.X;
                var dy = actualRelativePos.Y;
                _yaw += dx;
                _pitch += dy;
                
                // Rotate
                Rotation = QuaternionHelper.EulerAnglesInDegToQuaternion(_pitch * Sensitivity * 0.1, _yaw * Sensitivity * 0.1, 0);
                
                // Set mouse position back to the center of the viewport in screen coordinates
                MouseUtilities.SetPosition(centerOfViewport);
            }
            else
            {
                _viewport.Cursor = Cursors.Arrow;
            }
        }
Example #10
0
 public Particle_SmokeStream(Vector2 position)
 {
     this.position = position;
     size = new Point(10, 10);
     color = Color.White;
     texture = Texture2DLibrary.particle_smoke;
 }
	/// <summary>
	/// Constructor
	/// </summary>
	/// <param name="context"/>
	/// <param name="location"/>
	public InflAffixTemplateEventArgs(Control context, XmlNode node, Point location, int tag)
	{
		m_location = location;
		m_node = node;
		m_contextControl = context;
		m_tag = tag;
	}
Example #12
0
        internal TreeColumn GetColumnDividerAt(Point p)
        {
            if (p.Y > ColumnHeaderHeight)
                return null;

            int x = -OffsetX;
            TreeColumn prevCol = null;
            Rectangle left, right;
            foreach (TreeColumn col in Columns)
            {
                if (col.IsVisible)
                {
                    if (col.Width > 0)
                    {
                        left = new Rectangle(x, 0, DividerWidth / 2, ColumnHeaderHeight);
                        right = new Rectangle(x + col.Width - (DividerWidth / 2), 0, DividerWidth / 2, ColumnHeaderHeight);
                        if (left.Contains(p) && prevCol != null)
                            return prevCol;
                        else if (right.Contains(p))
                            return col;
                    }
                    prevCol = col;
                    x += col.Width;
                }
            }

            left = new Rectangle(x, 0, DividerWidth / 2, ColumnHeaderHeight);
            if (left.Contains(p) && prevCol != null)
                return prevCol;

            return null;
        }
 public void AddString(string s,	FontFamily family,	int style, float emSize, Point origin, StringFormat format)
 {
     var font = new Font (family.Name, emSize, (FontStyle)style);
     var layoutRect = RectangleF.Empty;
     layoutRect.Location = origin;
     NativeDrawString (s, font, Color.Red, layoutRect, format);
 }
 public static Point ScaleTo( Point value, Point source, Point dest )
 {
     return new Point(
         ScaleTo( value.X, source.X, dest.X ),
         ScaleTo( value.Y, source.Y, dest.Y )
         );
 }
Example #15
0
 private void InvokeSurfacePressed(Point position)
 {
     if (this.SurfacePressed != null)
     {
         this.SurfacePressed.Invoke(this, new SurfacePressedEventArgs(position));
     }
 }
Example #16
0
 public static Point GetCursorPosition()
 {
     Point currentMousePoint;
     var gotPoint = GetCursorPos(out currentMousePoint);
     if (!gotPoint) { currentMousePoint = new Point(0, 0); }
     return currentMousePoint;
 }
        public void Move(Point newLocation)
        {
            if (newLocation == null)
                throw new ArgumentNullException(nameof(newLocation), "The new location is null!");

            Move(newLocation.X, newLocation.Y);
        }
Example #18
0
        //private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksOutside),
        //                                        Bitmap.BitmapImageType.Gif);
        //private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksInside),
        //                                        Bitmap.BitmapImageType.Gif);


        public override void Render(Bitmap screen)
        {
            if (_screen == null) _screen = screen;

            screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);

            var text = "AGENT";
            Point textLocation = new Point(
                AGENT.Center.X - (drawing.MeasureString(text, smallFont) / 2), AGENT.Center.Y - 25);
            screen.DrawText(text, smallFont, Color.White, textLocation.X, textLocation.Y);

            var date = Settings.Now.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.MonthDayPattern);
            ; //time.MonthNameShort + " " + time.Day;

            Point dateLocation = new Point(
                AGENT.Center.X - (drawing.MeasureString(date, smallFont) / 2), AGENT.Center.Y + 20);
            screen.DrawText(date, smallFont, Color.White, dateLocation.X, dateLocation.Y);

            //draw our hands
            drawing.PaintSkinnyHands(screen, Settings.Now, AGENT.Center);


            
            drawing.DrawTray(screen, _notificationProvider, smallFont);

        }
 protected override void OnMouseDown(MouseEventArgs e)
 {
     _startPoint = e.Location;
     _hscrolloffset = LayoutTarget.HorizontalScroll.Value;
     _vscrolloffset = LayoutTarget.VerticalScroll.Value;
     base.OnMouseDown(e);
 }
Example #20
0
 public static Point RtlTransform(Control control, Point point)
 {
     if (control.RightToLeft != RightToLeft.Yes)
         return point;
     else
         return new Point(control.Right - point.X, point.Y);
 }
Example #21
0
        public RespawnInfo(BinaryReader reader, int Version, int Customversion)
        {
            MonsterIndex = reader.ReadInt32();

            Location = new Point(reader.ReadInt32(), reader.ReadInt32());

            Count = reader.ReadUInt16();
            Spread = reader.ReadUInt16();

            Delay = reader.ReadUInt16();
            Direction = reader.ReadByte();

            if (Envir.LoadVersion >= 36)
            {
                RoutePath = reader.ReadString();
            }

            if (Version > 67)
            {
                RandomDelay = reader.ReadUInt16();
                RespawnIndex = reader.ReadInt32();
                SaveRespawnTime = reader.ReadBoolean();
                RespawnTicks = reader.ReadUInt16();
            }
            else
            {
                RespawnIndex = ++SMain.Envir.RespawnIndex;
            }
        }
Example #22
0
        public override void Execute(TextArea textArea)
        {
            Point position = textArea.Caret.Position;
            List<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldedFoldingsWithEnd(position.Y);
            FoldMarker justBeforeCaret = null;
            foreach (FoldMarker fm in foldings) {
                if (fm.EndColumn == position.X) {
                    justBeforeCaret = fm;
                    break; // the first folding found is the folding with the smallest Startposition
                }
            }

            if (justBeforeCaret != null) {
                position.Y = justBeforeCaret.StartLine;
                position.X = justBeforeCaret.StartColumn;
            } else {
                if (position.X > 0) {
                    --position.X;
                } else if (position.Y  > 0) {
                    LineSegment lineAbove = textArea.Document.GetLineSegment(position.Y - 1);
                    position = new Point(lineAbove.Length, position.Y - 1);
                }
            }

            textArea.Caret.Position = position;
            textArea.SetDesiredColumn();
        }
Example #23
0
 public Texte(string message, Point position)
 {
     this.message = message;
     this.position = position;
     this.couleur = Structure.Color.White;
     this.police = Fonte.Arial15;
 }
Example #24
0
 /// <summary>
 /// Compute the distance between the two point values
 /// </summary>
 /// <param name="source">The source point</param>
 /// <param name="target">The target point</param>
 /// <returns>the distance between the two provided points</returns>
 public static double Distance(this Point source, Point target)
 {
     return Math.Sqrt(
         (source.X - target.X) * (source.X - target.X) +
         (source.Y - target.Y) * (source.Y - target.Y)
         );
 }
Example #25
0
 public Texte(string message, Point position, Color couleur, Fonte police)
 {
     this.message = message;
     this.position = position;
     this.couleur = couleur;
     this.police = police;
 }
        /// <summary>
        /// Rotate an image on a point with a specified angle
        /// </summary>
		/// <param name="pe">The paint area event where the image will be displayed</param>
		/// <param name="img">The image to display</param>
		/// <param name="alpha">The angle of rotation in radian</param>
		/// <param name="ptImg">The location of the left upper corner of the image to display in the paint area in nominal situation</param>
		/// <param name="ptRot">The location of the rotation point in the paint area</param>
		/// <param name="scaleFactor">Multiplication factor on the display image</param>
        protected void RotateImage(PaintEventArgs pe, Image img, Double alpha, Point ptImg, Point ptRot, float scaleFactor)
        {
            double beta = 0; 	// Angle between the Horizontal line and the line (Left upper corner - Rotation point)
            double d = 0;		// Distance between Left upper corner and Rotation point)		
            float deltaX = 0;	// X componant of the corrected translation
            float deltaY = 0;	// Y componant of the corrected translation

			// Compute the correction translation coeff
            if (ptImg != ptRot)
            {
				//
                if (ptRot.X != 0)
                {
                    beta = Math.Atan((double)ptRot.Y / (double)ptRot.X);
                }

                d = Math.Sqrt((ptRot.X * ptRot.X) + (ptRot.Y * ptRot.Y));

                // Computed offset
                deltaX = (float)(d * (Math.Cos(alpha - beta) - Math.Cos(alpha) * Math.Cos(alpha + beta) - Math.Sin(alpha) * Math.Sin(alpha + beta)));
                deltaY = (float)(d * (Math.Sin(beta - alpha) + Math.Sin(alpha) * Math.Cos(alpha + beta) - Math.Cos(alpha) * Math.Sin(alpha + beta)));
            }

            // Rotate image support
            pe.Graphics.RotateTransform((float)(alpha * 180 / Math.PI));

            // Dispay image
            pe.Graphics.DrawImage(img, (ptImg.X + deltaX) * scaleFactor, (ptImg.Y + deltaY) * scaleFactor, img.Width * scaleFactor, img.Height * scaleFactor);

            // Put image support as found
            pe.Graphics.RotateTransform((float)(-alpha * 180 / Math.PI));

        }
Example #27
0
        public AboutBox()
        {
            InitializeComponent();
            loc = label1.Location;

            label1.Text = "";
            try
            {
                var rm = new System.Resources.ResourceManager("BizHawk.Client.EmuHawk.Properties.Resources", GetType().Assembly);
                sfx = new SoundPlayer(rm.GetStream("nothawk"));
                sfx.Play();
            }
            catch
            {
            }

            //panel1.Size = new System.Drawing.Size(1000, 1000);
            //pictureBox5.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod).Invoke(pictureBox5, new object[] { ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true });
            pictureBox5.BackColor = Color.Transparent;
            pictureBox5.SendToBack();
            pictureBox3.BringToFront();
            pictureBox2.BringToFront();
            pictureBox1.BringToFront();
            pictureBox5.Visible = false;
        }
Example #28
0
 public FIARECT(Point location, Size size)
 {
     this.left = location.X;
     this.top = location.Y;
     this.right = this.left + size.Width - 1;
     this.bottom = this.top + size.Height - 1;
 }
Example #29
0
 public Point AddPoint(float value, DateTime timestamp)
 {
     var p = new Point(value, timestamp);
     _points.Add(p);
     _lastPoint = p;
     return p;
 }
Example #30
0
        public Unit(IEnumerable<Point> members, Point pivot)
        {
            Displacements = new PointF[6][];
            var pivotF = pivot.ToGeometry();
            Displacements[0] = members.Select(z => z.ToGeometry().Sub(pivotF)).ToArray();
            Array.Sort(Displacements[0], pointsComparer);
            Period = 6;

            for (int i = 1; i < 6; i++)
            {
                Displacements[i] = Displacements[i - 1]
                    .Select(z => z.Rotate(new Point(0, 0), angle))
                    .ToArray();
                Array.Sort(Displacements[i], pointsComparer);
                if (Displacements[i].Zip(Displacements[0], (p1, p2) => Math.Abs(p1.X - p2.X) + Math.Abs(p1.Y - p2.Y) < 1e-3).All(a => a))
                {
                    Period = i;
                    break;
                }
            }

            IsLine = Displacements
                .Where(z => z != null)
                .Any(z => z.All(x => Math.Abs(x.Y-z[0].Y)<1e-5));
            IsLine = IsLine && members.Count() > 1;
        }