//- 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 virtual PatchPanel loadFromXML(PatchBox box, XmlNode panelNode) { PatchPanel panel = new PatchPanel(box); panel.loadAttributesFromXML(panelNode); return(panel); }
//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); }
public void connectDestJack(PatchPanel _destPanel) { destPanel = _destPanel; destEnd = destPanel.ConnectionPoint; destPanel.connectLine(this); //connect line & dest panel in view connector = srcPanel.makeConnection(destPanel); //connect panels in model, get model connector if (connector != null) { connector.setLine(this); //and set this as connector's view } }
//for reloading existing connections from a stored patch public PatchLine(PatchCanvas _canvas, PatchPanel srcPanel, PatchPanel destPanel) { canvas = _canvas; connectSourceJack(srcPanel); connectDestJack(destPanel); //default appearance lineColor = Color.Black; selectedColor = Color.Red; lineWidth = 2.0f; path = new GraphicsPath(); updatePath(); isSelected = false; }
public void disconnect() { if (srcPanel != null) { srcPanel.breakConnection(destPanel); //disconnect panels in model srcPanel.disconnectLine(this); srcPanel = null; } if (destPanel != null) { destPanel.disconnectLine(this); destPanel = null; //disconnect line from both panels in view } path = null; }
//called on source panel when two panels are disconnected, so matching connection can be ended in the backing model public virtual void breakConnection(PatchPanel destPanel) { }
//called on source panel when a patch line connects two panels, so matching connection can be made in the backing model public virtual iPatchConnector makeConnection(PatchPanel destPanel) { return(null); }
//- connections --------------------------------------------------------------- public void connectSourceJack(PatchPanel _srcPanel) { srcPanel = _srcPanel; srcEnd = srcPanel.ConnectionPoint; srcPanel.connectLine(this); //connect line & source panel in view }