예제 #1
0
 /// <summary>
 /// Removes rectangle object from scene
 /// </summary>
 /// <param name="rectangle">Rectangle object</param>
 public void RemoveRectangle(RectangleObject rectangle)
 {
     if (Rectangles.Contains(rectangle))
     {
         Rectangles.Remove(rectangle);
     }
 }
예제 #2
0
 private void Rectangles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.OldItems != null)
     {
         foreach (Rectangle rectangle in e.OldItems)
         {
             Rectangles.Remove(rectangle);
         }
     }
     if (e.NewItems != null)
     {
         foreach (Rectangle rectangle in e.NewItems)
         {
             Rectangles.Add(rectangle);
         }
     }
 }
예제 #3
0
        private void CloseRectButton_Click(object sender, RoutedEventArgs e)
        {
            SelectableBoundingBox sb = (SelectableBoundingBox)((Button)sender).DataContext;

            Rectangles.Remove(sb);
        }
예제 #4
0
 private void DoRemoveRectangle()
 {
     Rectangles.Remove(Rectangles[Rectangles.Count - 1]);
 }
예제 #5
0
        public Rectangles AddRectangle(int x, int y, int id)
        {
            Rectangle        rec        = new Rectangle(new Point(x * 10, y * 10), 10, 10, false, id);
            List <Rectangle> rectangles = new List <Rectangle>();

            rectangles.Add(rec);
            foreach (var rectangle in _grid)
            {
                if (!rectangle.In(rec))
                {
                    continue;
                }
                var rectanglesSep = rectangle.Separe(false, (int)rec.Origin.X);
                if (rectanglesSep != null)
                {
                    rectangles.Add(rectanglesSep[0]);
                }
                rectanglesSep = rectangle.Separe(false, (int)rec.Origin.X + rec.Width);
                if (rectanglesSep != null)
                {
                    rectangles.Add(rectanglesSep[1]);
                }
                rectanglesSep = rectangle.Separe(true, (int)rec.Origin.Y);
                if (rectanglesSep != null)
                {
                    Rectangle haut = rectanglesSep[0];
                    rectanglesSep = haut.Separe(false, (int)rec.Origin.X);
                    if (rectanglesSep != null)
                    {
                        haut = rectanglesSep[1];
                    }
                    rectanglesSep = haut.Separe(false, (int)rec.Origin.X + rec.Width);
                    if (rectanglesSep != null)
                    {
                        haut = rectanglesSep[0];
                    }
                    rectangles.Add(haut);
                }
                rectanglesSep = rectangle.Separe(true, (int)rec.Origin.Y + rec.Width);
                if (rectanglesSep != null)
                {
                    Rectangle bas = rectanglesSep[1];
                    rectanglesSep = bas.Separe(false, (int)rec.Origin.X);
                    if (rectanglesSep != null)
                    {
                        bas = rectanglesSep[1];
                    }
                    rectanglesSep = bas.Separe(false, (int)rec.Origin.X + rec.Width);
                    if (rectanglesSep != null)
                    {
                        bas = rectanglesSep[0];
                    }
                    rectangles.Add(bas);
                }
                _grid.Remove(rectangle);
                rectangles.Remove(rec);
                break;
            }
            foreach (Rectangle t in rectangles)
            {
                Rectangle rect = t;
                _grid = AjoutRec(_grid, ref rect);
                _grid.Add(rect);
            }

            return(_grid);
        }