Пример #1
0
        private void FetchSpotifyWeb()
        {
            SongFetcher sf   = new SongFetcher();
            TrackInfo   info = sf.FetchSpotifyWeb();

            if (info != null)
            {
                if (!info.isPlaying)
                {
                    if (Settings.CustomPauseTextEnabled)
                    {
                        WriteSong("", "", "");
                    }
                    return;
                }

                string albumUrl = null;

                if (info.albums.Count != 0)
                {
                    albumUrl = info.albums[0].Url;
                }

                if (info.DurationMS > 2000)
                {
                    if (!_songTimer.Enabled)
                    {
                        _songTimer.Enabled = true;
                    }
                    _songTimer.Stop();
                    _songTimer.Interval = info.DurationMS + 400;
                    _songTimer.Start();
                }

                WriteSong(info.Artists, info.Title, "", albumUrl, false, info.SongID, info.url);
            }
            else
            {
                if (!_songTimer.Enabled)
                {
                    _songTimer.Enabled = true;
                }
                _songTimer.Stop();
                _songTimer.Interval = 1000;
                _songTimer.Start();
            }
        }
Пример #2
0
        private System.Timers.Timer GameCountdown(PlayerInfo user)
        {
            // Create a timer and set a two second interval.
            var countDown = new System.Timers.Timer();

            countDown.Interval = StartGameTimer;
            countDown.Elapsed += (sender, e) => GameStarted(sender, e, user, countDown);
            countDown.Start();
            return(countDown);
        }
Пример #3
0
        public void Start()
        {
            if (_timer == null)
            {
                _timer          = new System.Timers.Timer(_timeMs);
                _timer.Elapsed += TimerOnElapsed;
            }

            _timer.Start();
        }
Пример #4
0
        static void Main(string[] args)
        {
            var timer = new System.Timers.Timer();

            timer.Elapsed += OnTimedEvent;
            timer.Interval = 10000;
            timer.Start();
            //timer.Enabled = true;
            Console.ReadLine();
        }
Пример #5
0
        static public void ScheduleTask(TimeSpan TimeSpan, Action action)
        {
            var timer = new System.Timers.Timer(TimeSpan.TotalMilliseconds);

            timer.Elapsed += (sender, args) =>
            {
                timer.Stop();
                action();
            };
            timer.Start();
        }
Пример #6
0
        public void Authenticate()
        {
            Licensing.User user = new Licensing.User();
            user.hWID      = Program.fingerprint;
            user.timeStamp = DateTime.Now;

            try
            {
                var res    = CheckLicense(user).GetAwaiter().GetResult();
                var aTimer = new System.Timers.Timer(6 * 1000); //one hour in milliseconds
                aTimer.Enabled = true;

                if (res.status)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        label2.Text = res.expirationDate.ToString();
                        Bot.Log("License valid until: " + res.expirationDate);
                        DownloadFiles();
                    });
                    aTimer.Elapsed += new ElapsedEventHandler((sender, e) => OnTimedEvent(sender, e, res.expirationDate));
                    aTimer.Start();
                }
                else
                {
                    try
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            buttonStart.Invoke((MethodInvoker)(() =>
                            {
                                buttonStart.Enabled = false;
                            }));
                            Bot.Log(
                                "You don't have a valid license to use the bot! " +
                                "Please contact on the Discord server for more information.");
                        });
                    }
                    catch
                    {
                        Application.Exit();
                    }
                }
            }
            catch (Exception ex)
            {
                buttonStart.Invoke((MethodInvoker)(() =>
                {
                    buttonStart.Enabled = false;
                }));
                ShowErrorAndClose(ex.Message);
            }
        }
Пример #7
0
        /// <inheritdoc />
        public TorchServer(TorchConfig config) : base(config)
        {
            DedicatedInstance = new InstanceManager(this);
            AddManager(DedicatedInstance);
            AddManager(new EntityControlManager(this));
            AddManager(new RemoteAPIManager(this));

            var sessionManager = Managers.GetManager <ITorchSessionManager>();

            sessionManager.AddFactory(x => new MultiplayerManagerDedicated(this));

            // Needs to be done at some point after MyVRageWindows.Init
            // where the debug listeners are registered
            if (!((TorchConfig)Config).EnableAsserts)
            {
                MyDebug.Listeners.Clear();
            }
            _simUpdateTimer.Elapsed += SimUpdateElapsed;
            _simUpdateTimer.Start();
        }
