コード例 #1
0
        /// <summary>
        /// Adds a box to the desktop
        /// </summary>
        /// <param name="box">Box to be added</param>
        /// <returns>BoxNode that was created</returns>
        public BoxNode AddBox(IBoxModule box)
        {
            //Adapt();
            BoxNode boxNode = new BoxNode(this, box, SvgManager, view, ResManager);
            boxNode.X = view.GetPosition(box).X;
            boxNode.Y = view.GetPosition(box).Y;

            //adding the box
            Nodes.Add(boxNode);
            return boxNode;
        }
コード例 #2
0
        ///<summary>
        ///Redraws all shapes and connections according to a new state in
        ///the view object
        ///</summary>
        ///<remarks>
        ///Dont know if the control will remember previous shapes and connections
        ///and ask for the changed or write the entire structure over again...
        ///</remarks>
        public void Adapt()
        {
            this.Hide();
            Nodes.Clear();
            selectedBoxes.Clear();

            //We have to remove the handler because it would create a connection
            //that is already there
            OnNewConnection -= new NewConnection(FerdaDesktop_OnNewConnection);

            //adding the boxes on the desktop
            foreach ( IBoxModule box in view.Boxes)
            {
                BoxNode boxNode = new BoxNode(this, box, SvgManager, view, ResManager);
                boxNode.X = view.GetPosition(box).X;
                boxNode.Y = view.GetPosition(box).Y;

                Nodes.Add(boxNode);
            }

            //adding the connections on the desktop
            foreach (ProjectManager.Connection con in view.Connections)
            {
                //finding the from and to connectors
                Connector from = FromConnector(con.FromBox);
                Connector to = ToConnector(con.ToBox, con.ToSocket);

                //adding the connector
                AddEdge(from, to);
            }
            this.Show();

            OnNewConnection += new NewConnection(FerdaDesktop_OnNewConnection);
        }