Ejemplo n.º 1
0
        public static void ChangeShape(IGraphScene <IVisual, IVisualEdge> scene, IVisual visual, IShape newShape)
        {
            if (visual == null || (visual is IVisualEdge))
            {
                return;
            }

            if (newShape != null)
            {
                newShape          = (IShape)newShape.Clone();
                newShape.Location = visual.Shape.Location;
                newShape.DataSize = visual.Shape.DataSize;
                var changeShape =
                    new ActionCommand <IVisual, IShape> (
                        visual,
                        newShape,
                        delegate(IVisual target, IShape shape) { target.Shape = shape; });
                scene.Requests.Add(changeShape);
                if (visual.Shape is VectorShape || newShape is VectorShape)
                {
                    scene.Requests.Add(new LayoutCommand <IVisual> (visual, LayoutActionType.Justify));
                }
                foreach (var edge in scene.Twig(visual))
                {
                    scene.Requests.Add(new LayoutCommand <IVisual> (edge, LayoutActionType.Justify));
                }
            }
        }
Ejemplo n.º 2
0
 public void AddShape(IShape selShape)
 {
     if (selShape != null)
     {
         m_ShapeList.Add(selShape.Clone());
     }
 }
        /// <summary>
        /// Changes the color by some amount (default: ± 10).
        /// </summary>
        /// <param name="shape">The shape to change color of</param>
        /// <param name="delta">The maximum amount to change the value</param>
        /// <returns>The changed shape</returns>
        protected IShape MutateColor(IShape shape, byte delta = 10)
        {
            var p = shape.Clone() as Polygon;

            p.Alpha = p.Alpha.Change(delta, this.rand).Clip(0, 255);
            p.Red   = p.Red.Change(delta, this.rand).Clip(0, 255);
            p.Green = p.Green.Change(delta, this.rand).Clip(0, 255);
            p.Blue  = p.Blue.Change(delta, this.rand).Clip(0, 255);
            return(p);
        }
Ejemplo n.º 4
0
        //virtual protected IShape CreateDrawingShape(PointF point)
        //{
        //    Collection<PointF[]> mcolPoint = new Collection<PointF[]>();

        //    int Counter = 1;

        //    for (int i = 0; i < _points.Count; i++)
        //    {
        //        if (_points[i] != point)
        //        {
        //            Counter++;
        //        }
        //        else
        //        {
        //            PointF[] p1 = new PointF[Counter - 1];
        //            for (int j = 0; j < Counter - 1; j++)
        //            {
        //                p1.SetValue(_points[j], j);
        //            }
        //            mcolPoint.Add(p1);

        //        }
        //    }
        //    _shape.Geometric.AddLines(ToPointF(mcolPoint[0]));
        //    IShape shape = _shape.Clone() as IShape;
        //    shape.Selected = true;

        //    return shape;
        //}

        /// <summary>
        /// Creates a shape relative to actual points.
        /// </summary>
        /// <returns>New Shape.</returns>
        virtual protected IShape CreateDrawingShape(PointF point)
        {
            if (_points.Count == 0)
            {
                //Ellipse el = new Ellipse();
                //el.Center = point;
                //el.Dimension = new SizeF(2, 2);
                ////el.Dimension.Width = 2;
                ////el.Dimension.Height = 2;
                //_shape = new Sbn.AdvancedControls.Imaging.SbnPaint.Ellipse(el);

                // return null;
                _points.Add(point);
                _points.Add(new PointF(point.X + 1, point.Y + 1));
            }

            _shape = new CustomShape();   //added by rm


            Pen pen = new Pen(Color.Black, 2);

            pen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
            pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            _shape.Appearance.ActivePen = pen;
            if (_points.Count == 2)
            {
                _shape.Geometric.AddLines(ToPointF(_points));

//                Line ln = new Line(_points[0], _points[1]);
//                ln.Appearance.ActivePen = pen;

//                _shape = new Sbn.AdvancedControls.Imaging.SbnPaint.Line(ln); cmd by ghmhm
            }
            else
            if (_points.Count != 0)
            {
                _shape.Geometric.AddLines(ToPointF(_points));
            }
            else
            {
                return(null);
            }

            IShape shape = _shape.Clone() as IShape;

            pen.Dispose();

            // shape.Selected = true;  //Commented by rm
            shape.Selected = false;   //added by rm
            shape.Locked   = true;    //added by rm

            return(shape);
        }
