private void tUpdateIcon_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (!WorkdayHandler.getIsStarted()) { trayIcon.Icon = Helper.getTrayIcon(UserData.getTrayIconColor(), new Colour(Color.Transparent)); } else { if (WorkdayHandler.getPercent(UserData.getWorkTimeStart()) == 100) { if (bIcon) { trayIcon.Icon = Helper.getTrayIcon(UserData.getTrayIconColor(), Helper.getProgressColor(WorkdayHandler.getPercent(UserData.getWorkTimeStart()))); bIcon = false; } else { trayIcon.Icon = Helper.getTrayIcon(Helper.getProgressColor(WorkdayHandler.getPercent(UserData.getWorkTimeStart())), UserData.getTrayIconColor()); bIcon = true; } } else { trayIcon.Icon = Helper.getTrayIcon(UserData.getTrayIconColor(), Helper.getProgressColor(WorkdayHandler.getPercent(UserData.getWorkTimeStart()))); } } GC.WaitForPendingFinalizers(); GC.Collect(); }
public wndMain() { try { //Config.Import(); //UserData.ExportOldConfig(); // read user settings // ConfigHandler.Save(); UserData.ReadConfig(); if (WorkdayHandler.getIsStarted()) { WorkdayHandler.WorkdayStart(UserData.getWorkDuration(), UserData.getWorkTimeStart()); } ui_NotifyIcon Icon = new ui_NotifyIcon(); Icon.trayIcon.Click += OnTrayClick; Icon.trayIcon.ContextMenu.MenuItems["settings"].Click += OnSettingsClick; Icon.trayIcon.ContextMenu.MenuItems["history"].Click += OnHistoryClick; Icon.trayIcon.ContextMenu.MenuItems["exit"].Click += OnExitClick; SessionHandler UserSession = new SessionHandler(); UserSession.MyWorkdayEvent += new SessionHandler.EventDelegate(OnSessionStateChange); UserSession.VerifySessionState(); } catch (Exception e) { MessageBox.Show(e.Source + "-----" + e.Message + "-------" + e.StackTrace + "-----------" + e.Data); Application.Current.Shutdown(1); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Helper.EnableAeroBorder(5, this); labelHeaderSubtitle.Text = Helper.getSubtitle(WorkdayHandler.getPercent(UserData.getWorkTimeStart())); labelRemainingTime.Text = WorkdayHandler.getWorkTimeRemaining(UserData.getWorkTimeStart()).ToString("hh\\:mm"); labelRemainingText.Text = WorkdayHandler.getWorkTimeRemaining(UserData.getWorkTimeStart()) < TimeSpan.Zero ? "Overtime:" : "Remaining Time"; labelElapsedTime.Text = WorkdayHandler.getWorkTimeElapsed(UserData.getWorkTimeStart()).ToString("hh\\:mm"); labelEndTime.Text = WorkdayHandler.getWorkTimeEnd(UserData.getWorkTimeStart()).ToShortTimeString(); labelStartTime.Text = UserData.getWorkTimeStart().ToShortTimeString(); labelPercentage.Text = WorkdayHandler.getPercent(UserData.getWorkTimeStart()).ToString() + "%"; progressbarWorktime.Value = WorkdayHandler.getPercent(UserData.getWorkTimeStart()); progressbarWorktime.Foreground = new SolidColorBrush(Helper.getProgressColor(WorkdayHandler.getPercent(UserData.getWorkTimeStart()))); if (!WorkdayHandler.getIsStarted()) { grid.Children.Remove(labelWorkdayModify); labelWorkdayStartEnd.Text = "Start new Workday"; labelWorkdayStartEnd.Margin = new Thickness(0, 10, 0, 15); } else { labelWorkdayStartEnd.Text = "End current Workday"; } }
public static bool getIsStarted() { if (UserData.getWorkTimeStart().Equals(DateTime.MinValue)) { return(false); } else { return(true); } }
public static void WorkdayEnd(DateTime EndTime) { //Store the ended workday in the workday history List <Day> lTemp = UserData.getDays(); lTemp.Add(new Day(UserData.getWorkTimeStart(), EndTime)); UserData.setDays(lTemp); //Set all workday related parameters to Zero UserData.setWorkTimeStart(DateTime.MinValue); }
private void buttonSave_OnClick(object sender, RoutedEventArgs e) { //End the current workday using the start day and todays time WorkdayHandler.WorkdayEnd( new DateTime( UserData.getWorkTimeStart().Year, UserData.getWorkTimeStart().Month, UserData.getWorkTimeStart().Day, pickerEndtime.Value.Value.Hour, pickerEndtime.Value.Value.Minute, pickerEndtime.Value.Value.Second)); base.Close(); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { Dispatcher.Invoke(new Action(() => { labelRemainingTime.Text = WorkdayHandler.getWorkTimeRemaining(UserData.getWorkTimeStart()).ToString("hh\\:mm"); labelRemainingText.Text = WorkdayHandler.getWorkTimeRemaining(UserData.getWorkTimeStart()) < TimeSpan.Zero ? "Overtime:" : "Remaining Time"; labelElapsedTime.Text = WorkdayHandler.getWorkTimeElapsed(UserData.getWorkTimeStart()).ToString("hh\\:mm"); labelEndTime.Text = WorkdayHandler.getWorkTimeEnd(UserData.getWorkTimeStart()).ToShortTimeString(); labelStartTime.Text = UserData.getWorkTimeStart().ToShortTimeString(); labelPercentage.Text = WorkdayHandler.getPercent(UserData.getWorkTimeStart()).ToString() + "%"; progressbarWorktime.Value = WorkdayHandler.getPercent(UserData.getWorkTimeStart()); progressbarWorktime.Foreground = new SolidColorBrush(Helper.getProgressColor(WorkdayHandler.getPercent(UserData.getWorkTimeStart()))); })); }
public static int getPercent(DateTime dtStartTime) { if (!getIsStarted()) { return(0); } try { Double totalMinutes = getWorkTimeElapsed(UserData.getWorkTimeStart()).TotalMinutes; TimeSpan timeSpan = getWorkTimeElapsed(UserData.getWorkTimeStart()).Add(getWorkTimeRemaining(dtStartTime)); int num1 = Convert.ToInt32(totalMinutes / timeSpan.TotalMinutes * 100); return(num1 < 100 ? num1 : 100); } catch { return(0); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Helper.EnableAeroBorder(5, this); if (!WorkdayHandler.getIsStarted()) { labelHeaderTitle.Text = "Start new Workday"; pickerStartTime.Value = DateTime.Now; } else { labelHeaderTitle.Text = "Modify current Workday"; pickerStartTime.Value = UserData.getWorkTimeStart(); } pickerWorkDuration.Value = UserData.getWorkDuration(); }