Example #1
0
        void FinishProcessing(DesignError error)
        {
            if (error != null)
            {
                var errorLabel = new Label {
                    Text = error.Message, ToolTip = error.Details.ToString()
                };
                if (errorPanel.Visible)
                {
                    errorPanel.Content = errorLabel;
                }
                else
                {
                    errorContent = errorLabel;
                    errorTimer.Start();
                }
            }
            else
            {
                errorPanel.Visible = false;
                errorContent       = null;
            }

            if (processingCount > 1)
            {
                // process was requested while we were processing the last one, so redo
                processingCount = 1;
                timer.Start();
            }
            else
            {
                processingCount = 0;
            }
        }
Example #2
0
 private void StartTimerTick()
 {
     StopTimerTick();
     UiTimer = new UITimer();
     UiTimer.TimerTickEvent += OnUITimerTick;
     UiTimer.Start(TimerInfo.RemainingTime, TimeSpan.FromSeconds(1));
 }
Example #3
0
 protected override void StartTimer()
 {
     fTimer          = new UITimer();
     fTimer.Interval = TimerInterval / 1000;
     fTimer.Elapsed += TimerElapsed;
     fTimer.Start();
 }
Example #4
0
        private void GvSelectionChanged(object sender, EventArgs e)
        {
            var id = GetSlectedWorkflowId();
            var wf = GetWorkflow(id);

            if (_timer != null && _timer.Started)
            {
                _timer.Stop();
                _timer.Dispose();
            }

            if (wf != null && wf.IsEnabled)
            {
                _timer = new UITimer {
                    Interval = 0.5
                };
                _timer.Elapsed += (s, ea) => UpdateButtons(id, false);
                _timer.Start();

                UpdateButtons(id, true);
            }
            else
            {
                UpdateButtons(id, true);
            }
        }
Example #5
0
        //初始化窗口
        void InitForm()
        {
            //窗口全屏
            this.FormBorderStyle = FormBorderStyle.None;
            this.StartPosition   = FormStartPosition.CenterScreen;
            this.ClientSize      = Screen.PrimaryScreen.Bounds.Size;

            mSceneLeftX  = mSceneMargen;
            mSceneUpY    = mSceneMargen;
            mSceneRightX = ClientSize.Width - mSceneMargen;
            mSceneDownY  = ClientSize.Height - mSceneMargen;

            //窗口背景
            this.BackColor = Color.Black;
            //隐藏鼠标
            Cursor.Hide();
            this.ShowInTaskbar = false;
            //双帧缓冲打开
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.UpdateStyles();
            //定时器
            UITimer.Enabled  = true;
            UITimer.Interval = mRunSpeed;
            UITimer.Tick    += UITimer_Tick;
            UITimer.Start();
        }
Example #6
0
 void SetupIceColours()
 {
     if (!allowBlink)
     {
         blinkOn = true;
         ViewerControl.Invalidate();
         return;
     }
     if (CharacterDocument.ICEColours)
     {
         if (blinkTimer != null)
         {
             blinkTimer.Stop();
             blinkTimer.Dispose();
             blinkTimer = null;
             InvalidateBlinkingCharacters();
         }
     }
     else if (blinkTimer == null && HasViewer)
     {
         blinkTimer          = new UITimer();
         blinkTimer.Interval = 0.25;
         blinkTimer.Elapsed += delegate
         {
             blinkOn = !blinkOn;
             InvalidateBlinkingCharacters();
         };
         blinkTimer.Start();
     }
 }
Example #7
0
        Control StartStopButton(ProgressBar bar)
        {
            var control = new Button {
                Text = "Start Timer"
            };

            control.Click += delegate {
                if (timer == null)
                {
                    timer = new UITimer {
                        Interval = 0.5
                    };
                    timer.Elapsed += delegate {
                        if (bar.Value < bar.MaxValue)
                        {
                            bar.Value += 50;
                        }
                        else
                        {
                            bar.Value = bar.MinValue;
                        }
                    };
                    timer.Start();
                    control.Text = "Stop Timer";
                }
                else
                {
                    timer.Stop();
                    timer.Dispose();
                    timer        = null;
                    control.Text = "Start Timer";
                }
            };
            return(control);
        }
