Exemple #1
0
        /// <summary>
        /// Returns true if successful, implying a redraw
        /// </summary>
        /// <returns></returns>
        public bool ChangeBracingAtLocation(Point2d location, DisplayState displayState)
        {
            // Get currently displayed nodes
            List <Point2d> MyNodes = GetCurrentlyDisplayedNodes(displayState);

            // Check if point is within domain
            if (!location.IsWithinDomain(MyNodes))
            {
                return(false);
            }

            // Find closest node to point
            var closestNode      = location.FindClosest(MyNodes);
            var closestNodeIndex = MyNodes.IndexOf(closestNode);

            // See what side the point is relative to the node
            bool above = location.Y > closestNode.Y;
            bool left  = location.X < closestNode.X;

            // Find the relevant pixel
            try
            {
                // Bottom Right
                if (above && left)
                {
                    this.Pixels.Where(p => p.BottomRight == closestNodeIndex).First().FlipState();
                }
                // Bottom Left
                else if (above && !left)
                {
                    this.Pixels.Where(p => p.BottomLeft == closestNodeIndex).First().FlipState();
                }
                // Top Left
                else if (!above && !left)
                {
                    this.Pixels.Where(p => p.TopLeft == closestNodeIndex).First().FlipState();
                }
                // Top right
                else
                {
                    this.Pixels.Where(p => p.TopRight == closestNodeIndex).First().FlipState();
                }
            } catch { return(false); }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Returns true if successful, implying a redraw
        /// </summary>
        /// <param name="location"></param>
        /// <param name="displayState"></param>
        /// <returns></returns>
        public bool ChangeSupportAtLocation(Point2d location, DisplayState displayState)
        {
            // Get currently displayed nodes
            List <Point2d> MyNodes = GetCurrentlyDisplayedNodes(displayState);

            // Check if point is within domain
            if (!location.IsWithinDomain(MyNodes, 2))
            {
                return(false);
            }

            // Find closest node to point
            var closestNode = location.FindClosest(MyNodes);

            // Flip status of support
            closestNode.IsLocked = !closestNode.IsLocked;

            return(true);
        }