Пример #8
0
        static public void Run()
        {
            //setup
            Moveables      = new List <IMoveable>();
            BeginEndPoints = new List <Node>();
            listOfNodes    = new List <Node>();
            pedestrians    = new List <Pedestrian>();
            GetNodes();
            FillEndPoints();
            AssignPoints();


            CreatePedestrians();
            _pedestrianTimer.Elapsed += TimedPedestriansEvent;
            _pedestrianTimer.Interval = 150;
            _pedestrianTimer.Start();

            while (!ShouldStop)
            {
                CreateMovables();
                MoveMoveables();
                Refresh();
            }
            try
            {
                Moveables.Clear();
                _pedestrianTimer.Stop();
                foreach (Crossroad cross in grid.Controls)
                {
                    cross.KillTrafficTimer();
                }
                f1.Invoke((MethodInvoker) delegate {
                    f1.stopRunning();
                });
                f1.Invoke((MethodInvoker) delegate { Refresh(); });
            }
            catch (Exception)
            {
            }
        }
Пример #9
0
        private void Main_Load(object sender, EventArgs e)
        {
            treeView1.MouseDown += new MouseEventHandler(treeView1_MouseDown);

            loadTree();


            startHttpService();
            MailService();

            var timer = new System.Timers.Timer {
                Interval = 10000
            };                                                        //Interval = 30 * 60000

            timer.Elapsed += startWarningService;

            timer.Start();


            updateDataPackagesGrid();
            updateAlarmPackageGrid();
        }
Пример #10
0
        private void ButtonStart_Click(object sender, EventArgs e)
        {
            double restartInterval = (double)numericUpDownRestart.Value * 60 * 60 * 3600;

            System.Timers.Timer restartTimer = new System.Timers.Timer(restartInterval);
            if (fakeMove == null)
            {
                fakeMove = new System.Timers.Timer(6 * 1000); //one hour in millisecond
            }
            restartTimer.Elapsed += RestartTimer_Elapsed;

            if (buttonStart.Text == "Start")
            {
                if (!Client.ready)
                {
                    Bot.Log("Please wait until game loads.");
                    return;
                }

                Client.manuelStart = true;
                if (restartInterval > 0)
                {
                    restartTimer.Start();
                }
                BootstrapClient();
            }
            else if (buttonStart.Text == "Stop")
            {
                restartTimer.Stop();
                restartTimer.Close();
                buttonStart.Text = "Start";
                browser.Reload();
                Client.collecting  = false;
                Client.manuelStart = false;
            }
        }
Пример #11
0
    public override void ResetTimers()
    {
        if (AutoChecksAllowed == false)
        {
            return;
        }

        discoveryTimer.Stop();
        heartbeatTimer.Stop();
        ResettingTimers = true;

        Task.Delay((int)Id * Constants.ONE_MINUTE_IN_MILLISECONDS / Constants.TimeScale).ContinueWith(delegate
        {
            discoveryTimer.Interval = Constants.NODES_PER_CYCLE * Constants.ONE_MINUTE_IN_MILLISECONDS / Constants.TimeScale;
            discoveryTimer.Start();
        });

        Task.Delay((int)Id * Constants.ONE_MINUTE_IN_MILLISECONDS / Constants.TimeScale).ContinueWith(delegate
        {
            heartbeatTimer.Interval = Constants.NODES_PER_CYCLE * Constants.ONE_MINUTE_IN_MILLISECONDS / Constants.TimeScale;
            heartbeatTimer.Start();
            ResettingTimers = false;
        });
    }
Пример #12
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     _begin = DateTime.Now;
     _timer.Start();
 }
