Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
NormanL  
#1 Posted : Tuesday, February 5, 2013 3:13:59 AM(UTC)
NormanL

Rank: Advanced Member

Groups: Member
Joined: 4/26/2012(UTC)
Posts: 36

Thanks: 6 times
Hi,

I'm trying to add a new ImageVObject at the same location and orientation (angle) as an existing one. Please see step1-3.png attached for an illustration of what I'm trying to achieve. Step1.png shows the existing ImageVObject, Step2.png shows the new ImageVObject added at the same location, and Step3.png shows the final result after the existing ImageVObject was removed. My code to position the new ImageVObject is as shown below however the final position is not correct (i.e. the new ImageVObject appears either too high or low). Things appear to work out out if the angle is 0 so I don't think what I have takes this into account?

Code:
Dim voWidth As Single = voNew.Width
Dim voHeight As Single = voNew.Height
Dim oldRect As Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.RotatedRectangleF = voOld.Rectangle

Dim x As Single
Dim y As Single
If voWidth <= oldRect.Width Then
    x = oldRect.Location.X + ((oldRect.Width - voWidth) / 2)
Else
    x = oldRect.Location.X - ((voWidth - oldRect.Width) / 2)
End If
If voHeight <= oldRect.Height Then
    y = oldRect.Location.Y + ((oldRect.Height - voHeight) / 2)
Else
    y = oldRect.Location.Y - ((voHeight - oldRect.Height) / 2)
End If

voNew.Transform.Angle = vo.Rectangle.Angle
voNew.Location = New Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.PointF(x, y)

lyr.VObjects.Remove(voOld)
lyr.VObjects.Add(voNew)

(PS I tried setting the CentreX and CentreY properties of the new ImageVObject but this didn't appear to work.)

Edited by user Tuesday, February 5, 2013 3:16:50 AM(UTC)  | Reason: Not specified

NormanL attached the following image(s):
step1.png
step2.png
step3.png
vitaly  
#2 Posted : Thursday, February 7, 2013 1:05:43 AM(UTC)
vitaly

Rank: Advanced Member

Groups: Member
Joined: 12/19/2012(UTC)
Posts: 164

Was thanked: 8 time(s) in 8 post(s)
Hello NormanL,

The best way to create the same ImageVObject with different values of some properties is create new ImageVObject and set Data property the same as old object. After this you can set needed properties. For example on C# it looks like:

Code:

var voNew = new ImageVObject() { Data = voOld.Data };

// Set needed properties (i.e. ImageVObject.Rectangle property)
voNew.Rectangle = new RotatedRectangleF(100, 100, 100, 100, 45);
                                    
lyr.VObjects.Remove(voOld);
lyr.VObjects.Add(voNew);

I hope it helps.

Best regards,

Vitaly Kustov

Aurigma Technical Support

Best regards,

Vitaly Kustov

Aurigma Technical Support

NormanL  
#3 Posted : Thursday, February 7, 2013 10:48:08 AM(UTC)
NormanL

Rank: Advanced Member

Groups: Member
Joined: 4/26/2012(UTC)
Posts: 36

Thanks: 6 times
Hi,

That worked - thanks.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.