Exemplo n.º 1
0
//- persistance ---------------------------------------------------------------

        //get source & dest box nums from XML file and get the matching boxes from the canvas
        //then get the panel nums from XML and get the matching panels from the boxes
        //having the source & dest panels. create a new line between them
        //this will create a connection in the backing model, call loadFromXML() on it with XML node to set its properties
        public static PatchLine loadFromXML(PatchCanvas canvas, XmlNode lineNode)
        {
            PatchLine line = null;

            try
            {
                int srcBoxNum    = Convert.ToInt32(lineNode.Attributes["sourcebox"].Value);
                int srcPanelNum  = Convert.ToInt32(lineNode.Attributes["sourcepanel"].Value);
                int destBoxNum   = Convert.ToInt32(lineNode.Attributes["destbox"].Value);
                int destPanelNum = Convert.ToInt32(lineNode.Attributes["destpanel"].Value);

                PatchBox sourceBox = canvas.findPatchBox(srcBoxNum);
                PatchBox destBox   = canvas.findPatchBox(destBoxNum);
                if (sourceBox != null && destBox != null)
                {
                    PatchPanel sourcePanel = sourceBox.findPatchPanel(srcPanelNum);
                    PatchPanel destPanel   = destBox.findPatchPanel(destPanelNum);

                    if (sourcePanel != null && destPanel != null)
                    {
                        line = new PatchLine(canvas, sourcePanel, destPanel);
                    }
                }
            }
            catch (Exception e)
            {
                throw new PatchLoadException();
            }

            return(line);
        }
Exemplo n.º 2
0
 public virtual void disconnectLine(PatchLine line)
 {
     connectors.Remove(line);
 }
Exemplo n.º 3
0
 public virtual void connectLine(PatchLine line)
 {
     connectors.Add(line);
 }