private void Form1_Load(object sender, EventArgs e) { Text = "50PSAM"; ga = new GetApps(); listBoxApps.Items.AddRange(ga.GetAppsArray()); ga.ApplicationChanges += Ga_ApplicationChanges; timer1.Interval = settings.RefreshTimerInterval; timer2.Interval = settings.RefreshTimer2Interval * 1000; timer1.Enabled = true; timer2.Enabled = settings.AutoRefresh; tlSpustit.Enabled = false; tlUninstall.Enabled = false; tlUninstallAll.Enabled = (ga.appsCount == 0) ? false : true; hideOnClose = settings.HideOnClosing; tlRefresh.Enabled = !settings.AutoRefresh; for (int index = 0; index < ga.appsCount; index++) { ToolStripItem item = new ToolStripMenuItem(); item.Name = $"item{ga.Apps(index)}"; item.Text = $"Spustit {ga.Apps(index)}"; item.Click += Item_Click; contextMenuStrip1.Items.Add(item); } }
private void RefreshApplication() { if (changed) { tlSpustit.Enabled = false; tlUninstall.Enabled = false; listBoxApps.Items.Clear(); string[] apps = ga.GetAppsArray(); listBoxApps.Items.AddRange(apps); for (int index = 0; index < contextMenuStrip1.Items.Count; index++) { if (contextMenuStrip1.Items[index].Name.StartsWith("item")) { contextMenuStrip1.Items.RemoveAt(index); index = 0; } } if (ga.appsCount != 0) { for (int index = 0; index < ga.appsCount; index++) { ToolStripItem item = new ToolStripMenuItem(); item.Name = $"item{ga.Apps(index)}"; item.Text = $"Spustit {ga.Apps(index)}"; item.Click += Item_Click; contextMenuStrip1.Items.Add(item); } } changed = false; } else { changed = ga.ApplicationChanged(); Console.ForegroundColor = (changed) ? ConsoleColor.Green : ConsoleColor.Red; Console.WriteLine($"Changed: {changed}"); Console.ResetColor(); } //timer2.Enabled = (settings.AutoRefresh) ? true : false; }