Ejemplo n.º 5
0
 public Ghost(IShape shape)
 {
     this._referenceShape = shape;
     this._memoryShape    = (shape.Clone() as IShape);
     this._shape          = (this._memoryShape.Clone() as IShape);
     base.Geometric.Reset();
     base.Geometric.AddPath(shape.Geometric, false);
     this.Selected = false;
     this.Visible  = false;
     base.Transformer.MirrorHorizontalOccurred += new MirrorHorizontalHandler(this.Transformer_MirrorHorizontalOccurred);
     base.Transformer.MirrorVerticalOccurred   += new MirrorVerticalHandler(this.Transformer_MirrorVerticalOccurred);
     base.Appearance = new GhostAppearance();
 }
Ejemplo n.º 6
0
Archivo: Ghost.cs Proyecto: nistck/Jx
        /// <summary>
        /// Mouse down function.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">MouseEventArgs.</param>
        public override void MouseDown(IDocument document, System.Windows.Forms.MouseEventArgs e)
        {
            _shape = _memoryShape.Clone() as IShape;

            Geometric.Reset();
            Geometric.AddPath(_shape.Geometric, false);

            Visible  = false;
            Selected = false;

            InitializeVersors(_shape.HitTest(e.Location));

            base.MouseDown(document, e);
        }
Ejemplo n.º 7
0
Archivo: Ghost.cs Proyecto: nistck/Jx
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="ghost">Shape to copy.</param>
        public Ghost(Ghost ghost) : base(ghost)
        {
            _referenceShape = ghost.Shape;
            _memoryShape    = ghost.Shape.Clone() as IShape;
            _shape          = _memoryShape.Clone() as IShape;

            Geometric.Reset();
            Geometric.AddPath(ghost.Shape.Geometric, false);

            ghost.Selected = false;
            ghost.Visible  = false;

            this.Transformer.MirrorHorizontalOccurred += new MirrorHorizontalHandler(Transformer_MirrorHorizontalOccurred);
            this.Transformer.MirrorVerticalOccurred   += new MirrorVerticalHandler(Transformer_MirrorVerticalOccurred);

            this.Appearance = new GhostAppearance();
        }
        /// <summary>
        /// Mutate the coordinates position (all at the same time).
        /// default: ± 10 pixels.
        /// </summary>
        /// <param name="shape">The shape to change color of</param>
        /// <param name="delta">The maximum amount to change the value</param>
        /// <returns>The changed shape</returns>
        protected IShape MutatePosition(IShape shape, int delta = 100)
        {
            var polygon = shape.Clone() as Polygon;

            do
            {
                for (int i = 0; i < polygon.Coordinates.Count; i++)
                {
                    var coord = polygon.Coordinates[i];
                    var int1  = coord.Item1.Change(delta, this.rand).Clip(0, CanvasWidth);
                    var int2  = coord.Item2.Change(delta, this.rand).Clip(0, CanvasHeight);
                    polygon.Coordinates[i] = new Tuple <int, int>(int1, int2);
                }
            }while(!(polygon.IsConvex()));

            return(polygon);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a shape relative to actual points.
        /// </summary>
        /// <returns>New Shape.</returns>
        virtual protected IShape CreateDrawingShape()
        {
            if (_points.Count <= 1)
            {
                return(null);
            }

            if (_points.Count == 2)
            {
                _shape = new Jx.Drawing.Base.Line(_points[0], _points[1]);
            }
            else
            {
                _shape.Geometric.AddLines(ToPointF(_points));
            }

            IShape shape = _shape.Clone() as IShape;

            shape.Selected = true;

            return(shape);
        }
Ejemplo n.º 10
0
        public void TestClone(IShape shape)
        {
            IShape clone = (IShape)shape.Clone();

            TestShape(clone, shape.Location, shape.Size);
        }