Exemple #1
0
        public override void Undo()
        {
            foreach (IVisualElement entity in AffectedEntities)
            {
                _context.MapEntities.Add(entity);
            }

            if (_context is IVisualBuilding && RemovedFloor != null)
            {
                IVisualBuilding building = (IVisualBuilding)_context;
                building.Floors.Insert(RemovedFloorIndex, RemovedFloor);
            }
        }
Exemple #2
0
        public override void Do()
        {
            foreach (IVisualElement entity in AffectedEntities)
            {
                _context.SelectedEntities.Remove(entity);

                // remove all building shape manipulation helpers
                var items = _context.MapEntities.Where(item => item is VisualCornerManipulator).ToList();
                for (int i = 0; i < items.Count; i++)
                {
                    _context.MapEntities.Remove(items[i]);
                }
                if (_context is DataModel)
                {
                    ((DataModel)_context).CurrentCorners = null;
                }

                if (entity is WallElement)
                {
                    foreach (VisualDoor door in ((WallElement)entity).Doors)
                    {
                        _context.MapEntities.Remove(door);
                    }
                    //TODO: Windows
                }
                _context.MapEntities.Remove(entity);
            }

            // handle floor removal
            if (_context is IVisualBuilding)
            {
                IVisualBuilding building = (IVisualBuilding)_context;
                VisualFloor     floor    = building.CurrentFloor;
                if (floor != null && floor.IsSelected)
                {
                    RemovedFloorIndex = building.Floors.IndexOf(floor);
                    building.Floors.Remove(floor);
                    RemovedFloor = floor;
                    if (building.Floors.Count > 0)
                    {
                        building.CurrentFloor = building.Floors[0];
                    }
                    else
                    {
                        building.CurrentFloor = null;
                    }
                }
            }
        }
Exemple #3
0
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IVisualElement  selectedElement = (IVisualElement)((FrameworkElement)sender).DataContext;
            IVisualBuilding building        = (IVisualBuilding)DataContext;

            if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
            {
                building.SelectedEntities.Clear();
                foreach (VisualFloor floor in building.Floors)
                {
                    floor.IsSelected = false;
                }
            }
            selectedElement.IsSelected = !selectedElement.IsSelected;

            if (selectedElement is VisualFloor)
            {
                building.CurrentFloor = (VisualFloor)selectedElement;
                building.FireFloorSelectionEvent();
            }
        }
 private void DeleteCommand_FloorWasSelected(IVisualBuilding building)
 {
     OnCanExecutedChanged(this, null);
 }
 public AddFloorCommand(IVisualBuilding building)
 {
     _building = building;
 }