예제 #1
0
        public bool HaveTimersChanged()
        {
            if (FlowTimer.Settings.LastLoadedTimers == null)
            {
                return(false);
            }

            if (!File.Exists(FlowTimer.Settings.LastLoadedTimers))
            {
                return(false);
            }

            JsonTimersFile oldTimers = ReadTimers(FlowTimer.Settings.LastLoadedTimers);
            JsonTimersFile newTimers = BuildJsonTimerFile();

            if (oldTimers.Timers.Count != newTimers.Timers.Count)
            {
                return(true);
            }

            for (int i = 0; i < oldTimers.Timers.Count; i++)
            {
                JsonTimer timer1 = oldTimers[i];
                JsonTimer timer2 = newTimers[i];
                if (timer1.Name != timer2.Name ||
                    timer1.Offsets != timer2.Offsets ||
                    timer1.Interval != timer2.Interval ||
                    timer1.NumBeeps != timer2.NumBeeps)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public bool LoadTimers(string filePath, bool displayMessages = true)
        {
            JsonTimersFile file = ReadTimers(filePath);

            if (file.Timers.Count == 0)
            {
                if (displayMessages)
                {
                    MessageBox.Show("Timers could not be loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(false);
            }

            ClearAllTimers();
            for (int i = 0; i < file.Timers.Count; i++)
            {
                JsonTimer timer = file[i];
                AddTimer(new Timer(i, timer.Name, timer.Offsets, timer.Interval, timer.NumBeeps));
            }

            if (displayMessages)
            {
                MessageBox.Show("Timers successfully loaded from '" + filePath + "'.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            FlowTimer.Settings.LastLoadedTimers = filePath;
            return(true);
        }