Пример #1
0
        public Points_Editor()
        {
            this.InitializeComponent();
            serialPort = ManipulatorSerialPort.Instance;

            pbCanal_A.Minimum = Point.MinPoint.CanA;
            pbCanal_A.Maximum = Point.MaxPoint.CanA;
            pbCanal_B.Minimum = Point.MinPoint.CanB;
            pbCanal_B.Maximum = Point.MaxPoint.CanB;
            pbCanal_C.Minimum = Point.MinPoint.CanC;
            pbCanal_C.Maximum = Point.MaxPoint.CanC;
            pbCanal_D.Minimum = Point.MinPoint.CanD;
            pbCanal_D.Maximum = Point.MaxPoint.CanD;
            pbCanal_E.Minimum = Point.MinPoint.CanE;
            pbCanal_E.Maximum = Point.MaxPoint.CanE;
            pbCanal_F.Minimum = Point.MinPoint.CanF;
            pbCanal_F.Maximum = Point.MaxPoint.CanF;
            EditorUpdate();

            loopTimer          = new System.Timers.Timer();
            loopTimer.Interval = 500;
            loopTimer.Enabled  = false;
            ///  loopTimer.Elapsed += loopTimerEvent;
            loopTimer.AutoReset = true;
            //form button
        }
Пример #2
0
        public UiProgressWindow(string title)
        {
            #region Construct

            Height = 72;
            Width  = 320;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            WindowStyle           = WindowStyle.None;

            UiGrid root = UiGridFactory.Create(3, 1);
            root.SetRowsHeight(GridLength.Auto);
            root.Margin = new Thickness(5);

            UiTextBlock titleTextBlock = UiTextBlockFactory.Create(title);
            {
                titleTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                titleTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                root.AddUiElement(titleTextBlock, 0, 0);
            }

            _progressBar = UiProgressBarFactory.Create();
            {
                root.AddUiElement(_progressBar, 1, 0);
            }

            _progressTextBlock = UiTextBlockFactory.Create("100%");
            {
                _progressTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                _progressTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                root.AddUiElement(_progressTextBlock, 1, 0);
            }

            _elapsedTextBlock = UiTextBlockFactory.Create(Lang.Measurement.Elapsed + ": 00:00");
            {
                _elapsedTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
                root.AddUiElement(_elapsedTextBlock, 2, 0);
            }

            _processedTextBlock = UiTextBlockFactory.Create("0 / 0");
            {
                _processedTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                root.AddUiElement(_processedTextBlock, 2, 0);
            }

            _remainingTextBlock = UiTextBlockFactory.Create(Lang.Measurement.Remaining + ": 00:00");
            {
                _remainingTextBlock.HorizontalAlignment = HorizontalAlignment.Right;
                root.AddUiElement(_remainingTextBlock, 2, 0);
            }

            Content = root;

            #endregion

            Loaded  += OnLoaded;
            Closing += OnClosing;

            _timer          = new System.Timers.Timer(500);
            _timer.Elapsed += OnTimer;
        }
Пример #3
0
 private void GameStarted(object sender, ElapsedEventArgs e, PlayerInfo user, System.Timers.Timer countDown)
 {
     countDown.Stop();
     countDown.Dispose();
     startGame(user);
     Clients.Group(user.GroupId).gameIsStarting(user.GroupId);
 }
Пример #4
0
 private void startTimerToPrintMemoryStat()
 {
     aTimer          = new System.Timers.Timer();
     aTimer.Elapsed += new ElapsedEventHandler(printMemoryUsage);
     //.5 Minutes
     aTimer.Interval = 30000;
     aTimer.Enabled  = true;
 }
Пример #5
0
 private void startTimerToPrintMemoryStat()
 {
     aTimer          = new System.Timers.Timer();
     aTimer.Elapsed += new ElapsedEventHandler(printMemoryUsage);
     // Set the Interval to 5 seconds.
     aTimer.Interval = 120000;
     aTimer.Enabled  = true;
 }
 public SplashScreen()
 {
     Task<int> result = BindBranding();
     InitializeComponent();
     InsertDbBranding();
     _timer = new System.Timers.Timer {Interval = _timeSpec};
     _timer.Elapsed += OnTimedEvent;
     _timer.AutoReset = true;
 }
Пример #7
0
        public void Start()
        {
            if (_timer == null)
            {
                _timer          = new System.Timers.Timer(_timeMs);
                _timer.Elapsed += TimerOnElapsed;
            }

            _timer.Start();
        }
Пример #8
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();
        }
Пример #9
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);
        }
Пример #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        protected SimpleSocketClient() : base()
        {
            KeepAliveTimer           = new System.Timers.Timer(15000);
            KeepAliveTimer.Elapsed  += KeepAlive;
            KeepAliveTimer.AutoReset = true;
            KeepAliveTimer.Enabled   = false;


            SendBasicAuthMessage();
        }
Пример #11
0
        public void Stop()
        {
            if (_timer == null)
            {
                return;
            }

            _timer.Stop();
            _timer.Elapsed -= TimerOnElapsed;
            _timer          = null;
        }
Пример #12
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();
        }
Пример #13
0
        public SplashScreen()
        {
            Task <int> result = BindBranding();

            InitializeComponent();
            InsertDbBranding();
            _timer = new System.Timers.Timer {
                Interval = _timeSpec
            };
            _timer.Elapsed  += OnTimedEvent;
            _timer.AutoReset = true;
        }
Пример #14
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);
            }
        }
