Esempio n. 1
0
        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 buttonOK_Click(object sender, RoutedEventArgs e)
        {
            if (cbEndWorkday.IsChecked.Value)
            {
                WorkdayHandler.WorkdayEnd(pickerEndTime.Value.Value);
            }

            if (cbStartWorkday.IsChecked.Value)
            {
                WorkdayHandler.WorkdayStart(UserData.getWorkDuration(), pickerStartTime.Value.Value);
                UserData.setLastLockTime(DateTime.Now);
            }

            Close();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Import configuration into temporary variables
            iWorkDuration  = UserData.getWorkDuration();
            cTrayIconColor = UserData.getTrayIconColor();
            lBreak         = new ObservableCollection <Break>(UserData.getBreaks());
            lSubtitle      = new ObservableCollection <Subtitle>(UserData.getSubtitles());
            lThreshold     = new ObservableCollection <Threshold>(UserData.getThresholds());

            //Intitialize user control values
            iudWorkDuration.Value    = iWorkDuration;
            cpTrayIcon.SelectedColor = cTrayIconColor;
            lvBreaks.ItemsSource     = lBreak;
            lvSubtitles.ItemsSource  = lSubtitle;
            lvThresholds.ItemsSource = lThreshold;
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public static DateTime getWorkTimeEnd(DateTime dtStartTime)
        {
            if (!getIsStarted())
            {
                return(DateTime.MinValue);
            }

            DateTime dtEndTime = dtStartTime.AddMinutes(UserData.getWorkDuration());

            foreach (Break lBreak in UserData.getBreaks())
            {
                if ((!lBreak.enabled || !(dtStartTime.TimeOfDay < lBreak.starttime.TimeOfDay) ? false : dtEndTime.TimeOfDay >= lBreak.starttime.TimeOfDay))
                {
                    dtEndTime = dtEndTime.Add(lBreak.duration);
                }
            }

            return(dtEndTime);
        }