123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Optimizer
- {
- public partial class StartupPreviewForm : Form
- {
- string _token = string.Empty;
- public StartupPreviewForm(List<StartupBackupItem> items)
- {
- InitializeComponent();
- CheckForIllegalCrossThreadCalls = false;
- Options.ApplyTheme(this);
- // translate UI elements
- if (Options.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
- foreach (StartupBackupItem x in items)
- {
- if (File.Exists(SanitizePath(x.FileLocation)))
- {
- _token = "[✓] ";
- }
- else
- {
- _token = "[⚠] ";
- }
- listPreview.Items.Add(_token + x.Name + " - " + x.FileLocation);
- }
- }
- private void Translate()
- {
- this.Text = Options.TranslationList["StartupPreviewForm"];
- Dictionary<string, string> translationList = Options.TranslationList.ToObject<Dictionary<string, string>>();
- Control element;
- foreach (var x in translationList)
- {
- if (x.Key == null || x.Key == string.Empty) continue;
- element = this.Controls.Find(x.Key, true).FirstOrDefault();
- if (element == null) continue;
- element.Text = x.Value;
- }
- }
- private void StartupPreviewForm_Load(object sender, EventArgs e)
- {
- this.Focus();
- }
- private string SanitizePath(string s)
- {
- s = s.Replace("\"", string.Empty);
- int i;
- while (s.Contains("/"))
- {
- i = s.LastIndexOf("/");
- s = s.Substring(0, i);
- }
- i = s.IndexOf(".exe");
- s = s.Substring(0, i + 4);
- return s.Trim();
- }
- }
- }
|