Esempio n. 1
0
        public IVObject this[int index]
        {
            get
            {
                return((IVObject)_objects[index]);
            }
            set
            {
                if (index < 0 || index > _objects.Count)
                {
                    throw new System.ArgumentOutOfRangeException("index");
                }

                IVObject obj = (IVObject)_objects[index];
                OnVObjectRemoving(obj);
                OnVObjectAdding(value);

                _objects[index] = value;
                _objectHash.Remove(obj);
                _objectHash.Add(value, -1 /*dummy*/);

                OnVObjectRemoved(obj);
                OnVObjectAdded(value);
            }
        }
Esempio n. 2
0
 protected void OnVObjectRemoved(IVObject obj)
 {
     if (VObjectRemoved != null)
     {
         VObjectRemoved(this, new VObjectEventArgs(obj));
     }
 }
Esempio n. 3
0
        public override bool NotifyMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            if (e == null)
            {
                throw new System.ArgumentNullException("e");
            }

            bool result = false;

            base.Dragging      = false;
            _draggingPerformed = false;
            _objectToRemove    = null;

            //
            // Check for the control points click
            //
            System.Drawing.Point clickedPoint = new System.Drawing.Point(e.X, e.Y);
            if (base.GripsProvider != null)
            {
                base.DraggingPointIndex = base.GripsProvider.TestPoint(clickedPoint);
                if (base.DraggingPointIndex != GripsProvider.InvalidPointHandle)
                {
                    if (e.Button == System.Windows.Forms.MouseButtons.Left)
                    {
                        base.Dragging       = true;
                        result              = true;
                        _draggingStartPoint = clickedPoint;
                    }
                }

                if (base.GripsProvider.HitTest(clickedPoint))
                {
                    result = true;
                }
            }

            // If MultiSelect option is on we should also process Ctrl+Click action. If clicked object is
            // already selected - it should be removed from selection, otherwise it should be added to it.
            if (base.MultiSelect && (System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control)
            {
                System.Drawing.PointF clickedPointF = base.VObjectHost.HostViewer.ControlToWorkspace(clickedPoint, Aurigma.GraphicsMill.Unit.Point);
                IVObject clickedObj = base.VObjectHost.CurrentLayer.Find(clickedPointF, VObject.SelectionPrecisionDelta / base.VObjectHost.HostViewer.Zoom);
                if (clickedObj != null && !clickedObj.Locked)
                {
                    if (!this.CompositeVObject.Children.Contains(clickedObj))
                    {
                        this.CompositeVObject.Children.Add(clickedObj);
                        base.VObjectHost.CurrentDesigner = this;
                    }
                    else
                    {
                        _objectToRemove = clickedObj;
                    }
                }

                result = true;
            }

            return(result);
        }
Esempio n. 4
0
 protected void OnVObjectAdding(IVObject obj)
 {
     if (VObjectAdding != null)
     {
         VObjectAdding(this, new VObjectEventArgs(obj));
     }
 }
        protected override IVObject CreateObject(System.Drawing.RectangleF destinationRectangle)
        {
            IVObject obj = null;

            try
            {
                obj = new ImageVObject(_bitmap, _scaleToActualSize, 0, 0);
                System.Drawing.RectangleF bounds = obj.GetTransformedVObjectBounds();

                if (destinationRectangle.Width != 0 && destinationRectangle.Height != 0)
                {
                    float scaleX = (float)destinationRectangle.Width / bounds.Width,
                          scaleY = (float)destinationRectangle.Height / bounds.Height;

                    obj.Transform.Scale(scaleX, scaleY, System.Drawing.Drawing2D.MatrixOrder.Append);
                }

                obj.Transform.Translate(destinationRectangle.Left, destinationRectangle.Top, System.Drawing.Drawing2D.MatrixOrder.Append);
            }
            catch
            {
                obj = null;
            }

            return(obj);
        }
Esempio n. 6
0
        public bool Contains(IVObject value)
        {
            if (value == null)
            {
                throw new System.ArgumentNullException("value");
            }

            return(_objectHash.ContainsKey(value));
        }