Пример #13
0
        private async void BootstrapClient()
        {
            string lines = "";

#if DEBUG
            // === Replacement for Logic.js ===
            lines = File.ReadAllText(@"C:\Users\Abdullah\Desktop\ArColWeb\src\public\source\client_c.bin");
#else
            lines = Client.scriptCode;
#endif
            var    decText        = StringCipher.Decrypt(lines, "enjoylowlife");
            int    quantity       = 10000;
            string cannonBallType = "_id.cannonballDivisional";
            string pirateType     = "Juliette";
            metroComboBoxQuantity.Invoke((MethodInvoker)(() =>
            {
                quantity = Convert.ToInt32(metroComboBoxQuantity.Text);
            }));
            metroComboBoxCbType.Invoke((MethodInvoker)(() =>
            {
                cannonBallType = metroComboBoxCbType.Text;
                switch (cannonBallType)
                {
                case "Divisional":
                    cannonBallType = "_id.cannonballDivisional";
                    break;

                case "Hollow":
                    cannonBallType = "_id.cannonballHollow";
                    break;

                case "Stone":
                    cannonBallType = "_id.cannonballStone";
                    break;

                case "Slime":
                    cannonBallType = "_id.cannonballSlime";
                    break;

                default:
                    cannonBallType = "_id.cannonballHollow";
                    break;
                }
            }));
            metroComboBoxEquipPirates.Invoke((MethodInvoker)(() =>
            {
                pirateType = metroComboBoxEquipPirates.Text;
            }));
            await browser.EvaluateScriptAsync("let shootObj=[];" +
                                              "bs = {" +
                                              "   cb:false," +
                                              "   sa:false," +
                                              "   buyCannonball:{}," +
                                              "   equipPirates:{}," +
                                              "   sn:false," +
                                              "   ai:false," +
                                              "   onlyFullHp:" +
                                              "   false," +
                                              "   repLimit:50" +
                                              "}");

            if (collectboxcheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.cb=true;");
            }
            if (shootmonstercheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.sa=true;");
            }
            if (shootnpccheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.sn=true;");
            }
            if (avoidislandcheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.ai=true;");
            }
            if (checkBoxShootBack.Checked)
            {
                await browser.EvaluateScriptAsync("bs.shootBack=true;");
            }
            if (checkBoxEquipSails.Checked)
            {
                await browser.EvaluateScriptAsync("bs.equipSails=true;");
            }
            if (checkboxShootOnlyFullHp.Checked)
            {
                await browser.EvaluateScriptAsync("bs.onlyFullHp=true;");
            }
            if (checkBoxBuyCannonballs.Checked)
            {
                await browser.EvaluateScriptAsync("bs.buyCannonball.active=true;" +
                                                  "bs.buyCannonball.type=" + cannonBallType + ";" +
                                                  "bs.buyCannonball.quantity= " + quantity + ";" +
                                                  "bs.buyCannonball.ifBelow= " + numericUpDownIfBelow.Value + ";");
            }
            if (metroCheckBoxEquipPirates.Checked)
            {
                await browser.EvaluateScriptAsync("bs.equipPirates.active=true;" +
                                                  "bs.equipPirates.type=" + pirateType + ";");
            }
            await browser.EvaluateScriptAsync("bs.repLimit=" + numericUpDown1.Value + ";");

            if (collectboxcheckbox.Checked || shootnpccheckbox.Checked || shootmonstercheckbox.Checked)
            {
                await browser.EvaluateScriptAsync(decText); // change this !!!

                if (listBox1.Items.Count > 0)
                {
                    foreach (var item in listBox1.Items)
                    {
                        await browser.EvaluateScriptAsync("shootObj.push(\"" + item + "\");")
                        .ContinueWith(t =>
                        {
                            if (!t.IsFaulted)
                            {
                                var response = t.Result;
                                Bot.Log(response.Message);
                            }
                        });
                    }
                }

                Client.sessionStartTime = DateTime.Now;
                Client.running          = true;
                buttonStart.Text        = "Stop";
                Bot.Log("Bot started.");
            }
            else
            {
                Bot.Log("Check at least one checkbox to perform tasks!");
            }
            if (fakeMove.Enabled != true)
            {
                fakeMove.Enabled  = true;
                fakeMove.Elapsed += FakeMove_Elapsed;
                fakeMove.Start();
            }
        }