//void EndMove() //{ // mLastOffset = Point.e //} public void MoveControl(int x, int y, int keyPosX, int keyPosY) { mbMoving = true; Point thisPosition = this.PointToScreen(new Point(x, y)); thisPosition = this.Parent.PointToClient(thisPosition); thisPosition.Offset(-keyPosX, -keyPosY); bool hitTopBoundry = false; if (thisPosition.Y < 0) { hitTopBoundry = true; } if (thisPosition.X - mHost.AutoScrollPosition.X > 0 && thisPosition.Y - mHost.AutoScrollPosition.Y > 0) { this.Location = thisPosition; //OnMoved(); } else if (thisPosition.Y - mHost.AutoScrollPosition.Y > 0) //slide { thisPosition.X = 0; this.Location = thisPosition; //OnMoved(); } else if (thisPosition.X - mHost.AutoScrollPosition.X > 0) //slide { thisPosition.Y = 0; this.Location = thisPosition; //OnMoved(); } if (thisPosition.X - mHost.AutoScrollPosition.X > mHost.AutoScrollMinSize.Width - 300) { thisPosition.X = mHost.AutoScrollMinSize.Width + mHost.AutoScrollPosition.X - 300; this.Location = thisPosition; } if (thisPosition.Y - mHost.AutoScrollPosition.Y > mHost.AutoScrollMinSize.Height - 300) { thisPosition.Y = mHost.AutoScrollMinSize.Height + mHost.AutoScrollPosition.Y - 300; this.Location = thisPosition; } OnMoved(); //if (thisPosition != this.Location) //{ // OnMoved(); //} if (hitTopBoundry && thisPosition.X < 200) { DragOutOfHost(); } mHost.Invalidate(false); return; IControlPointOwner cpowner = this as IControlPointOwner; if (cpowner != null) { foreach (IControlPoint cp in cpowner.GetControlPoints()) { if (cp.isConnected()) { foreach (IControlPoint target in cp.GetTargets()) { if (target == null) { continue; } Point p1 = mHost.PointToClient(cp.GetPosition()); Point p2 = mHost.PointToClient(target.GetPosition()); int top = Math.Min(p1.Y, p2.Y); int bottom = Math.Max(p1.Y, p2.Y); int left = Math.Min(p1.X, p2.X); int right = Math.Max(p1.X, p2.X); Rectangle r = Rectangle.FromLTRB(left - 10, top - 10, right + 10, bottom + 10); mHost.Invalidate(r, false); } } } } }