public virtual PatchPanel loadFromXML(PatchBox box, XmlNode panelNode) { PatchPanel panel = new PatchPanel(box); panel.loadAttributesFromXML(panelNode); return(panel); }
//- 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); }
public PatchPanel(PatchBox box) { panelType = "PatchPanel"; panelNum = ++panelCount; patchbox = box; updateFrame(20, patchbox.frame.Width); connectors = new List <PatchLine>(); connType = CONNECTIONTYPE.NEITHER; }
//loading public static PatchPanel loadFromXML(PatchBox box, XmlNode panelNode) { PatchPanel panel = null; String panelName = panelNode.Attributes["paneltype"].Value; PatchPanelLoader loader = panelTypeList[panelName]; if (loader != null) { panel = loader.loadFromXML(box, panelNode); } return(panel); }