예제 #1
0
        public void Move(ImmutablePoint p)
        {
            double x  = _itemController.Snap(p.X, _state.Options.SnapSize);
            double y  = _itemController.Snap(p.Y, _state.Options.SnapSize);
            double x2 = _blockHelper.GetX2(TempLine);
            double y2 = _blockHelper.GetY2(TempLine);

            if (Math.Round(x, 1) != Math.Round(x2, 1) ||
                Math.Round(y, 1) != Math.Round(y2, 1))
            {
                _blockHelper.SetX2(TempLine, x);
                _blockHelper.SetY2(TempLine, y);
                _blockHelper.SetLeft(TempEndEllipse, x - 4.0);
                _blockHelper.SetTop(TempEndEllipse, y - 4.0);
            }
        }
예제 #2
0
        public void MoveDeltaEnd(double dx, double dy, XLine line)
        {
            double oldx = _blockHelper.GetX2(line);
            double oldy = _blockHelper.GetY2(line);

            _blockHelper.SetX2(line, oldx + dx);
            _blockHelper.SetY2(line, oldy + dy);
        }
예제 #3
0
 public ItemLine Serialize(XLine line)
 {
     return(new ItemLine()
     {
         Id = line.Id,
         X1 = _blockHelper.GetX1(line),
         Y1 = _blockHelper.GetY1(line),
         X2 = _blockHelper.GetX2(line),
         Y2 = _blockHelper.GetY2(line),
         Stroke = _blockHelper.GetStroke(line),
         StartId = line.Start == null ? -1 : line.Start.Id,
         EndId = line.End == null ? -1 : line.End.Id
     });
 }
예제 #4
0
파일: Plugins.cs 프로젝트: 15831944/Sheet
        private void InvertSelectedLineStart(ISheet contentSheet, IBlock contentBlock, IBlock selectedBlock, SheetOptions options)
        {
            // add for horizontal or vertical line start ellipse and shorten line
            if (_blockController.HaveSelected(selectedBlock) && selectedBlock.Lines != null && selectedBlock.Lines.Count > 0)
            {
                foreach (var line in selectedBlock.Lines)
                {
                    double x1    = _blockHelper.GetX1(line);
                    double y1    = _blockHelper.GetY1(line);
                    double x2    = _blockHelper.GetX2(line);
                    double y2    = _blockHelper.GetY2(line);
                    bool   sameX = Math.Round(x1, 1) == Math.Round(x2, 1);
                    bool   sameY = Math.Round(y1, 1) == Math.Round(y2, 1);

                    // vertical line
                    if (sameX && !sameY)
                    {
                        // X1, Y1 is start position
                        if (y1 < y2)
                        {
                            AddInvertedLineEllipse(contentSheet, contentBlock, selectedBlock, options, x1 - invertedEllipseWidth / 2.0, y1, invertedEllipseWidth, invertedEllipseHeight);
                            _blockHelper.SetY1(line, y1 + invertedEllipseHeight);
                        }
                        // X2, Y2 is start position
                        else
                        {
                            AddInvertedLineEllipse(contentSheet, contentBlock, selectedBlock, options, x2 - invertedEllipseWidth / 2.0, y2, invertedEllipseWidth, invertedEllipseHeight);
                            _blockHelper.SetY2(line, y2 + invertedEllipseHeight);
                        }
                    }
                    // horizontal line
                    else if (!sameX && sameY)
                    {
                        // X1, Y1 is start position
                        if (x1 < x2)
                        {
                            AddInvertedLineEllipse(contentSheet, contentBlock, selectedBlock, options, x1, y1 - invertedEllipseHeight / 2.0, invertedEllipseWidth, invertedEllipseHeight);
                            _blockHelper.SetX1(line, x1 + invertedEllipseWidth);
                        }
                        // X2, Y2 is start position
                        else
                        {
                            AddInvertedLineEllipse(contentSheet, contentBlock, selectedBlock, options, x2, y2 - invertedEllipseHeight / 2.0, invertedEllipseWidth, invertedEllipseHeight);
                            _blockHelper.SetX2(line, x2 + invertedEllipseWidth);
                        }
                    }
                }
            }
        }