Exemplo n.º 1
0
        public DoorKeyWindow(MainWindowManager manager, bool edit, Door door, KeyItem key)
        {
            InitializeComponent();

            this.manager = manager;
            openFileManager = new OpenFileManager();
            this.edit = edit;
            this.door = door;
            this.key = key;

            if (edit)
            {
                SetValues();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Inserts the selected element in the stage.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CanvasGame_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            string errorMessage = "An error ocurred when introducing the element.";

            try
            {
                if (currentID < 0)
                {
                    throw new NullReferenceException();
                }

                if (textureSelected != null)
                {
                    if (textureSelected.Uid == "Eraser")
                    {
                        CanvasGame_MouseRightButtonDown(sender, e);
                    }

                    textureCanvas = new Image();

                    textureCanvas.Source = textureSelected.Source;
                    textureCanvas.Width = textureSelected.Width;
                    textureCanvas.Height = textureSelected.Height;
                    textureCanvas.Uid = textureSelected.Uid;
                    textureCanvas.Name = textureSelected.Name;

                    Point pos = Mouse.GetPosition(CanvasGame);

                    pos.X -= textureCanvas.Width;
                    pos.Y -= textureCanvas.Height;

                    if (pos.X  < 0)
                    {
                        pos.X = 0;
                    }

                    if (pos.Y < 0)
                    {
                        pos.Y = 0;
                    }

                    //if ((pos.X + textureCanvas.Width) > 640)
                    //{
                    //    pos.X = 640 - textureCanvas.Width;
                    //}

                    //if ((pos.Y + textureCanvas.Height) > 380)
                    //{
                    //    pos.Y = 380 - textureCanvas.Height;
                    //}

                    pos.X = Math.Round(pos.X, 2);
                    pos.Y = Math.Round(pos.Y, 2);

                    Stage currentStage = manager.GetStage(currentID);

                    if (textureCanvas.Uid == "Character")
                    {
                        if (manager.Player.IsSet == true)
                        {
                            errorMessage = "The main character is already set.";
                            throw new Exception();
                        }

                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        currentStage.Player = manager.Player;

                        currentStage.Player.PositionX = (int)pos.X;
                        currentStage.Player.PositionY = (int)pos.Y;
                        currentStage.Player.CurrentImage = textureCanvas;

                        manager.Player.IsSet = true;
                    }
                    else if (textureCanvas.Uid == "Consumable")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        Consumable consumableStage = manager.GetConsumable(textureCanvas.Name);
                        Consumable newConsumable = new Consumable(consumableStage.Name, consumableStage.Type, consumableStage.Effect, consumableStage.Image);

                        newConsumable.PositionX = (int)pos.X;
                        newConsumable.PositionY = (int)pos.Y;
                        newConsumable.CurrentImage = textureCanvas;

                        currentStage.Consumables.Add(newConsumable);
                    }
                    else if (textureCanvas.Uid == "Weapon")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        Weapon weaponStage = manager.GetWeapon(textureCanvas.Name);
                        Weapon newWeapon = new Weapon(weaponStage.Name, weaponStage.Type, weaponStage.Damage, weaponStage.Speed, weaponStage.ImageWeapon,
                            weaponStage.ImageArrowUp, weaponStage.ImageArrowDown, weaponStage.ImageArrowLeft, weaponStage.ImageArrowRight);

                        newWeapon.PositionX = (int)pos.X;
                        newWeapon.PositionY = (int)pos.Y;
                        newWeapon.CurrentImage = textureCanvas;

                        currentStage.Weapons.Add(newWeapon);
                    }
                    else if (textureCanvas.Uid == "Enemy")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        Enemy enemyStage = manager.GetEnemy(textureCanvas.Name);
                        Enemy newEnemy = new Enemy(enemyStage.Name, enemyStage.Strenght, enemyStage.Intelligence, enemyStage.Dexterity, enemyStage.HitPoints,
                            enemyStage.ImageMovingUp, enemyStage.ImageMovingDown, enemyStage.ImageMovingLeft, enemyStage.ImageMovingRight, enemyStage.FrameCount,
                            enemyStage.ImageArrowUp, enemyStage.ImageArrowDown, enemyStage.ImageArrowLeft, enemyStage.ImageArrowRight, enemyStage.Loot,
                            enemyStage.Behavoir, enemyStage.Preference, enemyStage.Boss, enemyStage.InitialState, enemyStage.PatrolZone, enemyStage.DetectZone,
                            enemyStage.Speed);

                        newEnemy.PositionX = (int)pos.X;
                        newEnemy.PositionY = (int)pos.Y;
                        newEnemy.CurrentImage = textureCanvas;

                        currentStage.Enemies.Add(newEnemy);
                    }
                    else if (textureCanvas.Uid == "NPC")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        NPC npcStage = manager.GetNPC(textureCanvas.Name);
                        NPC newNPC = new NPC(npcStage.Name, npcStage.Image, npcStage.DialogImage);

                        newNPC.PositionX = (int)pos.X;
                        newNPC.PositionY = (int)pos.Y;
                        newNPC.CurrentImage = textureCanvas;

                        currentStage.NonPlayers.Add(newNPC);
                    }
                    else if (textureCanvas.Uid == "Wall")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        BackgroundItem wallStage = manager.GetBgItem(textureCanvas.Name);
                        BackgroundItem newWall = new BackgroundItem(wallStage.Name, wallStage.Solid, wallStage.BulletProof, wallStage.Image);

                        newWall.PositionX = (int)pos.X;
                        newWall.PositionY = (int)pos.Y;
                        newWall.CurrentImage = textureCanvas;

                        currentStage.BgItems.Add(newWall);
                    }
                    else if (textureCanvas.Uid == "Key")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        KeyItem keyStage = manager.GetKey(textureCanvas.Name);
                        KeyItem newKey = new KeyItem(keyStage.Name, keyStage.Image, keyStage.ID);

                        newKey.PositionX = (int)pos.X;
                        newKey.PositionY = (int)pos.Y;
                        newKey.CurrentImage = textureCanvas;

                        currentStage.Keys.Add(newKey);
                    }
                    else if (textureCanvas.Uid == "Door")
                    {
                        CanvasGame.Children.Add(textureCanvas);

                        Canvas.SetLeft(textureCanvas, pos.X);
                        Canvas.SetTop(textureCanvas, pos.Y);

                        Door doorStage = manager.GetDoor(textureCanvas.Name);
                        Door newDoor = new Door(doorStage.Name, doorStage.Image, doorStage.ID);

                        newDoor.PositionX = (int)pos.X;
                        newDoor.PositionY = (int)pos.Y;
                        newDoor.CurrentImage = textureCanvas;

                        currentStage.Doors.Add(newDoor);
                    }
                }
            }
            catch(NullReferenceException)
            {
                MessageBox.Show("You have to create a stage first.", "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Builds a string of the stage's information and content.
        /// </summary>
        /// <param name="manager">Main window manager</param>
        /// <returns>String for the DSL</returns>
        public string ToString(MainWindowManager manager)
        {
            string total = "";

            Background = Background.Replace('\\', '/');

            if (!String.IsNullOrEmpty(Music))
            {
                Music = Music.Replace('\\', '/');
            }

            total += "\t<stage>\r\n";

            total += "\t\t<window>\r\n" +
                     "\t\t\t<window_background>" + Background + "</window_background>\r\n" +
                     "\t\t\t<window_background_music>" + Music + "</window_background_music>\r\n" +
                     "\t\t\t<window_id>" + ID + "</window_id>\r\n" +
                     "\t\t\t<window_north>" + ExitUp + "</window_north>\r\n" +
                     "\t\t\t<window_east>" + ExitRight + "</window_east>\r\n" +
                     "\t\t\t<window_south>" + ExitDown + "</window_south>\r\n" +
                     "\t\t\t<window_west>" + ExitLeft + "</window_west>\r\n" +
                     "\t\t</window>\r\n";

            foreach (Enemy enemy in Enemies)
            {
                enemy.ImageMovingUp    = enemy.ImageMovingUp.Replace('\\', '/');
                enemy.ImageMovingDown  = enemy.ImageMovingDown.Replace('\\', '/');
                enemy.ImageMovingLeft  = enemy.ImageMovingLeft.Replace('\\', '/');
                enemy.ImageMovingRight = enemy.ImageMovingRight.Replace('\\', '/');

                if (!String.IsNullOrEmpty(enemy.ImageArrowUp))
                {
                    enemy.ImageArrowUp    = enemy.ImageArrowUp.Replace('\\', '/');
                    enemy.ImageArrowDown  = enemy.ImageArrowDown.Replace('\\', '/');
                    enemy.ImageArrowLeft  = enemy.ImageArrowLeft.Replace('\\', '/');
                    enemy.ImageArrowRight = enemy.ImageArrowRight.Replace('\\', '/');
                }

                int enemySpeed;

                if (enemy.Speed == "slow")
                {
                    enemySpeed = 1;
                }
                else if (enemy.Speed == "normal")
                {
                    enemySpeed = 2;
                }
                else
                {
                    enemySpeed = 3;
                }

                int bulletspeed = enemySpeed + 1;

                total += "\t\t<enemy>\r\n" +
                         "\t\t\t<enemy_image_up>" + enemy.ImageMovingUp + "</enemy_image_up>\r\n" +
                         "\t\t\t<enemy_image_down>" + enemy.ImageMovingDown + "</enemy_image_down>\r\n" +
                         "\t\t\t<enemy_image_left>" + enemy.ImageMovingLeft + "</enemy_image_left>\r\n" +
                         "\t\t\t<enemy_image_right>" + enemy.ImageMovingRight + "</enemy_image_right>\r\n" +
                         "\t\t\t<enemy_bullet_image_up>" + enemy.ImageArrowUp + "</enemy_bullet_image_up>\r\n" +
                         "\t\t\t<enemy_bullet_image_down>" + enemy.ImageArrowDown + "</enemy_bullet_image_down>\r\n" +
                         "\t\t\t<enemy_bullet_image_left>" + enemy.ImageArrowLeft + "</enemy_bullet_image_left>\r\n" +
                         "\t\t\t<enemy_bullet_image_right>" + enemy.ImageArrowRight + "</enemy_bullet_image_right>\r\n" +
                         "\t\t\t<enemy_initial_state>" + enemy.InitialState + "</enemy_initial_state>\r\n" +
                         "\t\t\t<enemy_framecount>" + enemy.FrameCount + "</enemy_framecount>\r\n" +
                         "\t\t\t<enemy_x_position>" + enemy.PositionX + "</enemy_x_position>\r\n" +
                         "\t\t\t<enemy_y_position>" + enemy.PositionY + "</enemy_y_position>\r\n" +
                         "\t\t\t<enemy_speed>" + enemySpeed + "</enemy_speed>\r\n" +
                         "\t\t\t<enemy_bullet_speed>" + bulletspeed + "</enemy_bullet_speed>\r\n" +
                         "\t\t\t<enemy_strenght>" + enemy.Strenght + "</enemy_strenght>\r\n" +
                         "\t\t\t<enemy_dexterity>" + enemy.Dexterity + "</enemy_dexterity>\r\n" +
                         "\t\t\t<enemy_intelligence>" + enemy.Intelligence + "</enemy_intelligence>\r\n" +
                         "\t\t\t<enemy_hit_points>" + enemy.HitPoints + "</enemy_hit_points>\r\n" +
                         "\t\t\t<enemy_ia>" + enemy.Behavoir + "</enemy_ia>\r\n" +
                         "\t\t\t<enemy_preference>" + enemy.Preference + "</enemy_preference>\r\n" +
                         "\t\t\t<enemy_boss>" + enemy.Boss + "</enemy_boss>\r\n" +
                         "\t\t\t<enemy_detect_zone>" + enemy.DetectZone + "</enemy_detect_zone>\r\n" +
                         "\t\t\t<enemy_patrol_zone>" + enemy.PatrolZone + "</enemy_patrol_zone>\r\n";

                if (manager.GetWeapon(enemy.Loot) != null)
                {
                    Weapon weapon = manager.GetWeapon(enemy.Loot);

                    weapon.ImageWeapon = weapon.ImageWeapon.Replace('\\', '/');

                    int weaponSpeed;

                    if (weapon.Speed == "slow")
                    {
                        weaponSpeed = 1;
                    }
                    else if (weapon.Speed == "normal")
                    {
                        weaponSpeed = 2;
                    }
                    else
                    {
                        weaponSpeed = 3;
                    }

                    if (weapon.Type == "melee")
                    {
                        total += "\t\t\t<melee>\r\n" +
                                 "\t\t\t\t<melee_image>" + weapon.ImageWeapon + "</melee_image>\r\n" +
                                 "\t\t\t\t<melee_damage>" + weapon.Damage + "</melee_damage>\r\n" +
                                 "\t\t\t\t<melee_speed>" + weaponSpeed + "</melee_speed>\r\n" +
                                 "\t\t\t</melee>\r\n";
                    }
                    else
                    {
                        weapon.ImageWeapon     = weapon.ImageWeapon.Replace('\\', '/');
                        weapon.ImageArrowUp    = weapon.ImageArrowUp.Replace('\\', '/');
                        weapon.ImageArrowDown  = weapon.ImageArrowDown.Replace('\\', '/');
                        weapon.ImageArrowLeft  = weapon.ImageArrowLeft.Replace('\\', '/');
                        weapon.ImageArrowRight = weapon.ImageArrowRight.Replace('\\', '/');

                        total += "\t\t\t<distance>\r\n" +
                                 "\t\t\t\t<distance_image>" + weapon.ImageWeapon + "</distance_image>\r\n" +
                                 "\t\t\t\t<distance_damage>" + weapon.Damage + "</distance_damage>\r\n" +
                                 "\t\t\t\t<distance_speed>" + weaponSpeed + "</distance_speed>\r\n" +
                                 "\t\t\t\t<distance_bullet_image_up>" + weapon.ImageArrowUp + "</distance_bullet_image_up>\r\n" +
                                 "\t\t\t\t<distance_bullet_image_down>" + weapon.ImageArrowDown + "</distance_bullet_image_down>\r\n" +
                                 "\t\t\t\t<distance_bullet_image_left>" + weapon.ImageArrowLeft + "</distance_bullet_image_left>\r\n" +
                                 "\t\t\t\t<distance_bullet_image_right>" + weapon.ImageArrowRight + "</distance_bullet_image_right>\r\n" +
                                 "\t\t\t</distance>\r\n";
                    }
                }
                else if (manager.GetKey(enemy.Loot) != null)
                {
                    KeyItem key = manager.GetKey(enemy.Loot);

                    key.Image = key.Image.Replace('\\', '/');

                    total += "\t\t\t<key>\r\n" +
                             "\t\t\t\t<key_image>" + key.Image + "</key_image>\r\n" +
                             "\t\t\t\t<key_id>" + key.ID + "</key_id>\r\n" +
                             "\t\t\t</key>\r\n";
                }
                else if (manager.GetConsumable(enemy.Loot) != null)
                {
                    Consumable consumable = manager.GetConsumable(enemy.Loot);

                    consumable.Image = consumable.Image.Replace('\\', '/');

                    total += "\t\t\t<consumable>\r\n" +
                             "\t\t\t\t<consumable_image>" + consumable.Image + "</consumable_image>\r\n" +
                             "\t\t\t\t<consumable_affect>" + consumable.Type + "</consumable_affect>\r\n" +
                             "\t\t\t\t<consumable_effect>" + consumable.Effect + "</consumable_effect>\r\n" +
                             "\t\t\t</consumable>\r\n";
                }

                total += "\t\t</enemy>\r\n";;
            }

            foreach (Consumable consumable in Consumables)
            {
                consumable.Image = consumable.Image.Replace('\\', '/');

                total += "\t\t<consumable>\r\n" +
                         "\t\t\t<consumable_image>" + consumable.Image + "</consumable_image>\r\n" +
                         "\t\t\t<consumable_affect>" + consumable.Type + "</consumable_affect>\r\n" +
                         "\t\t\t<consumable_effect>" + consumable.Effect + "</consumable_effect>\r\n" +
                         "\t\t\t<consumable_x_position>" + consumable.PositionX + "</consumable_x_position>\r\n" +
                         "\t\t\t<consumable_y_position>" + consumable.PositionY + "</consumable_y_position>\r\n" +
                         "\t\t</consumable>\r\n";
            }

            foreach (BackgroundItem wall in BgItems)
            {
                wall.Image = wall.Image.Replace('\\', '/');

                total += "\t\t<wall>\r\n" +
                         "\t\t\t<wall_image>" + wall.Image + "</wall_image>\r\n" +
                         "\t\t\t<wall_x_position>" + wall.PositionX + "</wall_x_position>\r\n" +
                         "\t\t\t<wall_y_position>" + wall.PositionY + "</wall_y_position>\r\n" +
                         "\t\t\t<wall_solid>" + wall.Solid + "</wall_solid>\r\n" +
                         "\t\t\t<wall_bullet_proof>" + wall.BulletProof + "</wall_bullet_proof>\r\n" +
                         "\t\t</wall>\r\n";
            }

            foreach (NPC npc in NonPlayers)
            {
                npc.Image       = npc.Image.Replace('\\', '/');
                npc.DialogImage = npc.DialogImage.Replace('\\', '/');

                total += "\t\t<npc>\r\n" +
                         "\t\t\t<npc_image>" + npc.Image + "</npc_image>\r\n" +
                         "\t\t\t<npc_dialog>" + npc.DialogImage + "</npc_dialog>\r\n" +
                         "\t\t\t<npc_x_position>" + npc.PositionX + "</npc_x_position>\r\n" +
                         "\t\t\t<npc_y_position>" + npc.PositionY + "</npc_y_position>\r\n" +
                         "\t\t</npc>\r\n";
            }

            foreach (Weapon weapon in Weapons)
            {
                weapon.ImageWeapon = weapon.ImageWeapon.Replace('\\', '/');

                int weaponSpeed;

                if (weapon.Speed == "slow")
                {
                    weaponSpeed = 1;
                }
                else if (weapon.Speed == "normal")
                {
                    weaponSpeed = 2;
                }
                else
                {
                    weaponSpeed = 3;
                }

                if (weapon.Type == "melee")
                {
                    total += "\t\t<melee>\r\n" +
                             "\t\t\t<melee_image>" + weapon.ImageWeapon + "</melee_image>\r\n" +
                             "\t\t\t<melee_damage>" + weapon.Damage + "</melee_damage>\r\n" +
                             "\t\t\t<melee_speed>" + weaponSpeed + "</melee_speed>\r\n" +
                             "\t\t\t<melee_x_position>" + weapon.PositionX + "</melee_x_position>\r\n" +
                             "\t\t\t<melee_y_position>" + weapon.PositionY + "</melee_y_position>\r\n" +
                             "\t\t</melee>\r\n";
                }
                else
                {
                    weapon.ImageWeapon     = weapon.ImageWeapon.Replace('\\', '/');
                    weapon.ImageArrowUp    = weapon.ImageArrowUp.Replace('\\', '/');
                    weapon.ImageArrowDown  = weapon.ImageArrowDown.Replace('\\', '/');
                    weapon.ImageArrowLeft  = weapon.ImageArrowLeft.Replace('\\', '/');
                    weapon.ImageArrowRight = weapon.ImageArrowRight.Replace('\\', '/');

                    total += "\t\t<distance>\r\n" +
                             "\t\t\t<distance_image>" + weapon.ImageWeapon + "</distance_image>\r\n" +
                             "\t\t\t<distance_damage>" + weapon.Damage + "</distance_damage>\r\n" +
                             "\t\t\t<distance_speed>" + weaponSpeed + "</distance_speed>\r\n" +
                             "\t\t\t<distance_bullet_image_up>" + weapon.ImageArrowUp + "</distance_bullet_image_up>\r\n" +
                             "\t\t\t<distance_bullet_image_down>" + weapon.ImageArrowDown + "</distance_bullet_image_down>\r\n" +
                             "\t\t\t<distance_bullet_image_left>" + weapon.ImageArrowLeft + "</distance_bullet_image_left>\r\n" +
                             "\t\t\t<distance_bullet_image_right>" + weapon.ImageArrowRight + "</distance_bullet_image_right>\r\n" +
                             "\t\t\t<distance_x_position>" + weapon.PositionX + "</distance_x_position>\r\n" +
                             "\t\t\t<distance_y_position>" + weapon.PositionY + "</distance_y_position>\r\n" +
                             "\t\t</distance>\r\n";
                }
            }

            foreach (Door door in Doors)
            {
                door.Image = door.Image.Replace('\\', '/');

                total += "\t\t<door>\r\n" +
                         "\t\t\t<door_image>" + door.Image + "</door_image>\r\n" +
                         "\t\t\t<door_x_position>" + door.PositionX + "</door_x_position>\r\n" +
                         "\t\t\t<door_y_position>" + door.PositionY + "</door_y_position>\r\n" +
                         "\t\t\t<door_id>" + door.ID + "</door_id>\r\n" +
                         "\t\t</door>\r\n";
            }

            foreach (KeyItem key in Keys)
            {
                key.Image = key.Image.Replace('\\', '/');

                total += "\t\t<key>\r\n" +
                         "\t\t\t<key_image>" + key.Image + "</key_image>\r\n" +
                         "\t\t\t<key_x_position>" + key.PositionX + "</key_x_position>\r\n" +
                         "\t\t\t<key_y_position>" + key.PositionY + "</key_y_position>\r\n" +
                         "\t\t\t<key_id>" + key.ID + "</key_id>\r\n" +
                         "\t\t</key>\r\n";
            }

            total += "\t</stage>\r\n";

            return(total);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Saves the door's information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptDoor_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;

            try
            {
                if (String.IsNullOrEmpty(nameDoor))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageDoor))
                {
                    errorMessage = "You have to select an image for the door.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageKey))
                {
                    errorMessage = "You have to select an image for the key.";
                    throw new NullReferenceException();
                }

                nameDoor = nameDoor.Replace(" ", "_");
                nameKey = nameKey.Replace(" ", "_");

                if (manager.CheckIfNumber(nameDoor))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    manager.Doors.Remove(door);
                    manager.Keys.Remove(key);
                }
                if (manager.NameRepeated(nameDoor))
                {
                    errorMessage = "This name already exists";
                    throw new NullReferenceException();
                }

                Door auxDoor = new Door(nameDoor, imageDoor, manager.DoorID);

                manager.Doors.Add(auxDoor);
                manager.Doors.OrderBy(x => x.Name);

                KeyItem auxKey = new KeyItem(nameKey, imageKey, manager.DoorID);

                manager.Keys.Add(auxKey);
                manager.Keys.OrderBy(x => x.Name);

                manager.DoorID++;

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }