2
0

StartupPreviewForm.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace Optimizer
  12. {
  13. public partial class StartupPreviewForm : Form
  14. {
  15. string _token = string.Empty;
  16. public StartupPreviewForm(List<StartupBackupItem> items)
  17. {
  18. InitializeComponent();
  19. CheckForIllegalCrossThreadCalls = false;
  20. Options.ApplyTheme(this);
  21. foreach (StartupBackupItem x in items)
  22. {
  23. if (File.Exists(SanitizePath(x.FileLocation)))
  24. {
  25. _token = "[✓] ";
  26. }
  27. else
  28. {
  29. _token = "[⚠] ";
  30. }
  31. listPreview.Items.Add(_token + x.Name + " - " + x.FileLocation);
  32. }
  33. }
  34. private void StartupPreviewForm_Load(object sender, EventArgs e)
  35. {
  36. this.Focus();
  37. }
  38. private string SanitizePath(string s)
  39. {
  40. s = s.Replace("\"", string.Empty);
  41. int i;
  42. while (s.Contains("/"))
  43. {
  44. i = s.LastIndexOf("/");
  45. s = s.Substring(0, i);
  46. }
  47. i = s.IndexOf(".exe");
  48. s = s.Substring(0, i + 4);
  49. return s.Trim();
  50. }
  51. }
  52. }