private void CreateStartItem(AppStartItem item, int imageIdx) { if (item.Category == null) { item.Category = "(no category)"; } var catNode = CategoryNodes.FirstOrDefault(c => c.Text == item.Category); if (catNode != null) { var starterNode = new TreeNode { Text = item.Text, ImageIndex = imageIdx, SelectedImageIndex = imageIdx, ToolTipText = item.Path }; if (imageIdx == 0) { starterNode.ForeColor = Color.Red; } catNode.Nodes.Add(starterNode); } else { throw new NoNullAllowedException(); } }
private void StartItem() { if (startBlocked) { return; } AppStartItem appStartItem = null; try { var selectedNode = treeView1.SelectedNode; if (selectedNode != null && selectedNode.Nodes.Count == 0 && selectedNode.ForeColor != Color.Red) { Console.WriteLine($"StartItem({selectedNode.Text})"); appStartItem = Data.Items.FirstOrDefault(i => i.Text == selectedNode.Text); if (appStartItem != null) { HideApp(); var startInfo = new ProcessStartInfo() { FileName = appStartItem.Path, Arguments = appStartItem.Arguments, UseShellExecute = false, CreateNoWindow = false }; Process.Start(startInfo); //Process.Start($"{appStartItem.Path} {startInfo}"); } } } catch (Exception ex) { var msg = $"Start-Pfad:{Environment.NewLine}" + $" {appStartItem.Path}{Environment.NewLine}" + $"Fehler:{Environment.NewLine}" + $" {ex.Message}"; MessageBox.Show(this, msg, "FEHLER beim Starten", MessageBoxButtons.OK, MessageBoxIcon.Error); } }