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

Notification

Icon
Error

Options
Go to last post Go to first unread
mzhao  
#1 Posted : Monday, September 9, 2013 12:55:28 PM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Hello,

we add a CompositeVObject to MultiLayerViewer.CurrentLayer.VObjects. but when we select this compositeVobject on MultiLayerViewer, the CurrentDesigner of MultiLayerViewer is not up and not selection handle on this compositeVobject and Designer_Change Event of MultiLayerViewer is not fired:

This is how we do it:

1 Create a CompositeVObject:

Code:
ImageVObject [] tempImageList = new ImageVObject[2];
tempImageList[0] = imageVobject1;
tempImageList[1] = imageVobject2;

CompositeVObject comVObj = new CompositeVObject (tempImageList);


2. add it to multiLayerViewer:

Code:
multiLayerView1.CurrentLayer.VObject.Add (comVObj);


=========================
Thank you.

Edited by moderator Monday, September 9, 2013 8:28:28 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Tuesday, September 10, 2013 12:22:19 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 868

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)
The CompositeVObject is designed to be created internally (when the user selects multiple VObjects). If you really need to have composite objects (like two images like in your example), more correct way would be to implement your own VObject implementation.

Here is an example of implementation of a custom VObject which contains two images displayed one next to another.

Code:
    class TwoImageVObject : Aurigma.GraphicsMill.WinControls.VObject
    {
        private Aurigma.GraphicsMill.WinControls.ImageVObject _image1;
        private Aurigma.GraphicsMill.WinControls.ImageVObject _image2;
        private Aurigma.GraphicsMill.WinControls.IDesigner _editDesigner;
        private int _distance = 10;

        public Aurigma.GraphicsMill.WinControls.ImageVObject Image1
        {
            get { return _image1; }
            set { _image1 = value; }
        }

        public Aurigma.GraphicsMill.WinControls.ImageVObject Image2
        {
            get { return _image2; }
            set { _image2 = value; }
        }

        public TwoImageVObject(Aurigma.GraphicsMill.Bitmap bitmap1, Aurigma.GraphicsMill.Bitmap bitmap2, bool scaleToActualSize, float x, float y) :
            base()
        {
            _image1 = new Aurigma.GraphicsMill.WinControls.ImageVObject(bitmap1, scaleToActualSize, x , y);
            _image2 = new Aurigma.GraphicsMill.WinControls.ImageVObject(bitmap2, scaleToActualSize, x, y);
        }

        public override RectangleF GetVObjectBounds()
        {
            RectangleF image1Bounds = _image1.GetVObjectBounds();
            RectangleF image2Bounds = _image2.GetVObjectBounds();
            return new RectangleF(image1Bounds.X, image1Bounds.Y, image1Bounds.Width + image2Bounds.Width + _distance, image1Bounds.Height);
        }

        public override RectangleF GetTransformedVObjectBounds()
        {
            RectangleF image1Bounds = _image1.GetTransformedVObjectBounds();
            RectangleF image2Bounds = _image2.GetTransformedVObjectBounds();
            return new RectangleF(image1Bounds.X, image1Bounds.Y, image1Bounds.Width + image2Bounds.Width + _distance, image1Bounds.Height);
        }
         
        public override bool HitTest(PointF point, float precisionDelta)
        {
            return _image1.HitTest(point, precisionDelta) | _image2.HitTest(point, precisionDelta);
        }

        public override System.Drawing.Drawing2D.Matrix Transform 
        {
            get {
                return _image1.Transform;
            }
            set {
                _image1.Transform = value;
                UpdateTransform();
           }
        }

        public override Aurigma.GraphicsMill.WinControls.IDesigner Designer
        {
            get {
                if (_editDesigner == null)
                    _editDesigner = new Aurigma.GraphicsMill.WinControls.GenericVObjectEditDesigner(this);

                return _editDesigner;
            }
        }

        private void UpdateTransform()
        {
            _image2.Transform = _image1.Transform.Clone();
            PointF secondImagePosition = new Point(_distance + (int)_image1.GetVObjectBounds().Width, 0);
            _image2.Transform.Translate(secondImagePosition.X, 0); ;
        }

        public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, Aurigma.GraphicsMill.WinControls.ICoordinateMapper coordinateMapper)
        {
            UpdateTransform();
            _image1.Draw(renderingRect, g, coordinateMapper);
            _image2.Draw(renderingRect, g, coordinateMapper);
        }
    }


Here is an example of its usage:

Code:
            TwoImageVObject twoImage = new TwoImageVObject(
                new Aurigma.GraphicsMill.Bitmap(@"C:\Temp\ocean-1.jpg"),
                new Aurigma.GraphicsMill.Bitmap(@"C:\Temp\ocean-2.jpg"),
                true, 10f, 20f);

            multiLayerViewer1.Layers[0].VObjects.Add(twoImage);


If you need to modify TwoImageVObject to change images layout, first of all, modify UpdateTransform method (which "shifts" the second image relatively to the first one) and methods which return VObject bounds.

Hope this helps.
mzhao  
#3 Posted : Friday, September 20, 2013 10:04:44 AM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Hello,

Thanks for the reply.

We tried exactly what you put here. but the situation is still the same:

The created TwoImageVObject is not in Editing State when doing mouse_ click on, no selection handle shows, thus, can not move and be resized and all kinds of editing work, etc.

it seems a CompositeVObject loses editing capability after it is added to MultiLayerViewer.CurrentLayer.VObjects. but it works fine if not in MultiLayerViewer.CurrentLayer.VObjects.

Why.

Thanks.
Andrew  
#4 Posted : Monday, September 23, 2013 12:40:50 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 868

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)
Could you please reproduce it on a blank project (which just contain the MultiLayerViewer and the TwoImageVObject code as I posted above)? If you still cannot edit the two-image v-object after you add it to the control, please post here this project (or, probably, open a support case and attach it there).
mzhao  
#5 Posted : Monday, September 23, 2013 12:14:18 PM(UTC)
mzhao

Rank: Advanced Member

Groups: Member
Joined: 9/10/2010(UTC)
Posts: 57

Thanks: 1 times
Well, we tried this on a blank project. It seems that it does work.

This is encouraging and we will have another look.

Thanks for the help.
Users browsing this topic
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.