public StickerRegister_Titan()
 {
     InitializeComponent();
     Titan.GetAll().GetMales().ForEach(x => fatherName_x_id.Add(x.Name, x.ID));
     Titan.GetAll().GetFemales().ForEach(x => motherName_x_id.Add(x.Name, x.ID));
     StickerNewStricker.StickerImage.Source = Sprite.Get("unknown").Source;
     //StickerNewStricker.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     ComboBoxRarity.ItemsSource   = rarityOptions.Keys;
     ComboBoxGender.ItemsSource   = genderOptions.Keys;
     ComboBoxFather.ItemsSource   = fatherName_x_id.Keys;
     ComboBoxMother.ItemsSource   = motherName_x_id.Keys;
     ComboBoxRarity.SelectedIndex = ComboBoxFather.SelectedIndex = ComboBoxGender.SelectedIndex = ComboBoxMother.SelectedIndex = 0;
 }
        private void ButtonRegister_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            bool hasError = false;

            if (TextBoxName.Text == null || TextBoxName.Text == "")
            {
                TextBoxName.Background = pinkBg;
                hasError = true;
            }
            else
            {
                TextBoxName.Background = normalBg;
            }
            if (TextBoxDescription.Text == null || TextBoxDescription.Text == "")
            {
                TextBoxDescription.Background = pinkBg;
                hasError = true;
            }
            else
            {
                TextBoxDescription.Background = normalBg;
            }
            if (StickerNewStricker.StickerImage.Source == Sprite.Get("unknown").Source)
            {
                LabelTip.Foreground = redBg;
                hasError            = true;
            }
            else
            {
                LabelTip.Foreground = new SolidColorBrush(Colors.Black);
            }
            if (hasError)
            {
                return;
            }

            String imgGuid = Guid.NewGuid().ToString();

            File.Copy(dlg.FileName, Path.Combine(Paths.CustomSpritesDirectory, imgGuid));
            Generics.LinkedList <Sprite> spritesMetadata = JsonConvert.DeserializeObject <Generics.LinkedList <Sprite> >(File.ReadAllText(Paths.CustomSpritesMetadata));
            spritesMetadata.Add(new Sprite()
            {
                ID       = imgGuid,
                Path     = imgGuid,
                IsCustom = true
            });
            File.WriteAllText(Paths.CustomSpritesMetadata, JsonConvert.SerializeObject(spritesMetadata, Formatting.Indented));

            Generics.LinkedList <Titan> customTitans = Titan.GetAll().Where(x => x.IsCustom).ToLinkedList();

            Titan newCustomTitan = new Titan()
            {
                Name        = TextBoxName.Text,
                Description = TextBoxDescription.Text,
                ID          = Guid.NewGuid().ToString(),
                SpriteID    = imgGuid,
                IsCustom    = true
            };

            fatherName_x_id.TryGetValue(ComboBoxFather.Text, out newCustomTitan.FatherID);
            motherName_x_id.TryGetValue(ComboBoxMother.Text, out newCustomTitan.MotherID);
            rarityOptions.TryGetValue(ComboBoxRarity.Text, out newCustomTitan.Rarity);
            genderOptions.TryGetValue(ComboBoxGender.Text, out newCustomTitan.Gender);

            customTitans.Add(newCustomTitan);

            File.WriteAllText(Paths.CustomTitansMetadata, JsonConvert.SerializeObject(customTitans, Formatting.Indented));

            Cache.Clear();
            Cache.Load();
            Cache.DumpLog();

            Game.GameMaster.Player.Inventory.Add(new SimpleSticker()
            {
                ItemID = newCustomTitan.ID
            });

            App.ClientWindow.SetCurrentPage(new StickerRegister_Finished(StickerNewStricker));
        }