public override bool OnMouseUp(MouseEventArgs param, ref bool isScreenDirty) { var sender = param.Source as DXElement; if (sender == null) { return(false); } if (_isVisible) { _isVisible = false; // Create new Polygon float top = Math.Max(_downPos.Y, _curPos.Y); float bottom = Math.Min(_downPos.Y, _curPos.Y); float left = Math.Min(_downPos.X, _curPos.X); float right = Math.Max(_downPos.X, _curPos.X); float centerX = (top + bottom) / 2.0f; float centerY = (left + right) / 2.0f; left -= centerX; right -= centerX; top -= centerY; bottom -= centerY; var vertices = new List <Polygon.Vertex>() { new Polygon.Vertex() { Id = 0, Y = top, X = left }, new Polygon.Vertex() { Id = 1, Y = top, X = right }, new Polygon.Vertex() { Id = 2, Y = bottom, X = right }, new Polygon.Vertex() { Id = 3, Y = bottom, X = left } }; var position = new Vector2(centerX, centerY); var polygon = new Polygon(position, vertices, Color, string.Format("Rectangle{0}", _RectangleCounter++)); //_models.Add(polygon); _items.AddItem(polygon); isScreenDirty = true; sender.Render(); } if (_downPos == default(Vector2)) { return(false); } _downPos = default(Vector2); return(true); }