private List <IssoBinding> FindBindings(ComponentNode node, IssoBinding Except) { List <IssoBinding> result = new List <IssoBinding>(); for (int i = 0; i < CompsList.Count; i++) { if ((Except != CompsList[i]) && (CompsList[i].CompType == ComponentTypes.ctBinding)) { IssoBinding b = (IssoBinding)CompsList[i]; if ((node == b.Source) || (node == b.Target)) { result.Add(b); } } } return(result); }
internal bool PreprocessBindingChange(IssoBinding b, float newDX, float newDY) { // Фактически модель - это система точек на плоскости // Между некоторыми из них установлены связи в виде размеров // Когда меняется значение отдельного размера или добавляется новый, // требуется преобразовать координаты точек (сдвинуть линейно по вертикали или горизонтали) // Точки, которые не связаны никакими ограничениями, из рассмотрения исключаются List <IssoBinding> bin = Bindings; List <ComponentNode> nodes = ModelNodes; int nodecnt = ModelNodes.Count; ndX = new float[nodecnt, nodecnt]; ndY = new float[nodecnt, nodecnt]; for (int y = 0; y < nodecnt; y++) { for (int x = 0; x < nodecnt; x++) { ndX[x, y] = float.MaxValue; ndY[x, y] = float.MaxValue; if (x == y) { ndX[x, y] = 0; ndY[x, y] = 0; } } } for (int i = 0; i < bin.Count; i++) { // Пропускаем устанавливаемую связь if (b == bin[i]) { continue; } ComponentNode nd1 = bin[i].Source; ComponentNode nd2 = bin[i].Target; int nd1i = nodes.IndexOf(nd1); int nd2i = nodes.IndexOf(nd2); switch (bin[i].Type) { case IssoBindingType.Horizontal: { ndX[nd1i, nd2i] = Math.Sign(nd2.Location.X - nd1.Location.X) * bin[i].Value; ndX[nd2i, nd1i] = -ndX[nd1i, nd2i]; break; } case IssoBindingType.Vertical: { ndY[nd1i, nd2i] = Math.Sign(nd2.Location.Y - nd1.Location.Y) * bin[i].Value; ndY[nd2i, nd1i] = -ndY[nd1i, nd2i]; break; } } } // Теперь пробуем изменить расстояние между src и tgt if (LocationFixed(b.Type, nodes.IndexOf(b.Source), nodes.IndexOf(b.Target), new List <int>())) { return(false); } else { RecoursiveMove(nodes, b.Source, b.Target, newDX, newDY); return(true); } }