Пример #15
0
    public Node(uint?ID, Vector3 position)
    {
        this.Id  = ID;
        State    = Node.NodeState.PASSIVE;
        Position = position;
        Active   = true;
        GenerateRouter();
        MainThread();

        heartbeatTimer = new System.Timers.Timer();
        discoveryTimer = new System.Timers.Timer();
    }
Пример #16
0
        private void RemoveLife(object sender, EventArgs e)
        {
            _lives--;
            if (_lives <= 0)
            {
                _level.RespawnEnabled = false;
                var wait = new System.Timers.Timer(3000);
                wait.AutoReset = false;
                wait.Enabled   = true;

                wait.Elapsed += BeginQuizLoad;
            }
        }
Пример #17
0
    /// <summary>
    /// 延迟执行操作
    /// </summary>
    /// <typeparam name="T">类型</typeparam>
    /// <param name="o">操作对象</param>
    /// <param name="延迟毫秒数">延迟毫秒数</param>
    /// <param name="执行内容">执行内容</param>
    public static void DelayRun <T>(this T o, int 延迟毫秒数, Action <T> 执行内容)
    {
        //Timer t = new Timer(r => { 执行内容(o); }, null, 延迟毫秒数, Timeout.Infinite);

        System.Timers.Timer t = new System.Timers.Timer();
        t.Interval = 延迟毫秒数;
        t.Elapsed += (sender, e) =>
        {
            执行内容(o);
            t.Dispose();
        };
        t.Enabled = true;

        //定时器 d = new 定时器(延迟毫秒数);
        //d.执行完毕事件 += (s, op, b) => { 执行内容(o); d.Dispose(); };
        //d.执行(null);
    }
Пример #18
0
        private void FetchTimer(int ms)
        {
            // Check if the timer is running, if yes stop it and start new with the ms giving in the parameter
            try
            {
                _timerFetcher.Dispose();
            }
            catch (Exception ex)
            {
                Logger.LogExc(ex);
            }

            _timerFetcher          = new System.Timers.Timer();
            _timerFetcher.Elapsed += OnTimedEvent;
            _timerFetcher.Interval = ms;
            _timerFetcher.Enabled  = true;
        }
Пример #19
0
        static void System_Timers_Timer(object secVal)
        {
            Console.WriteLine("Запуск первого таймера - {0:HH:mm:ss.fff}", DateTime.Now);
            DateTime  start          = new DateTime();
            DateTime  stop           = new DateTime();
            long      startTicks     = 0;
            long      stopTicks      = 0;
            long      difference     = 0;
            Exception timerException = null;

            try
            {
                Stopwatch stopwatch = new Stopwatch();  // Запускаем внутренний таймер объекта Stopwatch
                stopwatch.Start();
                start      = DateTime.Now;
                startTicks = DateTime.Now.Ticks;
                ////////////////////////////////////////////////////////////////////////////////////////////////////////
                //Thread.Sleep(100);
                // Create a timer with a two second interval.
                T1 = new System.Timers.Timer((int)secVal);
                // Hook up the Elapsed event for the timer.
                T1.Elapsed  += SomeFuncForTimer1;
                T1.AutoReset = false;
                T1.Enabled   = true;
                resetEvent.WaitOne(); // This blocks the thread until resetEvent is set
                resetEvent.Close();
                resetEvent.Dispose();
                ////////////////////////////////////////////////////////////////////////////////////////////////////////
                stopwatch.Stop(); // Останавливаем внутренний таймер объекта Stopwatch
                stop       = DateTime.Now;
                stopTicks  = DateTime.Now.Ticks;
                difference = stopwatch.ElapsedTicks;
            }
            catch (Exception e)
            {
                Console.WriteLine(Thread.CurrentThread.Name + ":" + e);
                timerException = e;
            }
            finally
            {
                Console.WriteLine("Первый таймер завершился.");
                TimerInfo timer = new TimerInfo(Thread.CurrentThread.Name, start, startTicks, stop, stopTicks, difference, timerException);
                Logging(timer);
            }
        }
Пример #20
0
        public LogWriter(string fileName = null)
        {
            _timer          = new System.Timers.Timer(10000); //定时周期2秒
            _timer.Elapsed += TimerElapsed;                   //到2秒了做的事件
            _timer.Enabled  = true;

            if (string.IsNullOrWhiteSpace(fileName))
            {
                fileName = string.Format("{0}\\Logs\\{1}.txt", Application.StartupPath, DateTime.Now.ToString("yyyy-MM-dd"));
            }

            if (fileName != _fileName)
            {
                _fileName = fileName;
                CreateDirectory(_fileName);
                _logStreamWriter = new StreamWriter(new FileStream(_fileName, FileMode.Append));
            }
        }
Пример #21
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();
        }
Пример #22
0
        static void Main(string[] args)
        {
            PrintWelcome();
            String commandStr;

            do
            {
                Console.WriteLine(@"
                    Please enter one of following commands:
                    
                    0 - Ping-pong implemented via standalone threads
                    1 - Ping-pong implemented via thread pool

                    exit - exit the program
                ");

                commandStr = Console.ReadLine();

                IPingPongRunner        pingPong = null;
                PingPongImplementation type;

                if (Enum.TryParse(commandStr, true, out type))
                {
                    pingPong = PingPongFactory.GetPingPongRunner(type);
                }

                if (pingPong != null)
                {
                    var timer = new System.Timers.Timer {
                        Interval = 5000, AutoReset = false, Enabled = true
                    };
                    timer.Elapsed += (sender, e) => pingPong.Stop();

                    pingPong.Start();
                }
            } while (!"exit".Equals(commandStr, StringComparison.InvariantCultureIgnoreCase));
        }
Пример #23
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;
            }
        }