/// <summary> /// generates one item (parcial cedent) to XML string /// </summary> /// <param name="box">box of parcial cedent</param> /// <param name="rCFCedent">record with CF cedent</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_CF_cedent rCFCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); // setting attribute "sub_cedent_cnt" (count of parcial cedents) rCFCedent.sub_cedent_cnt = SubCedents.Length; // adding CF cedent to XML if (rCFCedent.sub_cedent_cnt > 0) { resultStr = rCFCedent.ToXML(getOneCedentXML(SubCedents)); } return(resultStr); }
/// <summary> /// generates one cedent to XML string /// </summary> /// <param name="box">cedent box</param> /// <param name="rKLCedent">cedent record</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_KL_cedent rKLCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); rKLCedent.sub_cedent_cnt = SubCedents.Length; // adding KL cedent to XML if (rKLCedent.sub_cedent_cnt > 0) { resultStr = rKLCedent.ToXML(getOneCedentXML(SubCedents)); } return(resultStr); }
/// <summary> /// Gets boxes to which is connected box <paramref name="box"/>. /// </summary> /// <returns>An IBoxModule array of boxes to which is connected box /// <paramref name="box"/>.</returns> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <seealso cref="M:Ferda.ProjectManager.Archive.ConnectedTo(Ferda.ModulesManager.IBoxModule)"/> public IBoxModule[] ConnectionsFrom(IBoxModule box) { List<IBoxModule> result = new List<IBoxModule>(); foreach (SocketInfo socket in box.Sockets) { foreach (IBoxModule otherBox in box.GetConnections(socket.name)) { if (!result.Contains(otherBox)) result.Add(otherBox); } } IBoxModule[] resultArray = result.ToArray(); Array.Sort<IBoxModule>(resultArray); return resultArray; }
/// <summary> /// Removes box from archive. /// </summary> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <seealso cref="M:Ferda.ProjectManager.Archive.Add(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="P:Ferda.ProjectManager.Archive.Boxes"/> public void Remove(IBoxModule box) { foreach(IBoxModule otherBox in box.ConnectedTo()) { foreach(SocketInfo info in otherBox.Sockets) { foreach(IBoxModule thirdBox in otherBox.GetConnections(info.name)) { if(thirdBox == box) { otherBox.RemoveConnection(info.name,box); break; } } } } foreach(SocketInfo info in box.Sockets) { foreach(IBoxModule otherBox in box.GetConnections(info.name)) { box.RemoveConnection(info.name, otherBox); } } foreach(View view in views) { if(view.ContainsBox(box)) view.Remove(box); } if(boxes.Remove(box)) { removeBoxCategories(box); } boxesByProjectIdentifier.Remove(box.ProjectIdentifier); box.destroy(); }
/// <summary> /// generates one cedent to XML string /// </summary> /// <param name="box">cedent box</param> /// <param name="rKLCedent">cedent record</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_KL_cedent rKLCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); rKLCedent.sub_cedent_cnt = SubCedents.Length; // adding KL cedent to XML if (rKLCedent.sub_cedent_cnt > 0) resultStr = rKLCedent.ToXML(getOneCedentXML(SubCedents)); return resultStr; }
/// <summary> /// generates one item (parcial cedent) to XML string /// </summary> /// <param name="box">box of parcial cedent</param> /// <param name="rCFCedent">record with CF cedent</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_CF_cedent rCFCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); // setting attribute "sub_cedent_cnt" (count of parcial cedents) rCFCedent.sub_cedent_cnt = SubCedents.Length; // adding CF cedent to XML if (rCFCedent.sub_cedent_cnt > 0) resultStr = rCFCedent.ToXML(getOneCedentXML(SubCedents)); return resultStr; }
/// <summary> /// Recursively set topology from top of boxes transitively connected to box /// <paramref name="lastBox"/> /// </summary> /// <param name="lastBox">Box most on right to which topology from right will be set</param> /// <param name="temporaryFromTop">Topology from top</param> /// <param name="temporaryMaxTop">Maximums of topology from top in topologies from left</param> /// <param name="component">Component of boxes</param> /// <param name="topology">Topology from left</param> private void recurseTopsDown(IBoxModule lastBox, Dictionary<IBoxModule, int> temporaryFromTop, Dictionary<int, int> temporaryMaxTop, List<IBoxModule> component, Dictionary<IBoxModule, int> topology) { if (!temporaryFromTop.ContainsKey(lastBox)) { int fromLeft = topology[lastBox]; int top; if (!temporaryMaxTop.ContainsKey(fromLeft)) { temporaryMaxTop[fromLeft] = 0; top = 0; } else { top = temporaryMaxTop[fromLeft] + 1; temporaryMaxTop[fromLeft] = top; } temporaryFromTop[lastBox] = top; foreach (SocketInfo socket in lastBox.Sockets) { foreach (IBoxModule box in lastBox.GetConnections(socket.name)) { if (component.Contains(box)) recurseTopsDown(box, temporaryFromTop, temporaryMaxTop, component, topology); } } } }
/// <summary> /// Unpacks all layers of boxes connected to <paramref name="socketName"/> /// of box <paramref name="box"/>. /// </summary> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representing box from view</param> /// <param name="socketName">A string representing name /// of socket of box <paramref name="box"/></param> /// <seealso cref="M:Ferda.ProjectManager.View.PackSocket(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.PackAllSockets(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="M:Ferda.ProjectManager.View.IsAnyBoxPackedIn(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackOneLayer(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackOneLayerAllSockets(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackAllLayersAllSockets(Ferda.ModulesManager.IBoxModule)"/> public void UnpackAllLayers(IBoxModule box, string socketName) { foreach(IBoxModule otherBox in box.GetConnections(socketName)) { if(!this.ContainsBox(otherBox)) { this.Add(otherBox); UnpackAllLayersAllSockets(otherBox); } } }
/// <summary> /// Looks if is some box is packed in socket <paramref name="socketName"/> /// of box <paramref name="box"/>. /// </summary> /// <remarks> /// Looks if /// <see cref="M:Ferda.ProjectManager.View.UnpackOneLayer(Ferda.ModulesManager.IBoxModule,System.String)"/> /// will unpack something when called with box <paramref name="box"/> /// and socket <paramref name="socketName"/>. /// </remarks> /// <returns>True if some box is packed in socket <paramref name="socketName"/> /// of box <paramref name="box"/></returns> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representing box from view</param> /// <param name="socketName">A string representing name /// of socket of box <paramref name="box"/></param> /// <seealso cref="M:Ferda.ProjectManager.View.PackSocket(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.PackAllSockets(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackOneLayer(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackOneLayerAllSockets(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackAllLayers(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.UnpackAllLayersAllSockets(Ferda.ModulesManager.IBoxModule)"/> public bool IsAnyBoxPackedIn(IBoxModule box, string socketName) { foreach(IBoxModule otherBox in box.GetConnections(socketName)) { if(!this.ContainsBox(otherBox)) { return true; } } return false; }
/// <summary> /// Recursive method for packing of a socket /// </summary> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representing box from view which socket has to be packed</param> /// <param name="socketName">A string representing name /// of socket of box <paramref name="box"/></param> /// <param name="firstUse">If this method was called first time or in recursive propagation</param> /// <seealso cref="M:Ferda.ProjectManager.View.PackAllSockets(Ferda.ModulesManager.IBoxModule,System.Boolean)"/> /// <seealso cref="M:Ferda.ProjectManager.View.PackSocket(Ferda.ModulesManager.IBoxModule,System.String)"/> /// <seealso cref="M:Ferda.ProjectManager.View.PackAllSockets(Ferda.ModulesManager.IBoxModule)"/> private void PackSocket(IBoxModule box, string socketName, bool firstUse) { foreach(IBoxModule otherBox in box.GetConnections(socketName)) { if(this.ContainsBox(otherBox)) { bool noOther = true; if(!firstUse) { foreach(IBoxModule secBox in otherBox.ConnectedTo()) { if(this.ContainsBox(secBox) && secBox != box && secBox != otherBox) { noOther=false; break; } } } if(noOther) { this.Remove(otherBox); this.PackAllSockets(otherBox,false); } } } }