示例#1
0
        private void MoveAllLine(BaseComponentUI elementUi)
        {
            var oldPosition  = elementUi.oldPosition;
            var newPosition  = new Point(elementUi.Margin.Left, elementUi.Margin.Top);
            var truePosition = new Point(oldPosition.X - newPosition.X, oldPosition.Y - newPosition.Y);
            ViewModelComponentLine bufLine;
            var element = _elements.SingleOrDefault(e => e.Id == elementUi.ID);

            if (element == null)
            {
                return;
            }

            foreach (var pin in element.GetElementModel().GetAllPins())
            {
                foreach (var coPin in pin.GetAllCoWorker())
                {
                    if (FindElementId(coPin.GetParentId()).Name == ETypeOfElement.Line)
                    {
                        bufLine = (ViewModelComponentLine)FindViewModelId(coPin.GetParentId());
                        MoveLine(bufLine, truePosition, elementUi);
                    }
                }
            }
        }
示例#2
0
        private void MoveLine(ViewModelComponentLine bufLine, Point truePosition, BaseComponentUI element)
        {
            var bufPointPin0 = bufLine.FirstPin;
            var bufPointPin1 = bufLine.LastPin;

            if (element.ID == bufLine.FirstPin.IdParent)
            {
                bufPointPin0.X = bufLine.FirstPin.X - truePosition.X;
                bufPointPin0.Y = bufLine.FirstPin.Y - truePosition.Y;
                bufPointPin1.X = bufLine.LastPin.X;
                bufPointPin1.Y = bufLine.LastPin.Y;
            }
            else
            {
                bufPointPin0.X = bufLine.FirstPin.X;
                bufPointPin0.Y = bufLine.FirstPin.Y;
                bufPointPin1.X = bufLine.LastPin.X - truePosition.X;
                bufPointPin1.Y = bufLine.LastPin.Y - truePosition.Y;
            }

            bufLine.ReBuild(bufPointPin0, bufPointPin1);
        }