Example #8
0
 public void WindowFromPointShouldReturnWindowUnderPoint()
 {
     ManualForm("Move your mouse, it should show the title of the window under the mouse pointer",
                form =>
     {
         var content = new Panel {
             MinimumSize = new Size(100, 100)
         };
         var timer = new UITimer {
             Interval = 0.5
         };
         timer.Elapsed += (sender, e) =>
         {
             var window      = Window.FromPoint(Mouse.Position);
             content.Content = $"Window: {window?.Title}";
         };
         timer.Start();
         form.Closed += (sender, e) =>
         {
             timer.Stop();
         };
         form.Title = "Test Form";
         return(content);
     }
                );
 }
Example #9
0
 public EtoTimerBase(Action <object> callback)
 {
     _timer = new UITimer();
     Change(0, Timeout.Infinite);
     _timer.Elapsed += Elapsed(null, callback);
     _timer.Start();
 }
Example #10
0
        void FinishProcessing(DesignError error)
        {
            if (error != null)
            {
                var errorLabel = new Label {
                    Text = error.Message, ToolTip = error.Details.ToString()
                };
                if (errorPanel.Visible)
                {
                    errorPanel.Content = errorLabel;
                }
                else
                {
                    errorContent = errorLabel;
                    errorTimer.Start();
                }
            }
            else
            {
                errorPanel.Visible = false;
                errorContent       = null;
            }

            //sw.Stop();
            //System.Diagnostics.Debug.WriteLine($"Elapsed: {sw.Elapsed}");

            //if (processingCount > 1)
            //{
            //	// process was requested while we were processing the last one, so redo
            //	processingCount = 1;
            //	timer.Start();
            //}
            //else
            //	processingCount = 0;
        }
Example #11
0
File: Form1.cs Project: jwk000/Maze
        void Restart()
        {
            ResetRooms();
            ResetRoomLine();

            //画笔颜色也改掉
            int r = RandGen.Next(80, 255);
            int g = RandGen.Next(80, 255);
            int b = RandGen.Next(80, 255);

            doorPen = new Pen(Color.FromArgb(r, g, b), 2);
            //随机选择一个算法,然后初始化并开始
            int alg = RandGen.Next(1, 4);

            //alg = 2;
            if (alg == 1)
            {
                A1Reset();
                Ticker = A1_Tick;
            }
            else if (alg == 2)
            {
                A2Reset();
                Ticker = A2_Tick;
            }
            else if (alg == 3)
            {
                A3Reset();
                Ticker = A3_Tick;
            }

            System.Threading.Thread.Sleep(1000);
            UITimer.Start();
        }
Example #12
0
 private void PlayerEventHappened(object sender, PlayerEventArgs e)
 {
     switch (e.EventType)
     {
     case PlayerEventType.NewTurn:
     {
         if (Game.GetActiveUnit != null)
         {
             Map.ViewPieceMode = false;
         }
         animationTimer.Stop();
         animationCount = 0;
         animationTimer.Start();
         break;
     }
     }
 }
Example #13
0
 public EtoTimerBase(Action <object> callback, object state, TimeSpan dueTime, TimeSpan period)
 {
     _timer = new UITimer();
     ChangeDue(dueTime.TotalSeconds);
     ChangeInterval(dueTime.TotalSeconds);
     _timer.Elapsed += Elapsed(state, callback);
     _timer.Start();
 }
Example #14
0
 public EtoTimerBase(Action <object> callback, object state, long dueTime, long period)
 {
     _timer = new UITimer();
     ChangeDue(dueTime / 1000);
     ChangeInterval(period / 1000);
     _timer.Elapsed += Elapsed(state, callback);
     _timer.Start();
 }
Example #15
0
 /// <summary>
 /// Called after all other controls have been loaded
 /// </summary>
 /// <param name="e">Event arguments</param>
 public override void OnLoadComplete(EventArgs e)
 {
     base.OnLoadComplete(e);
     if (enabled)
     {
         timer.Start();
     }
 }
Example #16
0
 /// <summary>
 /// Perform the initial refresh on load
 /// </summary>
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     _refreshTimer          = new UITimer();
     _refreshTimer.Interval = RefreshInterval.TotalSeconds;
     _refreshTimer.Elapsed += _refresh;
     _refreshTimer.Start();
     _refresh(null, null);
 }
Example #17
0
 void RestartGame()
 {
     foreach (Grid g in AllGrids)
     {
         g.Reset();
     }
     GenerateMine();
     UseTimeSec = 0;
     UITimer.Start();
 }
