Skip to content

Commit

Permalink
add Delete key to remove project from Recent projects list (with conf…
Browse files Browse the repository at this point in the history
…irmation dialog)
  • Loading branch information
unitycoder committed Dec 6, 2024
1 parent f6095c4 commit b105fca
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
1 change: 0 additions & 1 deletion UnityLauncherPro/GetProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public static List<Project> Scan(bool getGitBranch = false, bool getPlasticBranc
//Console.WriteLine("Trimming projects list to " + MainWindow.maxProjectCount + " projects");
projectsFound.RemoveRange(MainWindow.maxProjectCount, projectsFound.Count - MainWindow.maxProjectCount);
}

return projectsFound;
} // Scan()

Expand Down
51 changes: 33 additions & 18 deletions UnityLauncherPro/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,35 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)

}

private void RemoveProjectFromList(bool confirm = false)
{
var proj = GetSelectedProject();
if (proj == null) return;

if (confirm == true)
{
// streamer mode, show first char and last 3 chars, rest as *
var cleantitle = proj.Title[0] + new string('*', proj.Title.Length - 1);
var title = chkStreamerMode.IsChecked == true ? cleantitle : proj.Title;
var result = MessageBox.Show("Are you sure you want to remove project from list?\n\n" + title, "Remove project", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No) return;
}

if (GetProjects.RemoveRecentProject(proj.Path))
{
RefreshRecentProjects();
}
else
{
// we had added this project manually, without opening yet, just remove item
projectsSource.Remove(proj);
gridRecent.Items.Refresh();
Tools.SetFocusToGrid(gridRecent);
gridRecent.SelectedIndex = 0;
}

}

private async void OnTabSelectionChanged(object sender, SelectionChangedEventArgs e)
{
// if going into updates tab, fetch list (first time only)
Expand Down Expand Up @@ -1378,6 +1407,7 @@ private void GridRecent_PreviewKeyDown(object sender, KeyEventArgs e)
// // if edit mode, dont override keys
if (IsEditingCell(gridRecent) == true) return;
e.Handled = true;
RemoveProjectFromList(confirm: true);
// MenuRemoveProject_Click(null, null);
break;
default:
Expand Down Expand Up @@ -3020,22 +3050,7 @@ private void BtnThemeEditor_Click(object sender, RoutedEventArgs e)

private void MenuRemoveProject_Click(object sender, RoutedEventArgs e)
{
// delete if enabled in settings
var proj = GetSelectedProject();
if (proj == null) return;

if (GetProjects.RemoveRecentProject(proj.Path))
{
RefreshRecentProjects();
}
else
{
// we had added this project manually, without opening yet, just remove item
projectsSource.Remove(proj);
gridRecent.Items.Refresh();
Tools.SetFocusToGrid(gridRecent);
gridRecent.SelectedIndex = 0;
}
RemoveProjectFromList();
}

private void MenuItemDownloadAndroidModule_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -3394,7 +3409,7 @@ private void Window_MouseDown(object sender, MouseButtonEventArgs e)

public void SetStatus(string msg, MessageType messageType = MessageType.Info)
{
Console.WriteLine(messageType);
//Console.WriteLine(messageType);
switch (messageType)
{
case MessageType.Info:
Expand Down Expand Up @@ -3772,7 +3787,7 @@ private void OnPipeConnection(IAsyncResult result)
private void CheckCustomIcon()
{
string customIconPath = Path.Combine(Environment.CurrentDirectory, "icon.ico");
Console.WriteLine(customIconPath);
//Console.WriteLine(customIconPath);

if (File.Exists(customIconPath))
{
Expand Down

0 comments on commit b105fca

Please sign in to comment.