Skip to content

Commit b105fca

Browse files
committedDec 6, 2024·
add Delete key to remove project from Recent projects list (with confirmation dialog)
1 parent f6095c4 commit b105fca

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed
 

‎UnityLauncherPro/GetProjects.cs

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
117117
//Console.WriteLine("Trimming projects list to " + MainWindow.maxProjectCount + " projects");
118118
projectsFound.RemoveRange(MainWindow.maxProjectCount, projectsFound.Count - MainWindow.maxProjectCount);
119119
}
120-
121120
return projectsFound;
122121
} // Scan()
123122

‎UnityLauncherPro/MainWindow.xaml.cs

+33-18
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,35 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
10681068

10691069
}
10701070

1071+
private void RemoveProjectFromList(bool confirm = false)
1072+
{
1073+
var proj = GetSelectedProject();
1074+
if (proj == null) return;
1075+
1076+
if (confirm == true)
1077+
{
1078+
// streamer mode, show first char and last 3 chars, rest as *
1079+
var cleantitle = proj.Title[0] + new string('*', proj.Title.Length - 1);
1080+
var title = chkStreamerMode.IsChecked == true ? cleantitle : proj.Title;
1081+
var result = MessageBox.Show("Are you sure you want to remove project from list?\n\n" + title, "Remove project", MessageBoxButton.YesNo, MessageBoxImage.Question);
1082+
if (result == MessageBoxResult.No) return;
1083+
}
1084+
1085+
if (GetProjects.RemoveRecentProject(proj.Path))
1086+
{
1087+
RefreshRecentProjects();
1088+
}
1089+
else
1090+
{
1091+
// we had added this project manually, without opening yet, just remove item
1092+
projectsSource.Remove(proj);
1093+
gridRecent.Items.Refresh();
1094+
Tools.SetFocusToGrid(gridRecent);
1095+
gridRecent.SelectedIndex = 0;
1096+
}
1097+
1098+
}
1099+
10711100
private async void OnTabSelectionChanged(object sender, SelectionChangedEventArgs e)
10721101
{
10731102
// if going into updates tab, fetch list (first time only)
@@ -1378,6 +1407,7 @@ private void GridRecent_PreviewKeyDown(object sender, KeyEventArgs e)
13781407
// // if edit mode, dont override keys
13791408
if (IsEditingCell(gridRecent) == true) return;
13801409
e.Handled = true;
1410+
RemoveProjectFromList(confirm: true);
13811411
// MenuRemoveProject_Click(null, null);
13821412
break;
13831413
default:
@@ -3020,22 +3050,7 @@ private void BtnThemeEditor_Click(object sender, RoutedEventArgs e)
30203050

30213051
private void MenuRemoveProject_Click(object sender, RoutedEventArgs e)
30223052
{
3023-
// delete if enabled in settings
3024-
var proj = GetSelectedProject();
3025-
if (proj == null) return;
3026-
3027-
if (GetProjects.RemoveRecentProject(proj.Path))
3028-
{
3029-
RefreshRecentProjects();
3030-
}
3031-
else
3032-
{
3033-
// we had added this project manually, without opening yet, just remove item
3034-
projectsSource.Remove(proj);
3035-
gridRecent.Items.Refresh();
3036-
Tools.SetFocusToGrid(gridRecent);
3037-
gridRecent.SelectedIndex = 0;
3038-
}
3053+
RemoveProjectFromList();
30393054
}
30403055

30413056
private void MenuItemDownloadAndroidModule_Click(object sender, RoutedEventArgs e)
@@ -3394,7 +3409,7 @@ private void Window_MouseDown(object sender, MouseButtonEventArgs e)
33943409

33953410
public void SetStatus(string msg, MessageType messageType = MessageType.Info)
33963411
{
3397-
Console.WriteLine(messageType);
3412+
//Console.WriteLine(messageType);
33983413
switch (messageType)
33993414
{
34003415
case MessageType.Info:
@@ -3772,7 +3787,7 @@ private void OnPipeConnection(IAsyncResult result)
37723787
private void CheckCustomIcon()
37733788
{
37743789
string customIconPath = Path.Combine(Environment.CurrentDirectory, "icon.ico");
3775-
Console.WriteLine(customIconPath);
3790+
//Console.WriteLine(customIconPath);
37763791

37773792
if (File.Exists(customIconPath))
37783793
{

0 commit comments

Comments
 (0)
Please sign in to comment.