Ejemplo n.º 1
0
        public void MoveDeltaStart(double dx, double dy, XLine line)
        {
            double oldx = _blockHelper.GetX1(line);
            double oldy = _blockHelper.GetY1(line);

            _blockHelper.SetX1(line, oldx + dx);
            _blockHelper.SetY1(line, oldy + dy);
        }
Ejemplo n.º 2
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
     });
 }
Ejemplo n.º 3
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void Finish(XPoint end)
        {
            double x1 = _blockHelper.GetX1(TempLine);
            double y1 = _blockHelper.GetY1(TempLine);
            double x2 = _blockHelper.GetX2(TempLine);
            double y2 = _blockHelper.GetY2(TempLine);

            if (Math.Round(x1, 1) == Math.Round(x2, 1) && Math.Round(y1, 1) == Math.Round(y2, 1))
            {
                Cancel();
            }
            else
            {
                if (end != null)
                {
                    TempLine.End = end;
                }

                _state.OverlaySheet.ReleaseCapture();
                _state.OverlaySheet.Remove(TempLine);
                _state.OverlaySheet.Remove(TempStartEllipse);
                _state.OverlaySheet.Remove(TempEndEllipse);

                _state.HistoryController.Register("Create Line");

                if (TempLine.Start != null)
                {
                    _pointController.ConnectStart(TempLine.Start, TempLine);
                }

                if (TempLine.End != null)
                {
                    _pointController.ConnectEnd(TempLine.End, TempLine);
                }

                _state.ContentBlock.Lines.Add(TempLine);
                _state.ContentSheet.Add(TempLine);

                TempLine         = null;
                TempStartEllipse = null;
                TempEndEllipse   = null;
            }
        }