Exemple #1
0
 public void Update()
 {
     if (visualisation == true)
     {
         ShapeDraw.DrawFill(this);
     }
 }
Exemple #2
0
        /// <summary>
        /// cancel the shapes selected
        /// </summary>
        /// <returns>if all selectd shapes are canceled, return true</returns>
        public bool CancelSelect(bool isOpenEvent)
        {
            bool cancelAll = true;

            foreach (ShapeBase shape in this)
            {
                if (isOpenEvent)
                {
                    shape.IsSelected = false;
                }
                else
                {
                    shape.BeginEdit();
                    shape.IsSelected = false;
                    shape.EndEdit();
                }
            }

            if (isOpenEvent)
            {
                ShapeDraw.IsSelected = false;
            }
            else
            {
                ShapeDraw.BeginEdit();
                ShapeDraw.IsSelected = false;
                ShapeDraw.EndEdit();
            }

            return(cancelAll);
        }
Exemple #3
0
        public void Dispose()
        {
            int length = Count;

            if (length > 0)
            {
                for (int i = 0; i < length; i++)
                {
                    if (this[i] != null)
                    {
                        this[i].Dispose();
                        this[i] = null;
                    }
                }
                if (_changedService != null)
                {
                    _changedService.Dispose();
                }
                _changedService = null;
                if (_shapeDraw != null)
                {
                    _shapeDraw.Dispose();
                }
                _shapeDraw              = null;
                _shapePropertyChanged   = null;
                _shapeBackgroundChanged = null;
            }
        }
        void ChildShape_SelectedChanged(object sender, EventArgs e)
        {
            ShapeDraw shape = _layer.Shape as ShapeDraw;

            if (shape.IsChildSelected != IsSelected)
            {
                IsSelected = shape.IsChildSelected;
            }
        }
Exemple #5
0
        private void InsertShape(Query query, ShapeDraw shape)
        {
            if (m_ShapesToDraw.Count > maxNumberOfQueries)
            {
                return;
            }

            m_ShapesToDraw.Add(query, shape);
        }
Exemple #6
0
        public override void VisitShapeDraw(ShapeDraw shapeDraw)
        {
            VisitShape(shapeDraw);

            foreach (var s in shapeDraw.Childs)
            {
                s.Accept(this);
            }
        }
Exemple #7
0
 public void Update()
 {
     if (ShapeMatchType.World == type)
     {
         if (visualisation == true)
         {
             ShapeDraw.DrawMatch(shapeA, shapeB);
         }
     }
 }
Exemple #8
0
        public new void Add(ShapeBase shape)
        {
            if (shape != null && !Contains(shape))
            {
                shape.Zoom = Zoom;

                if (shape.Index > -1)
                {
                    Insert(shape.Index, shape);
                }
                else
                {
                    if (shape.Type == ShapeType.ShapeDraw)
                    {
                        ShapeDraw tmp = null;
                        if (_shapeDraw == null)
                        {
                            _shapeDraw = shape as ShapeDraw;
                            tmp        = _shapeDraw;
                            foreach (ShapeBase item in _shapeDraw.Childs)
                            {
                                Add(item);
                            }
                        }
                        else
                        {
                            tmp = shape as ShapeDraw;
                            foreach (ShapeBase item in tmp.Childs)
                            {
                                _shapeDraw.AddChildShape(item);
                                Add(item);
                            }
                        }
                    }
                    else
                    {
                        AddEvent(shape);
                        base.Add(shape);
                        if (shape.LayerType == LayerType.Paint)
                        {
                            ShapeDraw.AddChildShape(shape);
                        }
                        _changedService.MarkChanged();
                    }

                    Document_AddRemoveShape(this, new AddRemoveShapeEventArgs(shape, AddRemoveShapeEventArgs.EventType.Add, this.IndexOf(shape)));
                }
            }
        }
Exemple #9
0
 public void Select(ShapeBase shape)
 {
     if (shape != null)
     {
         CancelSelect();
         if (shape.LayerType == LayerType.Paint)
         {
             ShapeDraw.BeginEdit();
             ShapeDraw.IsSelected = true;
             ShapeDraw.EndEdit();
         }
         else
         {
             shape.IsSelected = true;
         }
     }
 }
    static public void DrawFill(ShapeFill shape)
    {
        Vector2  pointInWorld;
        Vector2D pointInWorld2D = Vector2D.Zero();

        foreach (Vector2D point in shape.pointsIn)
        {
            pointInWorld = shape.transform.TransformPoint(point.ToVector2());

            pointInWorld2D.x = pointInWorld.x;
            pointInWorld2D.y = pointInWorld.y;

            if (ShapeObject.PointInShapes(pointInWorld2D) == false)
            {
                ShapeDraw.Draw(pointInWorld, shape.transform);
            }
        }
    }
