Esempio n. 1
0
        private void OnCreateProfile(object sender, RoutedEventArgs e)
        {
            //grab data
            string email    = RegisterEmail.Text;
            string password = RegisterPassword.Text;
            string nickname = RegisterNickname.Text;
            string side     = RegisterSide.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");

            //Create account
            ProfileSettings.AddProfile(email, password);
            //create folder
            int    ID             = ProfileSettings.GetProfile(email, password);
            string path           = laucherSettings.GetServerLocation() + "/data/profiles";
            string charactersJSON = "/character_" + ID + ".json";

            Directory.CreateDirectory(Path.GetDirectoryName(path + charactersJSON));
            //put contents into created files
            Uri charactersDefault = new Uri("pack://application:,,,/Resources/Data/characterDefault.json");

            Tools.SaveFileStream(charactersDefault, path + charactersJSON);
            //edit character and release it
            path = path + charactersJSON;
            ProfileCharacters tempCharacter = new ProfileCharacters(path);

            tempCharacter.ChangeNickname(nickname);
            tempCharacter.ChangeSide(side);
            tempCharacter.SetProfileID(ID);
            tempCharacter = null;//remove temp characters data
            HideAllGrids();
            LoginGrid.Visibility = Visibility.Visible;
        }