override internal void ConfirmAction(object sender, ExecutedRoutedEventArgs e) { UtilTimer.Current.StopCountdown(); UtilTimer.Current.Delete(); UtilTimer.LoadAllFromRegistry(); TimerTicker.ReloadTickerEntries(); PopupCloseAnimated(); }
public async Task CreateTickerChannel() { var heartbeatTicker = new TimerTicker(TimeSpan.FromSeconds(1)); var channel = heartbeatTicker.GetChannel(() => new Tick()); var res = await channel.WaitToReadAsync(); Assert.True(res); }
public void Run() { MainMenu(); HamsterDayCare dayCare = new HamsterDayCare(); TimerTicker timer = new TimerTicker(tickerSpeed, totalDays); timer.SendTick += dayCare.RunAll; dayCare.SendHamsterDayCareInfo += ShowHamsterDayCareStatus; dayCare.SendDailyInfo += timer.OnSendningDailyInfo; dayCare.SendDailyInfo += ShowDailyLog; timer.StartTicks(); Console.ReadLine(); }
public MainForm() { InitializeComponent(); //Запуск таймера безперервного виконання TimerTicker.Start(); if (Properties.Settings.Default.FullscreenMode == true) { WindowState = FormWindowState.Maximized; } consoleController = new ConsoleController(ConsoleView); cC = consoleController; cC.AddElement(ConsoleController.ConsoleElementType.notification, Greeting()); mainTabControl = MainTabControl; OnViewHelper += DisableHelperButtons; OnCloseHelper += EnableHelperButtons; }
public void Invoke() { var watch = new Stopwatch(); watch.Start(); var myTimer = new TimerTicker(PrintTime); var times = 0; while (true) { if (watch.Elapsed.Seconds != this.Seconds) { continue; } times++; myTimer.Invoke(); if (times == this.Times) { break; } watch.Restart(); } }
//// Provide CLR accessors for the event //public event RoutedEventHandler RoutedPopupClose //{ // add { AddHandler(WPopupTimer.PopupClose, value); } // remove { RemoveHandler(WPopupTimer.PopupClose, value); } //} //public static WPopupTimer Current //{ // get => _current; // set => _current = value; //} //public static WPopupTimer Last => All.Count > 0 ? All[All.Count - 1] : null; //public static bool IsOpened => Last != null; //public ICommand CommandCancel //{ // get => (ICommand)GetValue(CommandCancelProperty); // set => SetValue(CommandCancelProperty, value); //} ////public ICommand AnimationCompleted ////{ //// get => (ICommand)GetValue(AnimationCompletedProperty); //// set => SetValue(AnimationCompletedProperty, value); ////} //public ICommand CommandConfirm //{ // get => (ICommand)GetValue(CommandConfirmProperty); // set => SetValue(CommandConfirmProperty, value); //} //public void ClosePopup() //{ // All.Remove(this); // this.Close(); //} //public void DoPopupAlignment() //{ // // fade in animation // Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => // { // var source = PresentationSource.FromVisual(this); // var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea; // var transform = source.CompositionTarget.TransformFromDevice; // var corner = transform.Transform(new Point(workingArea.Right, workingArea.Bottom)); // this.Left = corner.X - this.ActualWidth - 100; // this.Top = corner.Y - this.ActualHeight; // })); //} //public void PopupCloseDo() //{ // PopupCloseRaise(); //} //private void CanExecuteTrue(object sender, CanExecuteRoutedEventArgs e) //{ // e.CanExecute = true; //} //// This method raises the PopupCloseEvent //private void PopupCloseRaise() //{ // Console.WriteLine("Raising PopupCloseEvent"); // RoutedEventArgs newEventArgs = new RoutedEventArgs(WPopupTimer.PopupClose, this); // this.RaiseEvent(newEventArgs); //} //private void PopupHide(object sender, ExecutedRoutedEventArgs e) //{ // Console.WriteLine("Starting to hide popup " + this.Name + "..."); // this.PopupCloseRaise(); //} private void StartAction() { // parse action from dropdown value TimedActionType timedActionType; if (!TimedActionType.TryParse(TimerAction.Text, true, out timedActionType)) { MessageBox.Show("Error parsing TimedActionType!"); return; } string nama = TimerName.Text; Console.WriteLine("Action for new timer [" + nama + "] was " + timedActionType.ToString()); // switch on action TimedAction action = default; string time = TimerTime.Text; bool warn = WarnCheck.IsChecked.Value; switch (timedActionType) { default: MessageBox.Show("Doing nothing then.."); this.PopupCloseAnimated(); return; case TimedActionType.Shutdown: ShutdownType sdType = ShutdownType.Shutdown; // TODO get real value bool force = true; // TODO get real value action = new TimedShutdownAction(sdType, force, nama, warn); action.image = TimerImages.Shutdown; break; case TimedActionType.Notification: var thetext = "bla"; action = new TimedNotificationAction(thetext, nama, warn); action.image = TimerImages.Notification; break; case TimedActionType.Custom: // TODO //action = new TimedNotificationAction(nama, thetext, warn); //action.image = TimerImages.Custom; break; } if (action != default) { // save last value of old timer in registry UtilTimer.Current.Save(); // create new timer with action associated var timer = new UtilTimer(action, time); //UtilTimer.Current = timer; TimerTicker.ReloadTickerEntries(); } else { MessageBox.Show("Could not create action, sorry my dude..."); } this.PopupCloseAnimated(); }