Пример #1
0
        public static void GetLocation(Wire wire1, Wire wire2, out PointEx start, out PointEx end)
        {
            var line1 = wire1.Line as ILine;
            var start1 = wire1.Start;
            var end1 = wire1.End;
            var line2 = wire2.Line as ILine;
            var start2 = wire2.Start;
            var end2 = wire2.End;

            start = null;
            end = null;

            if (start1 != null)
            {
                var margin = line1.GetMargin();
                start = new PointEx(margin.Left, margin.Top);
            }

            if (end1 != null)
                end = new PointEx(line1.GetX2(), line1.GetY2());

            if (start2 != null)
            {
                var margin = line2.GetMargin();
                start = new PointEx(margin.Left,  margin.Top);
            }

            if (end2 != null)
                end = new PointEx(line2.GetX2(), line2.GetY2());
        }
Пример #2
0
        private static ILine SecondConnection(IElement root, ILine line, double x, double y, List<Wire> wires)
        {
            var margin = line.GetMargin();

            line.SetX2(x - margin.Left);
            line.SetY2(y - margin.Top);

            string rootUid = root.GetUid();

            bool endIsIO = StringUtil.StartsWith(rootUid, Constants.TagElementInput) ||
                StringUtil.StartsWith(rootUid, Constants.TagElementOutput);

            line.SetEndIO(endIsIO);

            var wire = new Wire(line, null, root);
            wires.Add(wire);

            var lineTag = line.GetTag();
            if (lineTag != null)
            {
                var start = lineTag as IElement;
                if (start != null)
                    line.SetTag(new Wire(line, start, root));
            }

            return null;
        }
Пример #3
0
        private void MoveLine(double dX, double dY, bool snap, Wire wire)
        {
            var line = wire.Line as ILine;
            var start = wire.Start;
            var end = wire.End;

            if (start != null)
            {
                var margin = line.GetMargin();
                double left = margin.Left;
                double top = margin.Top;
                //line.X1 = SnapOffsetX(line.X1 + dX, snap);
                //line.Y1 = SnapOffsetY(line.Y1 + dY, snap);
                double x = SnapOffsetX(left + dX, snap);
                double y = SnapOffsetY(top + dY, snap);

                if (left != x || top != y)
                {
                    line.SetX2(line.GetX2() + (left - x));
                    line.SetY2(line.GetY2() + (top - y));
                    line.SetMargin(new MarginEx(0, x, 0, y));
                }
            }

            if (end != null)
            {
                double left = line.GetX2();
                double top = line.GetY2();
                double x = SnapX(left + dX, snap);
                double y = SnapY(top + dY, snap);
                line.SetX2(x);
                line.SetY2(y);
            }
        }