Esempio n. 1
0
 private void SwitchOptionClick(object sender, EventArgs e)
 {
     using (var dialog = new SwitchOptions())
         dialog.ShowDialog();
 }
Esempio n. 2
0
        private async Task Loop()
        {
            var       reload_count = 0;
            const int reload       = 75;
            var       Options      = SwitchOptions.LoadOptions();

            Options.TryGetValue("0", out Keys[] M1);
            Options.TryGetValue("1", out Keys[] M2);
            Options.TryGetValue("2", out Keys[] M3);
            while (!Token.IsCancellationRequested)
            {
                if (reload_count >= reload)
                {
                    reload_count = 0;
                    Options      = SwitchOptions.LoadOptions();
                    Options.TryGetValue("0", out M1);
                    Options.TryGetValue("1", out M2);
                    Options.TryGetValue("2", out M3);
                }

                bool s = false;
                if (IsKeysDown(M1))
                {
                    NUMC.Service.GetService()?.Start();
                    await Task.Delay(100);
                }
                else if (IsKeysDown(M2))
                {
                    NUMC.Service.GetService()?.Pause();
                    await Task.Delay(100);
                }
                else if (IsKeysDown(M3))
                {
                    var setvice = NUMC.Service.GetService();
                    var state   = setvice?.State;
                    Debug.WriteLine(state);
                    if (state == NUMC.Service.StateCode.Paused)
                    {
                        setvice?.Start();
                    }
                    else if (state == NUMC.Service.StateCode.Running)
                    {
                        setvice?.Pause();
                    }
                    await Task.Delay(100);
                }
                else
                {
                    s = true;
                }

                if (!s)
                {
                    SaveState(NUMC.Service.GetService()?.State
                              ?? NUMC.Service.StateCode.Running);
                }

                reload_count++;
                await Task.Delay(20);
            }
        }