Esempio n. 7
0
 private void InvalidateVObject(Layer layer, IVObject obj)
 {
     if (_hostViewer != null)
     {
         System.Drawing.Rectangle invalidationRect = _hostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point);
         invalidationRect.Inflate(VObject.InvalidationMargin);
         _hostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect, layer));
     }
 }
Esempio n. 8
0
        protected internal DefaultDesigner()
        {
            _objects = new IVObject[0];

            _multiSelect            = true;
            _selectionBasePoint     = _selectionCurPoint = System.Drawing.Point.Empty;
            _selectionPen           = new System.Drawing.Pen(System.Drawing.Color.Indigo, 2);
            _selectionPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
        }
Esempio n. 9
0
        protected PathVObjectCreateDesigner()
        {
            _objects = new IVObject[0];

            _pen          = new System.Drawing.Pen(System.Drawing.Color.FromArgb(0, 0, 0), 1.0f);
            _pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
            _brush        = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 255, 255));

            Reset();
        }
Esempio n. 10
0
        protected void InvalidateObject(IVObject obj)
        {
            if (obj == null)
            {
                throw new System.ArgumentNullException("obj");
            }

            System.Drawing.Rectangle areaToInvalidate = _objectHost.HostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point);
            areaToInvalidate.Inflate(VObject.InvalidationMargin);
            _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(areaToInvalidate, _objectHost.CurrentLayer));
        }
Esempio n. 11
0
 public void Clear()
 {
     for (int i = _objects.Count - 1; i >= 0; i--)
     {
         IVObject obj = (IVObject)_objects[i];
         OnVObjectRemoving(obj);
         _objectHash.Remove(obj);
         _objects.RemoveAt(i);
         OnVObjectRemoved(obj);
     }
 }
Esempio n. 12
0
        public GenericVObjectEditDesigner(IVObject obj)
            : this()
        {
            if (obj == null)
            {
                throw new System.ArgumentNullException("obj");
            }

            _obj          = obj;
            _obj.Changed += new System.EventHandler(ObjectChangedHandler);
        }
Esempio n. 13
0
        protected void CreateObjectAndDetach()
        {
            IVObject obj = CreateObject();

            if (obj != null)
            {
                _objectHost.CurrentLayer.VObjects.Add(obj);
                InvalidateObject(obj);
            }

            SwitchToDefaultDesigner();
        }
Esempio n. 14
0
        public void Remove(IVObject value)
        {
            if (!Contains(value))
            {
                return;
            }

            OnVObjectRemoving(value);

            _objects.Remove(value);
            _objectHash.Remove(value);

            OnVObjectRemoved(value);
        }
Esempio n. 15
0
        public void RemoveAt(int index)
        {
            if (index < 0 || index >= _objects.Count)
            {
                throw new System.ArgumentOutOfRangeException("index");
            }

            IVObject obj = (IVObject)_objects[index];

            OnVObjectRemoving(obj);
            _objects.RemoveAt(index);
            _objectHash.Remove(obj);
            OnVObjectRemoved(obj);
        }
Esempio n. 16
0
        /// <summary>
        /// Finds the top-most object of the layer's object located at a specified coordinate.
        /// </summary>
        /// <param name="point">Location for search.</param>
        /// <param name="precisionDelta">Search precision.</param>
        /// <returns>Returns the object when successful, otherwise null.</returns>
        public IVObject Find(System.Drawing.PointF point, float precisionDelta)
        {
            IVObject result = null;

            for (int i = _objects.Count - 1; i >= 0; i--)
            {
                if (_objects[i].HitTest(point, precisionDelta))
                {
                    result = _objects[i];
                    break;
                }
            }

            return(result);
        }
Esempio n. 17
0
        public int Add(IVObject value)
        {
            if (value == null)
            {
                throw new System.ArgumentNullException("value");
            }

            int result = -1;

            OnVObjectAdding(value);

            result = _objects.Add(value);
            _objectHash.Add(value, -1 /*dummy*/);

            OnVObjectAdded(value);
            return(result);
        }
