//- 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 PatchWindow(AudimatWindow _audimatWindow) { audimatWindow = _audimatWindow; canvas = new PatchCanvas(); canvas.Size = new Size(this.ClientSize.Width, this.ClientSize.Height); canvas.Location = new Point(0, 0); canvas.BackColor = Color.LawnGreen; this.Controls.Add(canvas); this.ShowInTaskbar = false; }
//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; }