Пример #1
0
        // таймер
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            // если текущее время >= времени события
            DateTime DT_Now = DateTime.Now;

            if (DT_Now >= NextSignaltime)
            {
                // остановить таймер
                MainTimer.Stop();

                // получить структуру события
                ReadWriteFile RWF = new ReadWriteFile(WorkDir + "\\" + EventListFile, vers);
                EventStruct   ES  = RWF.GetEvent(NextEventIndex);


                SignalText    = ES.Caption;
                SignalType    = ES.IsEarly;
                EventDay      = ES.Date;
                NeedSignalize = true;
                // сигализировать
                //Signalize(ES.Caption, ES.IsEarly, ES.Date);
                needBell = true;
                Signalize();

                // изменить статус события
                ES.Informed = true;
                RWF.EditEvent(NextEventIndex, ES);

                // перезапустить таймер
                ReloadTimer();
            }
        }
Пример #2
0
        // определить время следующего сигнала
        private bool DetectNextSignal()
        {
            ReadWriteFile RWF = new ReadWriteFile(WorkDir + "\\" + EventListFile, vers);
            // индекс ближайшего события
            int indx = RWF.NextEvent();

            if (indx >= 0)
            {
                NextEventIndex = indx;
                EventStruct ES = RWF.GetEvent(indx);
                NextSignaltime = ES.BeforeInform;
                //label10.Text = ES.BeforeInform.ToShortDateString() + " " + ES.BeforeInform.ToShortTimeString() + "\r\n" + ES.Caption;
                IconText = NextSignaltime.ToShortDateString() + " " +
                           NextSignaltime.ToShortTimeString() + "\r\n" + ES.Caption;
                if (IconText.Length > 63)
                {
                    IconText = IconText.Substring(0, 63);
                }
                notifyIcon1.Text = IconText;
                return(true);
            }
            return(false);
        }
Пример #3
0
        /// <summary>
        /// Изменить
        /// </summary>
        /// <param name="fName"></param>
        /// <param name="vr"></param>
        /// <param name="indx">индекс изменяемого события</param>
        public EditAddEvent(string fName, byte[] vr, int indx, MainForm fr)
        {
            InitializeComponent();

            FileName = fName;
            Array.Copy(vr, vers, 4);

            IndexOfEvent = indx;
            ReadWriteFile RWF = new ReadWriteFile(FileName, vers);
            //EventStruct ES = RWF.GetEvent(75);
            EventStruct ES = RWF.GetEvent(indx);

            DT      = ES.Date;
            Caption = ES.Caption;
            Event   = !ES.IsEarly;
            signal  = ES.NeedInform;
            TimeSpan ts = DT.Date - ES.BeforeInform.Date;

            BeforeDay = ts.Days;
            ts        = ES.BeforeInform.TimeOfDay;
            time      = new DateTime(ts.Ticks);

            mfr = fr;
        }