public Point GetLocation(enLocationType locType) { Point result = new Point(0, 0); switch (locType) { case enLocationType.center: { result = new Point(this.size.Location.X + (this.size.Width / 2), this.size.Location.Y + (this.size.Height / 2)); }; break; case enLocationType.topLeft: { result = this.size.Location; }; break; case enLocationType.topRight: { result = new Point(this.size.Location.X + this.size.Size.Width, this.size.Location.Y); }; break; case enLocationType.bottomLeft: { result = new Point(this.size.Location.X, this.size.Location.Y + this.size.Height); }; break; case enLocationType.bottomRight: { result = new Point(this.size.Location.X + this.size.Size.Width, this.size.Location.Y + this.size.Height); }; break; } return(result); }
//sets moving: endPoint is corner or middle of object specified by startPoint variable public void SetMove(Point endPoint, enMoveOn movingForm, bool rotateWanted = true, int speed = 1, enLocationType endPointType = enLocationType.center) { /*update me*/ frMain.movList.Remove(this); Point startPoint = GetLocation(enLocationType.topLeft); //transform of endPoint depending on endPointType selection (so that startPoint and endPoint mark same location of PB) switch (endPointType) { case (enLocationType.center): { endPoint = new Point(endPoint.X - PB.Width / 2, endPoint.Y - PB.Height / 2); }; break; case (enLocationType.topLeft): { }; break; case (enLocationType.topRight): { endPoint = new Point(endPoint.X - PB.Width, endPoint.Y); }; break; case (enLocationType.bottomLeft): { endPoint = new Point(endPoint.X, endPoint.Y - PB.Height); }; break; case (enLocationType.bottomRight): { endPoint = new Point(endPoint.X - PB.Width, endPoint.Y - PB.Height); }; break; } int pointsOnLine = (int)Math.Sqrt(Math.Pow((endPoint.Y - startPoint.Y), 2) + Math.Pow((endPoint.X - startPoint.X), 2)); movData.actualPoint = 0; movData.speed = speed; switch (movingForm) { case enMoveOn.Line: movData.path = GetPointsOnLine(startPoint, endPoint, pointsOnLine / movData.speed); break; case enMoveOn.PointToPoint: movData.path = new Point[] { endPoint }; break; //TODO more moving algorhitms } //Console.WriteLine("SetMove: startPoint{0}, endPoint:{1}.",startPoint.ToString(), endPoint.ToString()); /*update me*/ frMain.movList.Add(this); if (rotateWanted) { RotateImage(countAngle(startPoint, endPoint), Color.Transparent); } }