/// <summary>
 ///
 /// </summary>
 /// <param name="canvas"></param>
 public void CancelCreation(DrCanvas canvas)
 {
     if (_pointCounter == 2)
     {
         canvas.RemoveVisualObject(_fantom);
     }
 }
Exemplo n.º 2
0
        internal static bool ResolveConstraint(DrCanvas canvas, double newX, double newY, int issuerHash)
        {
            DcPoint issuerPoint = canvas.PointCollection[issuerHash];
            DcPoint subPoint    = canvas.PointCollection[issuerPoint.DependedHash];

            IVisualObject visualObject = canvas.GetDrawingVisualById(PointHash.GetIdFromHash(subPoint.GetHashCode()))?.VisualObject;

            if (visualObject is IPrimitive primitive)
            {
                return(primitive.SetPoint(newX, newY, subPoint.GetHashCode()));
            }

            return(false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="currentPoint"></param>
        /// <param name="canvas"></param>
        /// <returns></returns>
        public void DrawFantom(Point currentPoint, DrCanvas canvas)
        {
            if (_pointCounter == 2)
            {
                Point _secondPoint = new Point(currentPoint.X, canvas.Height - currentPoint.Y);

                if (_fantom != null)
                {
                    _fantom.X2 = _secondPoint.X;
                    _fantom.Y2 = _secondPoint.Y;
                    canvas.Update();
                }
                else
                {
                    _fantom = new DcLineSegment(_firstPoint.X, _firstPoint.Y, _secondPoint.X, _secondPoint.Y);
                    canvas.AddToVisualCollection(_fantom);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="currentPoint"></param>
        /// <param name="canvas"></param>
        /// <returns></returns>
        public IPrimitiveCreator Create(Point currentPoint, DrCanvas canvas)
        {
            if (_pointCounter == 1)
            {
                _firstPoint = new Point(currentPoint.X, canvas.Height - currentPoint.Y);
                _pointCounter++;
                return(this);
            }
            else if (_pointCounter == 2)
            {
                _fantom.X2 = currentPoint.X;
                _fantom.Y2 = canvas.Height - currentPoint.Y;
                canvas.Update();

                _pointCounter = 1;
                _fantom       = null;
                return(this);
            }
            return(null);
        }
 public static void ClassInitialize(TestContext context)
 {
     _canvas = new DrCanvas(800, 800);
 }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="owner"></param>
 public DcLineSegmentList(DrCanvas owner)
 {
     _canvas = owner;
 }