コード例 #1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="mSite"></param>
 protected GraphLayout(IGraphSite mSite)
 {
     if (mSite == null)
     {
         throw new Exception("No mSite specified in graph layout constructor.");
     }
     ;
     this.mSite = mSite;
     nnodes     = mSite.Shapes.Count;
     nedges     = mSite.Connections.Count;
     CanvasSize = mSite.Size;
     nodes      = mSite.Shapes;
     edges      = mSite.Connections;
     extract    = mSite.Abstract;
 }
コード例 #2
0
 /// <summary>
 /// Adds the shape to an GraphAbstract collection
 /// </summary>
 /// <param name="p"></param>
 internal void Insert(GraphAbstract p)
 {
     Parent = p;
     Parent.Shapes.Add(this);
     Invalidate();
 }
コード例 #3
0
        /// <summary>
        /// Removes itself from an GraphAbstract. The connectors are deleted as part of this deletion process.
        /// </summary>
        protected internal override void Delete()
        {
            Invalidate();

            // throw the connections away
             ArrayList toDelete = new ArrayList();

             // throw the connections away.
             // Action is done in two steps because calling Delete() of a connection manipulates the connector
             // collections. To Prevent an exception the connections are iterated and moved to a deletion list first.
             foreach (Connector c in Connectors)
             {
                 foreach (Connection cn in c.Connections)
                 {
                     toDelete.Add(cn);
                 }
             }

             foreach( Connection cn in toDelete )
             {
                 cn.Delete();
             }
            if (Parent.Shapes.Contains(this))
                Parent.Shapes.Remove(this);

            Parent = null;

            Invalidate();
        }
コード例 #4
0
 /// <summary>
 /// Adds the shape to an GraphAbstract collection
 /// </summary>
 /// <param name="p"></param>
 internal void Insert(GraphAbstract p)
 {
     Site.Abstract.Shapes.Add(this);
     Invalidate();
 }
コード例 #5
0
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <remarks>
        /// Notice the double buffering directives at the end
        /// </remarks>
        public GraphControl()
        {
            //Make sure the control repaints as it is resized
            SetStyle(ControlStyles.ResizeRedraw, true);
            //allow dragdrop
            this.AllowDrop=true;
            //instantiate the layout factory
            layoutFactory=new LayoutFactory(this);

            //instanciating an attached extract to the canvas
            extract = new GraphAbstract();
            extract.Site=this;

            //init the transmission timer
            transmissionTimer.Interval = AutomataPulse;
            transmissionTimer.Tick += new EventHandler(OnTransmissionTimer); //attach of the handler

            //enable double buffering of graphics
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            //instantiate the library collection
            mLibraries = new GraphObjectsLibraryCollection();

            this.KeyDown+=new KeyEventHandler(OnKeyDown);
            this.KeyPress+=new KeyPressEventHandler(OnKeyPress);

            AddBaseMenu();
            bag = new PropertyBag();
            AddProperties();

            this.AutoScroll=true;
            this.HScroll=true;
            this.VScroll=true;

            try
            {
                Assembly ass= Assembly.GetExecutingAssembly();
                MouseCursors.Add = new Cursor(  ass.GetManifestResourceStream("Netron.GraphLib.Resources.Add.cur"));
                MouseCursors.Cross = new Cursor(    ass.GetManifestResourceStream("Netron.GraphLib.Resources.Cross.cur"));
                MouseCursors.Grip =  new Cursor(   ass.GetManifestResourceStream("Netron.GraphLib.Resources.Grip.cur"));
                MouseCursors.Move =  new Cursor(  ass.GetManifestResourceStream("Netron.GraphLib.Resources.Move.cur"));
                MouseCursors.Select =  new Cursor(  ass.GetManifestResourceStream("Netron.GraphLib.Resources.Select.cur"));
            }
            catch(Exception exc)
            {
                Trace.WriteLine(exc.Message);
            }
        }
コード例 #6
0
        /// <summary>
        /// Creates a blank new canvas
        /// </summary>
        public void New()
        {
            //save before new?

            this.extract=new GraphAbstract();
            this.mFileName=null;
        }