Esempio n. 18
0
        internal void Swap(IVObject obj0, IVObject obj1)
        {
            int index0, index1;

            index0 = _objects.IndexOf(obj0);
            index1 = _objects.IndexOf(obj1);

            if (index0 == -1)
            {
                throw new System.ArgumentException(StringResources.GetString("ExStrLayerDoesntContainObject"), "obj0");
            }
            if (index1 == -1)
            {
                throw new System.ArgumentException(StringResources.GetString("ExStrLayerDoesntContainObject"), "obj1");
            }

            Swap(index0, index1);
        }
Esempio n. 19
0
        public void Insert(int index, IVObject value)
        {
            if (index < 0 || index > _objects.Count)
            {
                throw new System.ArgumentOutOfRangeException("index");
            }
            if (value == null)
            {
                throw new System.ArgumentNullException("value");
            }

            OnVObjectAdding(value);

            _objects.Insert(index, value);
            _objectHash.Add(value, -1 /*dummy*/);

            OnVObjectAdded(value);
        }
Esempio n. 20
0
        public void DrawContent(System.Drawing.Graphics g, System.Drawing.Rectangle rect, ICoordinateMapper coordinateMapper)
        {
            for (int i = 0; i < _layers.Count; i++)
            {
                if (!_layers[i].Visible)
                {
                    continue;
                }

                for (int j = 0; j < _layers[i].VObjects.Count; j++)
                {
                    IVObject obj = _layers[i].VObjects[j];
                    if (rect.IntersectsWith(coordinateMapper.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point)))
                    {
                        obj.Draw(rect, g, coordinateMapper);
                    }
                }
            }
        }
Esempio n. 21
0
        public GripsProvider(IVObject obj, ViewerBase hostControl)
        {
            if (hostControl == null)
            {
                throw new System.ArgumentNullException("hostControl");
            }

            if (obj == null)
            {
                throw new System.ArgumentNullException("obj");
            }

            _hostControl = hostControl;

            _obj = obj;
            _controlPointsProvider = obj as IControlPointsProvider;

            _objectBorderPen           = new System.Drawing.Pen(System.Drawing.Color.DarkGray, 1.0f);
            _objectBorderPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
        }
        public virtual bool NotifyMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            if (e == null)
            {
                throw new System.ArgumentNullException("e");
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left && _areaOriginDefined)
            {
                System.Drawing.RectangleF destinationRect;
                if (_areaDefined)
                {
                    destinationRect = VObjectsUtils.GetBoundingRectangle(_cornerPoints);
                }
                else
                {
                    destinationRect = new System.Drawing.RectangleF(_cornerPoints[0], System.Drawing.SizeF.Empty);
                }

                System.Drawing.Rectangle invalidationRect = System.Drawing.Rectangle.Empty;
                IVObject obj = CreateObject(destinationRect);
                if (obj != null)
                {
                    _objectHost.CurrentLayer.VObjects.Add(obj);
                    invalidationRect = _objectHost.HostViewer.WorkspaceToControl(obj.GetTransformedVObjectBounds(), Aurigma.GraphicsMill.Unit.Point);
                }

                if (_areaDefined)
                {
                    System.Drawing.Rectangle tmp = _objectHost.HostViewer.WorkspaceToControl(destinationRect, Aurigma.GraphicsMill.Unit.Point);
                    tmp.Inflate((int)_borderPen.Width * 2, (int)_borderPen.Width * 2);
                    invalidationRect = System.Drawing.Rectangle.Union(invalidationRect, tmp);
                    _areaDefined     = false;
                }

                _objectHost.HostViewer.InvalidateViewer(new MultiLayerViewerInvalidationTarget(invalidationRect, _objectHost.CurrentLayer));
                _objectHost.CurrentDesigner = _objectHost.DefaultDesigner;
            }

            return(true);
        }
