예제 #1
0
        public TileSelectionBorder GetTileSelectionBorder(Location tileLocation)
        {
            TileSelectionBorder tileSelectionBorder = new TileSelectionBorder();

            m_tileSelections.TryGetValue(tileLocation, out tileSelectionBorder);
            return(tileSelectionBorder);
        }
예제 #2
0
        public void SelectAll(Rectangle selectionContext)
        {
            m_bounds = selectionContext;
            Location location = selectionContext.Location;
            int      maxX     = location.X + selectionContext.Size.Width;
            int      maxY     = location.Y + selectionContext.Size.Height;

            m_tileSelections.Clear();
            for (; location.Y < maxY; location.Y++)
            {
                for (location.X = selectionContext.Location.X; location.X < maxX; location.X++)
                {
                    m_tileSelections[location] = new TileSelectionBorder();
                }
            }
            UpdateSelectionBorders();
        }
예제 #3
0
        public void Invert(Rectangle selectionContext)
        {
            Location location = selectionContext.Location;
            int      maxX     = location.X + selectionContext.Size.Width;
            int      maxY     = location.Y + selectionContext.Size.Height;

            List <Location> invertedSelections = new List <Location>();

            Location initialLocation = Location.Origin;

            for (; location.Y < maxY; location.Y++)
            {
                for (location.X = selectionContext.Location.X; location.X < maxX; location.X++)
                {
                    if (m_bounds.Contains(location))
                    {
                        if (!m_tileSelections.ContainsKey(location))
                        {
                            invertedSelections.Add(location);
                            initialLocation = location;
                        }
                    }
                    else
                    {
                        invertedSelections.Add(location);
                        initialLocation = location;
                    }
                }
            }

            m_tileSelections.Clear();
            foreach (Location tileLocation in invertedSelections)
            {
                m_tileSelections[tileLocation] = new TileSelectionBorder();
            }

            m_bounds.Location = initialLocation;
            m_bounds.Size     = Size.Zero;
            foreach (Location invertedLocation in invertedSelections)
            {
                m_bounds.ExtendTo(invertedLocation);
            }
            UpdateSelectionBorders();
        }
예제 #4
0
        public void AddLocation(Location tileLocation)
        {
            if (m_tileSelections.Count == 0)
            {
                m_tileSelections[tileLocation] = new TileSelectionBorder();
                m_bounds.Location = tileLocation;
                m_bounds.Size.Width = m_bounds.Size.Height = 1;
            }
            else
            {
                if (m_bounds.Contains(tileLocation)
                    && m_tileSelections.ContainsKey(tileLocation))
                    return;

                m_tileSelections[tileLocation] = new TileSelectionBorder();
                m_bounds.ExtendTo(tileLocation);
            }
            UpdateSelectionBorders();
        }
예제 #5
0
        public void AddLocation(Location tileLocation)
        {
            if (m_tileSelections.Count == 0)
            {
                m_tileSelections[tileLocation] = new TileSelectionBorder();
                m_bounds.Location   = tileLocation;
                m_bounds.Size.Width = m_bounds.Size.Height = 1;
            }
            else
            {
                if (m_bounds.Contains(tileLocation) &&
                    m_tileSelections.ContainsKey(tileLocation))
                {
                    return;
                }

                m_tileSelections[tileLocation] = new TileSelectionBorder();
                m_bounds.ExtendTo(tileLocation);
            }
            UpdateSelectionBorders();
        }
예제 #6
0
        private void UpdateSelectionBorders()
        {
            List <Location> tileLocations = new List <Location>(m_tileSelections.Keys);

            foreach (Location tileLocation in tileLocations)
            {
                TileSelectionBorder tileSelectionBorder = new TileSelectionBorder();

                Location tileLocationNeighbour = new Location(tileLocation.X - 1, tileLocation.Y);
                if (!Contains(tileLocationNeighbour))
                {
                    tileSelectionBorder.Left = true;
                }

                tileLocationNeighbour.X += 2;
                if (!Contains(tileLocationNeighbour))
                {
                    tileSelectionBorder.Right = true;
                }

                --tileLocationNeighbour.X;
                --tileLocationNeighbour.Y;
                if (!Contains(tileLocationNeighbour))
                {
                    tileSelectionBorder.Above = true;
                }

                tileLocationNeighbour.Y += 2;
                if (!Contains(tileLocationNeighbour))
                {
                    tileSelectionBorder.Below = true;
                }

                m_tileSelections[tileLocation] = tileSelectionBorder;
            }
        }
예제 #7
0
        private void UpdateSelectionBorders()
        {
            List<Location> tileLocations = new List<Location>(m_tileSelections.Keys);
            foreach (Location tileLocation in tileLocations)
            {
                TileSelectionBorder tileSelectionBorder = new TileSelectionBorder();

                Location tileLocationNeighbour = new Location(tileLocation.X - 1, tileLocation.Y);
                if (!Contains(tileLocationNeighbour))
                    tileSelectionBorder.Left = true;

                tileLocationNeighbour.X += 2;
                if (!Contains(tileLocationNeighbour))
                    tileSelectionBorder.Right = true;

                --tileLocationNeighbour.X;
                --tileLocationNeighbour.Y;
                if (!Contains(tileLocationNeighbour))
                    tileSelectionBorder.Above = true;

                tileLocationNeighbour.Y += 2;
                if (!Contains(tileLocationNeighbour))
                    tileSelectionBorder.Below = true;

                m_tileSelections[tileLocation] = tileSelectionBorder;
            }
        }
예제 #8
0
        public void SelectAll(Rectangle selectionContext)
        {
            m_bounds = selectionContext;
            Location location = selectionContext.Location;
            int maxX = location.X + selectionContext.Size.Width;
            int maxY = location.Y + selectionContext.Size.Height;

            m_tileSelections.Clear();
            for (; location.Y < maxY; location.Y++)
                for (location.X = selectionContext.Location.X; location.X < maxX; location.X++)
                    m_tileSelections[location] = new TileSelectionBorder();
            UpdateSelectionBorders();
        }
예제 #9
0
        public void Invert(Rectangle selectionContext)
        {
            Location location = selectionContext.Location;
            int maxX = location.X + selectionContext.Size.Width ;
            int maxY = location.Y + selectionContext.Size.Height;

            List<Location> invertedSelections = new List<Location>();

            Location initialLocation = Location.Origin;
            for (; location.Y < maxY; location.Y++)
                for (location.X = selectionContext.Location.X; location.X < maxX; location.X++)
                    if (m_bounds.Contains(location))
                    {
                        if (!m_tileSelections.ContainsKey(location))
                        {
                            invertedSelections.Add(location);
                            initialLocation = location;
                        }
                    }
                    else
                    {
                        invertedSelections.Add(location);
                        initialLocation = location;
                    }

            m_tileSelections.Clear();
            foreach (Location tileLocation in invertedSelections)
                m_tileSelections[tileLocation] = new TileSelectionBorder();

            m_bounds.Location = initialLocation;
            m_bounds.Size = Size.Zero;
            foreach (Location invertedLocation in invertedSelections)
                m_bounds.ExtendTo(invertedLocation);
            UpdateSelectionBorders();
        }
예제 #10
0
 public TileSelectionBorder GetTileSelectionBorder(Location tileLocation)
 {
     TileSelectionBorder tileSelectionBorder = new TileSelectionBorder();
     m_tileSelections.TryGetValue(tileLocation, out tileSelectionBorder);
     return tileSelectionBorder;
 }