iSpyApplication.Controls.VolumeLevel.ApplySchedule C# (CSharp) Method

ApplySchedule() public method

public ApplySchedule ( ) : bool
return bool
        public bool ApplySchedule()
        {
            var t = Convert.ToInt32(Math.Floor(DateTime.Now.TimeOfDay.TotalMinutes));
            bool enable = false, disable = false;
            var lRec = Schedule.Where(p => p.time < t).OrderBy(p => p.time).ToList();
            string dow = ((int)DateTime.Now.DayOfWeek).ToString(CultureInfo.InvariantCulture);

            foreach (var en in lRec)
            {
                if (en.daysofweek.Contains(dow))
                {
                    bool enable2, disable2;
                    ActionSchedule(en, out enable2, out disable2);
                    if (enable2)
                    {
                        enable = true;
                        disable = false;
                    }
                    else
                    {
                        if (disable2)
                        {
                            enable = false;
                            disable = true;
                        }
                    }
                }
            }
            if (enable)
                Enable();
            if (disable)
                Disable();
            return !(enable || disable);
        }

Usage Example

示例#1
0
        internal void DisplayMicrophone(objectsMicrophone mic)
        {
            var micControl = new VolumeLevel(mic);
            SetMicrophoneEvents(micControl);
            micControl.BackColor = Conf.BackColor.ToColor();
            _pnlCameras.Controls.Add(micControl);
            micControl.Location = new Point(mic.x, mic.y);
            micControl.Size = new Size(mic.width, mic.height);
            micControl.BringToFront();
            micControl.Tag = GetControlIndex();

            if (Conf.AutoSchedule && mic.schedule.active && mic.schedule.entries.Count() > 0)
            {
                mic.settings.active = false;
                micControl.ApplySchedule();
            }
            else
            {
                if (mic.settings.active)
                    micControl.Enable();
            }

            string path = Conf.MediaDirectory + "audio\\" + mic.directory + "\\";
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
        }