示例#1
0
        public ServiceTray()
        {
            icon = new NotifyIcon()
            {
                Icon             = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location),
                ContextMenuStrip = new ContextMenuStrip()
                {
                    Visible = true
                },
                Visible = true
            };
            icon.ContextMenuStrip.Items.Add("Exit", null, (sender, e) => Exit());
            icon.ContextMenuStrip.Items.Add("Open Configurator", null, (sender, e) => OpenConfigurator());
            icon.ShowBalloonTip(5000, "Welcome", "Welcome to AirPodsUI, to exit, click on the system tray icon.", ToolTipIcon.Info);

            json = PairedDevicesJson.FromJson(File.ReadAllText(Helper.PairedDevicesFile));

            Setup();

            newU = DeviceSearcher.Search();
            old  = DeviceSearcher.Search();

            timer          = new Timer();
            timer.Interval = 500;
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
示例#2
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            newU = DeviceSearcher.Search();

            var newList = newU.Except(old, new USBComparer()).ToList();

            if (newList.Count > 0)
            {
                for (int i = 0; i < json.Devices.Count; i++)
                {
                    if (json.Devices[i].DeviceAddress == newList[0].DeviceID)
                    {
                        Launch(json.Devices[i].TemplateLocation, json.Devices[i].DeviceName);
                        break;
                    }
                }
            }

            old = Copy(newU);
        }