Example #18
0
        void AddTimer_Click(object sender, RoutedEventArgs e)
        {
            UITimer timer = new UITimer();

            timer.Name = "Timer" + (Timers.Count + 1).ToString();

            Timers.Add(timer);

            timer.Start();
        }
Example #19
0
        void FinishProcessing(Control child, Exception error)
        {
            errorPanel.Visible = error != null;
            if (error != null)
            {
                errorPanel.Content = new Label {
                    Text = error.Message, ToolTip = error.ToString()
                }
            }
            ;
            if (child != null)
            {
                var window = child as Eto.Forms.Window;
                if (window != null)
                {
                    // swap out window for a panel so we can add it as a child
                    var content = window.Content;
                    window.Content = null;
                    child          = new Panel {
                        Content = content, Padding = window.Padding
                    };
                }
                previewPanel.Content = child;
            }

            if (processingCount > 1)
            {
                // process was requested while we were processing the last one, so redo
                processingCount = 1;
                timer.Start();
            }
            else
            {
                processingCount = 0;
            }
        }

        void Stop()
        {
            timer.Stop();
        }
Example #20
0
        internal void TriggerIsActiveChanged(bool gotFocus)
        {
            // don't do anything until we really need to know.
            if (_IsActiveChanged == null)
            {
                return;
            }

            _didGetFocus |= gotFocus;

            if (_timer == null)
            {
                // use a timer as the active window does not get updated immediately or when showing the task switcher
                // not sure if there's a platform-specific way to do this that would work better...
                _timer          = new UITimer();
                _timer.Elapsed += (sender, e) =>
                {
                    var windows = Gtk.Window.ListToplevels();
                    // first, check if any window has focus.. then yes, we are the active application.
                    bool isActive = _didGetFocus | windows.Any(r => r.HasFocus | r.HasToplevelFocus);
                    if (!isActive)
                    {
                        // no windows have focus, so check the active window
                        isActive = AnyIsActiveWindow(windows);

                        // we are "active" but not really as there's no top level window with focus.
                        // so keep checking until one of the top levels actually has focus or the active window changes.
                        if (isActive || _didGetFocus)
                        {
                            _timer.Interval = 0.5;
                        }
                        else
                        {
                            _timer.Stop();
                        }
                    }
                    else
                    {
                        _timer.Stop();
                    }

                    _didGetFocus = false;

                    if (_isActive != isActive)
                    {
                        _isActive = isActive;
                        OnIsActiveChanged(EventArgs.Empty);
                    }
                };
            }
            _timer.Interval = 0.2;
            _timer.Start();
        }
Example #21
0
 protected void StartTimer(object sender, EventArgs e)
 {
     isBreak = false;
     isRun   = true;
     ChangeState();
     countUp           = 0;
     countSeconds      = Convert.ToInt32(minutes.Value) * 60 + Convert.ToInt32(seconds.Value);
     progress.MaxValue = countSeconds;
     progress.MinValue = 0;
     progress.Value    = 0;
     timer.Start();
 }
Example #22
0
 private void btnTimerStart_Click(object sender, EventArgs e)
 {
     if (lockedOut || anyPadOn(interfaceBox.State))
     {
         time = 30;
     }
     else
     {
         time = 5;
     }
     lblTimerDisplay.Text = time.ToString();
     UITimer.Start();
 }
Example #23
0
        public override void StartTimer(TimeSpan interval, Func <bool> callback)
        {
            var timer = new UITimer {
                Interval = interval.TotalSeconds
            };

            timer.Elapsed += (s, e) => {
                if (!callback())
                {
                    timer.Stop();
                }
            };
            timer.Start();
        }
Example #24
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var database = BACnetSession.Current.GetProcess <NetworkDatabase>();

            this._devices             = new DeviceTreeStore(Application.Instance);
            this._devicesSubscription = database.Subscribe(new DescriptorQuery(objectType: 8), this._devices);
            _tree.DataStore           = this._devices;

            _refreshTimer          = new UITimer();
            _refreshTimer.Interval = .5;
            _refreshTimer.Elapsed += _refreshTimerElapsed;
            _refreshTimer.Start();
        }
