private void SaveButton_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (!(DataContext is ExecutableManager context)) { return; } // Reset error _blockClose = false; if (_executable == null) { _blockClose = true; // show fly out Flyout flyout = FlyoutHelper.CreateFlyout(includeButton: false); flyout.SetFlyoutLabelText(TryFindResource("ExecutableSelectInvalidErrorText") as string); flyout.ShowAt(TargetTextBox); return; } try { _executable.Name = NameTextBox.Text; _executable.TargetPath = TargetTextBox.Text; string locale = LocaleComboBox.SelectedItem as string; if ((LocaleComboBox.SelectedItem as string) == LeagueLocale.Custom.ToString()) { _executable.Locale = LeagueLocale.Custom; _executable.CustomLocale = CustomLocaleTextBox.Text; } else { _executable.Locale = ExeTools.GetLocaleEnum((LocaleComboBox.SelectedItem as string).Split('(', ')')[1]); } if (_isEditMode) { Hide(); } else { context.AddExecutable(_executable); } Hide(); } catch (Exception) { _blockClose = true; // show fly out Flyout flyout = FlyoutHelper.CreateFlyout(includeButton: false); flyout.SetFlyoutLabelText(TryFindResource("ExecutableSaveNullText") as string); flyout.ShowAt(TargetTextBox); } }
private void EditLaunchArgsButton_Click(object sender, RoutedEventArgs e) { if (_executable == null) { // show fly out Flyout flyout = FlyoutHelper.CreateFlyout(includeButton: false); flyout.SetFlyoutLabelText(TryFindResource("ExecutableSelectInvalidErrorText") as string); flyout.ShowAt(EditLaunchArgsButton); return; } Window parent = Window.GetWindow(this); ExecutableLaunchArgsWindow editDialog = new ExecutableLaunchArgsWindow(_executable) { Top = parent.Top + 50, Left = parent.Left + 50, Owner = parent }; editDialog.ShowDialog(); LaunchArgsTextBox.Text = PrettifyLaunchArgs(_executable.LaunchArguments); }
private void TargetButton_Click(object sender, RoutedEventArgs e) { _blockClose = false; string initialDirectory = TargetTextBox.Text; initialDirectory = string.IsNullOrEmpty(initialDirectory) ? Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.System)) : Path.GetDirectoryName(initialDirectory); using (CommonOpenFileDialog folderDialog = new CommonOpenFileDialog()) { folderDialog.Title = TryFindResource("ExecutableSelectDialogText") as string; folderDialog.IsFolderPicker = false; folderDialog.AddToMostRecentlyUsedList = false; folderDialog.AllowNonFileSystemItems = false; folderDialog.EnsureFileExists = true; folderDialog.EnsurePathExists = true; folderDialog.EnsureReadOnly = false; folderDialog.EnsureValidNames = true; folderDialog.Multiselect = false; folderDialog.ShowPlacesList = true; folderDialog.InitialDirectory = initialDirectory; folderDialog.DefaultDirectory = initialDirectory; if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok) { string selectedExe = folderDialog.FileName; if (ExeTools.CheckExecutableFile(selectedExe)) { LeagueExecutable newExe = null; try { newExe = ExeTools.CreateNewLeagueExecutable(selectedExe); try { newExe.Locale = ExeTools.DetectExecutableLocale(selectedExe); } catch (Exception) { newExe.Locale = LeagueLocale.EnglishUS; // do not stop operation } LoadLeagueExecutable(newExe); } catch (Exception) { _blockClose = true; // show fly out Flyout flyout = FlyoutHelper.CreateFlyout(includeButton: false); flyout.SetFlyoutLabelText(TryFindResource("ExecutableSelectInvalidErrorText") as string); flyout.ShowAt(TargetButton); } } else { _blockClose = true; // show fly out Flyout flyout = FlyoutHelper.CreateFlyout(includeButton: false); flyout.SetFlyoutLabelText(TryFindResource("ExecutableSelectInvalidErrorText") as string); flyout.ShowAt(TargetButton); } } } }