示例#1
0
        public void Setup()
        {
            try
            {
                devices = DevicesJson.GetDevices();

                if (devices.Count <= 0)
                {
                    MessageBox.Show("There are no devices added, please run the configurator to add devices.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(-1);
                }

                Settings settings = new Settings();

                lastTick = PNP.GetPNPDevices();

                timer  = new System.Threading.Timer(OnTick, null, 0, settings.RefreshRate);
                offset = settings.Offset;

                settings.Dispose();

                TrayService.Visible = true;
            }
            catch (Exception e)
            {
                Logger.Log("An error occured trying to setup the tray service", e);
                MessageBox.Show("An error occured trying to setup the tray service", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        public App()
        {
            Exception exLog = Logger.CreateLog("AirPodsUI Settings");

            if (exLog != null)
            {
                MessageBox.Show("Unable to create logging component. Logging will be unavailable.\n\n" + exLog.Message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            Logger.Log(LogType.Information, "Created logger!");

            try
            {
                NavPages = new Dictionary <string, Type>();
                Devices  = new List <Device>();
                Devices  = DevicesJson.GetDevices();
                OnDevicesChanged?.Invoke(this, new EventArgs());
            }
            catch (Exception e)
            {
                Logger.Log(LogType.Error, "Unable to get devices!", e);
                MessageBox.Show("There was an error trying to get the devices. Please see the log for more details. Shutting down.\n\n" + Logger.LogFile, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Shutdown();
            }
        }
示例#3
0
        public void Refresh()
        {
            busy    = true;
            devices = DevicesJson.GetDevices();
            if (devices.Count <= 0)
            {
                MessageBox.Show("There are no devices added, please run the configurator to add devices.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }

            Settings settings = new Settings();

            lastTick = PNP.GetPNPDevices();

            offset = settings.Offset;

            settings.Dispose();
            busy = false;
        }