Exemple #1
0
        /// <summary>
        /// Returns the adjacent shapes on the basis of a structuring IGraph, usually
        /// what is being returned by Prim's algorithm.
        /// This is equal to the adjacent nodes if the graph is a tree.
        /// Whether a connected nodes is really a 'child' is the sense of being positioned
        /// on a lower level cannot be decided here but belongs to the layout
        /// </summary>
        /// <param name="structure"></param>
        /// <param name="shape"></param>
        /// <returns>A ShapeCollection of shapes</returns>
        private ShapeCollection AdjacentNodes(IGraph structure, Shape shape)
        {
            try
            {
                mSite.OutputInfo("Adjacents of '" + shape.Text + "':");
                int     index = (int)shape.Tag;
                IVertex vertex;
                //TODO: take direction into account
                IEnumerator     numer  = structure.GetVertex(index).Successors.GetEnumerator();
                ShapeCollection shapes = new ShapeCollection();
                while (numer.MoveNext())
                {
                    vertex = numer.Current as IVertex;
                    shapes.Add(nodes[vertex.Number]);
                    mSite.OutputInfo("\t - '" + nodes[vertex.Number].Text + "'");
                }
                numer = structure.GetVertex(index).Predecessors.GetEnumerator();
                while (numer.MoveNext())
                {
                    vertex = numer.Current as IVertex;
                    shapes.Add(nodes[vertex.Number]);
                    mSite.OutputInfo("\t - '" + nodes[vertex.Number].Text + "'");
                }


                return(shapes);
            }
            catch
            {
                //don't return null, make the collection just empty
                return(new ShapeCollection());
            }
        }
Exemple #2
0
        /// <summary>
        /// Inserts a new object into the plex.
        /// </summary>
        /// <param name="so">the object to insert</param>
        /// <remarks>Note that you can add only one shape at a time.
        /// </remarks>
        internal protected void Insert(Shape so)
        {
            //so.Insert(this);
            so.Site = Site;
            mShapes.Add(so);
            so.SetLayer(mCurrentLayer.Name);

            so.AddProperties();

            Site.RaiseOnShapeAdded(so);
        }
Exemple #3
0
        /// <summary>
        /// return the shapes of layer
        /// </summary>
        /// <param name="layerName"></param>
        /// <returns></returns>
        public ShapeCollection ShapesOfLayer(string layerName)
        {
            ShapeCollection shapes = new ShapeCollection();
            GraphLayer      layer  = Layers[layerName];

            if (layer != null)
            {
                foreach (Shape shape in Shapes)
                {
                    if (shape.Layer == layer)
                    {
                        shapes.Add(shape);
                    }
                }
            }
            return(shapes);
        }
        /// <summary>
        /// Implements the copy function to the clipboard
        /// </summary>
        /// <remarks>
        /// This doesn't work, bug in Clipboard object, hopefully fixed in Net v2 
        ///</remarks>
        public void Copy()
        {
            ShapeCollection ar = new ShapeCollection();
            foreach(Shape so in extract.Shapes)
            {
                if(so.IsSelected)
                {
                    ar.Add(so);
                }
            }
            if(ar.Count>0)
            {

                DataObject blurb = new DataObject(format.Name,extract);
                Clipboard.SetDataObject(blurb);
            }
        }
Exemple #5
0
 public virtual ShapeCollection GetChildShapes()
 {
     ShapeCollection sc = new ShapeCollection();
     foreach (Connector cr in this.Connectors) {
         foreach (Connection cn in cr.Connections) {
             sc.Add(cn.From == cr ? cn.To.BelongsTo : cn.From.BelongsTo);
         }
     }
     return sc;
 }