Exemple #11
0
        public LayerControl GetLayerControl(ShapeBase shape)
        {
            if (shape == null)
            {
                return(null);
            }
            Control container = shape.IsDynamicLayer ? _dynamicContainer : _staticContainer;

            foreach (LayerControl frame in container.Controls)
            {
                if (frame.Shape == null)
                {
                    continue;
                }
                if (frame.Shape.ID == shape.ID)
                {
                    return(frame);
                }
                else if (shape.LayerType == LayerType.Paint &&
                         frame.Shape.LayerType == LayerType.Paint)
                {
                    if (frame.Shape.Type == ShapeType.ShapeDraw)
                    {
                        ShapeDraw sd = frame.Shape as ShapeDraw;
                        foreach (var s in sd.Childs)
                        {
                            if (s.ID == shape.ID)
                            {
                                return(frame);
                            }
                        }
                        return(null);
                    }
                }
            }
            return(null);
        }
    public static void DrawMatch(ShapeObject shapeA, ShapeObject shapeB)
    {
        Vector2   pointInWorld;
        Vector2D  pointInWorld2D = Vector2D.Zero();
        Polygon2D polyInWorld;

        foreach (Vector2D point in shapeA.pointsIn)
        {
            pointInWorld = shapeA.transform.TransformPoint(point.ToVector2());

            pointInWorld2D.x = pointInWorld.x;
            pointInWorld2D.y = pointInWorld.y;

            polyInWorld = shapeB.GetWorldPolygon();

            if (polyInWorld.PointInPoly(pointInWorld2D))
            {
                ShapeDraw.Draw(pointInWorld, shapeA.transform);
            }
        }

        foreach (Vector2D point in shapeB.pointsIn)
        {
            pointInWorld = shapeB.transform.TransformPoint(point.ToVector2());

            pointInWorld2D.x = pointInWorld.x;
            pointInWorld2D.y = pointInWorld.y;

            polyInWorld = shapeA.GetWorldPolygon();

            if (polyInWorld.PointInPoly(pointInWorld2D))
            {
                ShapeDraw.Draw(pointInWorld, shapeB.transform);
            }
        }
    }
Exemple #13
0
        protected override bool DoPaste()
        {
            if (ClipboardService.ContainsImage())
            {
                var img     = ClipboardService.GetImage();
                var imgFile = Constance.LibraryImageDir + Constance.DirectorySeparator + DateTime.Now.Ticks.ToString() + ".jpg";
                IOHelper.SaveImage(img, imgFile);
                innerControl.AddImageLayer(imgFile);
                return(true);
            }

            foreach (var item in items)
            {
                if (item.Layer.Shape.LayerType == LayerType.Paint)
                {
                    LayerControl lc = innerControl.GetLayerControl(item.Shape);

                    if (lc != null || innerControl.IsExistShapeDraw)
                    {
                        ShapeBase pastedShape = item.Shape;
                        pastedShape.ID = KeyGenerator.Shape;
                        pastedShape.Move(Point.Empty);
                        innerControl.AddLayer(pastedShape, ShapeAddMode.Clone);
                    }
                    else
                    {
                        IShapeLayer sl = item.Layer.Copy();
                        if (sl.Shape.Type == ShapeType.ShapeDraw)
                        {
                            ShapeDraw sd = sl.Shape as ShapeDraw;
                            sd.Clear();
                            sd.AddChildShape(item.Shape);
                            //sl.Shape = sd;
                        }
                        sl.Shape.Move(Point.Empty);
                        LayerControl tmlayer = innerControl.NewLayerControl(sl as ShapeLayer, true);
                        innerControl.AddLayer(tmlayer, ShapeAddMode.Clone);
                        tmlayer.Shape.Zoom = item.Shape.Zoom;
                    }
                }
                else
                {
                    //LayerControl layerControl = innerControl.GetLayerControl(item.Shape);

                    //if (layerControl != null)
                    //{
                    //    bool isBackGround = layerControl.Shape.IsBackground;
                    //    ShapeLayer item = layerControl.Layer.Copy();
                    //    item.Shape = item.Shape.Copy();
                    //    item.Shape.Move(Point.Empty);
                    //    if (isBackGround)
                    //    {
                    //        item.Shape.BeginEdit();
                    //        item.Shape.IsBackground = false;
                    //        item.Shape.EndEdit();
                    //    }
                    //    innerControl.AddLayer(innerControl.NewLayerControl(item, true), ShapeAddMode.Clone);
                    //    if(isBackGround)
                    //        item.Shape.IsBackground = isBackGround;
                    //}
                    //else
                    //{
                    bool isBackGround = item.Layer.Shape.IsBackground;
                    if (isBackGround)
                    {
                        item.Layer.Shape.BeginEdit();
                        item.Layer.Shape.IsBackground = false;
                        item.Layer.Shape.EndEdit();
                    }
                    var sl = item.Layer.Copy();
                    sl.Shape.Move(Point.Empty);
                    innerControl.AddLayer(innerControl.NewLayerControl(sl as ShapeLayer, true), ShapeAddMode.Clone);

                    if (isBackGround)
                    {
                        item.Layer.Shape.IsBackground = isBackGround;
                    }
                    //}
                }
            }
            innerControl.ShapeControl.Invalidate();
            return(true);
        }
Exemple #14
0
 public virtual void VisitShapeDraw(ShapeDraw shapeDraw)
 {
 }