public void GivenUnPomodoroNoIniciado() { var timer = new FakeTimer(null); var pomodoro = new Pomodoro(timer); ScenarioContext.Current.Set(pomodoro); ScenarioContext.Current.Set(timer); }
public void WhenCreoUnNuevoPomodoroSinEspecificarSuDuracion() { var timer = new FakeTimer(null); var pomodoro = new Pomodoro(timer); ScenarioContext.Current.Set(pomodoro); ScenarioContext.Current.Set(timer); }
public void WhenCreoUnNuevoPomodoroEspedificandounaDuracion(int minutes) { var timer = new FakeTimer(null); var pomodoro = new Pomodoro(timer, minutes); ScenarioContext.Current.Set(pomodoro); ScenarioContext.Current.Set(timer); }
public IHttpActionResult PutPomodoro(int id, Pomodoro pomodoro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pomodoro.PomodoroID) { return(BadRequest()); } db.Entry(pomodoro).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PomodoroExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private IEnumerator StartCountdown(int secondsCount) { currentSeconds = secondsCount; while (currentSeconds >= 0) { DisplayTime(currentSeconds); yield return(new WaitForSeconds(1f)); currentSeconds--; } // this is where the timer ends ResetTimeDisplay(); // wait for another second before starting the next timer // this way the 00 timer is visible // yield return new WaitForSeconds(1f); // play the end sound after the 00 time has been shown for one second settingsManager.PlayEndSound(currentPomodoro.SoundPath); //Debug.Log(currentPomodoro.Name); currentPomodoro = settingsManager.currentProfile.profileData.GetNextPomodoroToPlay(); timerSeconds = currentPomodoro.Duration; settingsManager.DisplayCurrentPomodoroName(currentPomodoro.Name); timerCoroutine = StartCountdown(timerSeconds); // reset pause // ResumeTimer(); StartCoroutine(timerCoroutine); }
public void StartNewPomodoros(ItemCollection tags) { int minutes = 25; DateTime date = new DateTime(); date = date.AddMinutes(minutes); this.time = date; this.tags = tags; string libelle = ((Tag)tags[0]).Libelle; this.tag.Content = libelle; Pomodoro pomodoro = new Pomodoro() { Libelle = libelle, Date = DateTime.Now }; PomodorosDataAccess pomodoroDataAccess = new PomodorosDataAccess(); pomodoroDataAccess.SavePomodoro(pomodoro); this.btn1.Content = "❚❚"; this.pause = false; this.start = true; }
public void OnPomodoroDone(Pomodoro pomodoro) { var @event = new EventGridEvent() { Id = Guid.NewGuid().ToString(), Data = pomodoro, EventTime = DateTime.Now, EventType = "Nebbodoro.OnPomodoroDone", Subject = "OnPomodoroDone", DataVersion = "1.0" }; if (_options.Value?.TopicEndpoint == null || _options.Value?.TopicKey == null) { return; } string topicEndpoint = _options.Value.TopicEndpoint; string topicKey = _options.Value.TopicKey; string topicHostname = new Uri(topicEndpoint).Host; TopicCredentials topicCredentials = new TopicCredentials(topicKey); EventGridClient client = new EventGridClient(topicCredentials); client.PublishEventsAsync(topicHostname, new[] { @event }, CancellationToken.None).Wait(); }
// // GET: /Work/Start public RedirectResult Start() { var currentUser = manager.FindById(User.Identity.GetUserId()); if (currentUser.WorkingPanelAvailable) { if (currentUser.ActionID.HasValue && currentUser.ActionID.Value > 0) { if (currentUser.Action.IsSelectable) { Pomodoro pomodoro = new Pomodoro(); pomodoro.Start = DateTime.UtcNow; pomodoro.Status = PomodoroStatus.Working; pomodoro.ActionID = currentUser.ActionID.Value; db.Entry(pomodoro).State = EntityState.Modified; db.Pomodoros.Add(pomodoro); } else { currentUser.ActionID = null; db.Entry(currentUser).State = EntityState.Modified; } db.SaveChanges(); } } return(Redirect(Request.GetReferrerUrlOrCurrent())); }
public IActionResult Post([FromRoute] string email) { var user = _pomodoroContext.Users.FirstOrDefault(u => u.Email == email); if (user == null) { return(NotFound()); } var pomodoro = new Pomodoro { Task = "Some task", Start = DateTime.Now, End = DateTime.Now, Duration = 25, User = user }; _pomodoroContext.Pomodoros.Add(pomodoro); _pomodoroContext.SaveChanges(); _eventGridManager.OnPomodoroDone(pomodoro); return(Ok()); }
private void Init(string goalString) { this.StartPosition = FormStartPosition.Manual; this.TopMost = true; this.hideWidth = this.Width; this.showWidth = this.Width; this.showHeight = this.Height; this.hideHeight = 4; this.centerLeft = Convert.ToInt32(Math.Round(Screen.PrimaryScreen.Bounds.Width / 2.0 - this.Width / 2.0)); this.MainPanel.MouseDown += MainPanelOnMouseDown; this.MouseDown += MainPanelOnMouseDown; this.GoalLabel.Text = goalString; SetBroadenSize(); this.Pomodoro = new Pomodoro(goalString); this.Pomodoro.OnStateChange -= OnPomodoroStateChanged; this.Pomodoro.OnStateChange += OnPomodoroStateChanged; this.Pomodoro.OnTimeFinish -= OnPomodoroTimeFinish; this.Pomodoro.OnTimeFinish += OnPomodoroTimeFinish; this.Timer.Enabled = true; this.Timer.Interval = 1000; this.TopLabel.Text = "PAUSE"; }
public void OnTimerStateChanged(object sender, TimerEventArgs e) { switch (Pomodoro.State) { case TimerServiceState.Stopped: CommandLabel = "Start"; break; case TimerServiceState.Running: CommandLabel = "Pause"; break; case TimerServiceState.Paused: CommandLabel = "Resume"; break; default: break; } Display = Pomodoro.TimeString(); Progress = Pomodoro.Progress; ((JFCommand)CancelTimerCommand).RaiseCanExecuteChanged(); }
public async Task <IActionResult> PutPomodoro([FromRoute] int id, [FromBody] Pomodoro pomodoro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pomodoro.PomodoroId) { return(BadRequest()); } _context.Entry(pomodoro).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PomodoroExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Program() { //InitializeComponent(); var pomodoro = new Pomodoro(this, 2); pomodoro.Start(); }
public IHttpActionResult PutPomodoro(Pomodoro pomodoro) { if (pomodoro == null) { throw new ArgumentNullException("pomodoro"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Pomodoros.Add(pomodoro); try { db.SaveChanges(); } catch (DbUpdateException) { if (PomodoroExists(pomodoro.PomodoroId)) { return(Conflict()); } throw; } return(CreatedAtRoute("DefaultApi", new { id = pomodoro.PomodoroId }, pomodoro)); }
public ActionResult Work(int?id) { //(first) pomodoro with status = working(if exists) Pomodoro pomodoro = db.GetMyPomodoros(User).FirstOrDefault(p => p.Status == PomodoroStatus.Working); if (pomodoro != null) { if (id.HasValue && id.Value == pomodoro.ActionID) { return(RedirectToAction("Working", "Pomodoro")); } else { return(RedirectToAction("CancelWorking", "Pomodoro", new { id = id })); } } Action action = null; //ToDo: Check conflicts if (id.HasValue) { action = db.Actions.Find(id); if (action != null) { UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); var currentUser = manager.FindById(User.Identity.GetUserId()); currentUser.ActionID = id.Value; db.Entry(currentUser).State = EntityState.Modified; db.SaveChanges(); } } return(View(action)); }
public IHttpActionResult PostPomodoro(Pomodoro pomodoro) { if (pomodoro == null) { throw new ArgumentNullException("pomodoro"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Entry(pomodoro).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PomodoroExists(pomodoro.PomodoroId)) { return(NotFound()); } throw; } return(StatusCode(HttpStatusCode.NoContent)); }
// GET: /Pomodoro/ChangeAction/5?parent=1 public ActionResult ChangeAction(int?id, int?parent) { if (id == null || parent.HasValue == false) { return(Redirect(Request.GetReferrerUrlOrCurrent())); } Pomodoro pomo = db.GetPomodoroById(User, id.Value); if (pomo == null) { return(HttpNotFound()); } if (pomo.Status == PomodoroStatus.Working || pomo.Status == PomodoroStatus.Unconfirmed) { //cannot perform change TempData["UpdateError"] = Settings.MSG_UNSUCCESSFUL_BECAUSE_WORKING; return(Redirect(Request.GetReferrerUrlOrCurrent())); } Action action = db.GetActionById(User, parent.Value); if (action == null) { return(HttpNotFound()); } pomo.ActionID = parent.Value; db.Entry(pomo).State = EntityState.Modified; db.SaveChanges(); TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_UPDATE; return(Redirect(Request.GetReferrerUrlOrCurrent())); }
public void MovePomodoroDown() { // there need to be more than 2 pomodoros, a pomodoro needs to be selected, and the selected pomodoro needs to not be the last element int selectedIndex = currentProfile.profileData.SelectedPomodoroIndex; int pomoCount = currentProfile.profileData.Pomodoros.Count; if (selectedIndex > -1 && selectedIndex < pomoCount - 1 && pomoCount > 1) { Pomodoro tempPomodoro = currentProfile.profileData.Pomodoros[selectedIndex]; currentProfile.profileData.Pomodoros[selectedIndex] = currentProfile.profileData.Pomodoros[selectedIndex + 1]; currentProfile.profileData.Pomodoros[selectedIndex + 1] = tempPomodoro; UpdatePomodoroPrefabText(selectedIndex); UpdatePomodoroPrefabText(selectedIndex + 1); if (currentProfile.profileData.PomodoroPlayIndex == selectedIndex) { currentProfile.profileData.PomodoroPlayIndex = selectedIndex + 1; } else if (currentProfile.profileData.PomodoroPlayIndex == selectedIndex + 1) { currentProfile.profileData.PomodoroPlayIndex = selectedIndex; } UpdatePomodorosPlayIcon(); currentProfile.profileData.SetSelectedPomodoro(currentProfile.profileData.SelectedPomodoroIndex + 1); } }
public void GetAllPomodoros_TestMethod() { var testPomorodo = new Pomodoro() { Id = Guid.NewGuid(), StartTime = "TestStartTime", FinishTime = "TestFinishTime", Description = "TestDescription" }; var repositoryMock = new Mock <IPomodoroRepository>(); repositoryMock.Setup(pr => pr.GetAllPomodoros()).ReturnsAsync(new List <Pomodoro> { testPomorodo }); var repositoryWrapperMock = new Mock <IRepositoryWrapper>(); repositoryWrapperMock.Setup(rw => rw.Pomodoro).Returns(repositoryMock.Object); var mapperMock = new Mock <IMapper>(); var loggerMock = new Mock <ILoggerManager>(); loggerMock.Setup(pr => pr.LogInfo("Test")); var pc = new PomodoroController(repositoryWrapperMock.Object, mapperMock.Object, loggerMock.Object); var result = pc.GetAllPomodoros().Result; var okResult = result as OkObjectResult; Assert.IsNotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); }
static void Main(string[] args) { var pom = new Pomodoro(propertyStore); pom.Progress += Pom_Progress; Console.WriteLine("Starting Pomodoro Timer"); pom.Run(); }
public void LoadCurrentPomodoro() { //timerSeconds = ProfileData.Current.Pomodoros[0].Duration; currentPomodoro = settingsManager.currentProfile.profileData.Pomodoros[settingsManager.currentProfile.profileData.PomodoroPlayIndex]; timerSeconds = currentPomodoro.Duration; DisplayTime(timerSeconds); settingsManager.DisplayCurrentPomodoroName(currentPomodoro.Name); }
public ActionResult DeleteConfirmed(int id, String UrlReferrer) { Pomodoro pomodoro = db.GetPomodoroById(User, id); db.Pomodoros.Remove(pomodoro); db.SaveChanges(); return(Redirect(UrlReferrer)); }
public ActionResult DeleteConfirmed(int id) { Pomodoro pomodoro = db.Pomodoroes.Find(id); db.Pomodoroes.Remove(pomodoro); db.SaveChanges(); return(RedirectToAction("Index")); }
public void GivenUnPomodoroIniciado() { var timer = new FakeTimer(null); var pomodoro = new Pomodoro(timer); SystemTime.Now = () => TestConstants.GeneralStartTime; pomodoro.Start(); ScenarioContext.Current.Set(pomodoro); ScenarioContext.Current.Set(timer); }
private void AddDefaultPomodoroFallback() { // the pomodoros list should always have a pomodoro in it // here we just generate a default pomodoro and add it to the current profile if (currentProfile.profileData.Pomodoros.Count == 0) { Pomodoro defaultPomodoro = new Pomodoro("default", 900, noSoundString); currentProfile.profileData.Pomodoros.Add(defaultPomodoro); } }
public IHttpActionResult Get(Guid id) { Pomodoro pomodoro = db.Pomodoros.Find(id); if (pomodoro == null) { return(NotFound()); } return(Ok(pomodoro)); }
public ActionResult Edit([Bind(Include = "ID,Start,ActionID,Status")] Pomodoro pomodoro) { if (ModelState.IsValid) { db.Entry(pomodoro).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = pomodoro.ID })); } ViewBag.ActionID = new SelectList(db.GetMyActions(User), "ID", "Name", pomodoro.ActionID); return(View(pomodoro)); }
public ActionResult Edit([Bind(Include = "PomodoroID,ProjectTaskID,StartTime,DurationInMinutes")] Pomodoro pomodoro) { if (ModelState.IsValid) { db.Entry(pomodoro).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectTaskID = new SelectList(db.ProjectTasks, "ProjectTaskID", "Description", pomodoro.ProjectTaskID); return(View(pomodoro)); }
public MainWindowViewModel() { Pomodoro = new Pomodoro(); var repo = new LogRepository(); PomodoroCount = repo.FindAllToday().Count(); Pomodoro.BreakTimeRaised += (s, e) => { ActivityName = "Break"; repo.Add(new Log { Activity = "Focus", StartTime = DateTime.Now.Subtract(new TimeSpan(0, 25, 0)), EndTime = DateTime.Now }); PomodoroCount = repo.FindAllToday().Count(); OnBreakTimeRaised(new EventArgs()); }; Pomodoro.WorkTimeRaised += (s, e) => { ActivityName = "Focus"; OnWorkTimeRaised(new EventArgs()); }; var timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 1) }; timer.Tick += (sender, e) => { Pomodoro.Update(); TimeSpan currentDuration = Pomodoro.GetCurrentDuration(); Duration = string.Format( "{0}:{1}", currentDuration.Minutes.ToString().PadLeft(2, '0'), currentDuration.Seconds.ToString().PadLeft(2, '0') ); }; timer.Start(); Hook.GlobalEvents().KeyDown += (sender, e) => Pomodoro.LastActivityTime = DateTime.Now; Hook.GlobalEvents().KeyPress += (sender, e) => Pomodoro.LastActivityTime = DateTime.Now; Hook.GlobalEvents().MouseMove += (sender, e) => Pomodoro.LastActivityTime = DateTime.Now; }
private ActivityTime ActivityTimeContains(Pomodoro pomodoro) { foreach (ActivityTime activity in this.times) { if (activity.Activities == pomodoro.Libelle) { return(activity); } } return(null); }
public void ToggleTimer() { if (Pomodoro.State != TimerServiceState.Running) { Pomodoro.StartTimer(); } else { Pomodoro.PauseTimer(); } }
public async Task <IHttpActionResult> GetPomodoro(int id) { Pomodoro pomodoro = await db.Pomodoroes.FindAsync(id); if (pomodoro == null) { return(NotFound()); } return(Ok(pomodoro)); }
// GET: /Work/CancelUnconfirmed/5 public RedirectResult CancelUnconfirmed(int id) { Pomodoro pomodoro = db.GetPomodoroById(User, id); if (pomodoro.Status == PomodoroStatus.Unconfirmed) { pomodoro.Status = PomodoroStatus.Cancelled; db.SaveChanges(); } return(Redirect(Request.GetReferrerUrlOrCurrent())); }
public async Task <IActionResult> PostPomodoro([FromBody] Pomodoro pomodoro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Pomodoroes.Add(pomodoro); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPomodoro", new { id = pomodoro.PomodoroId }, pomodoro)); }
private void MainForm_Load(object sender, EventArgs e) { Icon = Properties.Resources.Stopwatch; notifyIcon.Icon = Properties.Resources.Stopwatch; _dayTimer = new WorkDayTimer(); _dayTimer.Tick += DayTimer_Tick; _pomodoro = new Pomodoro(); _pomodoro.Tick += _pomodoro_Tick; clock.Interval = 1000; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; var settings = Settings.Default; if (settings.Date == DateTime.Today) { _pomodoro.LoadSettings(settings.TotalWork, settings.TotalPauze); } #if DEBUG sessionBox.Visible = true; sessionBox.Tag = true; sessionBox.Image = Properties.Resources.SecurityLock; #else #endif clock.Start(); _pomodoro.Start(); // Holy Crap! GC.Collect(); // as the form is minimized and not shown anyway, try to release as much VM as possible. }
public void Setup() { sut = new Pomodoro(); }
public Interaktoren() { timerProvider = new TimerProvider(); uhrzeitProvider = new UhrzeitProvider(); pomodoro = new Pomodoro(); synchronizer = new Synchronizer(); }