Ejemplo n.º 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            using (var control = new PlayerControllerService())
            {
                control.Player.OnAboutToPromptUserToQuitEvent += Application.Exit;

                // Hotkey service
                using (var hotkeyService = new HotkeyService())
                {
                    control.RegisterHotkeyService(hotkeyService);

                    var selectSongVisualService = new VisualService
                    {
                        Form = new SelectSongForm(control.Player),
                        MenuEntry = "&Select song"
                    };
                    hotkeyService.RegisterHotKey("SelectSong",
                        (o, e) => selectSongVisualService.Activate());

                    // Tray service
                    using (var trayService = new TrayService(new[] { selectSongVisualService,
                        new VisualService {
                            Form = new MainForm(control),
                            MenuEntry = "Show &MiniPlayer"
                        },
                        new VisualService {
                            Form = new SettingsForm(),
                            MenuEntry = "S&ettings"
                        }
                    }))
                    {
                        control.RegisterNotificationService(trayService);
                        using (new OSDService(control))
                        {
                            Application.Run();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public TrayService(VisualService[] visualServices)
 {
     _icon = new NotifyIcon {
         Icon = new Icon(GetType(), "Main.ico"),
         ContextMenu = new ContextMenu(
             visualServices
                 .Select(service => new MenuItem(service.MenuEntry, (o,e) => service.Activate()))
                 .Concat(new[] {
                     new MenuItem("-"),
                     new MenuItem("E&xit", (o,e) => Application.Exit())
                 }).ToArray()
             ),
         Text = "iTunes",
         Visible = true
     };
     if (visualServices.Length > 0)
     {
         _icon.ContextMenu.MenuItems.OfType<MenuItem>().First().DefaultItem = true;
         Action a = visualServices.First().Activate;
         _icon.DoubleClick += (o, e) => a();
     }
     _services = visualServices;
     Application.ApplicationExit += ApplicationExit;
 }