private void profilesDropDownBox_SelectedIndexChanged(object sender,
     PositionChangedEventArgs e)
 {
     if (profilesDropDownBox.SelectedItem == null) {
         return;
     }
     _profileManager.LastUsedProfile = profilesDropDownBox.SelectedItem.Text;
     _selectedProfile = _profileManager.Profiles[profilesDropDownBox.SelectedItem.Text];
     string path = Path.Combine(_applicationContext.McVersions,
         _selectedProfile.SelectedVersion ?? GetLatestVersion(_selectedProfile) + "\\");
     string state = _applicationContext.ProgramLocalization.ReadyToLaunch;
     if (!File.Exists(string.Format("{0}/{1}.json", path, _selectedProfile.SelectedVersion ??
                                                          GetLatestVersion(_selectedProfile)))) {
         state = _applicationContext.ProgramLocalization.ReadyToDownload;
     }
     SelectedVersion.Text = string.Format(state, (_selectedProfile.SelectedVersion ??
                                                  GetLatestVersion(_selectedProfile)));
 }
 public MinecraftProcess(Process minecraftProcess, LauncherForm launcherForm, Profile profile)
 {
     _launcherForm = launcherForm;
     _profile = profile;
     _minecraftProcess = minecraftProcess;
 }
 private string GetLatestVersion(Profile profile)
 {
     JObject versionsList = JObject.Parse(File.ReadAllText(_applicationContext.McVersions + "\\versions.json"));
     return profile.AllowedReleaseTypes != null
         ? profile.AllowedReleaseTypes.Contains("snapshot")
             ? versionsList["latest"]["snapshot"].ToString()
             : versionsList["latest"]["release"].ToString()
         : versionsList["latest"]["release"].ToString();
 }
 public ProfileForm(Profile profile, ApplicationContext appContext)
 {
     _applicationContext = appContext;
     CurrentProfile = profile;
     InitializeComponent();
     LoadLocalization();
     if (CurrentProfile.AllowedReleaseTypes != null) {
         foreach (string item in CurrentProfile.AllowedReleaseTypes) {
             switch (item) {
                 case "snapshot":
                     snapshotsCheckBox.Checked = true;
                     break;
                 case "old_beta":
                     betaCheckBox.Checked = true;
                     break;
                 case "old_alpha":
                     alphaCheckBox.Checked = true;
                     break;
                 case "other":
                     otherCheckBox.Checked = true;
                     break;
                 case "forge":
                     forgeCheckBox.Checked = true;
                     goto case "modified";
                 case "liteloader":
                     liteCheckBox.Checked = true;
                     goto case "modified";
                 case "optifine":
                     optifineCheckBox.Checked = true;
                     goto case "modified";
                 case "combined":
                     combinedCheckBox.Checked = true;
                     goto case "modified";
                 case "modified":
                     VersionSelector.SelectedPage = modVersionsPage;
                     break;
             }
         }
     }
     GetVersions();
     nameBox.Text = CurrentProfile.ProfileName;
     if (CurrentProfile.WorkingDirectory != null) {
         GameDirectoryCheckBox.Checked = true;
         gameDirectoryBox.Text = CurrentProfile.WorkingDirectory;
     } else {
         gameDirectoryBox.Text = _applicationContext.McDirectory;
     }
     if (CurrentProfile.WindowSize != null) {
         xResolutionBox.Text = CurrentProfile.WindowSize.X.ToString();
         yResolutionBox.Text = CurrentProfile.WindowSize.Y.ToString();
     }
     if (CurrentProfile.FastConnectionSettigs != null) {
         FastConnectCheckBox.Checked = true;
         ipTextBox.Text = CurrentProfile.FastConnectionSettigs.ServerIP;
         portTextBox.Text = CurrentProfile.FastConnectionSettigs.ServerPort.ToString();
     }
     switch (CurrentProfile.LauncherVisibilityOnGameClose) {
         case Profile.LauncherVisibility.HIDDEN:
             stateBox.SelectedIndex = 1;
             break;
         case Profile.LauncherVisibility.CLOSED:
             stateBox.SelectedIndex = 2;
             break;
         default:
             stateBox.SelectedIndex = 0;
             break;
     }
     if (Java.JavaExecutable == "\\bin\\java.exe") {
         RadMessageBox.Show(this, _applicationContext.ProgramLocalization.JavaDetectionFailed,
             _applicationContext.ProgramLocalization.Error, MessageBoxButtons.OK, RadMessageIcon.Error);
     }
     javaExecutableBox.Text = CurrentProfile.JavaExecutable ?? Java.JavaExecutable;
     JavaExecutableCheckBox.Checked = javaExecutableBox.Text != Java.JavaExecutable;
     javaArgumentsBox.Text = CurrentProfile.JavaArguments ?? "-Xmx1G";
     JavaArgumentsCheckBox.Checked = javaArgumentsBox.Text != "-Xmx1G";
 }
 /// <summary>
 /// Переименование профиля в списке.
 /// </summary>
 /// <param name="profile">Профиль для переименования.</param>
 /// <param name="newName">Новое название профиля.</param>
 public void RenameProfile(Profile profile, string newName)
 {
     if (LastUsedProfile == profile.ProfileName) {
         LastUsedProfile = newName;
     }
     Profiles.Remove(profile.ProfileName);
     profile.ProfileName = newName;
     Profiles[newName] = profile;
 }
 /// <summary>
 /// Удаление профиля из списка.
 /// </summary>
 /// <param name="profile">Удаляемый профиль.</param>
 public void DeleteProfile(Profile profile)
 {
     if (string.IsNullOrWhiteSpace(profile.ProfileName)) {
         throw new Exception("Field 'ProfileName' couldn't be empty");
     }
     Profiles.Remove(profile.ProfileName);
 }
 /// <summary>
 /// Добавление профиля в список.
 /// </summary>
 /// <param name="profile">Добавляемый профиль.</param>
 public void AddProfile(Profile profile)
 {
     if (string.IsNullOrWhiteSpace(profile.ProfileName)) {
         throw new Exception("Field 'ProfileName' couldn't be empty");
     }
     if (Profiles.Keys.Contains(profile.ProfileName)) {
         throw new Exception("Profile '" + profile.ProfileName + "' already exist in list.");
     }
     Profiles.Add(profile.ProfileName, profile);
 }