public static IsPointInTriangle ( Point p, Point a, Point b, Point c ) : bool | ||
p | Point | |
a | Point | |
b | Point | |
c | Point | |
Результат | bool |
private void PinboardControl_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int index = FindRectangle(e.Location); if (index == -1) { selectedIndex = -1; RaiseSelectionChangedEvent(); this.DisplayDirty = true; return; } this.Capture = true; PinboardFileV1.RectangleInfo dragRectInfo = Data.RectInfos[index]; Point[] points = this.GetCornerPoints(dragRectInfo.Rectangle); if (Vector.IsPointInTriangle(e.Location, points[0], points[1], points[2])) { this.dragOffset = new Point( dragRectInfo.X + dragRectInfo.Width - e.Location.X, dragRectInfo.Y + dragRectInfo.Height - e.Location.Y); dragOp = DragOperation.Sizing; this.Cursor = Cursors.SizeNWSE; } else { this.dragOffset = new Point( e.Location.X - dragRectInfo.Rectangle.X, e.Location.Y - dragRectInfo.Rectangle.Y); dragOp = DragOperation.Moving; this.Cursor = Cursors.Hand; } selectedIndex = index; RaiseSelectionChangedEvent(); this.DisplayDirty = true; } }
private void PinboardControl_MouseMove(object sender, MouseEventArgs e) { if (Capture == true) { switch (dragOp) { case DragOperation.Moving: SetRectanglePositionFromPoint(e.Location); break; case DragOperation.Sizing: SetRectangleSizeFromPoint(e.Location); break; } this.DataDirty = true; } else { int index = FindRectangle(e.Location); if (index != -1) { Point[] points = GetCornerPoints(Data.RectInfos[index].Rectangle); if (Vector.IsPointInTriangle(e.Location, points[0], points[1], points[2])) { this.Cursor = Cursors.SizeNWSE; } else { this.Cursor = Cursors.Hand; } } else { this.Cursor = Cursors.Arrow; } } }