Esempio n. 23
0
        public bool NotifyMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            if (e == null)
            {
                throw new System.ArgumentNullException("e");
            }

            if (this.IsCurrentLayerInaccessible)
            {
                return(true);
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                IVObject activeObj = null;
                if (!this.IsCurrentLayerInaccessible)
                {
                    activeObj = _objectHost.CurrentLayer.Find(_objectHost.HostViewer.ControlToWorkspace(new System.Drawing.Point(e.X, e.Y), Aurigma.GraphicsMill.Unit.Point), VObject.SelectionPrecisionDelta / _objectHost.HostViewer.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point));
                }

                IDesigner newDesigner = null;
                if (activeObj != null)
                {
                    newDesigner = _objectHost.CurrentDesigner = activeObj.Designer;
                }
                else if (_multiSelect)
                {
                    _selecting          = true;
                    _selectionBasePoint = _selectionCurPoint = new System.Drawing.Point(e.X, e.Y);
                }

                if (newDesigner != null)
                {
                    newDesigner.NotifyMouseDown(e);
                }
            }
            return(true);
        }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the XmlExporter class.
 /// </summary>
 /// <param name="data">Data to export</param>
 public XmlExporter(IVObject data)
 {
     this.Data = data;
     this.document = new XmlDocument();
 }
Esempio n. 25
0
        public virtual bool NotifyMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            if (e == null)
            {
                throw new System.ArgumentNullException("e");
            }

            _dragging = false;
            System.Drawing.Point clickedPoint = new System.Drawing.Point(e.X, e.Y);

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                //
                // Check if a control points was clicked
                //
                if (_gripsProvider != null)
                {
                    _dragPointIndex = _gripsProvider.TestPoint(clickedPoint);
                    if (_dragPointIndex != GripsProvider.InvalidPointHandle)
                    {
                        _dragging       = true;
                        _dragBeginPoint = clickedPoint;
                        return(true);
                    }
                }

                //
                // Check for a click on another object
                //
                // If MultiSelect option is on we should also process Ctrl+Click action. If another
                // object has been clicked - it should be added to the selected objects.
                IVObject clickedObj = _objectHost.CurrentLayer.Find(_objectHost.HostViewer.ControlToWorkspace(new System.Drawing.Point(e.X, e.Y), Aurigma.GraphicsMill.Unit.Point), VObject.SelectionPrecisionDelta / _objectHost.HostViewer.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point));
                if (clickedObj != _obj)
                {
                    if (_multiSelect && (System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control && clickedObj != null && !clickedObj.Locked && !_obj.Locked)
                    {
                        _objectHost.CurrentDesigner = new CompositeVObjectEditDesigner(new IVObject[] { _obj, clickedObj });
                        return(true);
                    }
                    else if (clickedObj != null)
                    {
                        _objectHost.CurrentDesigner = clickedObj.Designer;
                        return(true);
                    }
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //
                // Context menu handling
                //
                if (_contextMenu != null)
                {
                    IVObject clickedObj = _objectHost.CurrentLayer.Find(_objectHost.HostViewer.ControlToWorkspace(new System.Drawing.Point(e.X, e.Y), Aurigma.GraphicsMill.Unit.Point), VObject.SelectionPrecisionDelta / _objectHost.HostViewer.GetControlPixelsPerUnitX(Aurigma.GraphicsMill.Unit.Point));
                    if (clickedObj == _obj)
                    {
                        _contextMenu.Show(_objectHost.HostViewer, clickedPoint);
                    }
                }

                return(true);
            }

            return(false);
        }
Esempio n. 26
0
 public CompositeVObjectEditDesigner(IVObject obj)
     : base(obj)
 {
 }
Esempio n. 27
0
 public int IndexOf(IVObject value)
 {
     return(_objects.IndexOf(value));
 }
Esempio n. 28
0
 public VObjectEventArgs(IVObject obj)
 {
     _object = obj;
 }
Esempio n. 29
0
 public LayerChangedEventArgs(Layer layer, IVObject changedObj, LayerChangeType type)
     : base(layer)
 {
     _obj  = changedObj;
     _type = type;
 }