Your comments
@behnam263, it seems that the page http://blog.csharphelper.com/ is not available.
10 years ago
@elementu, please try the following code
double l,w,h;
double xGap, yGap;
double xOffsetIncrement, yOffsetIncrement;
xGap= mouseSelectionEndPoint.X - mouseSelectionStartPoint.X;
yGap = mouseSelectionEndPoint.Y - mouseSelectionStartPoint.Y;
l = Math.Abs(xGap);
w = Math.Abs(yGap);
h = 25;
xOffsetIncrement = l / 2;
yOffsetIncrement = w / 2;
if (xGap<0)
{
xOffsetIncrement *= -1;
}
if (yGap<0)
{
yOffsetIncrement *= -1;
}
TranslateTransform3D trans = new TranslateTransform3D();
trans.OffsetX = mouseSelectionStartPoint.X + xOffsetIncrement;
trans.OffsetY = mouseSelectionStartPoint.Y + yOffsetIncrement;
trans.OffsetZ = 12;
VolumeSelectionCube.Width = w;
VolumeSelectionCube.Length = l;
VolumeSelectionCube.Height = h;
VolumeSelectionCube.Transform = trans;
----------------------
VolumeSelectionCube is 'BoxVisual3D' object
<h:BoxVisual3D x:Name="VolumeSelectionCube"/>
also you have to assign "mouseSelectionEndPoint" and "mouseSelectionStartPoint" from mouse down/up events.
I am using this and working perfectly...
double l,w,h;
double xGap, yGap;
double xOffsetIncrement, yOffsetIncrement;
xGap= mouseSelectionEndPoint.X - mouseSelectionStartPoint.X;
yGap = mouseSelectionEndPoint.Y - mouseSelectionStartPoint.Y;
l = Math.Abs(xGap);
w = Math.Abs(yGap);
h = 25;
xOffsetIncrement = l / 2;
yOffsetIncrement = w / 2;
if (xGap<0)
{
xOffsetIncrement *= -1;
}
if (yGap<0)
{
yOffsetIncrement *= -1;
}
TranslateTransform3D trans = new TranslateTransform3D();
trans.OffsetX = mouseSelectionStartPoint.X + xOffsetIncrement;
trans.OffsetY = mouseSelectionStartPoint.Y + yOffsetIncrement;
trans.OffsetZ = 12;
VolumeSelectionCube.Width = w;
VolumeSelectionCube.Length = l;
VolumeSelectionCube.Height = h;
VolumeSelectionCube.Transform = trans;
----------------------
VolumeSelectionCube is 'BoxVisual3D' object
<h:BoxVisual3D x:Name="VolumeSelectionCube"/>
also you have to assign "mouseSelectionEndPoint" and "mouseSelectionStartPoint" from mouse down/up events.
I am using this and working perfectly...
Customer support service by UserEcho