Esempio n. 1
0
        private static void ParkObstacle(SnapObstacle avoider, SnapDescription snapDescription)
        {
            Point     newLocation      = avoider.Bounds.Location;
            Point     adjustedLocation = AdjustNewLocation(avoider, newLocation, snapDescription);
            Rectangle newBounds        = new Rectangle(adjustedLocation, avoider.Bounds.Size);

            avoider.RequestBoundsChange(newBounds);
        }
Esempio n. 2
0
        private void LoadSnapObstacleData(ISimpleCollection <string, string> loadFrom, SnapObstacle so)
        {
            string          prefix = so.Name + ".";
            SnapDescription sd;

            string isSnappedString = loadFrom.Get(prefix + isSnappedValueName);
            bool   isSnapped       = bool.Parse(isSnappedString);

            if (isSnapped)
            {
                string       snappedToString = loadFrom.Get(prefix + snappedToValueName);
                SnapObstacle snappedTo       = FindObstacle(snappedToString);

                string             horizontalEdgeString = loadFrom.Get(prefix + horizontalEdgeValueName);
                HorizontalSnapEdge horizontalEdge       = (HorizontalSnapEdge)Enum.Parse(typeof(HorizontalSnapEdge), horizontalEdgeString, true);

                string           verticalEdgeString = loadFrom.Get(prefix + verticalEdgeValueName);
                VerticalSnapEdge verticalEdge       = (VerticalSnapEdge)Enum.Parse(typeof(VerticalSnapEdge), verticalEdgeString, true);

                string xOffsetString = loadFrom.Get(prefix + xOffsetValueName);
                int    xOffset       = int.Parse(xOffsetString, CultureInfo.InvariantCulture);

                string yOffsetString = loadFrom.Get(prefix + yOffsetValueName);
                int    yOffset       = int.Parse(yOffsetString, CultureInfo.InvariantCulture);

                sd = new SnapDescription(snappedTo, horizontalEdge, verticalEdge, xOffset, yOffset);
            }
            else
            {
                sd = null;
            }

            this.obstacles[so] = sd;

            string leftString = loadFrom.Get(prefix + leftValueName);
            int    left       = int.Parse(leftString, CultureInfo.InvariantCulture);

            string topString = loadFrom.Get(prefix + topValueName);
            int    top       = int.Parse(topString, CultureInfo.InvariantCulture);

            string widthString = loadFrom.Get(prefix + widthValueName);
            int    width       = int.Parse(widthString, CultureInfo.InvariantCulture);

            string heightString = loadFrom.Get(prefix + heightValueName);
            int    height       = int.Parse(heightString, CultureInfo.InvariantCulture);

            Rectangle newBounds = new Rectangle(left, top, width, height);

            so.RequestBoundsChange(newBounds);

            if (sd != null)
            {
                ParkObstacle(so, sd);
            }
        }
Esempio n. 3
0
        private void LoadSnapObstacleData(ISimpleCollection<string, string> loadFrom, SnapObstacle so)
        {
            string prefix = so.Name + ".";
            SnapDescription sd;

            string isSnappedString = loadFrom.Get(prefix + isSnappedValueName);
            bool isSnapped = bool.Parse(isSnappedString);

            if (isSnapped)
            {
                string snappedToString = loadFrom.Get(prefix + snappedToValueName);
                SnapObstacle snappedTo = FindObstacle(snappedToString);

                string horizontalEdgeString = loadFrom.Get(prefix + horizontalEdgeValueName);
                HorizontalSnapEdge horizontalEdge = (HorizontalSnapEdge)Enum.Parse(typeof(HorizontalSnapEdge), horizontalEdgeString, true);

                string verticalEdgeString = loadFrom.Get(prefix + verticalEdgeValueName);
                VerticalSnapEdge verticalEdge = (VerticalSnapEdge)Enum.Parse(typeof(VerticalSnapEdge), verticalEdgeString, true);

                string xOffsetString = loadFrom.Get(prefix + xOffsetValueName);
                int xOffset = int.Parse(xOffsetString, CultureInfo.InvariantCulture);

                string yOffsetString = loadFrom.Get(prefix + yOffsetValueName);
                int yOffset = int.Parse(yOffsetString, CultureInfo.InvariantCulture);

                sd = new SnapDescription(snappedTo, horizontalEdge, verticalEdge, xOffset, yOffset);
            }
            else
            {
                sd = null;
            }

            this.obstacles[so] = sd;

            string leftString = loadFrom.Get(prefix + leftValueName);
            int left = int.Parse(leftString, CultureInfo.InvariantCulture);

            string topString = loadFrom.Get(prefix + topValueName);
            int top = int.Parse(topString, CultureInfo.InvariantCulture);

            string widthString = loadFrom.Get(prefix + widthValueName);
            int width = int.Parse(widthString, CultureInfo.InvariantCulture);

            string heightString = loadFrom.Get(prefix + heightValueName);
            int height = int.Parse(heightString, CultureInfo.InvariantCulture);

            Rectangle newBounds = new Rectangle(left, top, width, height);
            so.RequestBoundsChange(newBounds);

            if (sd != null)
            {
                ParkObstacle(so, sd);
            }
        }
Esempio n. 4
0
 private static void ParkObstacle(SnapObstacle avoider, SnapDescription snapDescription)
 {
     Point newLocation = avoider.Bounds.Location;
     Point adjustedLocation = AdjustNewLocation(avoider, newLocation, snapDescription);
     Rectangle newBounds = new Rectangle(adjustedLocation, avoider.Bounds.Size);
     avoider.RequestBoundsChange(newBounds);
 }