Rank: Advanced Member
Groups: Guest
Joined: 3/3/2008(UTC) Posts: 185
Thanks: 8 times
|
Hi, Thanks for the reply. Code:
private System.Drawing.PointF[] GetSelectedObjectsBound()
{
System.Drawing.PointF[] gsobSelectedPoints = null;
if (_workingMultilayerViewer.CurrentDesigner.VObjects.Count() == 1)
{
gsobSelectedPoints = GetTransformedCornerPoints((Aurigma.GraphicsMill.WinControls.VObject)_workingMultilayerViewer.CurrentDesigner.VObjects[0]);
}
else
{
var mvmvPointList = new List<PointF>();
foreach (Aurigma.GraphicsMill.WinControls.VObject swTmpVObject2 in _workingMultilayerViewer.CurrentDesigner.VObjects)
{
// Get Big Size
System.Drawing.PointF[] swObjBound = GetTransformedCornerPoints(swTmpVObject2);
mvmvPointList.AddRange(swObjBound);
}
System.Drawing.PointF[] mvmvPoints = mvmvPointList.ToArray();
General mvmvGeneral = new General();
float mvmvLeastX = mvmvGeneral.GetLeastX(mvmvPoints);
float mvmvLeastY = mvmvGeneral.GetLeastY(mvmvPoints);
float mvmvMostX = mvmvGeneral.GetMaxX(mvmvPoints);
float mvmvMostY = mvmvGeneral.GetMaxY(mvmvPoints);
gsobSelectedPoints = new PointF[] { new PointF(mvmvLeastX, mvmvLeastY), new PointF(mvmvMostX, mvmvLeastY), new PointF(mvmvMostX, mvmvMostY), new PointF(mvmvLeastX, mvmvMostY) };
}
return gsobSelectedPoints;
}
Code:
private ResizeVObjectInfo GetVObjectResizeMode(System.Drawing.PointF[] selectVObjectPoints)
{
ResizeVObjectInfo gvrmObj = new ResizeVObjectInfo();
Boolean gvrmResized = false;
gvrmResized = false;
Boolean gvrmConstantPoint1 = false;
Boolean gvrmConstantPoint2 = false;
Boolean gvrmConstantPoint3 = false;
Boolean gvrmConstantPoint4 = false;
if ((Math.Round(_selectItemPoints[0].X, 3) == Math.Round(selectVObjectPoints[0].X, 3)) && (Math.Round(_selectItemPoints[0].Y, 3) == Math.Round(selectVObjectPoints[0].Y, 3)))
{
gvrmResized = true;
gvrmConstantPoint1 = true;
}
if ((Math.Round(_selectItemPoints[1].X, 3) == Math.Round(selectVObjectPoints[1].X, 3)) && (Math.Round(_selectItemPoints[1].Y, 3) == Math.Round(selectVObjectPoints[1].Y, 3)))
{
gvrmResized = true;
gvrmConstantPoint2 = true;
}
if ((Math.Round(_selectItemPoints[2].X, 3) == Math.Round(selectVObjectPoints[2].X, 3)) && (Math.Round(_selectItemPoints[2].Y, 3) == Math.Round(selectVObjectPoints[2].Y, 3)))
{
gvrmResized = true;
gvrmConstantPoint3 = true;
}
if ((Math.Round(_selectItemPoints[3].X, 3) == Math.Round(selectVObjectPoints[3].X, 3)) && (Math.Round(_selectItemPoints[3].Y, 3) == Math.Round(selectVObjectPoints[3].Y, 3)))
{
gvrmResized = true;
gvrmConstantPoint4 = true;
}
if (gvrmConstantPoint1 && gvrmConstantPoint2 && gvrmConstantPoint3 && gvrmConstantPoint4)
{
gvrmResized = false;
}
else
{
if (!gvrmResized)
{
_selectItemPoints = selectVObjectPoints;
}
}
if (gvrmResized)
{
if (gvrmConstantPoint1)
{
if (gvrmConstantPoint2)
{
// Resize height to bottom or top (stupid drag till flip)
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[2].X, selectVObjectPoints[2].Y) };
//mvmvResizeHeight = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Bottom;
//_statusBar.Text = "Dragging to bottom";
}
else
{
if (gvrmConstantPoint4)
{
// Resize width to right or left (stupid drag till flip)
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[1].X, selectVObjectPoints[1].Y) };
//mvmvResizeWidth = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Right;
//_statusBar.Text = "Dragging to right";
}
else
{
// Resize height and width to right & bottom
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[2].X, selectVObjectPoints[2].Y) };
//mvmvResizeWidth = true;
//mvmvResizeHeight = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.BottomRight;
//_statusBar.Text = "Dragging to right + bottom";
}
}
}
else
{
if (gvrmConstantPoint2)
{
if (gvrmConstantPoint3)
{
// Resize width to left or right (stupid drag till flip)
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[0].X, selectVObjectPoints[0].Y) };
//mvmvResizeWidth = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Left;
//_statusBar.Text = "Dragging to left";
}
else
{
// Resize height and width to left & bottom
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[3].X, selectVObjectPoints[3].Y) };
//mvmvResizeWidth = true;
//mvmvResizeHeight = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.BottomLeft;
//_statusBar.Text = "Dragging to left + bottom";
}
}
else
{
if (gvrmConstantPoint3)
{
if (gvrmConstantPoint4)
{
// resize height to top
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[0].X, selectVObjectPoints[0].Y) };
//mvmvResizeHeight = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Top;
//_statusBar.Text = "Dragging to top";
}
else
{
// resize height and width to top & left
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[0].X, selectVObjectPoints[0].Y) };
//mvmvResizeWidth = true;
//mvmvResizeHeight = true;
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.TopLeft;
//_statusBar.Text = "Dragging to top + left";
}
}
else
{
//resize height and with to top & right
gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[1].X, selectVObjectPoints[1].Y) };
gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.TopRight;
//mvmvResizeWidth = true;
//mvmvResizeHeight = true;
//_statusBar.Text = "Dragging to top + right";
}
}
}
}
return gvrmObj;
}
// Snip code inside MouseMove for MultilayerViewer. Code:
System.Drawing.PointF[] mvmvSelectedPoints = GetSelectedObjectsBound();
ResizeVObjectInfo mvmvResizeObjInfo = new ResizeVObjectInfo();
if (_selectItemPoints == null)
{
_selectItemPoints = GetSelectedObjectsBound();
}
mvmvResizeObjInfo = GetVObjectResizeMode(mvmvSelectedPoints);
_statusbar.text = mvmvResizeObjInfo.ResizeMode.ToString();
This code works for most cases beside when the resize is in porpotional and user resize from left, right, top or bottom. But, if we keep on dragging to resize, on and off, we will see the action will actually detected "none" (no resize) for a short period..
|