Example #25
0
        void GvSelectionChanged(object sender, EventArgs e)
        {
            var id = GetSlectedWorkflowId();
            var wf = GetWorkflow(id);

            if (wf.IsEnabled)
            {
                _timer.Stop();
                _timer.Elapsed += (s, ea) => UpdateButtons(id, false);
                _timer.Start();

                UpdateButtons(id, true);
            }
            else
            {
                UpdateButtons(id, true);
            }
        }
Example #26
0
        private void PlayerEventHappened(object sender, PlayerEventArgs e)
        {
            switch (e.EventType)
            {
            case PlayerEventType.NewTurn:
            {
                unitPanel.Invalidate();
                break;
            }

            case PlayerEventType.WaitingAtEndOfTurn:
            {
                WaitingAtEndOfTurn = true;
                timer.Start();
                break;
            }
            }
        }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:WarCollege.SplashScreen"/> class.
        /// </summary>
        public SplashScreen()
        {
            TimeRemaining = new Label();
            Status        = new Label();
            ProgressBar   = new ProgressBar
            {
                MaxValue = 1000,
                Width    = 800,
                Style    = "ProgressBar"
            };

            Background       = new ImageView();
            Background.Image = Bitmap.FromResource("WarCollege.Resources.splash.jpg");
            ClientSize       = new Size(800, 675);
            WindowStyle      = WindowStyle.None;
            Resizable        = false;
            BackgroundColor  = Colors.White;
            //Content = background;
            Opacity              = .0;
            UpdateTimer          = new UITimer();
            UpdateTimer.Interval = (double)TIMER_INTERVAL / 1000;
            UpdateTimer.Elapsed += UpdateTimer_Tick;
            UpdateTimer.Start();

            var top  = (int)(Screen.WorkingArea.Height / 2) - (ClientSize.Height / 2);
            var left = (int)(Screen.WorkingArea.Width / 2) - (ClientSize.Width / 2);

            Location = new Point(left, top);

            var layout = new TableLayout
            {
                Rows =
                {
                    new TableRow(Background),
                    new TableRow(ProgressBar),
                    new TableRow(Status),
                    new TableRow(TimeRemaining),
                    null
                }
            };

            Content = layout;
        }
Example #28
0
        public void lb_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (lb.SelectedKey == null)
            {
                return;
            }

            SortingAlgorithm algorithm = AlgorithmDictionary[lb.SelectedKey.ToString()];

            instance = algorithm;
            //CachingList list = new CachingList(1000);
            CachingList list = new NoGetCachingList(1000);

            FisherYates.Shuffle <Int32>(list);

            int shuffleCount = list.Cache.Count;

            Console.WriteLine(string.Join <int>(",", list));
            instance.Sort <Int32>(list);

            Console.WriteLine(string.Join <int>(",", list));

            DisparityCachedList disparities = new DisparityCachedList(list);
            DisparityDots       dots        = new DisparityDots(disparities, shuffleCount, 10, 10 * algorithm.SpeedMultiplier);

            drawable        = new Drawable();
            drawable.Paint += dots.OnPaint;

            UITimer timer = new UITimer();

            timer.Interval = 0.0005;
            //Drawable.RegisterEvent(dots.OnPaint,)
            timer.Elapsed += (ts, te) =>
            {
                drawable.Update(new Rectangle(0, 0, drawable.Width, drawable.Height));
            };
            timer.Start();

            splitter.Panel1 = lb;
            splitter.Panel2 = drawable;
        }
Example #29
0
        private void ProgressReported(object sender, ProgressEventArgs e)
        {
            Application.Instance.Invoke(() =>
            {
                ProgressClearClock.Stop();

                if (e.Value != null)
                {
                    ProgressBar.Value = (int)e.Value;
                }

                if (!String.IsNullOrEmpty(e.Message))
                {
                    StatusDisplay.Text = e.Message;
                }

                if (e.Clear)
                {
                    ProgressClearClock.Start();
                }
            });
        }
Example #30
0
        protected override void OnExecuted(EventArgs e)
        {
            var rand = new Random();

            if (timer == null)
            {
                timer          = new UITimer();
                timer.Interval = 0.01;
                timer.Elapsed += delegate {
                    if (handler.CursorPosition.X == handler.CurrentPage.Canvas.Width - 1)
                    {
                        handler.CursorPosition = new Point(0, handler.CursorPosition.Y + 1);
                    }
                    handler.InsertCharacter(rand.Next(255));
                };
                timer.Start();
            }
            else
            {
                timer.Stop();
                timer = null;
            }
        }