コード例 #1
0
        /// <summary>
        /// Creates a new instance of <see cref="TangibleObject"/>.
        /// </summary>
        /// <param name="point1">The first point.</param>
        /// <param name="point2">The second point.</param>
        /// <param name="point3">The third point. This should be the direction point.</param>
        internal TangibleObject(TouchPoint point1, TouchPoint point2, TouchPoint point3)
        {
            Check.NotNull(point1, "point1");
            Check.NotNull(point2, "point2");
            Check.NotNull(point3, "point3");

            // Validate the points
            if (point1.IsDirectionPoint || point2.IsDirectionPoint)
                throw new InvalidOperationException("The first two points should not be direction points!");

            if (!point3.IsDirectionPoint)
                throw new InvalidOperationException("No direction point specified!");

            Points = new TouchPointCollection();
            Points.AddPoint(point1);
            Points.AddPoint(point2);
            Points.AddPoint(point3);

            // Create the bottom line
            _bottomLine = new TouchLine(point1, point2);

            // Calculate the top line
            _topLine = CalculateTopLine(_bottomLine, point3);
            _topLine.Owner = this;

            // Set the owner of the points.
            //Points.ForEach(p => p.Owner = this);

            foreach (var point in Points)
            {
                point.Owner = this;
                point.Changed += OnPointChanged;
            }
        }