コード例 #1
0
        private static void savePrefs(PrefsData userPrefs)
        {
            string filePath = System.Environment.CurrentDirectory + m_fileName;

            int logInterval = userPrefs.getInt(PrefsData.PrefInt.LogInterval);
            int idleTime    = userPrefs.getInt(PrefsData.PrefInt.IdleTime);
            int timeoutTime = userPrefs.getInt(PrefsData.PrefInt.TimeoutTime);
            int activeSheet = userPrefs.getInt(PrefsData.PrefInt.ActiveLog);

            string data =
                m_versionToken + Environment.getVersion() +
                "\n// Log interval, poll interval, time until idle and time until timeout" +
                "\n" + m_intToken + m_dataTokens[(int)PrefsData.PrefInt.LogInterval] + m_dataSeperator + logInterval +
                "\n" + m_intToken + m_dataTokens[(int)PrefsData.PrefInt.IdleTime] + m_dataSeperator + idleTime +
                "\n" + m_intToken + m_dataTokens[(int)PrefsData.PrefInt.TimeoutTime] + m_dataSeperator + timeoutTime +
                "\n" + m_intToken + m_dataTokens[(int)PrefsData.PrefInt.ActiveLog] + m_dataSeperator + activeSheet +
                "\n//";

            for (PrefsData.PrefLogIndex i = 0; i < PrefsData.PrefLogIndex.Count; i++)
            {
                data += "\n" +
                        m_stringToken + userPrefs.getLogName(i) +
                        m_sheetsSeperator + userPrefs.getProjectName(i) +
                        m_sheetsSeperator + userPrefs.getProjectDescription(i) +
                        m_sheetsSeperator + userPrefs.getLogGoogleId(i);
            }

            File.WriteAllText(filePath, data);
            Console.WriteLine("Pref file saved");
        }
コード例 #2
0
        public MainProgram()
        {
            m_timer          = new System.Windows.Forms.Timer();
            m_timer.Interval = m_pollInterval;
            m_timer.Enabled  = true;
            m_timer.Tick    += (s, e) =>
            {
                // remove sustain from flags
                if (m_state != (int)States.Pause)
                {
                    bool isUserActive = TCO.InputHook.getActivityDetected();

                    if (isUserActive == true)
                    {
                        m_state = (int)States.Active;
                    }
                    else
                    {
                        Console.WriteLine("user is inactive " + m_timeBuffer);
                    }

                    // do this if not timed out
                    if (m_state != (int)States.TimeOut)
                    {
                        m_timeBuffer += m_pollInterval;
                    }

                    // do this is user was active or program is in sustain mode
                    if (isUserActive == true ||
                        m_neverTimeout == true)
                    {
                        m_timePending        += m_timeBuffer;
                        m_logTimeAccumulator += m_timeBuffer;
                        m_timeBuffer          = 0;
                    }

                    timeToString();
                    updateTodaysLogEntries();
                    updateState();

                    if (m_timePending >= m_userPrefs.getInt(PrefsData.PrefInt.LogInterval))
                    {
                        logTime();
                    }
                }
                EventHandler handler = TimerTick;
                if (handler != null)
                {
                    handler(this, e);
                }
            };
            importFileData();
            googleSheetsInterfaceSetup();
        }